`define REPEAT(n, d) `REPEAT_``n(d)since that clearly forms the
REPEAT_
n macro's
name (during substitution of n) before invoking it.`CONCAT
)
below`define CNT 3
`REPEAT(`CNT, $write...
`CNT
before substituting for n
. 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 archive was generated by hypermail 2.1.8 : Tue Jun 22 2010 - 14:05:34 PDT