26 #include "mlir/Analysis/TopologicalSortUtils.h"
27 #include "mlir/IR/Builders.h"
28 #include "mlir/IR/DialectImplementation.h"
29 #include "mlir/IR/ImplicitLocOpBuilder.h"
30 #include "mlir/IR/Threading.h"
31 #include "mlir/Pass/Pass.h"
32 #include "mlir/Transforms/DialectConversion.h"
33 #include "llvm/ADT/IntervalMap.h"
34 #include "llvm/ADT/TypeSwitch.h"
35 #include "llvm/Support/Mutex.h"
37 #define DEBUG_TYPE "lower-seq-to-sv"
39 using namespace circt;
42 using llvm::MapVector;
45 #define GEN_PASS_DEF_LOWERSEQTOSV
46 #include "circt/Conversion/Passes.h.inc"
48 struct SeqToSVPass :
public impl::LowerSeqToSVBase<SeqToSVPass> {
50 void runOnOperation()
override;
52 using LowerSeqToSVBase<SeqToSVPass>::lowerToAlwaysFF;
53 using LowerSeqToSVBase<SeqToSVPass>::disableRegRandomization;
54 using LowerSeqToSVBase<SeqToSVPass>::emitSeparateAlwaysBlocks;
55 using LowerSeqToSVBase<SeqToSVPass>::LowerSeqToSVBase;
56 using LowerSeqToSVBase<SeqToSVPass>::numSubaccessRestored;
61 struct ModuleLoweringState {
63 : immutableValueLowering(module), module(module) {}
65 struct ImmutableValueLowering {
69 LogicalResult lower();
70 LogicalResult lower(seq::InitialOp initialOp);
73 lookupImmutableValue(mlir::TypedValue<seq::ImmutableType> immut)
const {
74 return mapping.lookup(immut);
77 sv::InitialOp getSVInitial()
const {
return svInitialOp; }
80 sv::InitialOp svInitialOp = {};
83 MapVector<mlir::TypedValue<seq::ImmutableType>, Value> mapping;
86 } immutableValueLowering;
89 bool needsRegFragment =
false;
90 bool needsMemFragment =
false;
96 LogicalResult ModuleLoweringState::ImmutableValueLowering::lower() {
101 auto initialOp = *result;
105 return lower(initialOp);
109 ModuleLoweringState::ImmutableValueLowering::lower(seq::InitialOp initialOp) {
110 OpBuilder builder = OpBuilder::atBlockBegin(module.getBodyBlock());
112 svInitialOp = builder.create<sv::InitialOp>(initialOp->getLoc());
114 assert(initialOp.getNumOperands() == 0 &&
115 "initial op should have no operands");
117 auto loc = initialOp.getLoc();
118 llvm::SmallVector<Value> results;
120 auto yieldOp = cast<seq::YieldOp>(initialOp.getBodyBlock()->getTerminator());
122 for (
auto [result, operand] :
123 llvm::zip(initialOp.getResults(), yieldOp->getOperands())) {
126 .create<mlir::UnrealizedConversionCastOp>(
127 loc, ArrayRef<Type>{result.getType()}, ArrayRef<Value>{})
129 result.replaceAllUsesWith(placeholder);
131 {cast<mlir::TypedValue<seq ::ImmutableType>>(placeholder), operand});
134 svInitialOp.getBodyBlock()->getOperations().splice(
135 svInitialOp.end(), initialOp.getBodyBlock()->getOperations());
137 assert(initialOp->use_empty());
145 template <
typename OpTy>
149 TypeConverter &typeConverter, MLIRContext *context,
bool lowerToAlwaysFF,
150 const MapVector<StringAttr, ModuleLoweringState> &moduleLoweringStates)
152 lowerToAlwaysFF(lowerToAlwaysFF),
153 moduleLoweringStates(moduleLoweringStates) {}
158 matchAndRewrite(OpTy
reg, OpAdaptor adaptor,
159 ConversionPatternRewriter &rewriter)
const final {
160 Location loc =
reg.getLoc();
163 ConversionPattern::getTypeConverter()->convertType(
reg.getType());
164 auto svReg = rewriter.create<
sv::RegOp>(loc, regTy,
reg.getNameAttr(),
165 reg.getInnerSymAttr());
167 svReg->setDialectAttrs(
reg->getDialectAttrs());
173 auto assignValue = [&] {
174 createAssign(rewriter,
reg.getLoc(), svReg,
reg);
176 auto assignReset = [&] {
177 rewriter.create<sv::PAssignOp>(loc, svReg, adaptor.getResetValue());
180 if (adaptor.getReset() && adaptor.getResetValue()) {
181 if (lowerToAlwaysFF) {
182 rewriter.create<sv::AlwaysFFOp>(
183 loc, sv::EventControl::AtPosEdge, adaptor.getClk(),
184 sv::ResetType::SyncReset, sv::EventControl::AtPosEdge,
185 adaptor.getReset(), assignValue, assignReset);
187 rewriter.create<sv::AlwaysOp>(
188 loc, sv::EventControl::AtPosEdge, adaptor.getClk(), [&] {
189 rewriter.create<sv::IfOp>(loc, adaptor.getReset(), assignReset,
194 if (lowerToAlwaysFF) {
195 rewriter.create<sv::AlwaysFFOp>(loc, sv::EventControl::AtPosEdge,
196 adaptor.getClk(), assignValue);
198 rewriter.create<sv::AlwaysOp>(loc, sv::EventControl::AtPosEdge,
199 adaptor.getClk(), assignValue);
204 if (
auto init =
reg.getInitialValue()) {
205 auto module =
reg->template getParentOfType<hw::HWModuleOp>();
206 const auto &initial =
207 moduleLoweringStates.find(module.getModuleNameAttr())
208 ->second.immutableValueLowering;
210 Value initialValue = initial.lookupImmutableValue(init);
212 if (
auto op = initialValue.getDefiningOp();
213 op && op->hasTrait<mlir::OpTrait::ConstantLike>()) {
214 auto clonedConstant = rewriter.clone(*op);
215 rewriter.moveOpBefore(clonedConstant, svReg);
216 svReg.getInitMutable().assign(clonedConstant->getResult(0));
218 OpBuilder::InsertionGuard guard(rewriter);
219 auto in = initial.getSVInitial();
220 rewriter.setInsertionPointToEnd(in.getBodyBlock());
221 rewriter.create<sv::BPAssignOp>(
reg->getLoc(), svReg, initialValue);
225 rewriter.replaceOp(
reg, regVal);
230 void createAssign(ConversionPatternRewriter &rewriter, Location loc,
234 bool lowerToAlwaysFF;
235 const MapVector<StringAttr, ModuleLoweringState> &moduleLoweringStates;
240 void CompRegLower<CompRegOp>::createAssign(ConversionPatternRewriter &rewriter,
242 OpAdaptor
reg)
const {
243 rewriter.create<sv::PAssignOp>(loc, svReg,
reg.getInput());
247 void CompRegLower<CompRegClockEnabledOp>::createAssign(
248 ConversionPatternRewriter &rewriter, Location loc,
sv::RegOp svReg,
249 OpAdaptor
reg)
const {
250 rewriter.create<sv::IfOp>(loc,
reg.getClockEnable(), [&]() {
251 rewriter.create<sv::PAssignOp>(loc, svReg,
reg.getInput());
258 FromImmutableLowering(
259 TypeConverter &typeConverter, MLIRContext *context,
260 const MapVector<StringAttr, ModuleLoweringState> &moduleLoweringStates)
262 moduleLoweringStates(moduleLoweringStates) {}
267 matchAndRewrite(FromImmutableOp fromImmutableOp, OpAdaptor adaptor,
268 ConversionPatternRewriter &rewriter)
const final {
269 Location loc = fromImmutableOp.getLoc();
271 auto regTy = ConversionPattern::getTypeConverter()->convertType(
272 fromImmutableOp.getType());
273 auto svReg = rewriter.create<
sv::RegOp>(loc, regTy);
278 auto module = fromImmutableOp->template getParentOfType<hw::HWModuleOp>();
279 const auto &initial = moduleLoweringStates.find(module.getModuleNameAttr())
280 ->second.immutableValueLowering;
283 initial.lookupImmutableValue(fromImmutableOp.getInput());
285 OpBuilder::InsertionGuard guard(rewriter);
286 auto in = initial.getSVInitial();
287 rewriter.setInsertionPointToEnd(in.getBodyBlock());
288 rewriter.create<sv::BPAssignOp>(fromImmutableOp->getLoc(), svReg,
291 rewriter.replaceOp(fromImmutableOp, regVal);
296 const MapVector<StringAttr, ModuleLoweringState> &moduleLoweringStates;
305 matchAndRewrite(ClockGateOp clockGate, OpAdaptor adaptor,
306 ConversionPatternRewriter &rewriter)
const final {
307 auto loc = clockGate.getLoc();
308 Value
clk = adaptor.getInput();
311 Value enable = adaptor.getEnable();
312 if (
auto te = adaptor.getTestEnable())
313 enable = rewriter.create<
comb::OrOp>(loc, enable, te);
316 Value enableLatch = rewriter.create<
sv::RegOp>(
317 loc, rewriter.getI1Type(), rewriter.getStringAttr(
"cg_en_latch"));
320 rewriter.create<sv::AlwaysOp>(
321 loc, llvm::SmallVector<sv::EventControl>{}, llvm::SmallVector<Value>{},
323 rewriter.create<sv::IfOp>(
325 rewriter.create<sv::PAssignOp>(loc, enableLatch, enable);
343 matchAndRewrite(ClockInverterOp op, OpAdaptor adaptor,
344 ConversionPatternRewriter &rewriter)
const final {
345 auto loc = op.getLoc();
346 Value
clk = adaptor.getInput();
348 StringAttr name = op->getAttrOfType<StringAttr>(
"sv.namehint");
350 auto newOp = rewriter.replaceOpWithNewOp<
comb::XorOp>(op,
clk, one);
352 rewriter.modifyOpInPlace(newOp,
353 [&] { newOp->setAttr(
"sv.namehint", name); });
366 matchAndRewrite(ClockMuxOp clockMux, OpAdaptor adaptor,
367 ConversionPatternRewriter &rewriter)
const final {
368 rewriter.replaceOpWithNewOp<
comb::MuxOp>(clockMux, adaptor.getCond(),
369 adaptor.getTrueClock(),
370 adaptor.getFalseClock(),
true);
376 struct SeqToSVTypeConverter :
public TypeConverter {
377 SeqToSVTypeConverter() {
378 addConversion([&](Type type) {
return type; });
379 addConversion([&](seq::ImmutableType type) {
return type.getInnerType(); });
380 addConversion([&](seq::ClockType type) {
383 addConversion([&](hw::StructType structTy) {
384 bool changed =
false;
386 SmallVector<hw::StructType::FieldInfo> newFields;
387 for (
auto field : structTy.getElements()) {
388 auto &newField = newFields.emplace_back();
389 newField.name = field.name;
390 newField.type = convertType(field.type);
391 if (field.type != newField.type)
400 addConversion([&](hw::ArrayType arrayTy) {
401 auto elementTy = arrayTy.getElementType();
403 if (elementTy != newElementTy)
408 addTargetMaterialization(
409 [&](mlir::OpBuilder &builder, mlir::Type resultType,
410 mlir::ValueRange inputs,
411 mlir::Location loc) -> std::optional<mlir::Value> {
412 if (inputs.size() != 1)
415 .create<mlir::UnrealizedConversionCastOp>(loc, resultType,
420 addSourceMaterialization(
421 [&](mlir::OpBuilder &builder, mlir::Type resultType,
422 mlir::ValueRange inputs,
423 mlir::Location loc) -> std::optional<mlir::Value> {
424 if (inputs.size() != 1)
427 .create<mlir::UnrealizedConversionCastOp>(loc, resultType,
435 template <
typename T>
441 matchAndRewrite(T op,
typename T::Adaptor adaptor,
442 ConversionPatternRewriter &rewriter)
const final {
444 if (Operation *inputOp = adaptor.getInput().getDefiningOp())
445 if (!isa<mlir::UnrealizedConversionCastOp>(inputOp))
447 rewriter.modifyOpInPlace(
448 inputOp, [&] { inputOp->setAttr(
"sv.namehint", name); });
450 rewriter.replaceOp(op, adaptor.getInput());
463 matchAndRewrite(ConstClockOp clockConst, OpAdaptor adaptor,
464 ConversionPatternRewriter &rewriter)
const final {
466 clockConst, APInt(1, clockConst.getValue() == ClockConst::High));
471 class AggregateConstantPattern
478 matchAndRewrite(hw::AggregateConstantOp aggregateConstant, OpAdaptor adaptor,
479 ConversionPatternRewriter &rewriter)
const final {
480 auto newType = typeConverter->convertType(aggregateConstant.getType());
481 auto newAttr = aggregateConstant.getFieldsAttr().replace(
482 [](seq::ClockConstAttr clockConst) {
485 APInt(1, clockConst.getValue() == ClockConst::High));
487 rewriter.replaceOpWithNewOp<hw::AggregateConstantOp>(
488 aggregateConstant, newType, cast<ArrayAttr>(newAttr));
501 matchAndRewrite(ClockDividerOp clockDiv, OpAdaptor adaptor,
502 ConversionPatternRewriter &rewriter)
const final {
503 Location loc = clockDiv.getLoc();
506 if (clockDiv.getPow2()) {
510 Value output = clockDiv.getInput();
512 SmallVector<Value> regs;
513 for (
unsigned i = 0; i < clockDiv.getPow2(); ++i) {
515 loc, rewriter.getI1Type(),
516 rewriter.getStringAttr(
"clock_out_" + std::to_string(i)));
519 rewriter.create<sv::AlwaysOp>(
520 loc, sv::EventControl::AtPosEdge, output, [&] {
523 rewriter.create<sv::BPAssignOp>(loc,
reg, inverted);
531 rewriter.
create<sv::InitialOp>(loc, [&] {
532 for (Value
reg : regs) {
533 rewriter.
create<sv::BPAssignOp>(loc,
reg, zero);
538 rewriter.replaceOp(clockDiv, output);
547 if (hw::type_isa<ClockType>(ty))
550 if (
auto arrayTy = hw::type_dyn_cast<hw::ArrayType>(ty))
553 if (
auto structTy = hw::type_dyn_cast<hw::StructType>(ty)) {
554 for (
auto field : structTy.getElements())
565 if (
auto module = dyn_cast<hw::HWModuleLike>(op)) {
566 for (
auto port : module.getHWModuleType().getPorts())
572 if (
auto hwAggregateConstantOp = dyn_cast<hw::AggregateConstantOp>(op)) {
573 bool foundClockAttr =
false;
574 hwAggregateConstantOp.getFieldsAttr().walk(
575 [&](seq::ClockConstAttr attr) { foundClockAttr =
true; });
580 bool allOperandsLowered = llvm::all_of(
581 op->getOperands(), [](
auto op) { return isLegalType(op.getType()); });
582 bool allResultsLowered = llvm::all_of(op->getResults(), [](
auto result) {
583 return isLegalType(result.getType());
585 return allOperandsLowered && allResultsLowered;
589 auto circuit = getOperation();
590 MLIRContext *context = &getContext();
592 auto modules = llvm::to_vector(circuit.getOps<
HWModuleOp>());
598 MapVector<HWModuleOp, SmallVector<FirMemLowering::MemoryConfig>> memsByModule;
599 for (
auto &[config, memOps] : uniqueMems) {
604 for (
auto memOp : memOps) {
605 auto parent = memOp->getParentOfType<
HWModuleOp>();
606 memsByModule[parent].emplace_back(&config, genOp, memOp);
611 std::atomic<bool> needsRegRandomization =
false;
612 std::atomic<bool> needsMemRandomization =
false;
614 MapVector<StringAttr, ModuleLoweringState> moduleLoweringStates;
615 for (
auto module : circuit.getOps<
HWModuleOp>())
616 moduleLoweringStates.try_emplace(module.getModuleNameAttr(),
617 ModuleLoweringState(module));
619 auto result = mlir::failableParallelForEach(
620 &getContext(), moduleLoweringStates, [&](
auto &moduleAndState) {
621 auto &state = moduleAndState.second;
622 auto module = state.module;
623 SeqToSVTypeConverter typeConverter;
625 disableRegRandomization,
626 emitSeparateAlwaysBlocks);
629 if (!disableRegRandomization) {
630 state.fragment.needsRegFragment =
true;
632 needsRegRandomization =
true;
636 if (
auto *it = memsByModule.find(module); it != memsByModule.end()) {
638 if (!disableMemRandomization) {
639 state.fragment.needsMemFragment =
true;
641 needsMemRandomization =
true;
643 return state.immutableValueLowering.lower();
647 return signalPassFailure();
649 auto randomInitFragmentName =
651 auto randomInitRegFragmentName =
653 auto randomInitMemFragmentName =
656 for (
auto &[_, state] : moduleLoweringStates) {
657 const auto &info = state.fragment;
658 if (!info.needsRegFragment && !info.needsMemFragment) {
663 SmallVector<Attribute> fragmentAttrs;
664 auto module = state.module;
667 fragmentAttrs = llvm::to_vector(others);
669 if (info.needsRegFragment)
670 fragmentAttrs.push_back(randomInitRegFragmentName);
671 if (info.needsMemFragment)
672 fragmentAttrs.push_back(randomInitMemFragmentName);
673 fragmentAttrs.push_back(randomInitFragmentName);
680 SeqToSVTypeConverter typeConverter;
681 ConversionTarget target(*context);
682 target.addIllegalDialect<SeqDialect>();
683 target.markUnknownOpDynamicallyLegal(
isLegalOp);
685 RewritePatternSet
patterns(context);
686 patterns.add<CompRegLower<CompRegOp>>(typeConverter, context, lowerToAlwaysFF,
687 moduleLoweringStates);
688 patterns.add<CompRegLower<CompRegClockEnabledOp>>(
689 typeConverter, context, lowerToAlwaysFF, moduleLoweringStates);
690 patterns.add<FromImmutableLowering>(typeConverter, context,
691 moduleLoweringStates);
692 patterns.add<ClockCastLowering<seq::FromClockOp>>(typeConverter, context);
693 patterns.add<ClockCastLowering<seq::ToClockOp>>(typeConverter, context);
694 patterns.add<ClockGateLowering>(typeConverter, context);
695 patterns.add<ClockInverterLowering>(typeConverter, context);
696 patterns.add<ClockMuxLowering>(typeConverter, context);
697 patterns.add<ClockDividerLowering>(typeConverter, context);
698 patterns.add<ClockConstLowering>(typeConverter, context);
700 patterns.add<AggregateConstantPattern>(typeConverter, context);
702 if (failed(applyPartialConversion(circuit, target, std::move(
patterns))))
706 auto b = ImplicitLocOpBuilder::atBlockBegin(loc, circuit.getBody());
707 if (needsRegRandomization || needsMemRandomization) {
708 b.create<sv::MacroDeclOp>(
"ENABLE_INITIAL_REG_");
709 b.create<sv::MacroDeclOp>(
"ENABLE_INITIAL_MEM_");
710 if (needsRegRandomization) {
711 b.create<sv::MacroDeclOp>(
"FIRRTL_BEFORE_INITIAL");
712 b.create<sv::MacroDeclOp>(
"FIRRTL_AFTER_INITIAL");
714 if (needsMemRandomization)
715 b.create<sv::MacroDeclOp>(
"RANDOMIZE_MEM_INIT");
716 b.create<sv::MacroDeclOp>(
"RANDOMIZE_REG_INIT");
717 b.create<sv::MacroDeclOp>(
"RANDOMIZE");
718 b.create<sv::MacroDeclOp>(
"RANDOMIZE_DELAY");
719 b.create<sv::MacroDeclOp>(
"RANDOM");
720 b.create<sv::MacroDeclOp>(
"INIT_RANDOM");
721 b.create<sv::MacroDeclOp>(
"INIT_RANDOM_PROLOG_");
724 bool hasRegRandomization = needsRegRandomization && !disableRegRandomization;
725 bool hasMemRandomization = needsMemRandomization && !disableMemRandomization;
726 if (!hasRegRandomization && !hasMemRandomization)
731 for (Operation &op : *circuit.getBody()) {
732 if (!isa<sv::VerbatimOp, sv::IfDefOp>(&op)) {
733 b.setInsertionPoint(&op);
741 for (
auto sym : circuit.getOps<sv::MacroDeclOp>())
742 symbols.insert(sym.getName());
743 if (!symbols.count(
"SYNTHESIS"))
744 b.create<sv::MacroDeclOp>(
"SYNTHESIS");
745 if (!symbols.count(
"VERILATOR"))
746 b.create<sv::MacroDeclOp>(
"VERILATOR");
751 auto emitGuardedDefine = [&](StringRef guard, StringRef defName,
752 StringRef defineTrue =
"",
753 StringRef defineFalse = StringRef()) {
754 if (!defineFalse.data()) {
755 assert(defineTrue.data() &&
"didn't define anything");
757 guard, [&]() { b.create<sv::MacroDefOp>(defName, defineTrue); });
762 if (defineTrue.data())
763 b.create<sv::MacroDefOp>(defName, defineTrue);
765 [&]() { b.create<sv::MacroDefOp>(defName, defineFalse); });
770 auto emitGuard = [&](
const char *guard, llvm::function_ref<void(
void)> body) {
772 guard, []() {}, body);
775 b.create<emit::FragmentOp>(randomInitFragmentName.getAttr(), [&] {
776 b.create<sv::VerbatimOp>(
777 "// Standard header to adapt well known macros for "
778 "register randomization.");
780 b.create<sv::VerbatimOp>(
781 "\n// RANDOM may be set to an expression that produces a 32-bit "
782 "random unsigned value.");
783 emitGuardedDefine(
"RANDOM",
"RANDOM", StringRef(),
"$random");
785 b.create<sv::VerbatimOp>(
786 "\n// Users can define INIT_RANDOM as general code that gets "
788 "into the\n// initializer block for modules with registers.");
789 emitGuardedDefine(
"INIT_RANDOM",
"INIT_RANDOM", StringRef(),
"");
791 b.create<sv::VerbatimOp>(
792 "\n// If using random initialization, you can also define "
793 "RANDOMIZE_DELAY to\n// customize the delay used, otherwise 0.002 "
795 emitGuardedDefine(
"RANDOMIZE_DELAY",
"RANDOMIZE_DELAY", StringRef(),
798 b.create<sv::VerbatimOp>(
799 "\n// Define INIT_RANDOM_PROLOG_ for use in our modules below.");
800 emitGuard(
"INIT_RANDOM_PROLOG_", [&]() {
804 emitGuardedDefine(
"VERILATOR",
"INIT_RANDOM_PROLOG_",
806 "`INIT_RANDOM #`RANDOMIZE_DELAY begin end");
808 [&]() { b.create<sv::MacroDefOp>(
"INIT_RANDOM_PROLOG_",
""); });
812 if (hasMemRandomization) {
813 b.create<emit::FragmentOp>(randomInitMemFragmentName.getAttr(), [&] {
814 b.create<sv::VerbatimOp>(
"\n// Include rmemory initializers in init "
815 "blocks unless synthesis is set");
816 emitGuard(
"RANDOMIZE", [&]() {
817 emitGuardedDefine(
"RANDOMIZE_MEM_INIT",
"RANDOMIZE");
819 emitGuard(
"SYNTHESIS", [&] {
820 emitGuardedDefine(
"ENABLE_INITIAL_MEM_",
"ENABLE_INITIAL_MEM_",
823 b.create<sv::VerbatimOp>(
"");
827 if (hasRegRandomization) {
828 b.create<emit::FragmentOp>(randomInitRegFragmentName.getAttr(), [&] {
829 b.create<sv::VerbatimOp>(
"\n// Include register initializers in init "
830 "blocks unless synthesis is set");
831 emitGuard(
"RANDOMIZE", [&]() {
832 emitGuardedDefine(
"RANDOMIZE_REG_INIT",
"RANDOMIZE");
834 emitGuard(
"SYNTHESIS", [&] {
835 emitGuardedDefine(
"ENABLE_INITIAL_REG_",
"ENABLE_INITIAL_REG_",
838 b.create<sv::VerbatimOp>(
"");
843 std::unique_ptr<Pass>
845 return std::make_unique<SeqToSVPass>(options);
assert(baseType &&"element must be base type")
static FIRRTLBaseType convertType(FIRRTLBaseType type)
Returns null type if no conversion is needed.
static bool isLegalType(Type ty)
static bool isLegalOp(Operation *op)
FIR memory lowering helper.
UniqueConfigs collectMemories(ArrayRef< hw::HWModuleOp > modules)
Groups memories by their kind from the whole design.
void lowerMemoriesInModule(hw::HWModuleOp module, ArrayRef< MemoryConfig > mems)
Lowers a group of memories from the same module.
hw::HWModuleGeneratedOp createMemoryModule(FirMemConfig &mem, ArrayRef< seq::FirMemOp > memOps)
Creates the generated module for a given configuration.
Lower FirRegOp to sv.reg and sv.always.
bool needsRegRandomization() const
unsigned numSubaccessRestored
def create(data_type, value)
Direction get(bool isOutput)
Returns an output direction if isOutput is true, otherwise returns an input direction.
Value createOrFoldNot(Location loc, Value value, OpBuilder &builder, bool twoState=false)
Create a `‘Not’' gate on a value.
StringRef getFragmentsAttrName()
Return the name of the fragments array attribute.
FailureOr< seq::InitialOp > mergeInitialOps(Block *block)
mlir::ArrayAttr getSVAttributes(mlir::Operation *op)
Return all the SV attributes of an operation, or null if there are none.
void setSVAttributes(mlir::Operation *op, mlir::ArrayAttr attrs)
Set the SV attributes of an operation.
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
std::unique_ptr< mlir::Pass > createLowerSeqToSVPass(const LowerSeqToSVOptions &options={})
StringRef chooseName(StringRef a, StringRef b)
Choose a good name for an item from two options.
def reg(value, clock, reset=None, reset_value=None, name=None, sym_name=None)
void runOnOperation() override
Generic pattern which replaces an operation by one of the same operation name, but with converted att...