将一个设备的输出寄存器设置为Verilog中另一设备的输入

问题描述 投票:0回答:1

我想将一个模块的输出reg的值用作另一个模块的输入。我该怎么做?以下代码显示了当我尝试将3位upcounter的输出连接到3to8解码器时的错误]

module combouno(clk,enb,rest,dec);
input clk,enb,rest;
output reg [7:0]dec;
 wire [2:0]Q;
thrbitup uno(clk,Q,enb,rest);   
egtbtdec dec1(Q,dec);
endmodule
module thrbitup(clkk,q,en,res);
input clkk,en,res;
output reg [2:0]q;
always@(posedge clkk,negedge res)

if(res==0)
q<=0;

else if(en)
q<=q+1;


endmodule

module egtbtdec(x,y);
input [2:0]x;
output reg [7:0]y;

always@(x)
begin
case(x)
3'b000 : y=8'b00000001;
3'b001 : y=8'b00000010;
3'b010 : y=8'b00000100;
3'b011 : y=8'b00001000;
3'b100 : y=8'b00010000;
3'b101 : y=8'b00100000;
3'b110 : y=8'b01000000;
3'b111 : y=8'b10000000;
endcase
end 
endmodule

错误如下错误(10663):combouno.v(6)上的Verilog HDL端口连接错误:必须将输出或输入端口“ y”连接到结构网络表达式

verilog hdl
1个回答
0
投票

您的端口仅应在分配值的位置为'reg'。

层次结构中传递此信号的任何其他端口都不需要知道原始端口是reg还是wire。

因此删除顶级模块中的注册表:

module combouno(clk,enb,rest,dec);
input clk,enb,rest;
output [7:0]dec;

无论如何,最好切换到ANSI端口样式:

module combouno
   (
   input clk,enb,rest, 
   output [7:0]dec  
   );

还要检查输入错误:您使用的是'res'和'rest'。

© www.soinside.com 2019 - 2024. All rights reserved.