mirror of
https://github.com/YosysHQ/yosys
synced 2025-06-06 14:13:23 +00:00
Added elsif preproc support
This commit is contained in:
parent
921064c200
commit
fbd06a1afc
2 changed files with 243 additions and 2 deletions
|
@ -206,6 +206,7 @@ std::string frontend_verilog_preproc(FILE *f, std::string filename, const std::m
|
|||
{
|
||||
std::map<std::string, std::string> defines_map(pre_defines_map);
|
||||
int ifdef_fail_level = 0;
|
||||
bool in_elseif = false;
|
||||
|
||||
output_code.clear();
|
||||
input_buffer.clear();
|
||||
|
@ -222,17 +223,29 @@ std::string frontend_verilog_preproc(FILE *f, std::string filename, const std::m
|
|||
if (tok == "`endif") {
|
||||
if (ifdef_fail_level > 0)
|
||||
ifdef_fail_level--;
|
||||
if (ifdef_fail_level == 0)
|
||||
in_elseif = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (tok == "`else") {
|
||||
if (ifdef_fail_level == 0)
|
||||
ifdef_fail_level = 1;
|
||||
else if (ifdef_fail_level == 1)
|
||||
else if (ifdef_fail_level == 1 && !in_elseif)
|
||||
ifdef_fail_level = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (tok == "`elsif") {
|
||||
skip_spaces();
|
||||
std::string name = next_token(true);
|
||||
if (ifdef_fail_level == 0)
|
||||
ifdef_fail_level = 1, in_elseif = true;
|
||||
else if (ifdef_fail_level == 1 && defines_map.count(name) != 0)
|
||||
ifdef_fail_level = 0, in_elseif = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (tok == "`ifdef") {
|
||||
skip_spaces();
|
||||
std::string name = next_token(true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue