From: Martin W. <ic...@ma...> - 2020-10-09 11:13:46
|
On 08/10/2020 13:30, Martin Whitaker wrote: > On 08/10/2020 12:27, Evan Lavelle wrote: >> Here's another one: >> >> `define \A foo >> >> module `\A; >> initial >> $display("%m: Ok"); >> endmodule >> this code doesn't work on any of the simulators on EDA Playground >> (https://www.edaplayground.com/x/6yZJ). However, the LRM seems pretty >> clear that it should: >> >> text_macro_definition ::= `define text_macro_name macro_text >> text_macro_name ::= text_macro_identifier [( list_of_formal_arguments )] >> text_macro_identifier ::= identifier >> identifier ::= simple_identifier | escaped_identifier >> >> In other words, a text macro name can be an escaped identifier, but >> no-one seems to support this. Xcelium, at least, just creates a macro >> named 'A'. > > I don't think we could fix that without breaking recognition of the SV > `\`" escape sequence. I figured out how to implement this, and it is now fixed in both the master and v11 branches. Note that for your example to work, you need to terminate the escaped name with white space, i.e. module `\A ; It's interesting to see that most other simulators fail on this more extensive test: `define simple "simple name" `define \escaped "escaped name" `define \`name "backtick name" `define \` "backtick" `define \quote (x) `"`\`"x`\`"`" `define \`\`" "escaped quote" module test(); initial begin $display(`simple); $display(`\simple ); $display(`escaped); $display(`\escaped ); $display(`\`name ); $display(`\` ); $display(`quote(text)); $display(`\quote (text)); $display(`\`\`" ); end endmodule |