diff options
author | Clifford Wolf <clifford@clifford.at> | 2013-03-24 11:13:32 +0100 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2013-03-24 11:13:32 +0100 |
commit | df9753d398ff1f10396a8561524fee20fdbf512c (patch) | |
tree | f614c10cca56acf78e3fda6a886d5ea0cdceaf96 /frontends/ast/simplify.cc | |
parent | 6960df7285fc7f2c703f349bea841800737f8dca (diff) | |
download | yosys-df9753d398ff1f10396a8561524fee20fdbf512c.tar.gz yosys-df9753d398ff1f10396a8561524fee20fdbf512c.tar.bz2 yosys-df9753d398ff1f10396a8561524fee20fdbf512c.zip |
Added mem2reg option to verilog frontend
Diffstat (limited to 'frontends/ast/simplify.cc')
-rw-r--r-- | frontends/ast/simplify.cc | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/frontends/ast/simplify.cc b/frontends/ast/simplify.cc index 6594cfcb3..8a02cc129 100644 --- a/frontends/ast/simplify.cc +++ b/frontends/ast/simplify.cc @@ -57,7 +57,7 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage) if (!flag_nomem2reg && attributes.count("\\nomem2reg") == 0) { std::set<AstNode*> mem2reg_set, mem2reg_candidates; - mem2reg_as_needed_pass1(mem2reg_set, mem2reg_candidates, false, false); + mem2reg_as_needed_pass1(mem2reg_set, mem2reg_candidates, false, false, flag_mem2reg); for (auto node : mem2reg_set) { @@ -924,7 +924,7 @@ void AstNode::replace_ids(std::map<std::string, std::string> &rules) } // find memories that should be replaced by registers -void AstNode::mem2reg_as_needed_pass1(std::set<AstNode*> &mem2reg_set, std::set<AstNode*> &mem2reg_candidates, bool sync_proc, bool async_proc) +void AstNode::mem2reg_as_needed_pass1(std::set<AstNode*> &mem2reg_set, std::set<AstNode*> &mem2reg_candidates, bool sync_proc, bool async_proc, bool force_mem2reg) { if ((type == AST_ASSIGN_LE && async_proc) || (type == AST_ASSIGN_EQ && (sync_proc || async_proc))) if (children[0]->type == AST_IDENTIFIER && children[0]->id2ast && children[0]->id2ast->type == AST_MEMORY && @@ -938,9 +938,12 @@ void AstNode::mem2reg_as_needed_pass1(std::set<AstNode*> &mem2reg_set, std::set< mem2reg_candidates.insert(children[0]->id2ast); } - if (type == AST_MEMORY && attributes.count("\\mem2reg") > 0) + if (type == AST_MEMORY && (attributes.count("\\mem2reg") > 0 || force_mem2reg)) mem2reg_set.insert(this); + if (type == AST_MODULE && attributes.count("\\mem2reg") > 0) + force_mem2reg = true; + if (type == AST_ALWAYS) { for (auto child : children) { if (child->type == AST_POSEDGE || child->type == AST_NEGEDGE) @@ -950,7 +953,7 @@ void AstNode::mem2reg_as_needed_pass1(std::set<AstNode*> &mem2reg_set, std::set< } for (auto child : children) - child->mem2reg_as_needed_pass1(mem2reg_set, mem2reg_candidates, sync_proc, async_proc); + child->mem2reg_as_needed_pass1(mem2reg_set, mem2reg_candidates, sync_proc, async_proc, force_mem2reg); } // actually replace memories with registers |