作为第一稿我会看的东西像这一点。
reg clk = 0;
reg rst_n;
initial
begin
rst_n = 'bx;
#5
rst_n = 1'b0;
#20
rst_n = 1'b1;
end
always @(clk)
begin
clk = #10 ~clk;
end
reg a,b;
wire adder = a + b;
task test;
input i0,i1,o;
a = i0;
b = i1;
#1
if (adder !== o)
$display("Error:Incorrect output");
endtask
initial
begin
wait(rst_n === 1'b0);
@(posedge clk)
test(0,0,0);
@(posedge clk)
test(0,1,1);
@(posedge clk)
test(1,1,0);
@(posedge clk)
test(1,0,1);
end
那你还不如第二稿器的测试数据是这样的:
wire [3:0] stim_data [1:0];
wire [3:0] expected_output;
always @(posedge clk)
if (!rst_n)
begin
cnt <= 2'b00;
end
else
begin
cnt <= cnt + 1;
end
assign {a,b} = stim_data[cnt];
always @(posedge clk)
if (!rst_n)
begin
end
else
begin
if (adder !== expected_output[cnt])
// add error message
end
希望这应该让你开始。
没有什么需要被驱动的数据,你如何期望吨至知道,它的作品的具体细节,这个问题是范围广了这个论坛, –
增加了一个具体的例子 – anderspitman
的Verilog +测试平台+为半+加法 –