torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PrimitiveStructure.hpp
Go to the documentation of this file.
1 // Torc - Copyright 2011-2013 University of Southern California. All Rights Reserved.
2 // $HeadURL$
3 // $Id$
4 
5 // This program is free software: you can redistribute it and/or modify it under the terms of the
6 // GNU General Public License as published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
11 // the GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License along with this program. If
14 // not, see <http://www.gnu.org/licenses/>.
15 
16 /// \file
17 /// \brief Header for the PrimitiveStructure class.
18 
19 #ifndef TORC_PACKER_PRIMITIVESTRUCTURE_HPP
20 #define TORC_PACKER_PRIMITIVESTRUCTURE_HPP
21 
23 #include <boost/regex.hpp>
24 #include <boost/shared_ptr.hpp>
25 #include <map>
26 #include <string>
27 
28 namespace torc {
29 namespace packer {
30 
31  //namespace packer { class PrimitiveStructureUnitTest; }
32  namespace architecture { class PackageUnitTest; }
33  namespace packer { class PrimitiveStructureUnitTest; }
34 
35  using namespace architecture;
36 
37  /// \brief Enumeration of logic types
38  enum ELogicType {
47  };
48 
49  /// \brief Encapsulation of the site index, pin name, and pin flags for a package.
51  protected:
52  /// \brief Our unit test class has access to our internals.
53  friend class torc::packer::packer::PrimitiveStructureUnitTest;
54  friend class Unpacker;
55 
56  // types
57  /// \brief Imported type name.
59  /// \brief Imported type name.
61  /// \brief Imported type name.
63  /// \brief Mapping from element name to element pointer.
64  typedef std::map<string, const PrimitiveElement*> NameToElementPtrMap;
65  /// \brief Mapping from principal element name to an orphan element pointer vector.
66  typedef std::map<string, std::vector<const PrimitiveElement*> > PrincipalToOrphanPtrMap;
67  /// \brief A set of configuration values.
68  typedef std::set<const torc::architecture::PrimitiveElementPin*> ElementPinPtrSet;
69  // members
70  /// \brief Pointer to the associated primitive definition.
72  // members (type-independent maps)
73  /// \brief Set of inverted element input pins.
75  /// \brief Map of unprocessed elements.
77  /// \brief Map of pre-classified elements (typically by a subclass).
79  /// \brief Map of all elements.
81  /// \brief Map of all principals.
83  /// \brief Map of all terminals.
85  /// \brief Map of all configurable muxes (including switches and inverters).
87  /// \brief Map of all Orphans.
89  // members (secondary classification)
90  /// \brief Map of all switches.
92 // we probably want to remember which mux pins are inverted, and not merely which muxes include inversion
93 // /// \brief Map of all inverters.
94 // NameToElementPtrMap mInverters;
95  // members (type-dependent maps)
96  /// \brief Map of all LUTs.
98  /// \brief Map of all flops.
100 // do we actually need this? how about XORs?
101 // /// \brief Map of all AND gates.
102 // NameToElementPtrMap mANDs;
103  /// \brief Map of all power sources.
105  /// \brief Map of all ground sources.
107  /// \brief Map of all routethroughs.
109  /// \brief Map of principals to orphans.
111  // statics
112  /// \brief Regular expression for routethroughs.
113  static boost::regex sRoutethroughRegEx;
114  /// \brief Regular expression for additional principal elements.
115  static boost::regex sPrincipalRegEx;
116  /// \brief Regular expression for LUTs.
117  static boost::regex sLUTRegEx;
118  /// \brief Regular expression for flops.
119  static boost::regex sFlopRegEx;
120  /// \brief Regular expression for power sources.
121  static boost::regex sPowerRegEx;
122  /// \brief Regular expression for ground sources.
123  static boost::regex sGroundRegEx;
124  /// \brief Regular expression for inverting input pins.
125  static boost::regex sInvertingInputRegEx;
126  // functions
127  /// \brief Initialize this object based on the PrimitiveDef information.
128  virtual void initialize(void);
129  public:
130  // constructors
131  /// \brief Default constructor.
132  PrimitiveStructure(const PrimitiveDef* inPrimitiveDefPtr)
133  : mPrimitiveDefPtr(inPrimitiveDefPtr) {
134  initialize();
135  }
136  /// \brief Null constructor.
137  PrimitiveStructure(void) : mPrimitiveDefPtr(0) {};
138  /// \brief Virtual destructor.
139  virtual ~PrimitiveStructure(void) {}
140  // functions
141  /// \brief Prints out debugging information for the specified element.
142  void debug(const PrimitiveElement& inPrimitiveElement);
143  /// \brief Return true if the element has been preclassified (typically by a subclass).
144  virtual bool isPreclassified(const PrimitiveElement& inElement);
145  /// \brief Return true if the element is the principal element (a parent to the orphans).
146  virtual bool isPrincipal(const PrimitiveElement& inElement);
147  /// \brief Return true if the element is a terminal.
148  virtual bool isTerminal(const PrimitiveElement& inElement);
149  /// \brief Return true if the element is an orphan.
150  virtual bool isOrphan(const PrimitiveElement& inElement);
151  /// \brief Return true if the element is a configurable mux.
152  virtual bool isMux(const PrimitiveElement& inElement, bool& outIsSwitch);
153  /// \brief Return true if the element is a power source.
154  virtual bool isPower(const PrimitiveElement& inElement);
155  /// \brief Return true if the element is a ground source.
156  virtual bool isGround(const PrimitiveElement& inElement);
157  /// \brief Return true if the element is a LUT.
158  virtual bool isLUT(const PrimitiveElement& inElement, const string& inConfig);
159  /// \brief Return true if the element is a flop.
160  virtual bool isFlop(const PrimitiveElement& inElement, const string& inConfig);
161  /// \brief Return true if the element is a routethrough.
162  virtual bool isRoutethrough(const PrimitiveElement& inElementPtr);
163  // accessors
164  /// \brief Returns a pointer to the associated primitive definition.
165  const PrimitiveDef* getPrimitiveDefPtr(void) const { return mPrimitiveDefPtr; }
166  };
167 
168  /// \brief Shared pointer encapsulation of a PrimitiveStructure.
169  typedef boost::shared_ptr<PrimitiveStructure> PrimitiveStructureSharedPtr;
170 
171 } // namespace architecture
172 } // namespace torc
173 
174 #endif // TORC_PACKER_PRIMITIVESTRUCTURE_HPP
static boost::regex sInvertingInputRegEx
Regular expression for inverting input pins.
NameToElementPtrMap mRoutethroughs
Map of all routethroughs.
NameToElementPtrMap mSwitches
Map of all switches.
torc::architecture::PrimitiveElement PrimitiveElement
Imported type name.
static boost::regex sLUTRegEx
Regular expression for LUTs.
static boost::regex sPowerRegEx
Regular expression for power sources.
static boost::regex sGroundRegEx
Regular expression for ground sources.
NameToElementPtrMap mUnprocessed
Map of unprocessed elements.
std::map< string, const PrimitiveElement * > NameToElementPtrMap
Mapping from element name to element pointer.
const PrimitiveDef * getPrimitiveDefPtr(void) const
Returns a pointer to the associated primitive definition.
NameToElementPtrMap mGround
Map of all ground sources.
ElementPinPtrSet mInvertedInputs
Set of inverted element input pins.
Encapsulation of primitive site definition, with associated connections, elements, and pins.
virtual ~PrimitiveStructure(void)
Virtual destructor.
NameToElementPtrMap mElements
Map of all elements.
PrimitiveStructure(const PrimitiveDef *inPrimitiveDefPtr)
Default constructor.
std::string string
Imported type name.
NameToElementPtrMap mPower
Map of all power sources.
static boost::regex sRoutethroughRegEx
Regular expression for routethroughs.
PrimitiveStructure(void)
Null constructor.
std::string string
NameToElementPtrMap mMuxes
Map of all configurable muxes (including switches and inverters).
std::map< string, std::vector< const PrimitiveElement * > > PrincipalToOrphanPtrMap
Mapping from principal element name to an orphan element pointer vector.
static boost::regex sPrincipalRegEx
Regular expression for additional principal elements.
Header for the PrimitiveDef class.
std::set< const torc::architecture::PrimitiveElementPin * > ElementPinPtrSet
A set of configuration values.
NameToElementPtrMap mPreclassified
Map of pre-classified elements (typically by a subclass).
static boost::regex sFlopRegEx
Regular expression for flops.
PrincipalToOrphanPtrMap mPrincipalsToOrphans
Map of principals to orphans.
NameToElementPtrMap mPrincipals
Map of all principals.
NameToElementPtrMap mFlops
Map of all flops.
NameToElementPtrMap mLUTs
Map of all LUTs.
Encapsulation of a primitive site element. Primitive elements are subcomponents of logic primitive s...
const PrimitiveDef * mPrimitiveDefPtr
Pointer to the associated primitive definition.
NameToElementPtrMap mTerminals
Map of all terminals.
ELogicType
Enumeration of logic types.
boost::shared_ptr< PrimitiveStructure > PrimitiveStructureSharedPtr
Shared pointer encapsulation of a PrimitiveStructure.
Encapsulation of the site index, pin name, and pin flags for a package.
torc::architecture::PrimitiveDef PrimitiveDef
Imported type name.
NameToElementPtrMap mOrphans
Map of all Orphans.