aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2021-01-25 18:20:42 +0100
committerTristan Gingold <tgingold@free.fr>2021-01-25 18:32:41 +0100
commitfdfdc927a129bce9c007dd69958987e340275001 (patch)
treef2c2cab05d1011b60b92fa6830d3cd152b341ea5
parent8b3e740fef9a653a20a838f1ade475960e1d379b (diff)
downloadghdl-yosys-plugin-fdfdc927a129bce9c007dd69958987e340275001.tar.gz
ghdl-yosys-plugin-fdfdc927a129bce9c007dd69958987e340275001.tar.bz2
ghdl-yosys-plugin-fdfdc927a129bce9c007dd69958987e340275001.zip
Minor rework on attributes.
-rw-r--r--src/ghdl.cc24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/ghdl.cc b/src/ghdl.cc
index 29b9e9a..933db24 100644
--- a/src/ghdl.cc
+++ b/src/ghdl.cc
@@ -355,17 +355,31 @@ static void set_src(std::vector<RTLIL::Wire *> &net_map, Net n, Wire *wire)
net_map[n.id] = wire;
}
+// Create a value from an attribute
+static RTLIL::Const build_attribute_val(Attribute attr)
+{
+ RTLIL::Const cst = pval_to_const(get_attribute_pval(attr));
+ if (get_attribute_type(attr) == Param_Pval_String)
+ cst.flags |= RTLIL::CONST_FLAG_STRING;
+ return cst;
+
+}
+
+// Create the identifier of an attribute
+static IdString build_attribute_id(Attribute attr)
+{
+ return IdString('\\' + string(get_cstr(get_attribute_name(attr))));
+}
+
// Convert attributes of INST to OBJ.
static void add_attributes (RTLIL::AttrObject &obj, Instance inst)
{
Attribute attr = get_first_attribute (inst);
while (attr.id != 0) {
- RTLIL::Const cst = pval_to_const(get_attribute_pval(attr));
- IdString id = IdString('\\' + string(get_cstr(get_attribute_name(attr))));
- if (get_attribute_type(attr) == Param_Pval_String)
- cst.flags |= RTLIL::CONST_FLAG_STRING;
- obj.attributes[id] = cst;
+ IdString id = build_attribute_id(attr);
+ obj.attributes[id] = build_attribute_val(attr);
+
attr = get_attribute_next(attr);
}
}