Warning:Instantiation 深度...这可能表示递归实例化
Warning:Instantiation depth... This might indicate a recursive instantiation
我想用 2to1 mux 实现 4to1 mux。但是,我无法模拟 4to1 mux testbench。
我已经在其他来源中搜索了问题,但找不到问题。
module mux2to1(I0,I1,A,Z);
input I0,I1,A;
output Z;
assign Z = (~A & I0) | (A & I1);
endmodule
module mux4to1(I0,I1,I2,I3,A,B,Z,R3,R4);
input I0,I1,I2,I3,A,B;
output Z,R3,R4;
mux2to1 mux2 (I0,I1,B,R3);
mux2to1 mux3 (I2,I3,B,R4);
mux2to1 mux4 (R3,R4,A,Z);
endmodule
`timescale 1ns/1ns
module mux4to1_tb();
reg I0,I1,I2,I3,A,B,R3,R4;
wire Z;
mux4to1 mux5 (I0,I1,I2,I3,A,B,Z,R3,R4);
initial begin
A=0; B=0; I0=1; I1=0; I2=0; I3=0; #1;
A=0; B=0; I0=0; I1=0; I2=0; I3=0; #1;
A=0; B=1; I0=0; I1=1; I2=0; I3=0; #1;
A=0; B=1; I0=0; I1=0; I2=0; I3=0; #1;
A=1; B=0; I0=0; I1=0; I2=1; I3=0; #1;
A=1; B=0; I0=0; I1=0; I2=0; I3=0; #1;
A=1; B=1; I0=0; I1=0; I2=0; I3=1; #1;
A=1; B=1; I0=0; I1=0; I2=0; I3=0;
end
endmodule
当我在另一个模拟器上编译你的代码时,我得到了这个有用的编译错误消息:
mux4to1 mux5 (I0,I1,I2,I3,A,B,Z,R3,R4);
|
xmelab: *E,RANOTL : A reg is not a legal lvalue in this context [6.1.2(IEEE)].
将信号连接到模块输出时,应将它们声明为 wire
,而不是 reg
。在您的测试台中,更改:
reg I0,I1,I2,I3,A,B,R3,R4;
wire Z;
至:
reg I0,I1,I2,I3,A,B;
wire Z,R3,R4;
这为我清除了错误,并为我清除了模拟 运行s,没有任何警告。您也可以尝试在 edaplayground 的不同模拟器上 运行 您的代码。有时您会收到更多有用的消息。
我想用 2to1 mux 实现 4to1 mux。但是,我无法模拟 4to1 mux testbench。
我已经在其他来源中搜索了问题,但找不到问题。
module mux2to1(I0,I1,A,Z);
input I0,I1,A;
output Z;
assign Z = (~A & I0) | (A & I1);
endmodule
module mux4to1(I0,I1,I2,I3,A,B,Z,R3,R4);
input I0,I1,I2,I3,A,B;
output Z,R3,R4;
mux2to1 mux2 (I0,I1,B,R3);
mux2to1 mux3 (I2,I3,B,R4);
mux2to1 mux4 (R3,R4,A,Z);
endmodule
`timescale 1ns/1ns
module mux4to1_tb();
reg I0,I1,I2,I3,A,B,R3,R4;
wire Z;
mux4to1 mux5 (I0,I1,I2,I3,A,B,Z,R3,R4);
initial begin
A=0; B=0; I0=1; I1=0; I2=0; I3=0; #1;
A=0; B=0; I0=0; I1=0; I2=0; I3=0; #1;
A=0; B=1; I0=0; I1=1; I2=0; I3=0; #1;
A=0; B=1; I0=0; I1=0; I2=0; I3=0; #1;
A=1; B=0; I0=0; I1=0; I2=1; I3=0; #1;
A=1; B=0; I0=0; I1=0; I2=0; I3=0; #1;
A=1; B=1; I0=0; I1=0; I2=0; I3=1; #1;
A=1; B=1; I0=0; I1=0; I2=0; I3=0;
end
endmodule
当我在另一个模拟器上编译你的代码时,我得到了这个有用的编译错误消息:
mux4to1 mux5 (I0,I1,I2,I3,A,B,Z,R3,R4);
|
xmelab: *E,RANOTL : A reg is not a legal lvalue in this context [6.1.2(IEEE)].
将信号连接到模块输出时,应将它们声明为 wire
,而不是 reg
。在您的测试台中,更改:
reg I0,I1,I2,I3,A,B,R3,R4;
wire Z;
至:
reg I0,I1,I2,I3,A,B;
wire Z,R3,R4;
这为我清除了错误,并为我清除了模拟 运行s,没有任何警告。您也可以尝试在 edaplayground 的不同模拟器上 运行 您的代码。有时您会收到更多有用的消息。