CIRCT  19.0.0git
Classes | Typedefs | Enumerations | Functions
circt::sv Namespace Reference

Classes

class  CasePattern
 
class  CaseDefaultPattern
 
class  CaseBitPattern
 
class  CaseEnumPattern
 
struct  CaseInfo
 
class  ProceduralRegion
 Signals that an operations regions are procedural. More...
 
class  ProceduralOp
 This class verifies that the specified op is located in a procedural region. More...
 
class  NonProceduralOp
 This class verifies that the specified op is not located in a procedural region. More...
 
class  VendorExtension
 This class provides a verifier for ops that are expecting their parent to be one of the given parent ops. More...
 
class  Visitor
 

Typedefs

using InOutType = circt::hw::InOutType
 

Enumerations

enum class  CasePatternBit { Zero = 0 , One = 1 , AnyX = 2 , AnyZ = 3 }
 This describes the bit in a pattern, 0/1/x/z. More...
 

Functions

bool hasSVAttributes (mlir::Operation *op)
 Helper functions to handle SV attributes. More...
 
mlir::ArrayAttr getSVAttributes (mlir::Operation *op)
 Return all the SV attributes of an operation, or null if there are none. More...
 
void setSVAttributes (mlir::Operation *op, mlir::ArrayAttr attrs)
 Set the SV attributes of an operation. More...
 
void setSVAttributes (mlir::Operation *op, mlir::ArrayRef< SVAttributeAttr > attrs)
 Set the SV attributes of an operation. More...
 
bool hasSVAttribute (mlir::Operation *op, SVAttributeAttr attr)
 Check if an op contains a specific SV attribute. More...
 
bool modifySVAttributes (mlir::Operation *op, llvm::function_ref< void(llvm::SmallVectorImpl< SVAttributeAttr > &)> modifyCallback)
 Modify the list of SV attributes of an operation. More...
 
unsigned addSVAttributes (mlir::Operation *op, llvm::ArrayRef< SVAttributeAttr > attrs)
 Add a list of SV attributes to an operation. More...
 
unsigned removeSVAttributes (mlir::Operation *op, llvm::function_ref< bool(SVAttributeAttr)> removeCallback)
 Remove the SV attributes from an operation for which removeCallback returns true. More...
 
unsigned removeSVAttributes (mlir::Operation *op, llvm::ArrayRef< SVAttributeAttr > attrs)
 Remove a list of SV attributes from an operation. More...
 
llvm::StringRef resolveKeywordConflict (llvm::StringRef origName, llvm::StringMap< size_t > &nextGeneratedNameIDs, bool caseInsensitiveKeywords)
 Given string origName, generate a new name if it conflicts with any keyword or any other name in the map nextGeneratedNameIDs. More...
 
StringRef legalizeName (llvm::StringRef name, llvm::StringMap< size_t > &nextGeneratedNameIDs, bool caseInsensitiveKeywords)
 Legalize the specified name for use in SV output. More...
 
bool isNameValid (llvm::StringRef name, bool caseInsensitiveKeywords)
 Check if a name is valid for use in SV output by only containing characters allowed in SV identifiers. More...
 
bool isExpression (Operation *op)
 Return true if the specified operation is an expression. More...
 
bool is2StateExpression (Value v)
 Returns if the expression is known to be 2-state (binary) More...
 
char getLetter (CasePatternBit bit)
 Return the letter for the specified pattern bit, e.g. "0", "1", "x" or "z". More...
 
LogicalResult verifyInProceduralRegion (Operation *op)
 Return true if the specified operation is in a procedural region. More...
 
LogicalResult verifyInNonProceduralRegion (Operation *op)
 Return true if the specified operation is not in a procedural region. More...
 
std::unique_ptr< mlir::Pass > createPrettifyVerilogPass ()
 
std::unique_ptr< mlir::Pass > createHWCleanupPass (bool mergeAlwaysBlocks=true)
 
std::unique_ptr< mlir::Pass > createHWStubExternalModulesPass ()
 
std::unique_ptr< mlir::Pass > createHWLegalizeModulesPass ()
 
std::unique_ptr< mlir::Pass > createSVTraceIVerilogPass ()
 
std::unique_ptr< mlir::Pass > createHWLowerInstanceChoices ()
 
std::unique_ptr< mlir::Pass > createHWGeneratorCalloutPass ()
 
std::unique_ptr< mlir::Pass > createHWEliminateInOutPortsPass (const HWEliminateInOutPortsOptions &options={})
 
std::unique_ptr< mlir::Pass > createSVExtractTestCodePass (bool disableInstanceExtraction=false, bool disableRegisterExtraction=false, bool disableModuleInlining=false)
 
