aboutsummaryrefslogtreecommitdiffstats
path: root/frontends/verific
diff options
context:
space:
mode:
authorMiodrag Milanovic <mmicko@gmail.com>2020-08-30 12:25:23 +0200
committerMiodrag Milanovic <mmicko@gmail.com>2020-08-30 12:25:23 +0200
commitb1e3bc059c61589551bc1a9204b517adfe9ea9ce (patch)
tree803e0b19b5644329092b63b5f2b77a5a648b630e /frontends/verific
parent3030c2b46cabee8eee5e3ae25c9859887b0b97a1 (diff)
downloadyosys-b1e3bc059c61589551bc1a9204b517adfe9ea9ce.tar.gz
yosys-b1e3bc059c61589551bc1a9204b517adfe9ea9ce.tar.bz2
yosys-b1e3bc059c61589551bc1a9204b517adfe9ea9ce.zip
Fix import of VHDL enums
Diffstat (limited to 'frontends/verific')
-rw-r--r--frontends/verific/verific.cc33
1 files changed, 22 insertions, 11 deletions
diff --git a/frontends/verific/verific.cc b/frontends/verific/verific.cc
index 52047ae2b..0bac2b57c 100644
--- a/frontends/verific/verific.cc
+++ b/frontends/verific/verific.cc
@@ -199,12 +199,19 @@ void VerificImporter::import_attributes(dict<RTLIL::IdString, RTLIL::Const> &att
attributes.emplace(stringf("\\enum_value_%s", p+2), RTLIL::escape_id(k));
}
else if (nl->IsFromVhdl()) {
- // Expect "<binary>"
+ // Expect "<binary>" or plain <binary>
auto p = v;
if (p) {
- if (*p != '"')
- p = nullptr;
- else {
+ if (*p != '"') {
+ auto *q = p;
+ for (; *q != '\0'; q++)
+ if (*q != '0' && *q != '1') {
+ p = nullptr;
+ break;
+ }
+ if (p != nullptr)
+ attributes.emplace(stringf("\\enum_value_%s", p), RTLIL::escape_id(k));
+ } else {
auto *q = p+1;
for (; *q != '"'; q++)
if (*q != '0' && *q != '1') {
@@ -213,16 +220,20 @@ void VerificImporter::import_attributes(dict<RTLIL::IdString, RTLIL::Const> &att
}
if (p && *(q+1) != '\0')
p = nullptr;
+
+ if (p != nullptr)
+ {
+ auto l = strlen(p);
+ auto q = (char*)malloc(l+1-2);
+ strncpy(q, p+1, l-2);
+ q[l-2] = '\0';
+ attributes.emplace(stringf("\\enum_value_%s", q), RTLIL::escape_id(k));
+ free(q);
+ }
}
}
if (p == nullptr)
- log_error("Expected TypeRange value '%s' to be of form \"<binary>\".\n", v);
- auto l = strlen(p);
- auto q = (char*)malloc(l+1-2);
- strncpy(q, p+1, l-2);
- q[l-2] = '\0';
- attributes.emplace(stringf("\\enum_value_%s", q), RTLIL::escape_id(k));
- free(q);
+ log_error("Expected TypeRange value '%s' to be of form \"<binary>\" or <binary>.\n", v);
}
}
}