Skip to content

Commit

Permalink
bmux works for SMT, simulation fails for C++
Browse files Browse the repository at this point in the history
  • Loading branch information
RCoeurjoly committed Jul 7, 2024
1 parent 3dad680 commit a459eb7
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion kernel/functionalir.cc
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,30 @@ class CellSimplifier {
}
} else if(cellType == ID($pow)) {
return handle_pow(inputs.at(ID(A)), a_width, inputs.at(ID(B)), b_width, y_width, a_signed && b_signed);
} else if (cellType == ID($bmux)) {
int width = parameters.at(ID(WIDTH)).as_int();
int s_width = parameters.at(ID(S_WIDTH)).as_int();
T a = inputs.at(ID(A));
T s = inputs.at(ID(S));

// Initialize the result with the first slice of A
T result = factory.slice(a, 0, width, width);

for (int i = 1; i < (1 << s_width); i++) {
// Compute the current slice of A
T current_slice = factory.slice(a, i * width, width, width);

// Compute the select signal for the current slice
RTLIL::Const const_i(i, s_width);
T current_select = factory.equal(s, factory.constant(const_i), s_width);

// Update the result based on the current select signal
result = factory.mux(result, current_slice, current_select, width);
}

return result;
} else{
log_error("unhandled cell in CellSimplifier %s\n", cellType.c_str());
log_error("unhandled cell in CellSimplifier %s\n", cellType.c_str());
}
}
};
Expand Down

0 comments on commit a459eb7

Please sign in to comment.