使用ModelSim PE Student Edition 10.4a。为1-4多路分配器编写了一个模块。为该模块写了一个测试台。编译好。当试图模拟,我得到以下错误:Verilog - 端口大小与连接大小不匹配
#**警告:(VSIM-3015)d:/ModelSim/examples/Lab3_3.v(42):PCDPC] - 端口尺寸(1)与端口'in'的连接大小(4)不匹配。端口定义位于:D:/ModelSim/examples/Lab3_3.v(1)。 D/ModelSim/examples /错误(可压缩):(vsim-3053)D:/ ModelSim/examples/Lab3_3.v(42):端口'out'非法输出或inout端口连接。 #Time:0 ns Iteration:0 Instance:/ tb_demux/DA0 File:D:/ModelSim/examples/Lab3_3.v
#**警告:(vsim-3015)D:/ModelSim/examples/Lab3_3.v( 42):[PCDPC] - 端口大小(4)与端口“out”的连接大小(1)不匹配。端口定义位于:D:/ModelSim/examples/Lab3_3.v(1)。
#时间:0纳秒迭代:0实例:/ tb_demux/DA0文件:d:/ModelSim/examples/Lab3_3.v
代码是:
module demux(input in, input[1:0] S, output reg[3:0] out);
always @(in or S)
begin
case(S)
2'b00: begin
out[0] = in;
out[1] = 0;
out[2] = 0;
out[3] = 0;
end
2'b01: begin
out[0] = 0;
out[1] = in;
out[2] = 0;
out[3] = 0;
end
2'b10: begin
out[0] = 0;
out[1] = 0;
out[2] = in;
out[3] = 0;
end
2'b11: begin
out[0] = 0;
out[1] = 0;
out[2] = 0;
out[3] = in;
end
endcase
end
endmodule
module tb_demux;
wire[3:0] out;
reg[1:0] S;
reg in;
demux DA0(out, S, in);
initial
begin
S = 2'b00; in = 0;
#100 S = 2'b01; in = 1;
#100 S = 2'b10; in = 0;
#100 S = 2'b11; in = 1;
end
initial #400 $stop;
initial $monitor("Select = %b, In = %b, Out = %b", S, in, out);
endmodule
似乎无法使这项工作。谢谢。
你是什么意思使用的名称,而不是订单? – whimsey
通过此链接(http://verilog.renerta.com/mobile/source/vrg00027.htm)了解Verilog中的不同实例: – vim
按名称连接:'demux DA0(.in(in),。 S(s),.out(out));'端口顺序无关紧要。另一个等价的例子:'demux DA0(.out(out),.in(in),.S(s));' – Greg