Skip to content

Commit

Permalink
[Seq] Copy fragments in HWMemSimImpl
Browse files Browse the repository at this point in the history
When lowering `hw.module.generated`, copy any emit dialect fragments that
were on the original operation.  This allows for fragments created
earlier to be propagated along without having to teach `HWMemSimImpl`
about them.

Signed-off-by: Schuyler Eldridge <[email protected]>
  • Loading branch information
seldridge committed Feb 2, 2025
1 parent af6761a commit 3cee475
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/Dialect/Seq/Transforms/HWMemSimImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,8 @@ void HWMemSimImplPass::runOnOperation() {
addVivadoRAMAddressConflictSynthesisBugWorkaround,
mlirModuleNamespace)
.generateMemory(newModule, mem);
if (auto fragments = oldModule->getAttr(emit::getFragmentsAttrName()))
newModule->setAttr(emit::getFragmentsAttrName(), fragments);
}

oldModule.erase();
Expand Down
26 changes: 26 additions & 0 deletions test/Dialect/Seq/hw-memsim.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -445,3 +445,29 @@ hw.module.generated @ReadWriteWithHighWriteLatency, @FIRRTLMem(in %rw_addr: i4,
// CHECK: [[TMP:%.+]] = comb.and [[WRITE_WMODE_3R]], %true
// CHECK: [[WCOND:%.+]] comb.and [[WRITE_EN_3R]], [[TMP]]
// CHECK: [[WPTR:%.+]] = sv.array_index_inout [[MEM]][[[WRITE_ADDR_3R]]]

emit.fragment @Fragment {}
hw.module.generated @TestFragment, @FIRRTLMem(
in %ro_addr_0: i4,
in %ro_en_0: i1,
in %ro_clock_0: i1,
out ro_data_0: i16
) attributes {
depth = 10 : i64,
numReadPorts = 1 : ui32,
numReadWritePorts = 0 : ui32,
numWritePorts = 0 : ui32,
readLatency = 0 : ui32,
readUnderWrite = 0 : i32,
width = 16 : ui32,
writeClockIDs = [],
writeLatency = 1 : ui32,
writeUnderWrite = 0 : i32,
initFilename = "",
initIsBinary = false,
initIsInline = false,
emit.fragments = [@Fragment]
}

// CHECK-LABEL: hw.module private @TestFragment
// CHECK-SAME: emit.fragments = [@Fragment]

0 comments on commit 3cee475

Please sign in to comment.