forked from pConst/basic_verilog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
set_reset.sv
45 lines (35 loc) · 868 Bytes
/
set_reset.sv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//--------------------------------------------------------------------------------
// set_reset.sv
// Konstantin Pavlov, [email protected]
//--------------------------------------------------------------------------------
// INFO --------------------------------------------------------------------------------
// Synchronous SR trigger variant
// No metastable state. RESET signal dominates here
/* --- INSTANTIATION TEMPLATE BEGIN ---
set_reset SR1 (
.clk( clk ),
.nrst( 1'b1 ),
.s( ),
.r( ),
.q( ),
.nq( )
);
--- INSTANTIATION TEMPLATE END ---*/
module set_reset(
input clk,
input nrst,
input s,
input r,
output logic q = 0, // aka "present state"
output nq
);
always_ff @(posedge clk) begin
if( ~nrst ) begin
q = 0;
end else begin
if( s ) q = 1'b1;
if( r ) q = 1'b0;
end
end
assign nq = ~q;
endmodule