[SOLVED] how to write multi line macro in verilog

Status
Not open for further replies.

hulk789

Junior Member level 3
Joined
Jul 18, 2015
Messages
27
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
211
Code:
`define print(v)\ 
$display("var v=%h",v)

module try();
reg [3:0] test1=4'b1111;
initial begin
  `print(test1);
end
endmodule
The above code is valid in system verilog but in verilog it will give the error
$display("var v=%h",v)
|
ncvlog: *E,EXPMPA (1.v,2|7): expecting the keyword 'module', 'macromodule' or 'primitive'[A.1].
`print(test1);
|
ncvlog: *E,NOTSTT (1.v,7|15): expecting a statement [9(IEEE)].
module worklib.try:v
errors: 1, warnings: 0
 

The problem is you have a space after the \, so you are escaping the space, not the newline.

This should be an error regardless of Verilog or SystemVerilog.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…