Verilog
Verilog
To
HDL
Verilog HDL
Debdeep Mukhopadhyay
debdeep@cse.iitm.ernet.in
Dept of CSE, IIT Madras 1
How it started!
endmodule a f1
nsel g1
g4
g3 f
b
g2
sel f2
endmodule a f1
nsel g1
g4
g3 f
b
g2
sel f2
endmodule a
f
b
sel
endmodule a
f
b
sel
endmodule
f
b
sel
• module reg_ex1;
reg Q; wire D;
always @(posedge clk) Q=D;
• Instances of
a = 1; a <= 1;
b = a; b <= a;
c = b; c <= b;
a = 1; “
a b c
b = a; ”
1
c = b;
1 a
a <= 1;
“
b <= a; b ”
c <= b;
c
Stimulus
Response
Result
checker
Alternative:
• Testbench
module testmux;
reg a, b, s;
wire f;
reg expected;
initial
begin
s=0; a=0; b=1; expected=0;
#10 a=1; b=0; expected=1;
#10 s=1; a=0; b=1; expected=1;
end
initial
$monitor(
"select=%b in0=%b in1=%b out=%b, expected out=%b time=%d",
s, a, b, f, expected, $time);
endmodule // testmux
Accelerate
SLOW MEDIUM
Brake
Accelerate
Accelerate
Brake Brake
~Brake
STOP FAST
endmodule