aboutsummaryrefslogtreecommitdiffstats
path: root/frontends/verific
diff options
context:
space:
mode:
authorMiodrag Milanovic <mmicko@gmail.com>2022-09-28 08:51:26 +0200
committerMiodrag Milanovic <mmicko@gmail.com>2022-09-28 08:51:26 +0200
commitf54ac8a6d641108b3637652921f65d76577881a8 (patch)
tree8dc4c46844aa60428dba08c8c0bce50bffed086c /frontends/verific
parenta9795c4fce52f825fbb455daa74b4d126a289ff6 (diff)
downloadyosys-f54ac8a6d641108b3637652921f65d76577881a8.tar.gz
yosys-f54ac8a6d641108b3637652921f65d76577881a8.tar.bz2
yosys-f54ac8a6d641108b3637652921f65d76577881a8.zip
Handle attributes imported from verific
Diffstat (limited to 'frontends/verific')
-rw-r--r--frontends/verific/verific.cc29
1 files changed, 24 insertions, 5 deletions
diff --git a/frontends/verific/verific.cc b/frontends/verific/verific.cc
index 6e95fde7b..3b2b47be5 100644
--- a/frontends/verific/verific.cc
+++ b/frontends/verific/verific.cc
@@ -190,6 +190,29 @@ RTLIL::IdString VerificImporter::new_verific_id(Verific::DesignObj *obj)
return s;
}
+static bool isNumber(const string& str)
+{
+ for (auto &c : str) {
+ if (std::isdigit(c) == 0) return false;
+ }
+ return true;
+}
+
+static const RTLIL::Const verific_const(const char *value)
+{
+ std::string val = std::string(value);
+ if (val.size()>1 && val[0]=='\"' && val.back()=='\"')
+ return RTLIL::Const(val.substr(1,val.size()-2));
+ else
+ if (val.find("'b") != std::string::npos)
+ return RTLIL::Const::from_string(val.substr(val.find("'b") + 2));
+ else
+ if (isNumber(val))
+ return RTLIL::Const(std::stoi(val),32);
+ else
+ return RTLIL::Const(val);
+}
+
void VerificImporter::import_attributes(dict<RTLIL::IdString, RTLIL::Const> &attributes, DesignObj *obj, Netlist *nl)
{
MapIter mi;
@@ -198,14 +221,10 @@ void VerificImporter::import_attributes(dict<RTLIL::IdString, RTLIL::Const> &att
if (obj->Linefile())
attributes[ID::src] = stringf("%s:%d", LineFile::GetFileName(obj->Linefile()), LineFile::GetLineNo(obj->Linefile()));
- // FIXME: Parse numeric attributes
FOREACH_ATTRIBUTE(obj, mi, attr) {
if (attr->Key()[0] == ' ' || attr->Value() == nullptr)
continue;
- std::string val = std::string(attr->Value());
- if (val.size()>1 && val[0]=='\"' && val.back()=='\"')
- val = val.substr(1,val.size()-2);
- attributes[RTLIL::escape_id(attr->Key())] = RTLIL::Const(val);
+ attributes[RTLIL::escape_id(attr->Key())] = verific_const(attr->Value());
}
if (nl) {