21 #include "boost/regex.hpp"
34 if(!inPtr)
return "null";
35 switch(inPtr->getCompositionType()) {
40 default:
return "unknown";
49 std::pair<const CellSharedPtr, bool> element = *p++;
50 if(element.second)
continue;
56 cellPtr->getOriginalName());
62 if(
DEBUG) std::cerr <<
"AstNetlist" << std::endl;
65 nodePtr->iterateChildren(*
this);
70 typedef vector<CellSharedPtr> CellSharedPtrVector;
71 CellSharedPtrVector cells;
80 if(
DEBUG) std::cerr <<
"AstModule" << std::endl;
85 bool libraryCell = nodePtr->inLibrary();
88 std::cerr <<
"module " << nodePtr->name() << std::endl;
92 if(nodePtr->prettyName() != nodePtr->name())
104 nodePtr->iterateChildren(*
this);
109 if(
DEBUG) std::cerr <<
"AstCell" << std::endl;
111 std::cerr <<
" " << nodePtr->modName() <<
" " << nodePtr->name();
112 if(nodePtr->prettyName() != nodePtr->name())
113 std::cerr <<
" \"" << nodePtr->prettyName() <<
"\"";
116 AstNode* modPtr = nodePtr->modp();
117 bool found = (modPtr != 0 && !modPtr->castNotFoundModule());
122 modPtr->accept(*
this, userPtr);
132 if(nodePtr->prettyName() != nodePtr->name())
135 nodePtr->iterateChildren(*
this);
140 if(
DEBUG) std::cerr <<
"AstPin" << std::endl;
142 string pinName = nodePtr->name();
143 if(pinName.substr(0, 11) ==
"__pinNumber") {
144 std::cerr <<
"Warning: Instance port binding by port order is not currently supported."
157 nodePtr->iterateChildren(*
this);
165 bool isConcat =
false;
166 bool isVector =
false;
188 if(!portReferencePtr) {
205 if(nodePtr->name() != nodePtr->prettyName())
206 portPtr->setOriginalName(nodePtr->prettyName());
222 if(nodePtr->name() != nodePtr->prettyName())
223 portPtr->setOriginalName(nodePtr->prettyName());
237 if(!portReferencePtr) {
238 std::cerr <<
"Warning: Unable to find or infer port " << pinName
246 size_t portSize = portReferencePtr->getSize();
248 if(portSize != netSize) {
249 std::cerr <<
"Warning: bundle and pin sizes do not match on "
259 portIndices.push_back(0);
266 std::cerr <<
"Warning: unexpected vector net or bundle remaining in "
277 portBitReferencePtr->connect(netPtr);
292 if(
DEBUG) std::cerr <<
"AstPort" << std::endl;
299 if(
DEBUG) std::cerr <<
"AstSelBit" << std::endl;
302 AstNode* bitp = nodePtr->bitp();
303 switch(bitp->type()) {
304 case AstType::atCONST:
307 std::cerr <<
"FAILED TO PROCESS SELBIT OF TYPE " << bitp->type().ascii();
throw;
310 nodePtr->iterateChildren(*
this);
314 if(
DEBUG) std::cerr <<
"AstSelExtract" << std::endl;
317 nodePtr->iterateChildren(*
this);
319 AstNode* msbp = nodePtr->msbp();
320 AstNode* lsbp = nodePtr->lsbp();
321 if(msbp->type() == AstType::atCONST && lsbp->type() == AstType::atCONST) {
325 std::cerr <<
"FAILED TO PROCESS SELEXTRACT OF TYPES " << msbp->type().ascii()
326 <<
" and " << lsbp->type().ascii() << std::endl;
334 if(
DEBUG) std::cerr <<
"AstRange" << std::endl;
343 if(
DEBUG) std::cerr <<
"AstDefParam" << std::endl;
350 std::cerr <<
"FAILED TO FIND DEFPARAM INSTANCE " << nodePtr->path() << std::endl;
356 nodePtr->iterateChildren(*
this);
358 std::cerr <<
"FAILED TO FIND A CONSTANT FOR DEFPARAM " << nodePtr->path() << std::endl;
375 if(
DEBUG) std::cerr <<
"AstVar" << std::endl;
380 AstVarType varType = nodePtr->varType();
382 if(varType == AstVarType::WIRE) {
386 nodePtr->iterateChildren(*
this);
392 if(nodePtr->prettyName() != nodePtr->name())
393 netPtr->setOriginalName(nodePtr->prettyName());
402 if(nodePtr->prettyName() != nodePtr->name())
403 netPtr->setOriginalName(nodePtr->prettyName());
411 }
else if(varType == AstVarType::PORT || varType == AstVarType::INPUT
412 || varType == AstVarType::OUTPUT || varType == AstVarType::INOUT) {
421 nodePtr->iterateChildren(*
this);
427 if(nodePtr->prettyName() != nodePtr->name())
428 portPtr->setOriginalName(nodePtr->prettyName());
441 if(nodePtr->prettyName() != nodePtr->name())
442 portPtr->setOriginalName(nodePtr->prettyName());
451 visit(dynamic_cast<AstNode*>(nodePtr), userPtr);
457 if(
DEBUG) std::cerr <<
"AstAssignW" << std::endl;
462 nodePtr->lhsp()->iterateAndNext(*
this, userPtr);
467 nodePtr->rhsp()->iterateAndNext(*
this, userPtr);
485 std::cerr <<
"FAILED TO FIND PORT OR NET ASSIGNMENT TARGET FOR " << signal << std::endl;
490 if(
DEBUG) std::cerr <<
"AstParseRef" << std::endl;
500 nodePtr->iterateChildren(*
this);
508 string indexedNetName;
511 std::cerr <<
"Warning: Multidimensional arrays and ports are not yet supported."
526 netSize = portPtr->getSize();
545 }
else if(hasRange) {
559 int32_t formalIndex = i;
561 if(formalIndex <= msb && formalIndex >= lsb) {
562 index = msb - formalIndex;
563 }
else if(formalIndex >= msb && formalIndex <= lsb) {
564 index = formalIndex - msb;
574 indexedNetName = ss.str();
586 indices.push_back(index);
598 std::cerr <<
"Warning: Encountered vector net within concatenation."
620 else std::cerr <<
"FAILED TO FIND PORT " << netName << std::endl;
655 int32_t formalIndex = i;
657 if(formalIndex <= msb && formalIndex >= lsb) {
658 index = msb - formalIndex;
659 }
else if(formalIndex >= msb && formalIndex <= lsb) {
660 index = formalIndex - msb;
671 indexedNetName = ss.str();
685 netPtr->setOriginalName(indexedNetName);
716 if(
DEBUG) std::cerr <<
"AstText" << std::endl;
727 if(
DEBUG) std::cerr <<
"AstConst" << std::endl;
730 int widthMin = nodePtr->widthMin();
747 if(
DEBUG) std::cerr <<
"AstNot" << std::endl;
752 nodePtr->iterateChildren(*
this);
756 if(
DEBUG) std::cerr <<
"AstNotFoundModule" << std::endl;
759 std::cerr <<
"// NOTICE: black-boxed module " << nodePtr->name() << std::endl;
761 nodePtr->iterateChildren(*
this);
765 if(
DEBUG) std::cerr <<
"AstBasicDType" << std::endl;
768 if(nodePtr->name() !=
"logic")
769 std::cerr <<
" UNPROCESSED: basicdtype " << nodePtr->name() << std::endl;
771 nodePtr->iterateChildren(*
this);
775 if(
DEBUG) std::cerr <<
"AstConcat" << std::endl;
780 nodePtr->iterateChildren(*
this);
784 if(
DEBUG) std::cerr <<
"AstNode" << std::endl;
787 std::cerr <<
"FAILED TO PROCESS NODE "; nodePtr->dump(std::cerr); std::cerr
788 <<
" in line " << nodePtr->fileline() << std::endl;
790 nodePtr->iterateChildren(*
this);
V3Number mCurrentConstNum
The current constant number object.
NetSharedPtr mCurrentNetPtr
The current net shared pointer;.
boost::shared_ptr< Instance > InstanceSharedPtr
InstanceSharedPtr mCurrentInstancePtr
The current instance shared pointer.
ViewSharedPtr findMasterView(std::string inMasterName, std::string inOriginalName, bool inCreate)
Find the specified view, or optionally create it.
Header for the TemporaryAssignment class.
static string getTorcAssignRHSPropertyName(void)
Property name for the wire assignment right-hand-side.
std::string compositionTypeString(const T &inPtr)
static string getTorcRangeMSBPropertyName(void)
Property name for the vector range MSB.
bool mCurrentNotFlag
The current inversion flag.
boost::shared_ptr< ScalarPort > ScalarPortSharedPtr
boost::shared_ptr< ScalarNet > ScalarNetSharedPtr
boost::shared_ptr< PortBundle > PortBundleSharedPtr
LibrarySharedPtr mCurrentLibraryPtr
The current library shared pointer.
ViewSharedPtr mCurrentViewPtr
The current view shared pointer.
void createDesigns(void)
Create top-level designs for all Verilog modules that are never instantiated.
static const int32_t cUndefined
Undefined index constant.
virtual void forceAutoBlast(void)
NetSharedPtrVector mCurrentNetPtrVector
The current net vector.
static string getTorcRangeLSBPropertyName(void)
Property name for the vector range LSB.
CompositionType
Defines possible Composition types.
static FileLine sNullFileLine
Initial file line information.
Header for the VerilogImporterVisitor class.
Template class that stores the current value of a variable and restores that value when this object g...
boost::shared_ptr< VectorPort > VectorPortSharedPtr
boost::shared_ptr< VectorNet > VectorNetSharedPtr
string mCurrentConstStr
The current constant string.
bool mImportLibraryCells
A flag to indicate whether we should currently allow library cells.
boost::shared_ptr< Net > NetSharedPtr
boost::shared_ptr< Library > LibrarySharedPtr
bool mCurrentConcatFlag
The current concatenation flag.
boost::shared_ptr< PortReference > PortReferenceSharedPtr
int32_t mCurrentRange[2]
The current range.
CellToBoolMap mCellInstantiationFlag
A map of cell shared pointers to instantiation settings.
LibrarySharedPtr mInferredBlackBoxesLibraryPtr
The inferred black-box library shared pointer.
RootSharedPtr mRootPtr
The root shared pointer.
StringToNetMap mVectorBitNameToNet
A map of net bit names to net shared pointers.
IndexVector mCurrentIndices
The current array indices.
string mCurrentText
The current text string.
int32_t mCurrentConstInt
The current constant signed integer.
virtual void visit(AstNetlist *nodePtr, AstNUser *userPtr)
Visit the top-level netlist.
uint32_t mCurrentIndex
A unique index to avoid name collisions.
vector< size_t > IndexVector
A vector of element indices.
LibrarySharedPtr mImportedCellLibraryPtr
The cell library shared pointer.
boost::shared_ptr< View > ViewSharedPtr
boost::shared_ptr< Cell > CellSharedPtr
boost::shared_ptr< Port > PortSharedPtr
ObjectFactorySharedPtr mObjectFactoryPtr
The object factory shared pointer.
boost::shared_ptr< Property > PropertySharedPtr
StringToViewMap mMasterNameToView
A map from module name to master view pointer.
static string getImportedVerilogViewName(void)
Returns the imported Verilog view name.
boost::shared_ptr< NetBundle > NetBundleSharedPtr
CellSharedPtr mCurrentCellPtr
The current cell shared pointer.
boost::shared_ptr< PortBundleReference > PortBundleReferenceSharedPtr
std::vector< Pointer > List