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
 
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 22 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 80 of file FirRegLowering.h.

◆ IfKeyType

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

Definition at line 85 of file FirRegLowering.h.

Constructor & Destructor Documentation

◆ FirRegLowering()

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

Definition at line 24 of file FirRegLowering.h.

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 566 of file FirRegLowering.cpp.

References assert(), and builder.

◆ addToIfBlock()

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

Definition at line 54 of file FirRegLowering.cpp.

References builder.

◆ 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 68 of file FirRegLowering.h.

References builder, constantCache, and module.

◆ initialize()

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

Definition at line 540 of file FirRegLowering.cpp.

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

◆ initializeRegisterElements()

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

Definition at line 510 of file FirRegLowering.cpp.

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

◆ lower() [1/2]

void FirRegLowering::lower ( )

Definition at line 73 of file FirRegLowering.cpp.

References builder, circt::calyx::direction::get(), and seq::reg().

◆ lower() [2/2]

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

◆ needsRegRandomization()

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

Definition at line 33 of file FirRegLowering.h.

References needsRandom.

◆ 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 83 of file FirRegLowering.h.

◆ arrayIndexCache

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

Definition at line 89 of file FirRegLowering.h.

◆ constantCache

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

Definition at line 88 of file FirRegLowering.h.

Referenced by getOrCreateConstant().

◆ disableRegRandomization

bool circt::FirRegLowering::disableRegRandomization
private

Definition at line 94 of file FirRegLowering.h.

◆ emitSeparateAlwaysBlocks

bool circt::FirRegLowering::emitSeparateAlwaysBlocks
private

Definition at line 95 of file FirRegLowering.h.

◆ ifCache

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

Definition at line 86 of file FirRegLowering.h.

◆ module

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

◆ needsRandom

bool circt::FirRegLowering::needsRandom = false
private

Definition at line 97 of file FirRegLowering.h.

Referenced by needsRegRandomization().

◆ numSubaccessRestored

unsigned circt::FirRegLowering::numSubaccessRestored = 0

Definition at line 35 of file FirRegLowering.h.

◆ typeConverter

TypeConverter& circt::FirRegLowering::typeConverter
private

Definition at line 91 of file FirRegLowering.h.


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