00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef TORC_PACKER_PRIMITIVESTRUCTURE_HPP
00020 #define TORC_PACKER_PRIMITIVESTRUCTURE_HPP
00021
00022 #include "torc/architecture/PrimitiveDef.hpp"
00023 #include <boost/regex.hpp>
00024 #include <boost/shared_ptr.hpp>
00025 #include <map>
00026 #include <string>
00027
00028 namespace torc {
00029 namespace packer {
00030
00031
00032 namespace architecture { class PackageUnitTest; }
00033 namespace packer { class PrimitiveStructureUnitTest; }
00034
00035 using namespace architecture;
00036
00037
00038 enum ELogicType {
00039 eLogicTypeUnknown = 0,
00040 eLogicTypeLUT,
00041 eLogicTypeFlop,
00042 eLogicTypeInv,
00043 eLogicTypeAnd,
00044 eLogicTypeXor,
00045 eLogicTypeMux,
00046 eLogicTypeCount
00047 };
00048
00049
00050 class PrimitiveStructure {
00051 protected:
00052
00053 friend class torc::packer::packer::PrimitiveStructureUnitTest;
00054 friend class Unpacker;
00055
00056
00057
00058 typedef std::string string;
00059
00060 typedef torc::architecture::PrimitiveDef PrimitiveDef;
00061
00062 typedef torc::architecture::PrimitiveElement PrimitiveElement;
00063
00064 typedef std::map<string, const PrimitiveElement*> NameToElementPtrMap;
00065
00066 typedef std::map<string, std::vector<const PrimitiveElement*> > PrincipalToOrphanPtrMap;
00067
00068 typedef std::set<const torc::architecture::PrimitiveElementPin*> ElementPinPtrSet;
00069
00070
00071 const PrimitiveDef* mPrimitiveDefPtr;
00072
00073
00074 ElementPinPtrSet mInvertedInputs;
00075
00076 NameToElementPtrMap mUnprocessed;
00077
00078 NameToElementPtrMap mPreclassified;
00079
00080 NameToElementPtrMap mElements;
00081
00082 NameToElementPtrMap mPrincipals;
00083
00084 NameToElementPtrMap mTerminals;
00085
00086 NameToElementPtrMap mMuxes;
00087
00088 NameToElementPtrMap mOrphans;
00089
00090
00091 NameToElementPtrMap mSwitches;
00092
00093
00094
00095
00096
00097 NameToElementPtrMap mLUTs;
00098
00099 NameToElementPtrMap mFlops;
00100
00101
00102
00103
00104 NameToElementPtrMap mPower;
00105
00106 NameToElementPtrMap mGround;
00107
00108 NameToElementPtrMap mRoutethroughs;
00109
00110 PrincipalToOrphanPtrMap mPrincipalstoOrphans;
00111
00112
00113 static boost::regex sRoutethroughRegEx;
00114
00115 static boost::regex sPrincipalRegEx;
00116
00117 static boost::regex sLUTRegEx;
00118
00119 static boost::regex sFlopRegEx;
00120
00121 static boost::regex sPowerRegEx;
00122
00123 static boost::regex sGroundRegEx;
00124
00125 static boost::regex sInvertingInputRegEx;
00126
00127
00128 virtual void initialize(void);
00129
00130 virtual bool isPreclassified(const PrimitiveElement& inElement);
00131
00132 virtual bool isPrincipal(const PrimitiveElement& inElement);
00133
00134 virtual bool isTerminal(const PrimitiveElement& inElement);
00135
00136 virtual bool isOrphan(const PrimitiveElement& inElement);
00137
00138 virtual bool isMux(const PrimitiveElement& inElement, bool& outIsSwitch);
00139
00140 virtual bool isPower(const PrimitiveElement& inElement);
00141
00142 virtual bool isGround(const PrimitiveElement& inElement);
00143
00144 virtual bool isLUT(const PrimitiveElement& inElement, const string& inConfig);
00145
00146 virtual bool isFlop(const PrimitiveElement& inElement, const string& inConfig);
00147
00148 virtual bool isRoutethrough(const PrimitiveElement& inElementPtr);
00149 public:
00150
00151
00152 PrimitiveStructure(const PrimitiveDef* inPrimitiveDefPtr)
00153 : mPrimitiveDefPtr(inPrimitiveDefPtr) {
00154 initialize();
00155 }
00156
00157 PrimitiveStructure(void) : mPrimitiveDefPtr(0) {};
00158
00159 virtual ~PrimitiveStructure(void) {}
00160
00161
00162 void debug(const PrimitiveElement& inPrimitiveElement);
00163
00164
00165 const PrimitiveDef* getPrimitiveDefPtr(void) const { return mPrimitiveDefPtr; }
00166 };
00167
00168
00169 typedef boost::shared_ptr<PrimitiveStructure> PrimitiveStructureSharedPtr;
00170
00171 }
00172 }
00173
00174 #endif // TORC_PACKER_PRIMITIVESTRUCTURE_HPP