From b1e3bc059c61589551bc1a9204b517adfe9ea9ce Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sun, 30 Aug 2020 12:25:23 +0200 Subject: [PATCH 1/3] Fix import of VHDL enums --- frontends/verific/verific.cc | 33 ++++++++++++++++++++++----------- 1 file 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 &att attributes.emplace(stringf("\\enum_value_%s", p+2), RTLIL::escape_id(k)); } else if (nl->IsFromVhdl()) { - // Expect "" + // Expect "" or plain 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 &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 \"\".\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 \"\" or .\n", v); } } } From 2f93579bd1d4d81b0ee3d327e604c0c4773759a7 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sun, 30 Aug 2020 13:15:06 +0200 Subject: [PATCH 2/3] Do not check for 1 and 0 only --- frontends/verific/verific.cc | 6 ------ 1 file changed, 6 deletions(-) diff --git a/frontends/verific/verific.cc b/frontends/verific/verific.cc index 0bac2b57c..c974c3faa 100644 --- a/frontends/verific/verific.cc +++ b/frontends/verific/verific.cc @@ -203,12 +203,6 @@ void VerificImporter::import_attributes(dict &att auto p = v; if (p) { 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 { From 3af499c60f664711501cf3ee1ab5ff1943315e82 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sun, 30 Aug 2020 13:33:03 +0200 Subject: [PATCH 3/3] ast recognize lower case x and z and verific gives upper case --- frontends/verific/verific.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/frontends/verific/verific.cc b/frontends/verific/verific.cc index c974c3faa..4358d957d 100644 --- a/frontends/verific/verific.cc +++ b/frontends/verific/verific.cc @@ -203,8 +203,12 @@ void VerificImporter::import_attributes(dict &att auto p = v; if (p) { if (*p != '"') { - if (p != nullptr) - attributes.emplace(stringf("\\enum_value_%s", p), RTLIL::escape_id(k)); + auto l = strlen(p); + auto q = (char*)malloc(l+1); + strncpy(q, p, l); + q[l] = '\0'; + for(char *ptr = q; *ptr; ++ptr )*ptr = tolower(*ptr); + attributes.emplace(stringf("\\enum_value_%s", q), RTLIL::escape_id(k)); } else { auto *q = p+1; for (; *q != '"'; q++)