CIRCT  19.0.0git
Classes | Public Member Functions | Public Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
circt::FirRegLowering Class Reference

Lower FirRegOp to sv.reg and sv.always. More...

#include <FirRegLowering.h>

Collaboration diagram for circt::FirRegLowering:
Collaboration graph
[legend]

Classes

struct  RegLowerInfo
 

Public Member Functions

 FirRegLowering (TypeConverter &typeConverter, hw::HWModuleOp module, bool disableRegRandomization=false, bool emitSeparateAlwaysBlocks=false)
 
void lower ()
 
bool needsRegRandomization () const
 

Public Attributes

unsigned numSubaccessRestored = 0
 

Private Types

using AlwaysKeyType = std::tuple< Block *, sv::EventControl, Value, ResetType, sv::EventControl, Value >
 
using IfKeyType = std::pair< Block *, Value >
 

Private Member Functions

RegLowerInfo lower (seq::FirRegOp reg)
 
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, 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)
 
hw::ConstantOp getOrCreateConstant (Location loc, const APInt &value)
 

Private Attributes

llvm::SmallDenseMap< AlwaysKeyType, std::pair< sv::AlwaysOp, sv::IfOp > > alwaysBlocks
 
llvm::SmallDenseMap< IfKeyType, sv::IfOp > ifCache
 
llvm::SmallDenseMap< APInt, hw::ConstantOpconstantCache
 
llvm::SmallDenseMap< std::pair< Value, unsigned >, Value > arrayIndexCache
 
std::unique_ptr< ReachableMuxesreachableMuxes
 
TypeConverter & typeConverter
 
hw::HWModuleOp module
 
bool disableRegRandomization
 
bool emitSeparateAlwaysBlocks
 
bool needsRandom = false
 

Detailed Description

Lower FirRegOp to sv.reg and sv.always.

Definition at line 76 of file FirRegLowering.h.

Member Typedef Documentation

◆ AlwaysKeyType

using circt::FirRegLowering::AlwaysKeyType = std::tuple<Block *, sv::EventControl, Value, ResetType, sv::EventControl, Value>
private

Definition at line 130 of file FirRegLowering.h.

◆ IfKeyType

using circt::FirRegLowering::IfKeyType = std::pair<Block *, Value>
private

Definition at line 135 of file FirRegLowering.h.

Constructor & Destructor Documentation

◆ FirRegLowering()

FirRegLowering::FirRegLowering ( TypeConverter &  typeConverter,
hw::HWModuleOp  module,
bool  disableRegRandomization = false,
bool  emitSeparateAlwaysBlocks = false 
)

Definition at line 108 of file FirRegLowering.cpp.

References module, and reachableMuxes.

Member Function Documentation

◆ addToAlwaysBlock()

void FirRegLowering::addToAlwaysBlock ( Block *  block,
sv::EventControl  clockEdge,
Value  clock,
const std::function< void(OpBuilder &)> &  body,
ResetType  resetStyle = {},
sv::EventControl  resetEdge = {},
Value  reset = {},
const std::function< void(OpBuilder &)> &  resetBody = {} 
)
private

Definition at line 617 of file FirRegLowering.cpp.

References alwaysBlocks, assert(), builder, and emitSeparateAlwaysBlocks.

◆ addToIfBlock()

void FirRegLowering::addToIfBlock ( OpBuilder &  builder,
Value  cond,
const std::function< void()> &  trueSide,
const std::function< void()> &  falseSide 
)
private

Definition at line 89 of file FirRegLowering.cpp.

References builder.

Referenced by createTree().

◆ createTree()

void FirRegLowering::createTree ( OpBuilder &  builder,
Value  reg,
Value  term,
Value  next 
)
private

◆ getOrCreateConstant()

hw::ConstantOp circt::FirRegLowering::getOrCreateConstant ( Location  loc,
const APInt &  value 
)
inlineprivate

Definition at line 118 of file FirRegLowering.h.

References builder.

Referenced by createTree(), initializeRegisterElements(), lower(), and tryRestoringSubaccess().

◆ initialize()

void FirRegLowering::initialize ( OpBuilder &  builder,
RegLowerInfo  reg,
ArrayRef< Value >  rands 
)
private

Definition at line 591 of file FirRegLowering.cpp.

References builder, concat(), initializeRegisterElements(), seq::reg(), and width.

Referenced by lower().

◆ initializeRegisterElements()

void FirRegLowering::initializeRegisterElements ( Location  loc,
OpBuilder &  builder,
Value  reg,
Value  rand,
unsigned &  pos 
)
private

Definition at line 561 of file FirRegLowering.cpp.

References assert(), builder, getOrCreateConstant(), and seq::reg().

Referenced by initialize().

◆ lower() [1/2]

void FirRegLowering::lower ( )

◆ lower() [2/2]

RegLowerInfo circt::FirRegLowering::lower ( seq::FirRegOp  reg)
private

◆ needsRegRandomization()

bool circt::FirRegLowering::needsRegRandomization ( ) const
inline

Definition at line 83 of file FirRegLowering.h.

◆ tryRestoringSubaccess()

std::optional< std::tuple< Value, Value, Value > > FirRegLowering::tryRestoringSubaccess ( OpBuilder &  builder,
Value  reg,
Value  term,
hw::ArrayCreateOp  nextRegValue 
)
private

Member Data Documentation

◆ alwaysBlocks

llvm::SmallDenseMap<AlwaysKeyType, std::pair<sv::AlwaysOp, sv::IfOp> > circt::FirRegLowering::alwaysBlocks
private

Definition at line 133 of file FirRegLowering.h.

Referenced by addToAlwaysBlock().

◆ arrayIndexCache

llvm::SmallDenseMap<std::pair<Value, unsigned>, Value> circt::FirRegLowering::arrayIndexCache
private

Definition at line 139 of file FirRegLowering.h.

Referenced by createTree().

◆ constantCache

llvm::SmallDenseMap<APInt, hw::ConstantOp> circt::FirRegLowering::constantCache
private

Definition at line 138 of file FirRegLowering.h.

◆ disableRegRandomization

bool circt::FirRegLowering::disableRegRandomization
private

Definition at line 145 of file FirRegLowering.h.

Referenced by lower().

◆ emitSeparateAlwaysBlocks

bool circt::FirRegLowering::emitSeparateAlwaysBlocks
private

Definition at line 146 of file FirRegLowering.h.

Referenced by addToAlwaysBlock().

◆ ifCache

llvm::SmallDenseMap<IfKeyType, sv::IfOp> circt::FirRegLowering::ifCache
private

Definition at line 136 of file FirRegLowering.h.

◆ module

hw::HWModuleOp circt::FirRegLowering::module
private

◆ needsRandom

bool circt::FirRegLowering::needsRandom = false
private

Definition at line 148 of file FirRegLowering.h.

Referenced by lower().

◆ numSubaccessRestored

unsigned circt::FirRegLowering::numSubaccessRestored = 0

Definition at line 85 of file FirRegLowering.h.

Referenced by createTree().

◆ reachableMuxes

std::unique_ptr<ReachableMuxes> circt::FirRegLowering::reachableMuxes
private

Definition at line 140 of file FirRegLowering.h.

Referenced by createTree(), and FirRegLowering().

◆ typeConverter

TypeConverter& circt::FirRegLowering::typeConverter
private

Definition at line 142 of file FirRegLowering.h.


The documentation for this class was generated from the following files: