mirror of
https://github.com/steveicarus/iverilog.git
synced 2026-08-29 01:03:29 +02:00
By adding ivtest to the iverilog source tree, it is easier to keep the regression test synchronized with the source that is being tested. This should be especially helpful for PRs that add a new feature, and have a matching ivtest PR with the regression test for that feature.
70 lines
1.5 KiB
Verilog
70 lines
1.5 KiB
Verilog
// Copyright 2007, Martin Whitaker
|
|
// This file may be freely copied for any purpose.
|
|
module macro_with_args();
|
|
|
|
`define forward_and_reverse(str1,str2,str3) /* comment */ \
|
|
$write("%0s", str1); /* comment */ \
|
|
$write(".."); /* comment */ \
|
|
$write("%0s", str3); /* comment */ \
|
|
$write("%0s", str2); /* comment */ \
|
|
$write("%0s", str3); /* comment */ \
|
|
$write(".."); /* comment */ \
|
|
$write("%0s", str1); /* comment */ \
|
|
$write("\n")
|
|
|
|
`define sqr( x ) (x * x) // comment
|
|
|
|
`define sum( a /* comment */ , b /* comment */ ) /* comment */ \
|
|
(a + b)
|
|
|
|
`define sumsqr(
|
|
a // comment
|
|
,
|
|
b // comment
|
|
) \
|
|
`sum ( \
|
|
`sqr(a) \
|
|
, \
|
|
`sqr(b) \
|
|
)
|
|
|
|
`define no_args (a,b,c)
|
|
|
|
`define null1 // null
|
|
`define null2
|
|
|
|
integer value;
|
|
|
|
reg [79:0] astr, bstr, cstr;
|
|
|
|
initial begin
|
|
`forward_and_reverse("first"," first,last ","last");
|
|
|
|
$sformat(astr, "(a%s)", ``null1);
|
|
$sformat(bstr, " %s ", ``no_args);
|
|
$sformat(cstr, "(c%s)", ``null2);
|
|
`forward_and_reverse // comment
|
|
( // comment
|
|
astr // comment
|
|
, // comment
|
|
bstr // comment
|
|
, // comment
|
|
cstr // comment
|
|
); // comment
|
|
|
|
value = `sumsqr(3,4);
|
|
$display("sumsqr(3,4) = %1d", value);
|
|
if (value != `sqr(5)) $display("sumsqr expansion failed");
|
|
|
|
value = `sumsqr
|
|
(
|
|
(2 + 3) /* 5 */
|
|
,
|
|
(4 + 8) /* 12 */
|
|
);
|
|
$display("sumsqr(5,12) = %1d", value);
|
|
if (value != `sqr(13)) $display("sumsqr expansion failed");
|
|
end
|
|
|
|
endmodule
|