Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[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
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
 

dave_59

Advanced Member level 3
Joined
Dec 15, 2011
Messages
816
Helped
361
Reputation
726
Reaction score
354
Trophy points
1,353
Location
Fremont, CA, USA
Activity points
6,586
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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top