Skip to content

Commit 842496f

Browse files
committed
Updated SystemVerilog variants of SR trigger featuring dominant logic state
1 parent d39ccb2 commit 842496f

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed

reset_set.sv

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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

set_reset.sv

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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

0 commit comments

Comments
 (0)