CIRCT 22.0.0git
|
Lower FirRegOp to sv.reg
and sv.always
.
More...
#include <FirRegLowering.h>
Classes | |
struct | RegCondition |
The conditions under which a register is defined. More... | |
struct | RegLowerInfo |
Public Types | |
using | PathTable = DenseMap< seq::FirRegOp, hw::HierPathOp > |
A map sending registers to their paths. | |
Public Member Functions | |
FirRegLowering (TypeConverter &typeConverter, hw::HWModuleOp module, const PathTable &pathTable, bool disableRegRandomization=false, bool emitSeparateAlwaysBlocks=false) | |
void | lower () |
bool | needsRegRandomization () const |
Static Public Member Functions | |
static PathTable | createPaths (mlir::ModuleOp top) |
When a register is buried under an ifdef op, the initialization code at the footer of the HW module will refer to the register using a hierarchical path op. | |
Public Attributes | |
unsigned | numSubaccessRestored = 0 |
Private Types | |
using | AlwaysKeyType = std::tuple< Block *, sv::EventControl, Value, sv::ResetType, sv::EventControl, Value > |
using | IfKeyType = std::pair< Block *, Value > |
Private Member Functions | |
void | lowerUnderIfDef (sv::IfDefOp ifDefOp) |
void | lowerInBlock (Block *block) |
void | lowerReg (seq::FirRegOp reg) |
void | createInitialBlock () |
void | initialize (OpBuilder &builder, RegLowerInfo reg, ArrayRef< Value > rands) |
void | initializeRegisterElements (Location loc, OpBuilder &builder, Value reg, Value rand, unsigned &pos) |
void | createTree (OpBuilder &builder, Value reg, Value term, Value next) |
std::optional< std::tuple< Value, Value, Value > > | tryRestoringSubaccess (OpBuilder &builder, Value reg, Value term, hw::ArrayCreateOp nextRegValue) |
void | addToAlwaysBlock (Block *block, sv::EventControl clockEdge, Value clock, const std::function< void(OpBuilder &)> &body, sv::ResetType resetStyle={}, sv::EventControl resetEdge={}, Value reset={}, const std::function< void(OpBuilder &)> &resetBody={}) |
void | addToIfBlock (OpBuilder &builder, Value cond, const std::function< void()> &trueSide, const std::function< void()> &falseSide) |
SmallVector< Value > | createRandomizationVector (OpBuilder &builder, Location loc) |
void | createRandomInitialization (ImplicitLocOpBuilder &builder) |
void | createPresetInitialization (ImplicitLocOpBuilder &builder) |
void | createAsyncResetInitialization (ImplicitLocOpBuilder &builder) |
hw::ConstantOp | getOrCreateConstant (Location loc, const APInt &value) |
void | buildRegConditions (OpBuilder &b, sv::RegOp reg) |
Recreate the ifdefs under which reg was defined. | |
Private Attributes | |
llvm::SmallDenseMap< AlwaysKeyType, std::pair< sv::AlwaysOp, sv::IfOp > > | alwaysBlocks |
llvm::SmallDenseMap< IfKeyType, sv::IfOp > | ifCache |
llvm::SmallDenseMap< APInt, hw::ConstantOp > | constantCache |
llvm::SmallDenseMap< std::pair< Value, unsigned >, Value > | arrayIndexCache |
std::vector< RegCondition > | conditions |
The ambient ifdef conditions we have encountered while lowering. | |
SmallVector< RegLowerInfo > | randomInitRegs |
A list of registers discovered, bucketed by initialization style. | |
SmallVector< RegLowerInfo > | presetInitRegs |
DenseMap< sv::RegOp, std::vector< RegCondition > > | regConditionTable |
A map from RegOps to the ifdef conditions under which they are defined. | |
llvm::MapVector< Value, SmallVector< RegLowerInfo > > | asyncResets |
A map from async reset signal to the registers that use it. | |
std::unique_ptr< ReachableMuxes > | reachableMuxes |
const PathTable & | pathTable |
TypeConverter & | typeConverter |
hw::HWModuleOp bool | disableRegRandomization |
bool | emitSeparateAlwaysBlocks |
bool | needsRandom = false |
Lower FirRegOp to sv.reg
and sv.always
.
Definition at line 78 of file FirRegLowering.h.
|
private |
Definition at line 175 of file FirRegLowering.h.
|
private |
Definition at line 180 of file FirRegLowering.h.
using circt::FirRegLowering::PathTable = DenseMap<seq::FirRegOp, hw::HierPathOp> |
A map sending registers to their paths.
Definition at line 81 of file FirRegLowering.h.
FirRegLowering::FirRegLowering | ( | TypeConverter & | typeConverter, |
hw::HWModuleOp | module, | ||
const PathTable & | pathTable, | ||
bool | disableRegRandomization = false , |
||
bool | emitSeparateAlwaysBlocks = false |
||
) |
Definition at line 236 of file FirRegLowering.cpp.
References reachableMuxes.
|
private |
Definition at line 865 of file FirRegLowering.cpp.
References alwaysBlocks, assert(), emitSeparateAlwaysBlocks, and getBlockEnd().
Referenced by lowerReg().
|
private |
|
private |
Recreate the ifdefs under which reg
was defined.
Leave the builder with its insertion point inside the created ifdef guards.
Definition at line 798 of file FirRegLowering.cpp.
References conditions, circt::FirRegLowering::RegCondition::IfDefElse, circt::FirRegLowering::RegCondition::IfDefThen, seq::reg(), and regConditionTable.
Referenced by createPresetInitialization(), and initialize().
|
private |
Definition at line 385 of file FirRegLowering.cpp.
References asyncResets.
Referenced by createInitialBlock().
|
private |
Definition at line 408 of file FirRegLowering.cpp.
References asyncResets, createAsyncResetInitialization(), createPresetInitialization(), createRandomInitialization(), needsRandom, presetInitRegs, and randomInitRegs.
Referenced by lower().
|
static |
When a register is buried under an ifdef op, the initialization code at the footer of the HW module will refer to the register using a hierarchical path op.
This function creates any necessary hier paths and returns a map from buried registers to their hier path ops. HierPathOps creation needs to be serialized to keep the symbol creation deterministic, so this is done as a pre-pass on the entire MLIR module. The result should be passed in to each invocation of FirRefLowering.
Definition at line 226 of file FirRegLowering.cpp.
References circt::Namespace::add(), getAllBuriedRegs(), and getHierPathTo().
Referenced by circt::SeqToSVPass::runOnOperation().
|
private |
Definition at line 358 of file FirRegLowering.cpp.
References buildRegConditions(), buildXMRTo(), hw.BitcastOp::create(), getOrCreateConstant(), and presetInitRegs.
Referenced by createInitialBlock().
|
private |
Definition at line 341 of file FirRegLowering.cpp.
References createRandomizationVector(), initialize(), and randomInitRegs.
Referenced by createInitialBlock().
|
private |
Definition at line 285 of file FirRegLowering.cpp.
References comb.ExtractOp::create(), getOrCreateConstant(), randomInitRegs, and seq::reg().
Referenced by createRandomInitialization().
|
private |
Definition at line 569 of file FirRegLowering.cpp.
References addToIfBlock(), areEquivalentValues(), arrayIndexCache, assert(), hw.ArrayGetOp::create(), getOrCreateConstant(), numSubaccessRestored, reachableMuxes, seq::reg(), and tryRestoringSubaccess().
|
inlineprivate |
Definition at line 159 of file FirRegLowering.h.
References constantCache.
Referenced by createPresetInitialization(), createRandomizationVector(), createTree(), initializeRegisterElements(), and tryRestoringSubaccess().
|
private |
Definition at line 825 of file FirRegLowering.cpp.
References buildRegConditions(), buildXMRTo(), concat(), sv.ReadInOutOp::create(), initializeRegisterElements(), and seq::reg().
Referenced by createRandomInitialization().
|
private |
Definition at line 768 of file FirRegLowering.cpp.
References assert(), getOrCreateConstant(), initializeRegisterElements(), and seq::reg().
Referenced by initialize(), and initializeRegisterElements().
void FirRegLowering::lower | ( | ) |
Definition at line 247 of file FirRegLowering.cpp.
References createInitialBlock(), and lowerInBlock().
Referenced by circt::SeqToSVPass::runOnOperation().
|
private |
Definition at line 269 of file FirRegLowering.cpp.
References lowerInBlock(), lowerReg(), and lowerUnderIfDef().
Referenced by lower(), lowerInBlock(), and lowerUnderIfDef().
|
private |
Definition at line 688 of file FirRegLowering.cpp.
References addToAlwaysBlock(), asyncResets, conditions, sv.ReadInOutOp::create(), disableRegRandomization, circt::hw::getBitWidth(), pathTable, presetInitRegs, randomInitRegs, seq::reg(), circt::FirRegLowering::RegLowerInfo::reg, regConditionTable, and typeConverter.
Referenced by lowerInBlock().
|
private |
Definition at line 254 of file FirRegLowering.cpp.
References conditions, circt::FirRegLowering::RegCondition::IfDefElse, circt::FirRegLowering::RegCondition::IfDefThen, and lowerInBlock().
Referenced by lowerInBlock().
|
inline |
Definition at line 98 of file FirRegLowering.h.
References needsRandom.
Referenced by circt::SeqToSVPass::runOnOperation().
|
private |
Definition at line 496 of file FirRegLowering.cpp.
References areEquivalentValues(), extractConditions(), getConstantValue(), getOrCreateConstant(), and seq::reg().
Referenced by createTree().
|
private |
Definition at line 178 of file FirRegLowering.h.
Referenced by addToAlwaysBlock().
|
private |
Definition at line 184 of file FirRegLowering.h.
Referenced by createTree().
|
private |
A map from async reset signal to the registers that use it.
Definition at line 197 of file FirRegLowering.h.
Referenced by createAsyncResetInitialization(), createInitialBlock(), and lowerReg().
|
private |
The ambient ifdef conditions we have encountered while lowering.
Definition at line 187 of file FirRegLowering.h.
Referenced by buildRegConditions(), lowerReg(), and lowerUnderIfDef().
|
private |
Definition at line 183 of file FirRegLowering.h.
Referenced by getOrCreateConstant().
|
private |
Definition at line 205 of file FirRegLowering.h.
Referenced by lowerReg().
|
private |
Definition at line 206 of file FirRegLowering.h.
Referenced by addToAlwaysBlock().
|
private |
Definition at line 181 of file FirRegLowering.h.
Referenced by addToIfBlock().
|
private |
Definition at line 208 of file FirRegLowering.h.
Referenced by createInitialBlock(), and needsRegRandomization().
unsigned circt::FirRegLowering::numSubaccessRestored = 0 |
Definition at line 100 of file FirRegLowering.h.
Referenced by createTree(), and circt::SeqToSVPass::runOnOperation().
|
private |
Definition at line 201 of file FirRegLowering.h.
Referenced by lowerReg().
|
private |
Definition at line 190 of file FirRegLowering.h.
Referenced by createInitialBlock(), createPresetInitialization(), and lowerReg().
|
private |
A list of registers discovered, bucketed by initialization style.
Definition at line 190 of file FirRegLowering.h.
Referenced by createInitialBlock(), createRandomInitialization(), createRandomizationVector(), and lowerReg().
|
private |
Definition at line 199 of file FirRegLowering.h.
Referenced by createTree(), and FirRegLowering().
|
private |
A map from RegOps to the ifdef conditions under which they are defined.
We only bother recording a list of conditions if there is at least one.
Definition at line 194 of file FirRegLowering.h.
Referenced by buildRegConditions(), and lowerReg().
|
private |
Definition at line 202 of file FirRegLowering.h.
Referenced by lowerReg().