Skip to content

Commit 921ebc1

Browse files
committed
Add ReduceOr (haven't yet added it to egglog!!!)
1 parent 7e9a195 commit 921ebc1

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

backends/lakeroad/lakeroad.cc

+22
Original file line numberDiff line numberDiff line change
@@ -1383,6 +1383,28 @@ struct LakeroadWorker {
13831383
f << stringf("(union %s (Op2 %s %s %s))\n", y_let_name.c_str(), op_str.c_str(), a_let_name.c_str(),
13841384
b_let_name.c_str())
13851385
.c_str();
1386+
} else if (cell->type.in(ID($reduce_or))) {
1387+
// Unary ops that result in one bit.
1388+
assert(cell->connections().size() == 2);
1389+
auto y = sigmap(cell->getPort(ID::Y));
1390+
auto a = sigmap(cell->getPort(ID::A));
1391+
1392+
if (y.size() != 1)
1393+
log_error("Expected 1-bit output for cell %s.\n", log_id(cell));
1394+
1395+
// Extend the inputs to the same width.
1396+
int to_width = a.size();
1397+
auto a_let_name = get_expression_for_signal(sigmap(cell->getPort(ID::A)), to_width);
1398+
1399+
auto y_let_name = get_expression_for_signal(y, -1);
1400+
1401+
std::string op_str;
1402+
if (cell->type == ID($reduce_or))
1403+
op_str = "(ReduceOr)";
1404+
else
1405+
log_error("This should be unreachable. You are missing an else if branch.\n");
1406+
1407+
f << stringf("(union %s (Op1 %s %s))\n", y_let_name.c_str(), op_str.c_str(), a_let_name.c_str()).c_str();
13861408
} else if (cell->type == ID($dff)) {
13871409
assert(cell->connections().size() == 3);
13881410
auto q = sigmap(cell->getPort(ID::Q));

0 commit comments

Comments
 (0)