aboutsummaryrefslogtreecommitdiffstats
path: root/tests/verilog
diff options
context:
space:
mode:
authorZachary Snow <zach@zachjs.com>2021-07-15 10:36:50 -0400
committerZachary Snow <zachary.j.snow@gmail.com>2021-07-28 21:52:16 -0400
commit3156226233133f5da9dba15c63ca560b4794b831 (patch)
tree9d45120e6b8554df2c1b1f71cf90ea0fc124f270 /tests/verilog
parenta055145b95b08bc97f3e3ee27842576d8ea09a94 (diff)
downloadyosys-3156226233133f5da9dba15c63ca560b4794b831.tar.gz
yosys-3156226233133f5da9dba15c63ca560b4794b831.tar.bz2
yosys-3156226233133f5da9dba15c63ca560b4794b831.zip
verilog: save and restore overwritten macro arguments
Diffstat (limited to 'tests/verilog')
-rw-r--r--tests/verilog/macro_arg_tromp.sv21
-rw-r--r--tests/verilog/macro_arg_tromp.ys2
2 files changed, 23 insertions, 0 deletions
diff --git a/tests/verilog/macro_arg_tromp.sv b/tests/verilog/macro_arg_tromp.sv
new file mode 100644
index 000000000..a9c68a417
--- /dev/null
+++ b/tests/verilog/macro_arg_tromp.sv
@@ -0,0 +1,21 @@
+// Taken from: https://github.com/YosysHQ/yosys/issues/2867
+
+`define MIN(x, y) ((x) < (y) ? (x) : (y))
+`define CEIL_DIV(x, y) (((x) / (y)) + `MIN((x) % (y), 1))
+
+module pad_msg1 (input logic [`MIN(512*`CEIL_DIV(64, 512), 64)-1:0] x,
+ output logic [`MIN(512*`CEIL_DIV(64, 512), 64)-1:0] y);
+ assign y[63:0] = x;
+endmodule
+
+module pad_msg2 (input logic [((512*`CEIL_DIV(64, 512)) < (64) ? (512*`CEIL_DIV(64,512)) : (64))-1:0] x,
+ output logic [((512*`CEIL_DIV(64, 512)) < (64) ? (512*`CEIL_DIV(64,512)) : (64))-1:0] y);
+ assign y[63:0] = x;
+endmodule
+
+module top(...);
+`define add(x) x +
+input [3:0] A;
+output [3:0] B;
+assign B = `add(`add(3)A)A;
+endmodule
diff --git a/tests/verilog/macro_arg_tromp.ys b/tests/verilog/macro_arg_tromp.ys
new file mode 100644
index 000000000..e8bd58e9b
--- /dev/null
+++ b/tests/verilog/macro_arg_tromp.ys
@@ -0,0 +1,2 @@
+logger -expect-no-warnings
+read_verilog -sv macro_arg_tromp.sv