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


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>

Definition at line 80 of file FirRegLowering.h.

◆ IfKeyType

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

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 

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 = {} 

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 

Definition at line 54 of file FirRegLowering.cpp.

References builder.

◆ createTree()

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

◆ getOrCreateConstant()

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

Definition at line 68 of file FirRegLowering.h.

References builder, constantCache, and module.

◆ initialize()

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

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 

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)

◆ needsRegRandomization()

bool circt::FirRegLowering::needsRegRandomization ( ) const

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 

Member Data Documentation

◆ alwaysBlocks

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

Definition at line 83 of file FirRegLowering.h.

◆ arrayIndexCache

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

Definition at line 89 of file FirRegLowering.h.

◆ constantCache

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

Definition at line 88 of file FirRegLowering.h.

Referenced by getOrCreateConstant().

◆ disableRegRandomization

bool circt::FirRegLowering::disableRegRandomization

Definition at line 94 of file FirRegLowering.h.

◆ emitSeparateAlwaysBlocks

bool circt::FirRegLowering::emitSeparateAlwaysBlocks

Definition at line 95 of file FirRegLowering.h.

◆ ifCache

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

Definition at line 86 of file FirRegLowering.h.

◆ module

hw::HWModuleOp circt::FirRegLowering::module

◆ needsRandom

bool circt::FirRegLowering::needsRandom = false

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

Definition at line 91 of file FirRegLowering.h.

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