我试图用modelsim中的verilog语言编写一个测试平台。我已经为测试平台以及测试中的模块编写了代码。但是在编译它的时候,我收到一个错误,说编译失败了。那么,我们必须在单独的模块中编写测试平台代码吗?对于被测试的模块,也必须编写相同的代码吗?
//Writing a test bench
module test_bench;
wire w1,w2,w3;
xyz(w1,w2,w3);
test_xyz(w1,w2,w3);
endmodule;
//现在,我们将定义我们在testbench模块中实现的模块
//定义模块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;
发布于 2015-01-26 12:44:06
endmodule
不需要分号。
实例应该具有实例名称:
module test_bench;
wire w1,w2,w3;
xyz dut (w1,w2,w3);
test_xyz test(w1,w2,w3);
endmodule
如果您要从初始块或alwys块中驱动信号,则它们需要是reg
而不是wire
。
module test_xyz(f,A,B);
input f;
output reg A,B; //A B are regs
*示波器:当导线被驱动时,它是一个雷格,但模块的输出驱动一条导线。Verilog类型不跨越端口边界。
EDA游乐场上的示例。
https://stackoverflow.com/questions/28144607
复制相似问题