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

在verilog中将一个设备的输出寄存器设置为另一个设备的输入,verilog,hdl,Verilog,Hdl,我想将一个模块的输出寄存器的值用作另一个模块的输入。我如何才能这样做? 下面的代码显示了当我尝试将3位递增计数器的输出连接到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(clk

我想将一个模块的输出寄存器的值用作另一个模块的输入。我如何才能这样做? 下面的代码显示了当我尝试将3位递增计数器的输出连接到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
模块组合(时钟、enb、rest、dec);
输入时钟、enb、rest;
输出寄存器[7:0]dec;
导线[2:0]Q;
thrbitup uno(clk、Q、enb、rest);
egtbtdec dec1(Q,dec);
端模
模块thrbitup(clkk、q、en、res);
输入clkk、en、res;
输出寄存器[2:0]q;
始终@(posedge clkk、negedge res)
如果(res==0)

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

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

因此,删除顶层模块中的reg:

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”