CIRCT 24.0.0git
Loading...
Searching...
No Matches
LowerToHW.cpp File Reference
#include "circt/Conversion/FIRRTLToHW.h"
#include "circt/Conversion/SVLoweringUtils.h"
#include "circt/Dialect/Comb/CombOps.h"
#include "circt/Dialect/Emit/EmitOps.h"
#include "circt/Dialect/FIRRTL/AnnotationDetails.h"
#include "circt/Dialect/FIRRTL/FIRRTLAnnotations.h"
#include "circt/Dialect/FIRRTL/FIRRTLInstanceGraph.h"
#include "circt/Dialect/FIRRTL/FIRRTLOps.h"
#include "circt/Dialect/FIRRTL/FIRRTLTypes.h"
#include "circt/Dialect/FIRRTL/FIRRTLUtils.h"
#include "circt/Dialect/FIRRTL/FIRRTLVisitors.h"
#include "circt/Dialect/FIRRTL/NLATable.h"
#include "circt/Dialect/FIRRTL/Namespace.h"
#include "circt/Dialect/HW/HWAttributes.h"
#include "circt/Dialect/HW/HWOps.h"
#include "circt/Dialect/HW/HWTypes.h"
#include "circt/Dialect/HW/InnerSymbolNamespace.h"
#include "circt/Dialect/LTL/LTLOps.h"
#include "circt/Dialect/SV/SVOps.h"
#include "circt/Dialect/SV/SVTypes.h"
#include "circt/Dialect/Seq/SeqOps.h"
#include "circt/Dialect/Sim/SimOps.h"
#include "circt/Dialect/Verif/VerifOps.h"
#include "circt/Support/BackedgeBuilder.h"
#include "circt/Support/Namespace.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/ImplicitLocOpBuilder.h"
#include "mlir/IR/Threading.h"
#include "mlir/Pass/Pass.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Mutex.h"
#include "llvm/Support/Path.h"
#include "circt/Conversion/Passes.h.inc"
Include dependency graph for LowerToHW.cpp:

Go to the source code of this file.

Namespaces

namespace  circt
 The InstanceGraph op interface, see InstanceGraphInterface.td for more details.

Macros

#define DEBUG_TYPE   "lower-to-hw"
#define GEN_PASS_DEF_LOWERFIRRTLTOHW

Functions

static bool isZeroBitFIRRTLType (Type type)
 Return true if the specified type is a sized FIRRTL type (Int or Analog) with zero bits.
static Value getSingleNonInstanceOperand (AttachOp op)
static LogicalResult verifyOpLegality (Operation *op)
 This verifies that the target operation has been lowered to a legal operation.
static IntType getWidestIntType (Type t1, Type t2)
 Given two FIRRTL integer types, return the widest one.
static Value castToFIRRTLType (Value val, Type type, ImplicitLocOpBuilder &builder)
 Cast a value to a desired target type.
static Value castFromFIRRTLType (Value val, Type type, ImplicitLocOpBuilder &builder)
 Cast from a FIRRTL type (potentially with a flip) to a standard type.
static unsigned getBitWidthFromVectorSize (unsigned size)
static void tryCopyName (Operation *dst, Operation *src)
static ArrayAttr getHWParameters (FExtModuleOp module, bool ignoreValues)
 Map the parameter specifier on the specified extmodule into the HWModule representation for parameters.
static Value tryEliminatingAttachesToAnalogValue (Value value, Operation *insertPoint)
 Given a value of analog type, check to see the only use of it is an attach.
static Value tryEliminatingConnectsToValue (Value flipValue, Operation *insertPoint, CircuitLoweringState &loweringState)
 Given a value of flip type, check to see if all of the uses of it are connects.
static SmallVector< SubfieldOp > getAllFieldAccesses (Value structValue, StringRef field)
static LogicalResult handleZeroBit (Value failedOperand, const std::function< LogicalResult()> &fn)
 Zero bit operands end up looking like failures from getLoweredValue.
static ltl::ClockEdge firrtlToLTLClockEdge (EventControl eventControl)
static LogicalResult resolveFormatString (Location loc, StringRef originalFormatString, ValueRange operands, StringAttr &result)
template<typename... Args>
static Operation * buildImmediateVerifOp (ImplicitLocOpBuilder &builder, StringRef opName, Args &&...args)
 Helper function to build an immediate assert operation based on the original FIRRTL operation name.
template<typename... Args>
static Operation * buildConcurrentVerifOp (ImplicitLocOpBuilder &builder, StringRef opName, Args &&...args)
 Helper function to build a concurrent assert operation based on the original FIRRTL operation name.
static verif::ClockEdge firrtlToVerifClockEdge (EventControl eventControl)

Variables

static const char moduleHierarchyFileAttrName [] = "firrtl.moduleHierarchyFile"
 Attribute that indicates that the module hierarchy starting at the annotated module should be dumped to a file.

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "lower-to-hw"

Definition at line 48 of file LowerToHW.cpp.

◆ GEN_PASS_DEF_LOWERFIRRTLTOHW

#define GEN_PASS_DEF_LOWERFIRRTLTOHW

Definition at line 51 of file LowerToHW.cpp.

Function Documentation

◆ buildConcurrentVerifOp()

template<typename... Args>
Operation * buildConcurrentVerifOp ( ImplicitLocOpBuilder & builder,
StringRef opName,
Args &&... args )
static

Helper function to build a concurrent assert operation based on the original FIRRTL operation name.

This reduces code duplication in lowerVerificationStatement.

Definition at line 5687 of file LowerToHW.cpp.

◆ buildImmediateVerifOp()

