aboutsummaryrefslogtreecommitdiffstats
path: root/frontends/ast/genrtlil.cc
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2019-06-19 17:25:39 +0200
committerGitHub <noreply@github.com>2019-06-19 17:25:39 +0200
commit8395f837c33a1f08ed67995ef8274219b0af27c8 (patch)
treee4fa22a4a4598e86f0fa324741fb6062dca851e8 /frontends/ast/genrtlil.cc
parent5a1f1caa44fb3f4427813acab61aaecc06bae7ba (diff)
parentec4565009ae69409eb01f1b595f5f59fcc969ce2 (diff)
downloadyosys-8395f837c33a1f08ed67995ef8274219b0af27c8.tar.gz
yosys-8395f837c33a1f08ed67995ef8274219b0af27c8.tar.bz2
yosys-8395f837c33a1f08ed67995ef8274219b0af27c8.zip
Merge pull request #1109 from YosysHQ/clifford/fix1106
Add "read_verilog -pwires" feature
Diffstat (limited to 'frontends/ast/genrtlil.cc')
-rw-r--r--frontends/ast/genrtlil.cc21
1 files changed, 20 insertions, 1 deletions
diff --git a/frontends/ast/genrtlil.cc b/frontends/ast/genrtlil.cc
index 32ed401eb..079fc11e5 100644
--- a/frontends/ast/genrtlil.cc
+++ b/frontends/ast/genrtlil.cc
@@ -853,7 +853,6 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint)
case AST_FUNCTION:
case AST_DPI_FUNCTION:
case AST_AUTOWIRE:
- case AST_LOCALPARAM:
case AST_DEFPARAM:
case AST_GENVAR:
case AST_GENFOR:
@@ -895,6 +894,26 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint)
// remember the parameter, needed for example in techmap
case AST_PARAMETER:
current_module->avail_parameters.insert(str);
+ /* fall through */
+ case AST_LOCALPARAM:
+ if (flag_pwires)
+ {
+ if (GetSize(children) < 1 || children[0]->type != AST_CONSTANT)
+ log_file_error(filename, linenum, "Parameter `%s' with non-constant value!\n", str.c_str());
+
+ RTLIL::Const val = children[0]->bitsAsConst();
+ RTLIL::Wire *wire = current_module->addWire(str, GetSize(val));
+ current_module->connect(wire, val);
+
+ wire->attributes["\\src"] = stringf("%s:%d", filename.c_str(), linenum);
+ wire->attributes[type == AST_PARAMETER ? "\\parameter" : "\\localparam"] = 1;
+
+ for (auto &attr : attributes) {
+ if (attr.second->type != AST_CONSTANT)
+ log_file_error(filename, linenum, "Attribute `%s' with non-constant value!\n", attr.first.c_str());
+ wire->attributes[attr.first] = attr.second->asAttrConst();
+ }
+ }
break;
// create an RTLIL::Wire for an AST_WIRE node