aboutsummaryrefslogtreecommitdiffstats
path: root/frontends
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2015-02-18 23:35:23 +0100
committerClifford Wolf <clifford@clifford.at>2015-02-18 23:35:23 +0100
commitc2ba4fb2fdfde25c10930d7399bacee390a3cc65 (patch)
treec019981b0babc75c63ef5683f4555a4ddfeed0e9 /frontends
parentf41378af8c463f2f49f3a04bcbc39419b83c9553 (diff)
downloadyosys-c2ba4fb2fdfde25c10930d7399bacee390a3cc65.tar.gz
yosys-c2ba4fb2fdfde25c10930d7399bacee390a3cc65.tar.bz2
yosys-c2ba4fb2fdfde25c10930d7399bacee390a3cc65.zip
Convert floating point cell parameters to strings
Diffstat (limited to 'frontends')
-rw-r--r--frontends/ast/genrtlil.cc21
1 files changed, 12 insertions, 9 deletions
diff --git a/frontends/ast/genrtlil.cc b/frontends/ast/genrtlil.cc
index 4b3310501..4a84e0a9e 100644
--- a/frontends/ast/genrtlil.cc
+++ b/frontends/ast/genrtlil.cc
@@ -1336,16 +1336,19 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint)
continue;
}
if (child->type == AST_PARASET) {
- if (child->children[0]->type != AST_CONSTANT)
- log_error("Parameter `%s' with non-constant value at %s:%d!\n",
- child->str.c_str(), filename.c_str(), linenum);
- if (child->str.size() == 0) {
- char buf[100];
- snprintf(buf, 100, "$%d", ++para_counter);
- cell->parameters[buf] = child->children[0]->asParaConst();
- } else {
- cell->parameters[child->str] = child->children[0]->asParaConst();
+ IdString paraname = child->str.empty() ? stringf("$%d", ++para_counter) : child->str;
+ if (child->children[0]->type == AST_REALVALUE) {
+ log_warning("Replacing floating point parameter %s.%s = %f with string at %s:%d.\n",
+ log_id(cell), log_id(paraname), child->children[0]->realvalue,
+ filename.c_str(), linenum);
+ auto strnode = AstNode::mkconst_str(stringf("%f", child->children[0]->realvalue));
+ strnode->cloneInto(child->children[0]);
+ delete strnode;
}
+ if (child->children[0]->type != AST_CONSTANT)
+ log_error("Parameter %s.%s with non-constant value at %s:%d!\n",
+ log_id(cell), log_id(paraname), filename.c_str(), linenum);
+ cell->parameters[paraname] = child->children[0]->asParaConst();
continue;
}
if (child->type == AST_ARGUMENT) {