SR Latch (NOR-based)
Introduction
An SR latch stores one bit of information using Set (S) and Reset (R) inputs. It is level-sensitive and implemented using NOR gates in this version.
Problem Statement
Design an SR latch that sets the output when S is high, resets the output when R is high, and holds the output when both S and R are low.
Specifications
-
Inputs: S (Set), R (Reset)
​
-
Outputs: Q, Qbar (Complement)
​
-
Invalid state occurs when S=1 and R=1 simultaneously
Truth Table

Verilog RTL Code
Verilog
module sr_latch_nor (
input wire S,
input wire R,
output wire Q,
output wire Qbar
);
assign Q = ~(R | Qbar);
assign Qbar = ~(S | Q);
endmodule
Testbench Code
Verilog
module tb_sr_latch_nor();
reg S, R;
wire Q, Qbar;
sr_latch_nor tb_sr_latch (.S(S), .R(R), .Q(Q), .Qbar(Qbar));
initial begin
$monitor("Time=%0t | S=%b R=%b | Q=%b Qbar=%b", $time, S, R, Q, Qbar);
S = 0; R = 0;
#5 S = 1; R = 0;
#5 S = 0; R = 1;
#5 S = 0; R = 0;
#5 S = 1; R = 1; // Invalid
#5 $finish;
end
endmodule
