Just wanting to expand on what I said in a comment in reply to this:
What's wrong with begin and end? – Paul S yesterday
@PaulS: because then my_macro(1); expands to begin end; and that trailing semicolon is a syntax error. And how does the person who called my macro know whether it's a single statement or a multi-statement one? (or it might even change ...) – dave yesterday
The UVM library uses the following idiom extensively:
`define uvm_info(ID,MSG,VERBOSITY) \
begin \
if (uvm_report_enabled(VERBOSITY,UVM_INFO,ID)) \
uvm_report_info (ID, MSG, VERBOSITY, `uvm_file, `uvm_line); \
end
I've never had IES report a syntax error because I put a trailing semicolon on that macro, and I'm pretty sure I do it a lot. Granted I can't find in the spec if it should be a syntax error or not, but I think it gets interpreted as a null statement.
Regardless, I think it's probably a good rule to say that if my_macro
is a single statement it should include its ;
. Then single statement and multi statement macros work in the same way.