0

I would like to use a SystemVerilog Class constructor inside a generate-if statement using a parameter like so:

N is an input parameter.

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

This way I can use fft.something in the code. Vivado gives an error.

Thanks.

willems28
  • 1
  • 1

1 Answers1

0

Verilog does not allow you to create dynamic objects (i.e. classes) outside of procedural blocks. So, you are missing somethning like initial fft = new;

Here is an example:

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
Serge
  • 11,616
  • 3
  • 18
  • 28