【问题标题】:SystemVerilog Class inside Generate生成内的 SystemVerilog 类
【发布时间】:2021-08-04 05:40:22
【问题描述】:

我想在一个 SystemVerilog 类构造函数中使用 使用如下参数的 generate-if 语句:

N 是一个输入参数。

generate begin
   if(N == 144) fft_144 fft = new; 
  else if(N == 180) fft_180 fft = new;  
end
endgenerate

这样我可以在代码中使用 fft.something。 Vivado 报错。

谢谢。

【问题讨论】:

  • 显示错误信息。显示示例中所有内容的声明。

标签: class parameters verilog generate


【解决方案1】:

Verilog 不允许您在程序块之外创建动态对象(即类)。所以,你错过了initial fft = new;

这是一个例子:

class A;
  function new();
  endfunction
endclass
class B;
  function new();
  endfunction
endclass

module C#(int N = 0)();
  A a;
  B b;
  if (N == 0)
    initial a = new;
  else 
    initial b = new;
endmodule

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多