File tree 2 files changed +90
-0
lines changed
2 files changed +90
-0
lines changed Original file line number Diff line number Diff line change
1
+ // --------------------------------------------------------------------------------
2
+ // reset_set.sv
3
+ // Konstantin Pavlov, [email protected]
4
+ // --------------------------------------------------------------------------------
5
+
6
+ // INFO --------------------------------------------------------------------------------
7
+ // SR trigger variant
8
+ // No metastable state. SET dominates here
9
+
10
+
11
+ /* --- INSTANTIATION TEMPLATE BEGIN ---
12
+
13
+ reset_set RS1 (
14
+ .clk( clk ),
15
+ .nrst( 1'b1 ),
16
+ .s( ),
17
+ .r( ),
18
+ .q( ),
19
+ .nq( )
20
+ );
21
+
22
+ --- INSTANTIATION TEMPLATE END ---*/
23
+
24
+
25
+ module reset_set (
26
+ input wire clk,
27
+ input wire nrst,
28
+ input wire s,
29
+ input wire r,
30
+ output reg q = 0 , // aka "present state"
31
+ output wire nq
32
+ );
33
+
34
+ always_ff @ (posedge clk) begin
35
+ if (~ nrst) begin
36
+ q = 0 ;
37
+ end else begin
38
+ if r q = 0 ;
39
+ if s q = 1 ;
40
+ end
41
+ end
42
+
43
+ assign nq = ~ q;
44
+
45
+ endmodule
Original file line number Diff line number Diff line change
1
+ // --------------------------------------------------------------------------------
2
+ // set_reset.sv
3
+ // Konstantin Pavlov, [email protected]
4
+ // --------------------------------------------------------------------------------
5
+
6
+ // INFO --------------------------------------------------------------------------------
7
+ // SR trigger variant
8
+ // No metastable state. RESET dominates here
9
+
10
+
11
+ /* --- INSTANTIATION TEMPLATE BEGIN ---
12
+
13
+ set_reset SR1 (
14
+ .clk( clk ),
15
+ .nrst( 1'b1 ),
16
+ .s( ),
17
+ .r( ),
18
+ .q( ),
19
+ .nq( )
20
+ );
21
+
22
+ --- INSTANTIATION TEMPLATE END ---*/
23
+
24
+
25
+ module set_reset (
26
+ input wire clk,
27
+ input wire nrst,
28
+ input wire s,
29
+ input wire r,
30
+ output reg q = 0 , // aka "present state"
31
+ output wire nq
32
+ );
33
+
34
+ always_ff @ (posedge clk) begin
35
+ if (~ nrst) begin
36
+ q = 0 ;
37
+ end else begin
38
+ if s q = 1 ;
39
+ if r q = 0 ;
40
+ end
41
+ end
42
+
43
+ assign nq = ~ q;
44
+
45
+ endmodule
You can’t perform that action at this time.
0 commit comments