The major tasks for creating a testbench are as follows:
-
Create a top level for your design by connecting and instantiating the digital and analog components.
In the following excerpt, wiresvcoclk,clock_2,clock_1,clock_0,net036, andp0connect to the digital instances (counteranddivider) and the analog instance (pll_top):// Testbench`timescale 1ps/1psmodule testbench ();
...wire vcoclk, clock_2, clock_1, clock_0, net036, p0;
...counter counter (reset, vcoclk, clock_2, clock_1, clock_0);divider divider (vcoclk, net036, p0, reset);pll_top pll_top (refclk, reset, vcoclk, clock_2, clock_1, clock_0, net036, p0, clk_p0_1x, clk_p0_4x);
endmoduleIn a testbench file, you do not have to declare the
electricaldiscipline for any wires even when you use them to connect to the ports of analog instances. You therefore do not need to include thedisciplines.vamsfile. -
Create the stimuli to the device under test (DUT).
In the following excerpt, we add reset andrefclk:// Testbench`timescale 1ps/1ps
module testbench ();reg reset;reg refclk;...wire vcoclk, clock_2, clock_1, clock_0, net036, p0;
initial beginreset=1;#200reset=0;end
initial beginrefclk=0;#200refclk=1;endalways #2500refclk=~refclk;...counter counter (reset, vcoclk, clock_2, clock_1, clock_0);divider divider (vcoclk, net036, p0, reset);pll_top pll_top (refclk, reset, vcoclk, clock_2, clock_1, clock_0, net036, p0, clk_p0_1x, clk_p0_4x);
endmodule - (Optional) Monitor or self-check the output.
You can monitor the output by adding$monitorto your module definition:
initial begin
$monitor (y);
end
