RE: [sv-bc] Expected behavior of macro concatenation of macro

From: Bresticker, Shalom <shalom.bresticker@intel.com>
Date: Tue Jun 22 2010 - 11:35:10 PDT

I tried the example on 3 different simulators.

One gave the answer you expected.

Another crashed.

The third considered the code illegal.

Wilson, we'll be establishing a sub-group to clarify macro semantics. Would you like to join?

Regards,
Shalom Bresticker

> -----Original Message-----
> From: owner-sv-bc@eda.org [mailto:owner-sv-bc@eda.org] On
> Behalf Of Wilson Snyder
> Sent: Tuesday, June 22, 2010 9:24 PM
> To: sv-bc@eda.org
> Subject: [sv-bc] Expected behavior of macro concatenation of macro
>
>
> What is the expected result of this code, which uses `` to
> build a macro name? I'd like the answer to be "repeats: 1 1
> 1" to match the C preprocessor, but this doesn't seem to be
> well supported. Either way, a spec example stating the
> behavior using `` to concatenate a define name would be
> appreciated.
>
> `define REPEAT_0(d)
> `define REPEAT_1(d) d
> `define REPEAT_2(d) `REPEAT_1(d)d
> `define REPEAT_3(d) `REPEAT_2(d)d
> `define REPEAT_4(d) `REPEAT_3(d)d
> `define REPEAT_5(d) `REPEAT_4(d)d
> `define REPEAT_6(d) `REPEAT_5(d)d
> `define REPEAT_7(d) `REPEAT_6(d)d
> `define REPEAT_8(d) `REPEAT_7(d)d
> `define REPEAT_9(d) `REPEAT_8(d)d
>
> `define CONCAT(a, b) a``b
> `define REPEAT(n, d) `CONCAT(`REPEAT_, n)(d)
>
> module t;
> initial begin
> $write("repeats: ");
> `REPEAT(3, $write("1 ");)
> $write("\n");
> end
> endmodule
>
> --
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
>
>
---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Tue Jun 22 11:35:40 2010

This archive was generated by hypermail 2.1.8 : Tue Jun 22 2010 - 11:38:21 PDT