adder8.v
module adder8 (
input clk,
input [7:0] a_i,
input [7:0] b_i,
output reg [8:0] c_o
);
always @ (posedge clk) begin
c_o <= a_i + b_i;
end
endmodule
adder8_tb.v
`ifndef TB_SEED
`define TB_SEED 0
`endif
module tb_adder8 ();
wire [8:0] result;
reg [7:0] input_0;
reg [7:0] input_1;
reg clk;
wire #5 clk2;
assign clk2 = clk;
initial begin
// $fsdbDumpfile("top.fsdb");
// $fsdbDumpvars(0,tb_adder8);
$vcdpluson();
$display("TB_SEED is %d", `TB_SEED);
clk = 0;
input_0 = 8'd0;
input_1 = 8'd0;
#1000
$display("All test PASS!");
$finish;
end
always begin
#10 clk = ~clk;
end
// Generate input
always @ (negedge clk) begin
input_0 = $random() % 256;
input_1 = $random() % 256;
end
// Check result
always @ (posedge clk2) begin
if ((input_0 + input_1) != result) begin
$display("Test failed for %x + %x = %x", input_0, input_1, result);
$finish;
end else begin
$display("%x + %x = %x", input_0, input_1, result);
end
end
adder8 dut(
.clk(clk),
.a_i(input_0),
.b_i(input_1),
.c_o(result)
);
endmodule
makefile文件
.PHONY:comp run_dve run_verdi clean
VCS = vcs -sverilog -timescale=1ns/1ns +vpi -l build.log -debug_pp +v2k -fsdb -full64 \
-ucli -i ucli_dump_fsdb.tcl \
-LDFLAGS -rdynamic \
-vcs+lic+wait \
-P /opt/Synopsys/Verdi2015/share/PLI/VCS/LINUX64/novas.tab \
/opt/Synopsys/Verdi2015/share/PLI/VCS/LINUX64/pli.a \
-Mupdate -R
ifndef TB_SEED
TB_SEED = 500
endif
all:comp run_dve run_verdi
comp:
$(VCS) +define+TB_SEED=$(TB_SEED) +incdir+. \
adder8.v \
tb_adder8.v
run_dve:
dve -vpd vcdplus.vpd &
run_verdi:
verdi -f file.f -ssf top.fsdb -nologo -sv &
clean:
rm -rf core csrc simv* vc_hdrs.h ucli.key urg* *.log *.fsdb novas.* verdiLog *.fsdb *.vpd *.dat *files *.log
.PHONY:comp run run_dve run_verdi clean
VCS = vcs -sverilog -timescale=1ns/1ns +vpi -l build.log -debug_pp +v2k -fsdb -full64
SIMV = ./simv -l simv.log
ifndef TB_SEED
TB_SEED = 500
endif
all:comp run run_dve run_verdi
comp:
$(VCS) +define+TB_SEED=$(TB_SEED) +incdir+. \
adder8.v \
tb_adder8.v
run:
$(SIMV) +fsdbfile+top.fsdb
run_dve:
dve -vpd vcdplus.vpd &
run_verdi:
verdi -f file.f -ssf top.fsdb -nologo -sv &
clean:
rm -rf core csrc simv* vc_hdrs.h ucli.key urg* *.log *.fsdb novas.* verdiLog *.fsdb *.vpd *.dat *files *.log
filelist文件
tb_adder8.v
adder8.v
tcl文件
global env
fsdbDumpfile "top.fsdb"
fsdbDumpvars 1 "tb_adder8"
run