# backtick in verilog numeric constant

So I was writing some verilog in quartus and wondering why the heck it was misbehaving.

I eventually discovered the problem was some constants where I had inadvertantly used a backtick instead of a single quote. For example I had 32hdeadbeef instead of 32'hdeadbeef.

What I find surprising is that this compiled, did I find a bug in quartus? is this some obscure bit of verilog syntax? if so what does it mean?

I have just been reading the IEEE standard about macro's and defines. There is nothing in there which says that the macro name must be known. (In your case hdeadbeef would not match any define).

However I can imagine them not defining that as that would be too far fetched.

Using common sense I would say it is a bug in the parser.

Speculating:
The following is allowed:

ifdef this_variable_is_not_defined


So maybe the code for that got also used for this_macro_does_not_exist

• It does seem quite plausible that it is treating the unknown macro as an empty string and then treating the number that was supposed to represent the width as a straight decimal constant of default width. – Peter Green Mar 9 '18 at 19:35
• That is what I was assuming. Just tried it in Vivado but there I get an error message. – Oldfart Mar 9 '18 at 19:38
• I haven't tried Vivado but I have noticed in the past that Quartus is a lot less strict about Verilog than Modelsim is. – Peter Green Mar 9 '18 at 19:42
• The LRM says "After a text macro is defined, it can be used in the source description by using the (  ) character, followed by the macro name." I understand this to mean "before a text macro is defined, it cannot be used ..." Otherwise, a simple misspelling of a compiler directive, like celdefine would go unnoticed. This is the only rational behavior. – dave_59 Mar 10 '18 at 5:29

This is most likely a bug and should have been an error . The backtick  is only used in with compiler directives

• Yes, and one of those directives is define <name> -- and when you want to use <name> in a statement, you say <name>. Not a bug. – Dave Tweed Mar 9 '18 at 23:18
• @DaveTweed that assumes someone already has the statement define deadbeef in their code, which I doubt – dave_59 Mar 10 '18 at 0:27
• No, it doesn't. It's perfectly OK to refer to an undefined symbol, which expands to nothing. – Dave Tweed Mar 10 '18 at 1:52
• Not true. You should get an undefined compiler directive or macro. Try it. – dave_59 Mar 10 '18 at 2:38