14:332:231 Digital Logic Design: Ivan Marsic, Rutgers University Electrical & Computer Engineering Fall 2013
14:332:231 Digital Logic Design: Ivan Marsic, Rutgers University Electrical & Computer Engineering Fall 2013
1
Abstract Model Functionality
[ behavioral style ]
Abstract functionality is
represented using
procedures module FullAdder(input wire a,
input wire b,
Begin with the keywords input wire ci,
initial or always output reg sum, co);
– An initial procedure
will execute once, initial
beginning at simulated begin
time zero sum = 0;
co = 0;
– always procedures
end
model the continuous
operation of hardware
always @(a or b or ci)
Procedures contain begin
programming {co, sum} = a + b + ci;
statements end
endmodule
Multiple statements are
grouped with begin
and end
3 of 10
2
Verilog Time Scale
[ Verilog time dimension ]
6 of 10
3
Verilog Test Benches
Unit under test (UUT) = the entity/module being tested
– Also called Device under test (DUT)
Verilog Test Bench consists of:
– UUT
– UUT stimulus, to provide inputs to the UUT
– UUT monitor, to capture and analyze the UUT output
7 of 10
4
Example Verilog Test Bench (2)
select
initial begin
m_in0 = 1'b0;
m_in1 = 1'b0;
m_sel = 1'b0;
assert ( m_out === 0 ) else $error("000 failed");
#5 // wait 5 ns
m_in0 = 1'b1;
m_sel = 1'b1; // selects m_in1, which is 1'b0
assert ( m_out === 0 ) else $error("101 failed");
$finish;
end
endmodule // mux2_tb3
10 of 10