define macro
在define macro中:
`", 替代"
`\`",替代\"
``,一边跟在macro变量前或后,表明不需要空格。
`define msg(x,y) `"x: `\`"y`\`"`"
$display(`msg(left,right)); 扩展为 $diplay("x: \"y\"");
`define foo(f) f``_suffix
`foo(bar) 扩展为bar_suffix
如果macro的内容需要换行,则在后面加\,注意\后面不能有空格或其他字符。
`define func(x) \
int func(x){\
return x*x; \
}
浙公网安备 33010602011771号