Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Verilog 如何编写多模块测试台?_Verilog_Test Bench - Fatal编程技术网

Verilog 如何编写多模块测试台?

Verilog 如何编写多模块测试台?,verilog,test-bench,Verilog,Test Bench,我是这个领域的新手, 我不知道以前有没有人问过他们。 我通过创建单独的模块来编写代码,以适应大型项目。 我在创建模块方面没有问题,但我不知道如何创建测试台。所以我应该根据主模块编写测试台。 但是主模块是参照3个独立的模块创建的。 下面代码的testbench应该是什么? 你能帮我查一下这个密码吗 //location of the main program module circuit1_main(A,sel_m,Q); input [2:0]A; input sel_m; output Q

我是这个领域的新手, 我不知道以前有没有人问过他们。 我通过创建单独的模块来编写代码,以适应大型项目。 我在创建模块方面没有问题,但我不知道如何创建测试台。所以我应该根据主模块编写测试台。 但是主模块是参照3个独立的模块创建的。 下面代码的testbench应该是什么? 你能帮我查一下这个密码吗

//location of the main program

module circuit1_main(A,sel_m,Q);

input [2:0]A;
input sel_m;
output Q;
wire clk_m,reset_m,ud_m,load_m;

wire [2:0]A;
wire sel_m;
wire Q;

wire internal1;
wire internal2;
wire internal3;
wire internal4;

circuit1_counter cnt1(.clk(clk_m),.reset(reset_m),
                 .en(1'b1),.ud(ud_m),.load(load_m),
                      .d(A),.cnt(internal1));

assign internal2 = ~internal1;


circuit1_mux mux1(.a(internal1),.b(internal2),
                  .sel(sel_m),.out(internal3));


circuit1_shiftreg shiftreg1(.clk(clk_m),.reset(reset_m),
                            .sin(internal3),.sout(internal4));

assign Q = internal4;

endmodule

我有一些坏消息要告诉你:你不能为你的“circuit1_main”写一个测试台,因为它已经坏了

您的模块有许多内部信号:
clk\u m、reset\u m、ud\u m、load\u m应该全部来自外部。它们都应该是您必须从测试台上驾驶的输入端口

我怀疑,从使用“主”这个名字,你更容易使用C,C++或其他标准编程语言。认识到编写HDL是完全不同的,这一点非常重要。因此,我建议您看看现有的一些HDL代码。
我知道互联网上到处都是FIFO、UART、计数器等的HDL示例,但测试台很少,而且相差很远,只有代码和附带的测试台

我还建议您不要将代码拆分为非常非常小的模块:您的
circuit1\u mux
将是一行代码:
assign out=sel?a:b1编写一个模块并将其连接起来的工作量是使用这一行代码的十倍,而且更容易混淆。
out
等于
a
还是
b
sel\u m
较高时

1替换端口名可能会使其为'assign internal3=sel\m?内部1:内部2;这会让任何人立即明白,sel_m选择了内部案例