Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ExternalizeRegisters][NFC] Clean up initial value fetching #7843

Merged
merged 2 commits into from
Nov 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions lib/Tools/circt-bmc/ExternalizeRegisters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,22 +96,15 @@ void ExternalizeRegistersPass::runOnOperation() {
}
mlir::Attribute initState;
if (auto initVal = regOp.getInitialValue()) {
// Find the seq.initial op where the initial value is defined and
// fetch the operation inside that defines the value
auto initialOp =
regOp.getInitialValue().getDefiningOp<seq::InitialOp>();
if (!initialOp) {
// Find the constant op that defines the reset value in an initial
// block (if it exists)
if (!initVal.getDefiningOp<seq::InitialOp>()) {
regOp.emitError("registers with initial values not directly "
"defined by a seq.initial op not yet supported");
return signalPassFailure();
}
auto index = cast<OpResult>(initVal).getResultNumber();
auto initValDef =
initialOp->getRegion(0).front().getTerminator()->getOperand(
index);
// If it's defined by a constant op then just fetch the constant
// value - otherwise unsupported
if (auto constantOp = initValDef.getDefiningOp<hw::ConstantOp>()) {
if (auto constantOp = circt::seq::unwrapImmutableValue(initVal)
.getDefiningOp<hw::ConstantOp>()) {
// Fetch value from constant op - leave removing the dead op to
// DCE
initState = constantOp.getValueAttr();
Expand Down
Loading