ppTests Extend non-IEEE tests around macros.
This commit is contained in:
parent
1be39f0ce9
commit
28cbd8aaf4
23
sv-parser-pp/testcases/expected/macro_arguments.sv
Normal file
23
sv-parser-pp/testcases/expected/macro_arguments.sv
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// Macro with parameters with usage spread over multiple lines.
|
||||||
|
// Final line of macro is line14.
|
||||||
|
// Argument value `clk` is equal to its name.
|
||||||
|
// Argument value of exp contains matching brackets and parentheses.
|
||||||
|
// Bracketed value of msg is required to avoid being parsed as a parameterized
|
||||||
|
// macro instead of argumnts to $display.
|
||||||
|
// NOTE: Trailing whitespace is not exercised here, i.e. continuations
|
||||||
|
// immediately follow non-whitespace.
|
||||||
|
`define disp(clk, exp, msg)\
|
||||||
|
always @(posedge clk)\
|
||||||
|
if (exp) begin\
|
||||||
|
$display msg;\
|
||||||
|
end\
|
||||||
|
|
||||||
|
module M ();
|
||||||
|
|
||||||
|
always @(posedge clk)
|
||||||
|
if (!(a[i].b && c[i])) begin
|
||||||
|
$display ("xxx(()[]]{}}}", a[i].b, c[i]);
|
||||||
|
end
|
||||||
|
; // NOTE: Semi-colon is unnecessary.
|
||||||
|
|
||||||
|
endmodule
|
@ -1,4 +1,6 @@
|
|||||||
`define MOD_INST u_mysubmod
|
`define A aaa
|
||||||
module mymod;
|
module M;
|
||||||
mysubmod u_mysubmod() ;
|
aaa#() a0 (.*); // No trailing whitespace.
|
||||||
|
aaa #() a1 (.*); // Trailing 1 space.
|
||||||
|
aaa #() a2 (.*); // Trailing 2 spaces.
|
||||||
endmodule
|
endmodule
|
||||||
|
@ -1,2 +1,16 @@
|
|||||||
`define A 42 // Comment
|
/* IEEE1800-2017 Clause 22.5.1, page 676
|
||||||
interface i #(p = 42) (); endinterface
|
If a one-line comment (that is, a comment specified with the characters //) is
|
||||||
|
included in the text, then the comment shall not become part of the substituted
|
||||||
|
text.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// A has no comment
|
||||||
|
// B has a comment after 1 space
|
||||||
|
// C has a comment after 3 spaces
|
||||||
|
`define A 11
|
||||||
|
`define B 22 // Comment not included in macro, but whitespace before `//` is.
|
||||||
|
`define C 33 // Comment not included in macro, but whitespace before `//` is.
|
||||||
|
|
||||||
|
interface A #(p=11) (); endinterface
|
||||||
|
interface B #(p=22 ) (); endinterface
|
||||||
|
interface C #(p=33 ) (); endinterface
|
||||||
|
17
sv-parser-pp/testcases/expected/macro_delimiters.sv
Normal file
17
sv-parser-pp/testcases/expected/macro_delimiters.sv
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// Multi-line macro defined with 2 trailing spaces before initial continuation.
|
||||||
|
// First line has no trailing space, second has trailing space, third is end.
|
||||||
|
// Macro contains 2-space indent, so indented usage gets extra.
|
||||||
|
// Delimiters (``) used before and after arguments.
|
||||||
|
`define connect(NAME, INDEX = 0) \
|
||||||
|
assign NAME``_``INDEX``__x = NAME[INDEX].x;\
|
||||||
|
assign NAME``_``INDEX``__y = NAME[INDEX].y; \
|
||||||
|
assign NAME``_``INDEX``__z = NAME[INDEX].z;
|
||||||
|
|
||||||
|
module M ();
|
||||||
|
assign a_0__x = a[0].x;
|
||||||
|
assign a_0__y = a[0].y;
|
||||||
|
assign a_0__z = a[0].z;
|
||||||
|
assign a_1__x = a[1].x;
|
||||||
|
assign a_1__y = a[1].y;
|
||||||
|
assign a_1__z = a[1].z;
|
||||||
|
endmodule
|
@ -1,10 +1,10 @@
|
|||||||
module a;
|
|
||||||
`define A "aaa"
|
`define A "aaa"
|
||||||
`define \B "bbb"
|
`define \B "bbb"
|
||||||
initial begin
|
module M;
|
||||||
$display("aaa");
|
initial begin
|
||||||
$display("aaa");
|
$display("aaa");
|
||||||
$display("bbb");
|
$display("aaa" );
|
||||||
$display("bbb");
|
$display("bbb");
|
||||||
end
|
$display("bbb" );
|
||||||
|
end
|
||||||
endmodule
|
endmodule
|
||||||
|
@ -1,10 +1,19 @@
|
|||||||
|
// Leading whitespace on 4 lines.
|
||||||
|
// initial \ Space before line continuation.
|
||||||
|
// begin\ No space before line continuation.
|
||||||
|
// $display(); // comment \ Continuation at end of comment.
|
||||||
|
// end
|
||||||
|
// NOTE: Trailing whitespace on lines ending `initial ` and `$display(); `.
|
||||||
|
|
||||||
`define A \
|
`define A \
|
||||||
initial begin // comment \
|
initial \
|
||||||
end
|
begin\
|
||||||
|
$display(); // comment \
|
||||||
module test();
|
end
|
||||||
|
|
||||||
initial begin
|
|
||||||
end
|
|
||||||
|
|
||||||
|
module M;
|
||||||
|
initial
|
||||||
|
begin
|
||||||
|
$display();
|
||||||
|
end
|
||||||
endmodule
|
endmodule
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
`define connect(NAME, INDEX = 0) \
|
|
||||||
assign NAME``_``INDEX``__x = NAME[INDEX].x; \
|
|
||||||
assign NAME``_``INDEX``__y = NAME[INDEX].y;
|
|
||||||
|
|
||||||
module a ();
|
|
||||||
|
|
||||||
assign a_0__x = a[0].x;
|
|
||||||
assign a_0__y = a[0].y; assign a_1__x = a[1].x;
|
|
||||||
assign a_1__y = a[1].y; endmodule
|
|
@ -1,17 +0,0 @@
|
|||||||
`define disp(clk, exp, msg) \
|
|
||||||
always @(posedge clk) begin \
|
|
||||||
if (!(exp)) begin \
|
|
||||||
$display msg; \
|
|
||||||
end \
|
|
||||||
end \
|
|
||||||
|
|
||||||
module a ();
|
|
||||||
|
|
||||||
always @(posedge clk) begin
|
|
||||||
if (!(!(a[i].b && c[i]))) begin
|
|
||||||
$display ("xxx(()[]]{}}}", a[i].b, c[i]);
|
|
||||||
end
|
|
||||||
end
|
|
||||||
;
|
|
||||||
|
|
||||||
endmodule
|
|
23
sv-parser-pp/testcases/macro_arguments.sv
Normal file
23
sv-parser-pp/testcases/macro_arguments.sv
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// Macro with parameters with usage spread over multiple lines.
|
||||||
|
// Final line of macro is line14.
|
||||||
|
// Argument value `clk` is equal to its name.
|
||||||
|
// Argument value of exp contains matching brackets and parentheses.
|
||||||
|
// Bracketed value of msg is required to avoid being parsed as a parameterized
|
||||||
|
// macro instead of argumnts to $display.
|
||||||
|
// NOTE: Trailing whitespace is not exercised here, i.e. continuations
|
||||||
|
// immediately follow non-whitespace.
|
||||||
|
`define disp(clk, exp, msg)\
|
||||||
|
always @(posedge clk)\
|
||||||
|
if (exp) begin\
|
||||||
|
$display msg;\
|
||||||
|
end\
|
||||||
|
|
||||||
|
module M ();
|
||||||
|
|
||||||
|
`disp(
|
||||||
|
clk,
|
||||||
|
!(a[i].b && c[i]),
|
||||||
|
("xxx(()[]]{}}}", a[i].b, c[i])
|
||||||
|
); // NOTE: Semi-colon is unnecessary.
|
||||||
|
|
||||||
|
endmodule
|
@ -1,4 +1,6 @@
|
|||||||
`define MOD_INST u_mysubmod
|
`define A aaa
|
||||||
module mymod;
|
module M;
|
||||||
mysubmod `MOD_INST ();
|
`A#() a0 (.*); // No trailing whitespace.
|
||||||
|
`A #() a1 (.*); // Trailing 1 space.
|
||||||
|
`A #() a2 (.*); // Trailing 2 spaces.
|
||||||
endmodule
|
endmodule
|
||||||
|
@ -1,2 +1,16 @@
|
|||||||
`define A 42 // Comment
|
/* IEEE1800-2017 Clause 22.5.1, page 676
|
||||||
interface i #(p = `A) (); endinterface
|
If a one-line comment (that is, a comment specified with the characters //) is
|
||||||
|
included in the text, then the comment shall not become part of the substituted
|
||||||
|
text.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// A has no comment
|
||||||
|
// B has a comment after 1 space
|
||||||
|
// C has a comment after 3 spaces
|
||||||
|
`define A 11
|
||||||
|
`define B 22 // Comment not included in macro, but whitespace before `//` is.
|
||||||
|
`define C 33 // Comment not included in macro, but whitespace before `//` is.
|
||||||
|
|
||||||
|
interface A #(p=`A) (); endinterface
|
||||||
|
interface B #(p=`B) (); endinterface
|
||||||
|
interface C #(p=`C) (); endinterface
|
||||||
|
13
sv-parser-pp/testcases/macro_delimiters.sv
Normal file
13
sv-parser-pp/testcases/macro_delimiters.sv
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// Multi-line macro defined with 2 trailing spaces before initial continuation.
|
||||||
|
// First line has no trailing space, second has trailing space, third is end.
|
||||||
|
// Macro contains 2-space indent, so indented usage gets extra.
|
||||||
|
// Delimiters (``) used before and after arguments.
|
||||||
|
`define connect(NAME, INDEX = 0) \
|
||||||
|
assign NAME``_``INDEX``__x = NAME[INDEX].x;\
|
||||||
|
assign NAME``_``INDEX``__y = NAME[INDEX].y; \
|
||||||
|
assign NAME``_``INDEX``__z = NAME[INDEX].z;
|
||||||
|
|
||||||
|
module M ();
|
||||||
|
`connect(a)
|
||||||
|
`connect(a, 1)
|
||||||
|
endmodule
|
@ -1,10 +1,10 @@
|
|||||||
module a;
|
|
||||||
`define A "aaa"
|
`define A "aaa"
|
||||||
`define \B "bbb"
|
`define \B "bbb"
|
||||||
initial begin
|
module M;
|
||||||
$display(`A);
|
initial begin
|
||||||
$display(`\A );
|
$display(`A);
|
||||||
$display(`B);
|
$display(`\A );
|
||||||
$display(`\B );
|
$display(`B);
|
||||||
end
|
$display(`\B );
|
||||||
|
end
|
||||||
endmodule
|
endmodule
|
||||||
|
@ -1,9 +1,16 @@
|
|||||||
|
// Leading whitespace on 4 lines.
|
||||||
|
// initial \ Space before line continuation.
|
||||||
|
// begin\ No space before line continuation.
|
||||||
|
// $display(); // comment \ Continuation at end of comment.
|
||||||
|
// end
|
||||||
|
// NOTE: Trailing whitespace on lines ending `initial ` and `$display(); `.
|
||||||
|
|
||||||
`define A \
|
`define A \
|
||||||
initial begin // comment \
|
initial \
|
||||||
end
|
begin\
|
||||||
|
$display(); // comment \
|
||||||
module test();
|
end
|
||||||
|
|
||||||
|
module M;
|
||||||
`A
|
`A
|
||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
`define connect(NAME, INDEX = 0) \
|
|
||||||
assign NAME``_``INDEX``__x = NAME[INDEX].x; \
|
|
||||||
assign NAME``_``INDEX``__y = NAME[INDEX].y;
|
|
||||||
|
|
||||||
module a ();
|
|
||||||
|
|
||||||
`connect(a)
|
|
||||||
`connect(a, 1)
|
|
||||||
|
|
||||||
endmodule
|
|
@ -1,16 +0,0 @@
|
|||||||
`define disp(clk, exp, msg) \
|
|
||||||
always @(posedge clk) begin \
|
|
||||||
if (!(exp)) begin \
|
|
||||||
$display msg; \
|
|
||||||
end \
|
|
||||||
end \
|
|
||||||
|
|
||||||
module a ();
|
|
||||||
|
|
||||||
`disp(
|
|
||||||
clk,
|
|
||||||
!(a[i].b && c[i]),
|
|
||||||
("xxx(()[]]{}}}", a[i].b, c[i])
|
|
||||||
);
|
|
||||||
|
|
||||||
endmodule
|
|
Loading…
x
Reference in New Issue
Block a user