std::unique_ptr< mlir::Pass > createHWExportModuleHierarchyPass ()
 
mlir::Type getInOutElementType (mlir::Type type)
 Return the element type of an InOutType or null if the operand isn't an InOut type. More...
 
mlir::Type getAnyHWArrayElementType (mlir::Type type)
 Return the element type of an ArrayType or UnpackedArrayType, or null if the operand isn't an array. More...
 

Typedef Documentation

◆ InOutType

using circt::sv::InOutType = typedef circt::hw::InOutType

Definition at line 25 of file SVTypes.h.

Enumeration Type Documentation

◆ CasePatternBit

This describes the bit in a pattern, 0/1/x/z.

Enumerator
Zero 
One 
AnyX 
AnyZ 

Definition at line 46 of file SVOps.h.

Function Documentation

◆ addSVAttributes()

unsigned circt::sv::addSVAttributes ( mlir::Operation *  op,
llvm::ArrayRef< SVAttributeAttr >  attrs 
)

Add a list of SV attributes to an operation.

The attributes are deduplicated such that only one copy of each attribute is kept on the operation. Returns the number of attributes that were added.

Referenced by applyAttributeAnnotation(), and legalizeHWModule().

◆ createHWCleanupPass()

std::unique_ptr< Pass > circt::sv::createHWCleanupPass ( bool  mergeAlwaysBlocks = true)

Definition at line 245 of file HWCleanup.cpp.

Referenced by circt::firtool::populateHWToSV().

◆ createHWEliminateInOutPortsPass()

std::unique_ptr< Pass > circt::sv::createHWEliminateInOutPortsPass ( const HWEliminateInOutPortsOptions &  options = {})

Definition at line 233 of file HWEliminateInOutPorts.cpp.

◆ createHWExportModuleHierarchyPass()

std::unique_ptr< mlir::Pass > circt::sv::createHWExportModuleHierarchyPass ( )

◆ createHWGeneratorCalloutPass()

std::unique_ptr< Pass > circt::sv::createHWGeneratorCalloutPass ( )

Definition at line 162 of file GeneratorCallout.cpp.

◆ createHWLegalizeModulesPass()

std::unique_ptr< Pass > circt::sv::createHWLegalizeModulesPass ( )

Definition at line 418 of file HWLegalizeModules.cpp.

Referenced by detail::populatePrepareForExportVerilog().

◆ createHWLowerInstanceChoices()

std::unique_ptr<mlir::Pass> circt::sv::createHWLowerInstanceChoices ( )

◆ createHWStubExternalModulesPass()

std::unique_ptr< Pass > circt::sv::createHWStubExternalModulesPass ( )

Definition at line 57 of file HWStubExternalModules.cpp.

◆ createPrettifyVerilogPass()

std::unique_ptr< Pass > circt::sv::createPrettifyVerilogPass ( )

Definition at line 571 of file PrettifyVerilog.cpp.

Referenced by detail::populatePrepareForExportVerilog().

◆ createSVExtractTestCodePass()

std::unique_ptr< Pass > circt::sv::createSVExtractTestCodePass ( bool  disableInstanceExtraction = false,
bool  disableRegisterExtraction = false,
bool  disableModuleInlining = false 
)

Definition at line 873 of file SVExtractTestCode.cpp.

Referenced by circt::firtool::populateHWToSV().

◆ createSVTraceIVerilogPass()

std::unique_ptr< Pass > circt::sv::createSVTraceIVerilogPass ( )

Definition at line 73 of file SVTraceIVerilog.cpp.

◆ getAnyHWArrayElementType()

mlir::Type circt::sv::getAnyHWArrayElementType ( mlir::Type  type)

Return the element type of an ArrayType or UnpackedArrayType, or null if the operand isn't an array.

◆ getInOutElementType()

mlir::Type circt::sv::getInOutElementType ( mlir::Type  type)

Return the element type of an InOutType or null if the operand isn't an InOut type.

Definition at line 42 of file SVTypes.cpp.

◆ getLetter()

char circt::sv::getLetter ( CasePatternBit  bit)

Return the letter for the specified pattern bit, e.g. "0", "1", "x" or "z".

Definition at line 726 of file SVOps.cpp.

References AnyX, AnyZ, One, and Zero.

◆ getSVAttributes()

mlir::ArrayAttr circt::sv::getSVAttributes ( mlir::Operation *  op)

Return all the SV attributes of an operation, or null if there are none.

All array elements are SVAttributeAttr.

Referenced by hasSVAttribute().

◆ hasSVAttribute()

bool circt::sv::hasSVAttribute ( mlir::Operation *  op,
SVAttributeAttr  attr 
)
inline

