3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-07-24 13:18:56 +00:00

verilog: fix handling of nested ifdef directives

- track depth so we know whether to consider higher-level elsifs
- error on unmatched endif/elsif/else
This commit is contained in:
Zachary Snow 2021-02-25 15:53:55 -05:00 committed by Zachary Snow
parent b6904a8e53
commit 1ec5994100
8 changed files with 197 additions and 11 deletions

View file

@ -0,0 +1,30 @@
`ifdef GUARD_5
module top;
wire x;
endmodule
`elsif GUARD_4
`define GUARD_5
`include "include_self.v"
`elsif GUARD_3
`define GUARD_4
`include "include_self.v"
`elsif GUARD_2
`define GUARD_3
`include "include_self.v"
`elsif GUARD_1
`define GUARD_2
`include "include_self.v"
`elsif GUARD_0
`define GUARD_1
`include "include_self.v"
`else
`define GUARD_0
`include "include_self.v"
`endif

View file

@ -0,0 +1,2 @@
read_verilog include_self.v
select -assert-count 1 top/x

View file

@ -0,0 +1,6 @@
logger -expect error "Found `else outside of macro conditional branch!" 1
read_verilog <<EOT
module top;
`else
endmodule
EOT

View file

@ -0,0 +1,6 @@
logger -expect error "Found `elsif outside of macro conditional branch!" 1
read_verilog <<EOT
module top;
`elsif
endmodule
EOT

View file

@ -0,0 +1,6 @@
logger -expect error "Found `endif outside of macro conditional branch!" 1
read_verilog <<EOT
module top;
`endif
endmodule
EOT