【发布时间】:2015-01-26 03:56:34
【问题描述】:
我正在尝试在 modelsim 中用 verilog 编写一个测试台。我已经为测试平台和被测模块编写了代码。但是在编译它时,我收到一条错误消息,说编译失败。 那么我们是否必须在单独的模块中编写测试台代码,并且对于被测模块也一样?
//Writing a test bench
module test_bench;
wire w1,w2,w3;
xyz(w1,w2,w3);
test_xyz(w1,w2,w3);
endmodule;
//现在我们将定义我们在测试平台模块中实例化的模块
//定义模块xyz
module xyz(f,A,B);
input A,B;
output f;
nor(f,A,B);
endmodule;
//Defining the test module which we are going to apply to the module xyz
module test_xyz(f,A,B);
input f;
output A,B;
initial
begin
$monitor ($time ,"A=%b","B=%b", "f=%b",A,B,f);
#10 A=0;B=0;
#10 A=1;B=0;
#10 A=1;B=1;
#10 $finish ;
end
endmodule;
【问题讨论】: