SVTB 2005.06 LG 01
SVTB 2005.06 LG 01
SVTB 2005.06 LG 01
Verification Flow
Learning Objectives
Lab Duration:
30 minutes
Getting Started
Once logged in, you will see three directories: rtl, labs and solutions.
In this lab, you will develop a simple SystemVerilog test program to reset the
DUT.
Test program
Configure DUT
program router_test
reset()
router
DUT
reset_n
Lab Overview
This lab takes you through the process of building, compiling, simulating and
debugging the testbench:
Generate
SystemVerilog files
Develop testbench to
reset DUT
Verify simulation
results with DVE
Note: You will find Answers for all questions and solutions in the
Answers / Solutions at the end of this lab.
Configure
Generator Coverage
Test
Transactor Self Check Transactor program
Top level
harness file
Driver Monitor
DUT
interface
router.v
Discard
router.test_top.v router.vr.tmp router.if.vrh
simv
This command creates three files intended to be used for the VCS Native
Testbench simulation environment. You will be using only one of the files,
router.test_top.v. The other two will be discarded.
module router_test_top;
...
endmodule
To:
This starts the process of building the interface between the DUT and the test
program.
5. Retain the wire declarations with the exception of clock and delete all other
content of the interface block.
Change:
To:
At this stage, all interface signals are asynchronous and without direction
specification (i.e. input, output, inout).
The next step is to create the set of synchronous signal for the test program to
drive and sample the DUT signals. This is done with clocking block
declarations.
7. Declare a clocking block driven by the posedge of the signal clock. This
clocking block will be used by the test program to execute synchronous drives
and samples. All directions for the signals in this clocking block must be with
respect to the test program.
8. In the clocking block, make sure that race conditions are avoided by adding in
specification for input and output skews:
9. Lastly, create a modport to be used for connection with the test program. In
the argument list, there should be references to the clocking block created in
the previous step and all other potential asynchrous signals.
2. In this file, declare a test program block with arguments which connects to the
TB modport in the interface block:
endprogram
1. Create the SystemVerilog test harness file by rename the Verilog test harness
file created by the template generator:
> mv router.test_top.v router.test_top.sv
3. Clean out the content of the file keeping only the following:
module router_test_top;
parameter simulation_cycle = 100;
reg SystemClock;
router dut(
.reset_n (reset_n),
.clock (clock),
.din (din),
.frame_n (frame_n),
.valid_n (valid_n),
.dout (dout),
.valido_n (valido_n),
.busy_n (busy_n),
.frameo_n (frameo_n)
);
initial begin
SystemClock = 0;
forever begin
#(simulation_cycle/2)
SystemClock = ~SystemClock;
end
end
endmodule
module router_test_top;
parameter simulation_cycle = 100;
reg SystemClock;
router_io top_io(SystemClock); // instantiating interface
router dut( … );
initial begin
SystemClock = 0;
...
end
endmodule
5. Instantiate the test program (make I/O connection via interface instance):
module router_test_top;
parameter simulation_cycle = 100;
reg SystemClock;
router_io top_io(SystemClock); // instantiating interface
router_test test(top_io); // add program
router dut( … );
initial begin
SystemClock = 0;
...
end
endmodule
module router_test_top;
parameter simulation_cycle = 100;
reg SystemClock;
router_io top_io(SystemClock); // instantiating interface
router_test test(top_io, top_io.reset_n); // add program
router dut(
.reset_n (top_io.reset_n),
.clock (top_io.clock),
.din (top_io.din),
.frame_n (top_io.frame_n),
.valid_n (top_io.valid_n),
.dout (top_io.dout),
.valido_n (top_io.valido_n),
.busy_n (top_io.busy_n),
.frameo_n (top_io.frameo_n)
);
initial begin
SystemClock = 0;
Connect DUT via
...
end interface instance
endmodule
VCS will compile the files and create an executable file called simv.
simv
2. In the program block define a task called reset()to reset the DUT per spec.
as described in lecture: (bear in mind that reset_n is an asynchronous
signal where as all other signals are synchronous to the clock signal)
clock
reset_n
frame_n[i]
15 clock
3. Replace the $display() call in the initial block to create vcd+ dump file
with $vcdpluson followed by calling the reset() task.
When completed, your program should look like:
Once you are finished writing the router.vr routine, compile and simulate the router
rtl code with the OpenVera testbench. This is done in a single step.
Did the simulation execute correctly? Looking at the simulation print out,
there is no way to know for sure. You will need to examine the simulation
waveform with a waveform viewer to verify that your testbench was executed
correctly.
For future compile/simulate iterations, there is a make file (Makefile)
already written to simplify this process. To use it, just type “make” to
recompile and run simulation.
The content of the Makefile is as follows:
sim:
./simv | tee log
template:
ntb_template -t router -c clock $(RTL)
sv_cmp:
vcs -sverilog -PP -debug_all $(RTL) $(SVTB)
clean:
rm -rf simv* csrc* *.tmp *.vpd *.key *.log log *.tcl *.old *debugger_rc
nuke: clean
rm -rf *.v* *.sv include .*.lock .*.old
The DVE debugging windows should now be opened with the RTL hierarchy and
source code. This window is the Source window of DVE.
The only signal that shows up is the signal declared in the top level harness
file, SystemClock. To add other signals, you will need to add the rest of the
signals.
6. Select Signal -> Signal Group to open up a window for configuring signals.
In the Signal Groups window, you can access the signals in the interface block and
placing them into either the existing signal group or create new signal groups. In
this step, you will be creating new signal groups.
8. To create a new signal group, click on router_io, Then, highlight the signals
in middle pane, and drag and drop them into New Group on the right pane.
10. Close the Signal Group window to go back to the Waveform window.
11. Click on Signal -> Display Signal Group -> All in the Waveform window to
see the waveforms.
13. Visually verify the operation of the reset signal in the Waveform window. If
there are errors, correct the error then type “make” to re-compile and re-
simulate the modified code.
If there are no errors, you are done with lab1.
Answers / Solutions
router.if.sv Solution:
router.tb.sv Solution:
initial begin
$vcdpluson;
reset();
end
task reset();
router.reset_n <= 1'b0;
router.cb.frame_n <= '1;
router.cb.valid_n <= '1;
##2 router.cb.reset_n <= 1'b1;
repeat(15) @(router.cb);
endtask
endprogram
router.test_top.sv Solution:
module router_test_top;
reg SystemClock;
router_io top_io(SystemClock);
router_test test(top_io);
router dut(
.reset_n (top_io.reset_n),
.clock (top_io.clock),
.din (top_io.din),
.frame_n (top_io.frame_n),
.valid_n (top_io.valid_n),
.dout (top_io.dout),
.valido_n (top_io.valido_n),
.busy_n (top_io.busy_n),
.frameo_n (top_io.frameo_n)
);
initial begin
SystemClock = 0;
forever begin
#(simulation_cycle/2)
SystemClock = ~SystemClock;
end
end
endmodule