VHDL: make casez support 'x' and handle a full don't care case.

The VHDL converter erroneously treated a casez and casex exactly
the same. In reality a casez compares a 'x' value (it is not a
don't care). It also adds support for a full don't care case by
just returning True for the condition.
This commit is contained in:
Cary R 2008-11-18 12:59:07 -08:00 committed by Stephen Williams
parent 35e0a98732
commit ec0e718151
1 changed files with 24 additions and 18 deletions

View File

@ -608,15 +608,17 @@ int draw_casezx(vhdl_procedural *proc, stmt_container *container,
vhdl_binop_expr *all =
new vhdl_binop_expr(VHDL_BINOP_AND, vhdl_type::boolean());
bool just_dont_care = true;
for (unsigned i = 0; i < ivl_expr_width(net); i++) {
switch (bits[i]) {
case 'x':
if (ivl_statement_type(stmt) == IVL_ST_CASEZ) break;
case '?':
case 'z':
case 'x':
// Ignore it
break;
default:
{
continue;
}
// Generate a comparison for this bit position
vhdl_binop_expr *cmp =
new vhdl_binop_expr(VHDL_BINOP_EQ, vhdl_type::boolean());
@ -630,8 +632,12 @@ int draw_casezx(vhdl_procedural *proc, stmt_container *container,
cmp->add_expr(new vhdl_const_bit(bits[i]));
all->add_expr(cmp);
just_dont_care = false;
}
}
// If there are no bits comparisons then just put a True
if (just_dont_care) {
all->add_expr(new vhdl_const_bool(true));
}
if (result)