I am implementing SR latch without clock signal using Verilog. I am trying with the code given below, but I am getting the value of Qb
as X. Please help me.
// design.v file
module sr_latch(q,qb,s,r);// module declaration
input s,r;
output q,qb;
assign qb=~q;
nand (q,s,qb);
nand (qb,r,q);
endmodule
// testbench.v file
module stimulus;
reg set,reset;
wire Q,Qb;
sr_latch mylatch(Q,Qb,set,rest);
initial
begin
$dumpfile("dump.vcd");
$dumpvars;
$monitor($time,"set=%b,reset=%b,Q=%b,Qb=%b\n",set,reset,Q,Qb);
set=0; reset=0;
#5 set=0; reset=1;
#5 set=1; reset=0;
#5 set=1; reset=1;
end
endmodule
Result:
0set=0,reset=0,Q=1,Qb=x
5set=0,reset=1,Q=1,Qb=x
10set=1,reset=0,Q=x,Qb=x
15set=1,reset=1,Q=x,Qb=x