Check if an op contains a specific SV attribute.

Definition at line 43 of file SVAttributes.h.

References getSVAttributes().

◆ hasSVAttributes()

bool circt::sv::hasSVAttributes ( mlir::Operation *  op)

Helper functions to handle SV attributes.

◆ is2StateExpression()

bool circt::sv::is2StateExpression ( Value  v)

Returns if the expression is known to be 2-state (binary)

Return true if the specified expression is 2-state.

This is determined by looking at the defining op. This can look as far through the dataflow as it wants, but for now, it is just looking at the single value.

Definition at line 38 of file SVOps.cpp.

◆ isExpression()

bool circt::sv::isExpression ( Operation *  op)

Return true if the specified operation is an expression.

Definition at line 48 of file SVOps.cpp.

◆ isNameValid()

bool circt::sv::isNameValid ( llvm::StringRef  name,
bool  caseInsensitiveKeywords 
)

Check if a name is valid for use in SV output by only containing characters allowed in SV identifiers.

Call legalizeName() to obtain a legal version of the name. If caseInsensitive is true, then the check will be done case insensitively.

Referenced by circt::ExportVerilog::FieldNameResolver::getRenamedFieldName(), and circt::ExportVerilog::GlobalNameResolver::GlobalNameResolver().

◆ legalizeName()

StringRef circt::sv::legalizeName ( llvm::StringRef  name,
llvm::StringMap< size_t > &  nextGeneratedNameIDs,
bool  caseInsensitiveKeywords 
)

Legalize the specified name for use in SV output.

Auto-uniquifies the name through resolveKeywordConflict if required. If the name is empty, a unique temp name is created.

Referenced by circt::ExportVerilog::NameCollisionResolver::getLegalName(), and circt::ExportVerilog::FieldNameResolver::getRenamedFieldName().

◆ modifySVAttributes()

bool circt::sv::modifySVAttributes ( mlir::Operation *  op,
llvm::function_ref< void(llvm::SmallVectorImpl< SVAttributeAttr > &)>  modifyCallback 
)

Modify the list of SV attributes of an operation.

This function offers a read-modify-write interface where the callback can modify the list of attributes how it sees fit. Returns true if any modifications occurred.

◆ removeSVAttributes() [1/2]

unsigned circt::sv::removeSVAttributes ( mlir::Operation *  op,
llvm::ArrayRef< SVAttributeAttr >  attrs 
)

Remove a list of SV attributes from an operation.

Returns the number of attributes actually removed.

◆ removeSVAttributes() [2/2]

unsigned circt::sv::removeSVAttributes ( mlir::Operation *  op,
llvm::function_ref< bool(SVAttributeAttr)>  removeCallback 
)

Remove the SV attributes from an operation for which removeCallback returns true.

Returns the number of attributes actually removed.

◆ resolveKeywordConflict()

llvm::StringRef circt::sv::resolveKeywordConflict ( llvm::StringRef  origName,
llvm::StringMap< size_t > &  nextGeneratedNameIDs,
bool  caseInsensitiveKeywords 
)

Given string origName, generate a new name if it conflicts with any keyword or any other name in the map nextGeneratedNameIDs.

Use the value of nextGeneratedNameIDs as a counter for suffix. Update the nextGeneratedNameIDs with the generated name and return the StringRef. If is true, then check against the reserved keywords in a case insensitive manner.

◆ setSVAttributes() [1/2]

void circt::sv::setSVAttributes ( mlir::Operation *  op,
mlir::ArrayAttr  attrs 
)

Set the SV attributes of an operation.

If attrs is null or contains no attributes, the attribute is removed from the op.

Referenced by getMemoryRead(), and PlusArgsValueLowering::matchAndRewrite().

◆ setSVAttributes() [2/2]

void circt::sv::setSVAttributes ( mlir::Operation *  op,
mlir::ArrayRef< SVAttributeAttr >  attrs 
)

Set the SV attributes of an operation.

If attrs is empty the attribute is removed from the op. The attributes are deduplicated such that only one copy of each attribute is kept on the operation.

◆ verifyInNonProceduralRegion()

LogicalResult circt::sv::verifyInNonProceduralRegion ( Operation *  op)

Return true if the specified operation is not in a procedural region.

Definition at line 61 of file SVOps.cpp.

Referenced by circt::sv::NonProceduralOp< ConcreteType >::verifyTrait().

◆ verifyInProceduralRegion()

LogicalResult circt::sv::verifyInProceduralRegion ( Operation *  op)

Return true if the specified operation is in a procedural region.

Definition at line 54 of file SVOps.cpp.

Referenced by circt::sv::ProceduralOp< ConcreteType >::verifyTrait().