Verilog模块3位输出

时间:2017-05-13 11:39:40

标签: module output warnings verilog hardware

我的问题似乎很简单,但不知怎的,我无法让它发挥作用。 我试图在verilog中创建一个输出3位信号的模块。到目前为止,我尝试了很多不同的方法,但似乎没有一种方法可行。 我正在使用Veriwell编译我的代码,因为我正在为大学做这个,所以我不想使用它,所以请不要向我推荐不同的编译器。

以下是我尝试过的一些方法,但没有一种方法可行 (我总是得到'端口大小与端口#2不匹配'警告)

module testmod (in, out);
  input [2:0] in;
  output [2:0] out;

  wire [2:0] out;
  assign out = in;  //trying just to connect in to out
endmodule

module testmod (in, out);
  input [2:0] in;
  output [2:0] out;

  wire [2:0] out;
  assign out = 3'b1;  //trying to assign a random value to out
endmodule

module testmod (in, out);
  input [2:0] in;
  output [2:0] out;
  reg [2:0] test;
  always @(in)
    test = in;        //saving in in a register (which i believe is unnecessary but I've tried it nonetheless)

  wire [2:0] out;
  assign out = test;  //trying just to connect in to out
endmodule

我像这样实现模块:

testmod mod (.in(3'b1), .out(out));

1 个答案:

答案 0 :(得分:0)

在我的测试平台中声明为3位信号完成了这项工作。由于我只使用了1位输出信号,显然根本不需要在测试平台中声明,所以我甚至都没想到。

非常感谢您的答案!