首页 > 解决方案 > 在 Verilog 中调用模块

问题描述

我刚开始使用 Verilog 学习硬件编程,我感到迷茫,因为我无法理解错误的含义。在这里,我正在调用模块reg31

module nbit_register(input clk, input [31:0]in, input reset, input L,
input load, input shift, output reg[31:0] out);
always@(*)begin
if(load==1) 

  reg32 add(clk, in, reset,L, out);
  
   else
        out={ in[30:0],1'b0};
   end
    
   endmodule

但是,我得到这个错误:

错误:“reg32”附近的语法错误

这是模块的样子

module reg32(
    input clk,
    input [31:0] in,
    input rst,
    input  L,
    output  [31:0] out
    );

有人可以指出这里的错误吗?

标签: veriloghardwarevivado

解决方案


因为您想“选择”并使模块在分支reg32中“工作” 。if

对手机 PCB 板进行成像。扬声器单元就在那里,即使它处于静音模式。所以单独实例化reg32,然后使用自己的逻辑来处理连接到reg32.

wire [31:0] add_out;
reg32 add(clk, in, reset,L, add_out); // here the 4 inputs are connected to top inputs
                                      // directly. but if you want, you can use 'load'
                                      // to control them similar to the code below.

always@(*)begin
  if(load==1)
    out = add_out;
  else
    out = { in[30:0],1'b0};
  end

如果您主要从事软件工作,则需要熟悉以“硬件”方式思考。


推荐阅读