【发布时间】:2021-09-10 17:48:15
【问题描述】:
我正在使用iverilog 从互联网上运行代码,如下所示:
example.v
module example
(A,B,C,D,E,F,Y);
wire t1, t2, t3, Y;
nand #1 G1 (t1,A,B);
and #2 G2 (t2,C,~B,D);
nor #1 G3 (t3,E,F);
nand #1 G4 (Y,t1,t2,t3);
endmodule
和example-test.v
module testbench;
reg A,B,C,D,E,F; wire Y;
example DUT(A,B,C,D,E,F,Y);
initial
begin
$monitor ($time," A=%b, B=%b, C=%b, D=%b, E=%b, F=%b, Y=%b", A,B,C,D,E,F,Y);
#5 A=1; B=0; C=0; D=1; E=0; F=0;
#5 A=0; B=0; C=1; D=1; E=0; F=0;
#5 A=1; C=0; D=1;
#5 F=1;
#5 $finish;
end
endmodule
我使用以下命令编译它
iverilog -o mysim example.v example-test.v
并得到以下错误:
example.v:1: error: Port A (1) of module example has no direction declaration.
example.v:1: error: Port B (2) of module example has no direction declaration.
example.v:1: error: Port C (3) of module example has no direction declaration.
example.v:1: error: Port D (4) of module example has no direction declaration.
example.v:1: error: Port E (5) of module example has no direction declaration.
example.v:1: error: Port F (6) of module example has no direction declaration.
example.v:1: error: Port Y (7) of module example has no direction declaration.
example.v:2: error: signal A in module testbench.DUT is not a port.
example.v:2: : Are you missing an input/output/inout declaration?
example.v:2: error: signal B in module testbench.DUT is not a port.
example.v:2: : Are you missing an input/output/inout declaration?
example.v 代码中的整个 Verilog 语法是否不正确/已过时?
为什么会出现编译错误?
示例取自 youtube nptel verilog tutorial
【问题讨论】: