【问题标题】:Calling a Module in Verilog在 Verilog 中调用模块
【发布时间】:2025-12-28 07:50:10
【问题描述】:

我刚开始使用 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
    );

谁能指出这里的错误?

【问题讨论】:

  • 基本上,您调用模块的方式与不调用 IC 的方式不同。您实例化一个模块,当您焊接一个 IC 时,您就是在“实例化”它。
  • 我明白了 - 谢谢

标签: verilog hardware vivado


【解决方案1】:

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

对手机 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

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

【讨论】: