>> I would like the behavior to match the C
>>preprocessor, but did not mean to imply that what I want was
>>already LRM specified.
>
>Everywhere you look, Verilog and SV resemble - but seldom
>accurately mimic - C.
Unfortunately very true. Of course that's not an argument
to avoid pulling more features from C.
>>Here's an example to disect further. The VALUEb one seems
>>to fail on (I suspect) every simulator.
>>
>>`define ZERO_0 "0"
>>`define CONCAT(a, b) a``b
>>`define NOTNOT(a) a
>>`define VALUEa(a) `CONCAT(`ZERO_,a)
>>`define VALUEb(a) `CONCAT(`ZERO_,`NOTNOT(a))
>>
>>module t;
>> initial begin
>>`define CNT 0
>> // Works on at least one
>> $write("EXP: '0' GOT '"); $write(`VALUEa(`CNT)); $write("'\n");
>> // Fails on the one that DOES work
>> $write("EXP: '0' GOT '"); $write(`VALUEb(`CNT)); $write("'\n");
>> end
>>endmodule
>>
>>Follwing the `VALUEb expansion, I would like the LRM to require:
>>
>> `VALUEb(`CNT) // LRM: outer first
>> `CONCAT(`ZERO_,`NOTNOT(`CNT)) // LRM: outer first
>> `ZERO_```NOTNOT(`CNT) // See below
>> `ZERO_``CNT // Same rule as above
>
>The three possibilities I see are
>
> `ZERO_```CNT ,
> `ZERO_`NOTNOT(`CNT) , or
> *** Undefined macro `ZERO_ ***.
>
>Of these, the middle one seems most in tune with the LRM:
>
>`` cannot delimit tokens indefinitely; it should vanish
>along with the formal argument(s) it conjoined.
>
>Recall that the stated purpose for `` is "allowing
>identifiers to be constructed from arguments."
Which I think is what I'm trying to do; what isn't clear is
what if the "argument" is another macro call?
>>[Does anyone know a workaround to get the behavior I would
>>like?]
>
>Yes - parrot the LRM examples and write:
>
>`define REPEAT(n, d) `REPEAT_``n(d)
That isn't the problem; I should have been more specific.
Can we rewrite REPEAT (preferrably with an existing
simulator, or at least in a way that *might* be next-spec
compliant) so that this will work:
`REPEAT(`FUNC(n), d)
Or this
`REPEAT(`REPEAT(n,foo), d)
>expand the actual argument macro invocation at the point
>when it is used in a formal substitution.
Yes, I think that's the right track.
-Wilson
-- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.Received on Wed Jun 23 05:26:29 2010
This archive was generated by hypermail 2.1.8 : Wed Jun 23 2010 - 05:29:33 PDT