aboutsummaryrefslogtreecommitdiffstats
path: root/frontends
diff options
context:
space:
mode:
authorMarcelina Koƛcielnicka <mwk@0x04.net>2020-04-16 15:51:03 +0200
committerMarcelina Koƛcielnicka <mwk@0x04.net>2020-04-21 19:09:00 +0200
commit06a344efcb4a8c56f230715481ce07e715a7a4b3 (patch)
tree7d5aa868e0843ab0309b7325b88f145493d962e9 /frontends
parent79efaa65ad73520e4354bdc33622216bf29892fc (diff)
downloadyosys-06a344efcb4a8c56f230715481ce07e715a7a4b3.tar.gz
yosys-06a344efcb4a8c56f230715481ce07e715a7a4b3.tar.bz2
yosys-06a344efcb4a8c56f230715481ce07e715a7a4b3.zip
ilang, ast: Store parameter order and default value information.
Fixes #1819, #1820.
Diffstat (limited to 'frontends')
-rw-r--r--frontends/ast/ast.cc2
-rw-r--r--frontends/ast/genrtlil.cc5
-rw-r--r--frontends/ilang/ilang_parser.y11
3 files changed, 13 insertions, 5 deletions
diff --git a/frontends/ast/ast.cc b/frontends/ast/ast.cc
index 9ddd538b5..733556621 100644
--- a/frontends/ast/ast.cc
+++ b/frontends/ast/ast.cc
@@ -1074,8 +1074,6 @@ static AstModule* process_module(AstNode *ast, bool defer, AstNode *original_ast
if (child->type == AST_WIRE && (child->is_input || child->is_output)) {
new_children.push_back(child);
} else if (child->type == AST_PARAMETER) {
- child->delete_children();
- child->children.push_back(AstNode::mkconst_int(0, false, 0));
new_children.push_back(child);
} else if (child->type == AST_CELL && child->children.size() > 0 && child->children[0]->type == AST_CELLTYPE &&
(child->children[0]->str == "$specify2" || child->children[0]->str == "$specify3" || child->children[0]->str == "$specrule")) {
diff --git a/frontends/ast/genrtlil.cc b/frontends/ast/genrtlil.cc
index ff3f5b84c..d35335747 100644
--- a/frontends/ast/genrtlil.cc
+++ b/frontends/ast/genrtlil.cc
@@ -1015,7 +1015,10 @@ 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);
+ current_module->avail_parameters(str);
+ if (GetSize(children) >= 1 && children[0]->type == AST_CONSTANT) {
+ current_module->parameter_default_values[str] = children[0]->asParaConst();
+ }
/* fall through */
case AST_LOCALPARAM:
if (flag_pwires)
diff --git a/frontends/ilang/ilang_parser.y b/frontends/ilang/ilang_parser.y
index 0522fa72a..8e21fb176 100644
--- a/frontends/ilang/ilang_parser.y
+++ b/frontends/ilang/ilang_parser.y
@@ -143,11 +143,18 @@ module_body:
/* empty */;
module_stmt:
- param_stmt | attr_stmt | wire_stmt | memory_stmt | cell_stmt | proc_stmt | conn_stmt;
+ param_stmt | param_defval_stmt | attr_stmt | wire_stmt | memory_stmt | cell_stmt | proc_stmt | conn_stmt;
param_stmt:
TOK_PARAMETER TOK_ID EOL {
- current_module->avail_parameters.insert($2);
+ current_module->avail_parameters($2);
+ free($2);
+ };
+
+param_defval_stmt:
+ TOK_PARAMETER TOK_ID constant EOL {
+ current_module->avail_parameters($2);
+ current_module->parameter_default_values[$2] = *$3;
free($2);
};