template<typename... Args>
Operation * buildImmediateVerifOp ( ImplicitLocOpBuilder & builder,
StringRef opName,
Args &&... args )
static

Helper function to build an immediate assert operation based on the original FIRRTL operation name.

This reduces code duplication in lowerVerificationStatement.

Definition at line 5672 of file LowerToHW.cpp.

◆ castFromFIRRTLType()

Value castFromFIRRTLType ( Value val,
Type type,
ImplicitLocOpBuilder & builder )
static

Cast from a FIRRTL type (potentially with a flip) to a standard type.

Definition at line 148 of file LowerToHW.cpp.

References circt::firrtl::type_cast().

Referenced by tryEliminatingAttachesToAnalogValue(), and tryEliminatingConnectsToValue().

◆ castToFIRRTLType()

Value castToFIRRTLType ( Value val,
Type type,
ImplicitLocOpBuilder & builder )
static

Cast a value to a desired target type.

This will insert struct casts and unrealized conversion casts as necessary.

Definition at line 134 of file LowerToHW.cpp.

◆ firrtlToLTLClockEdge()

ltl::ClockEdge firrtlToLTLClockEdge ( EventControl eventControl)
static

Definition at line 4855 of file LowerToHW.cpp.

◆ firrtlToVerifClockEdge()

verif::ClockEdge firrtlToVerifClockEdge ( EventControl eventControl)
static

Definition at line 5698 of file LowerToHW.cpp.

◆ getAllFieldAccesses()

SmallVector< SubfieldOp > getAllFieldAccesses ( Value structValue,
StringRef field )
static

Definition at line 1554 of file LowerToHW.cpp.

References assert().

◆ getBitWidthFromVectorSize()

unsigned getBitWidthFromVectorSize ( unsigned size)
static

Definition at line 167 of file LowerToHW.cpp.

◆ getHWParameters()

ArrayAttr getHWParameters ( FExtModuleOp module,
bool ignoreValues )
static

Map the parameter specifier on the specified extmodule into the HWModule representation for parameters.

If ignoreValues is true, all the values are dropped.

Definition at line 1022 of file LowerToHW.cpp.

◆ getSingleNonInstanceOperand()

Value getSingleNonInstanceOperand ( AttachOp op)
static

Definition at line 72 of file LowerToHW.cpp.

References isZeroBitFIRRTLType().

◆ getWidestIntType()

IntType getWidestIntType ( Type t1,
Type t2 )
static

Given two FIRRTL integer types, return the widest one.

Definition at line 127 of file LowerToHW.cpp.

References circt::firrtl::type_cast().

◆ handleZeroBit()

LogicalResult handleZeroBit ( Value failedOperand,
const std::function< LogicalResult()> & fn )
static

Zero bit operands end up looking like failures from getLoweredValue.

This helper function invokes the closure specified if the operand was actually zero bit, or returns failure() if it was some other kind of failure.

Definition at line 2422 of file LowerToHW.cpp.

References assert(), failure(), and isZeroBitFIRRTLType().

◆ isZeroBitFIRRTLType()

bool isZeroBitFIRRTLType ( Type type)
static

Return true if the specified type is a sized FIRRTL type (Int or Analog) with zero bits.

Definition at line 65 of file LowerToHW.cpp.

Referenced by getSingleNonInstanceOperand(), and handleZeroBit().

◆ resolveFormatString()

LogicalResult resolveFormatString ( Location loc,
StringRef originalFormatString,
ValueRange operands,
StringAttr & result )
static

Definition at line 5449 of file LowerToHW.cpp.

References assert(), failure(), isdigit, success(), and circt::firrtl::type_isa().

◆ tryCopyName()

void tryCopyName ( Operation * dst,
Operation * src )
static

Definition at line 173 of file LowerToHW.cpp.

◆ tryEliminatingAttachesToAnalogValue()

Value tryEliminatingAttachesToAnalogValue ( Value value,
Operation * insertPoint )
static

Given a value of analog type, check to see the only use of it is an attach.

If so, remove the attach and return the value being attached to it, converted to an HW inout type. If this isn't a situation we can handle, just return null.

Definition at line 1433 of file LowerToHW.cpp.

References castFromFIRRTLType(), and circt::firrtl::lowerType().

Referenced by tryEliminatingConnectsToValue().

◆ tryEliminatingConnectsToValue()

Value tryEliminatingConnectsToValue ( Value flipValue,
Operation * insertPoint,
CircuitLoweringState & loweringState )
static

Given a value of flip type, check to see if all of the uses of it are connects.

If so, remove the connects and return the value being connected to it, converted to an HW type. If this isn't a situation we can handle, just return null.

This can happen when there are no connects to the value. The 'mergePoint' location is where a 'hw.merge' operation should be inserted if needed.

Definition at line 1470 of file LowerToHW.cpp.

References assert(), castFromFIRRTLType(), tryEliminatingAttachesToAnalogValue(), circt::firrtl::type_cast(), and circt::firrtl::type_isa().

◆ verifyOpLegality()

LogicalResult verifyOpLegality ( Operation * op)
static

This verifies that the target operation has been lowered to a legal operation.

This checks that the operation recursively has no FIRRTL operations or types.

Definition at line 90 of file LowerToHW.cpp.

References failure(), and success().

Variable Documentation

◆ moduleHierarchyFileAttrName

const char moduleHierarchyFileAttrName[] = "firrtl.moduleHierarchyFile"
static

Attribute that indicates that the module hierarchy starting at the annotated module should be dumped to a file.

Definition at line 61 of file LowerToHW.cpp.