1

I wanted to add a header file to my Verilog project. This should be a very easy thing to do. However, it turns out is is not trivial. This my header file. Let's say the file name is parameters.vh

`ifndef _parameters_vh_
`define _parameters_vh_
parameter Tm = 2;
parameter Tn = 2;
`endif

Then I include it to the top module

`include "parameters.vh"

But it cannot get synthesized. This is the error message:

Verilog HDL error at parameters.vh(3): declaring global objects is a SystemVerilog feature. I am wondering if anyone can help me here.

Martin Zabel
  • 3,589
  • 3
  • 19
  • 34
MTMD
  • 1,162
  • 2
  • 11
  • 23

2 Answers2

3

In Quartus-II, you can enable SystemVerilog features via menu Assignments -> Settings -> Verilog HDL Input.

Otherwise you have to move the inclusion of the parameters file within a module definition like here:

module top (x,y);
`include "parameters.vh"
   input x;
   output y;
   assign y = x;
endmodule // top
Martin Zabel
  • 3,589
  • 3
  • 19
  • 34
  • 2
    Although it is legal in SystemVerilog, it is never a good idea to put global definitions outside a module. Much better to put them in a package and import the package. – dave_59 Dec 12 '15 at 15:50
1

it's not a systemverilog issue, just think of what the pre processor is doing when it finds your include line. you can't have parameters outside modules, doesn't make sense.

Sam
  • 11
  • 1