(1). 先撰寫Test.v、testbench.v、Makefile。
/*****RTL code*****/
`timescale 1ns / 1ns
module Test(a, b, c, d, En, Sel, f);
input a, b, c, d, En, Sel;
output f;
wire f;
wire g, h, i, j;
assign g = a | b;
assign i = g & En;
assign h = c | d;
assign j = h & En;
assign f = (Sel==1'b0) ? i : j;
endmodule
/*****Testbench*****/
`timescale 1ns / 1ns
module testbench;
reg a, b, c, d, En, Sel;
wire f;
Test UUT(
.a(a),
.b(b),
.c(c),
.d(d),
.En(En),
.Sel(Sel),
.f(f) );
initial
begin
a = 1'b0; // Time = 0
b = 1'b1;
c = 1'b0;
d = 1'b1;
En = 1'b0;
Sel = 1'b0;
#20; // Time = 20
a = 1'b1;
#10; // Time = 30
b = 1'b0;
c = 1'b1;
#10; // Time = 40
a = 1'b0;
#10; // Time = 50
En = 1'b1;
#10; // Time = 60
c = 1'b0;
#10; // Time = 70
a = 1'b1;
d = 1'b0;
#20; // Time = 90
c = 1'b1;
#20; // Time = 110
a = 1'b0;
#10; // Time = 120
a = 1'b1;
#10; // Time = 130
c = 1'b0;
Sel= 1'b1;
#10; // Time = 140
a = 1'b0;
#30; // Time = 170
a = 1'b1;
#10; // Time = 180
c = 1'b1;
#20; // Time = 200
a = 1'b0;
end
//for Verdi simulation
`ifdef DUMP_FSDB
initial
begin
$fsdbDumpfile("Test.fsdb"); //RTL
$fsdbDumpvars(0,"testbench");
end
`endif
endmodule
/*****Makefile*****/
VLOG = vcs
SIM = ./simv
VERDI = verdi
SRC = Test.v testbench.v
VLOG_CONF = -l readme.log +v2k -full64 -debug +define+DUMP_FSDB \
<Tab>-P /opt/Synopsys/Verdi2015/share/PLI/VCS/linux64/novas.tab \
<Tab>/opt/Synopsys/Verdi2015/share/PLI/VCS/linux64/pli.a
SIM_CONF = -l run.log
VERDI_CONF = -sv -nologo -undockWin -ssf Test.fsdb
RM = -rm -rf
TMPFILE = simv.* \
<Tab>*.log *.vpd *.key *.conf *.rc *.fsdb *.dat \
<Tab>simv* csrc* DVE* INCA* verdi* waves*
help:
<Tab>@echo "make help"
<Tab>@echo "make all"
<Tab>@echo "make comp"
<Tab>@echo "make sim"
<Tab>@echo "make verdi"
<Tab>@echo "make clean"
all::clean comp sim verdi
comp:
<Tab>$(VLOG) $(SRC) $(VLOG_CONF)
sim:
<Tab>$(SIM) $(SIM_CONF)
verdi:
<Tab>$(VERDI) $(SRC) $(VERDI_CONF)
clean:
<Tab>$(RM) $(TMPFILE)
(2). 存檔至同一資料夾下。