为什么我对所有电线都"Module port is neither input nor output"?



我在尝试运行程序时遇到的错误是:

Yosys失败,代码1未命名。sv:5:错误:模块端口"\D0"为既不是输入也不是输出。

所有导线都会发生这种情况。

module twobitmulti (A1, A0, B1,B0, P0, P1, P2, P3, C1, D0, D1, D2);
input A1, A0;
input B1, B0;
output P0, P1, P2, P3;
wire D0,D1,D2, C1;
assign D0 =A1&&B0;
assign D1 =A0&&B1;
assign D2 =A1&&B1;
assign C1 =D0&&D1;
assign P0 =A0&&B0;
assign P1 =D0^^D1;
assign P2 =C1^^D1;
assign P3 =C1^^D2;
endmodule

错误告诉D0在这行的端口列表中:

module twobitmulti (A1, A0, B1,B0, P0, P1, P2, P3, C1, D0, D1, D2);

但是,您后来没有使用inputoutput关键字声明D0。一个简单的修复方法是删除所有未声明的信号:

module twobitmulti (A1, A0, B1,B0, P0, P1, P2, P3);

推荐的编码样式是使用ANSI端口:

module twobitmulti (
input A1, A0,
input B1, B0,
output P0, P1, P2, P3
);
wire D0, D1, D2, C1;
assign D0 =A1&&B0;
assign D1 =A0&&B1;
assign D2 =A1&&B1;
assign C1 =D0&&D1;
assign P0 =A0&&B0;
assign P1 =D0^^D1;
assign P2 =C1^^D1;
assign P3 =C1^^D2;
endmodule

相关内容

最新更新