aboutsummaryrefslogtreecommitdiffstats
path: root/frontends
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2013-12-18 13:41:36 +0100
committerClifford Wolf <clifford@clifford.at>2013-12-18 13:41:36 +0100
commitfbd06a1afcef77e32b1fbe6405f1e639995d2fa5 (patch)
tree941a167a848251dd026f9bbd9903a6146720c402 /frontends
parent921064c20044f72a64bec12dbd73103bdd3f45e3 (diff)
downloadyosys-fbd06a1afcef77e32b1fbe6405f1e639995d2fa5.tar.gz
yosys-fbd06a1afcef77e32b1fbe6405f1e639995d2fa5.tar.bz2
yosys-fbd06a1afcef77e32b1fbe6405f1e639995d2fa5.zip
Added elsif preproc support
Diffstat (limited to 'frontends')
-rw-r--r--frontends/verilog/preproc.cc15
1 files changed, 14 insertions, 1 deletions
diff --git a/frontends/verilog/preproc.cc b/frontends/verilog/preproc.cc
index e17531be2..023c4dbcc 100644
--- a/frontends/verilog/preproc.cc
+++ b/frontends/verilog/preproc.cc
@@ -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);