aiger2: Use shorthands

This commit is contained in:
Martin Povišer 2024-09-11 21:08:03 +02:00
parent e59387e5a9
commit d7128cb787
1 changed files with 13 additions and 10 deletions

View File

@ -42,6 +42,9 @@ PRIVATE_NAMESPACE_BEGIN
template<typename Writer, typename Lit> template<typename Writer, typename Lit>
struct Index { struct Index {
static constexpr Lit CFALSE = Writer::CONST_FALSE;
static constexpr Lit CTRUE = Writer::CONST_TRUE;
struct HierCursor; struct HierCursor;
struct ModuleInfo { struct ModuleInfo {
Module *module; Module *module;
@ -122,11 +125,11 @@ struct Index {
Lit AND(Lit a, Lit b) Lit AND(Lit a, Lit b)
{ {
if (const_folding) { if (const_folding) {
if (a == Writer::CONST_FALSE || b == Writer::CONST_FALSE) if (a == CFALSE || b == CFALSE)
return Writer::CONST_FALSE; return CFALSE;
if (a == Writer::CONST_TRUE) if (a == CTRUE)
return b; return b;
if (b == Writer::CONST_TRUE) if (b == CTRUE)
return a; return a;
} }
@ -161,9 +164,9 @@ struct Index {
if (const_folding) { if (const_folding) {
if (a == b) if (a == b)
return a; return a;
if (s == Writer::CONST_FALSE) if (s == CFALSE)
return a; return a;
if (s == Writer::CONST_TRUE) if (s == CTRUE)
return b; return b;
} }
@ -233,7 +236,7 @@ struct Index {
if (cell->getParam(ID::A_SIGNED).as_bool()) if (cell->getParam(ID::A_SIGNED).as_bool())
a = visit(cursor, aport.msb()); a = visit(cursor, aport.msb());
else else
a = Writer::CONST_FALSE; a = CFALSE;
} }
if (cell->type.in(ID($buf), ID($pos), ID($_BUF_))) { if (cell->type.in(ID($buf), ID($pos), ID($_BUF_))) {
@ -249,7 +252,7 @@ struct Index {
if (cell->getParam(ID::B_SIGNED).as_bool()) if (cell->getParam(ID::B_SIGNED).as_bool())
b = visit(cursor, bport.msb()); b = visit(cursor, bport.msb());
else else
b = Writer::CONST_FALSE; b = CFALSE;
} }
if (cell->type.in(ID($and), ID($_AND_))) { if (cell->type.in(ID($and), ID($_AND_))) {
@ -357,9 +360,9 @@ struct Index {
{ {
if (!bit.wire) { if (!bit.wire) {
if (bit == State::S1) if (bit == State::S1)
return Writer::CONST_TRUE; return CTRUE;
else if (bit == State::S0) else if (bit == State::S0)
return Writer::CONST_FALSE; return CFALSE;
else else
log_error("Unhandled state %s\n", log_signal(bit)); log_error("Unhandled state %s\n", log_signal(bit));
} }