作爲第一稿我會看的東西像這一點。
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 +測試平臺+爲半+加法 –