mirror of
https://github.com/YosysHQ/yosys
synced 2025-06-12 17:06:15 +00:00
Fixed handling of parameters and const functions in casex/casez pattern
This commit is contained in:
parent
f38ca3e18f
commit
5a09fa4553
5 changed files with 37 additions and 8 deletions
|
@ -540,6 +540,18 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage,
|
|||
}
|
||||
}
|
||||
|
||||
if (type == AST_CONDX && children.size() > 0 && children.at(0)->type == AST_CONSTANT) {
|
||||
for (auto &bit : children.at(0)->bits)
|
||||
if (bit == State::Sz || bit == State::Sx)
|
||||
bit = State::Sa;
|
||||
}
|
||||
|
||||
if (type == AST_CONDZ && children.size() > 0 && children.at(0)->type == AST_CONSTANT) {
|
||||
for (auto &bit : children.at(0)->bits)
|
||||
if (bit == State::Sz)
|
||||
bit = State::Sa;
|
||||
}
|
||||
|
||||
if (const_fold && type == AST_CASE)
|
||||
{
|
||||
while (children[0]->simplify(const_fold, at_zero, in_lvalue, stage, width_hint, sign_hint, in_param)) { }
|
||||
|
@ -548,7 +560,7 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage,
|
|||
new_children.push_back(children[0]);
|
||||
for (int i = 1; i < GetSize(children); i++) {
|
||||
AstNode *child = children[i];
|
||||
log_assert(child->type == AST_COND);
|
||||
log_assert(child->type == AST_COND || child->type == AST_CONDX || child->type == AST_CONDZ);
|
||||
for (auto v : child->children) {
|
||||
if (v->type == AST_DEFAULT)
|
||||
goto keep_const_cond;
|
||||
|
@ -1125,7 +1137,7 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage,
|
|||
AstNode *selected_case = NULL;
|
||||
for (size_t i = 1; i < children.size(); i++)
|
||||
{
|
||||
log_assert(children.at(i)->type == AST_COND);
|
||||
log_assert(children.at(i)->type == AST_COND || children.at(i)->type == AST_CONDX || children.at(i)->type == AST_CONDZ);
|
||||
|
||||
AstNode *this_genblock = NULL;
|
||||
for (auto child : children.at(i)->children) {
|
||||
|
@ -2984,7 +2996,7 @@ AstNode *AstNode::eval_const_function(AstNode *fcall)
|
|||
for (size_t i = 1; i < stmt->children.size(); i++)
|
||||
{
|
||||
bool found_match = false;
|
||||
log_assert(stmt->children.at(i)->type == AST_COND);
|
||||
log_assert(stmt->children.at(i)->type == AST_COND || stmt->children.at(i)->type == AST_CONDX || stmt->children.at(i)->type == AST_CONDZ);
|
||||
|
||||
if (stmt->children.at(i)->children.front()->type == AST_DEFAULT) {
|
||||
sel_case = stmt->children.at(i)->children.back();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue