25 using namespace torc::architecture;
37 return mPreclassified.find(inElement.
getName()) != mPreclassified.end();
41 return inElement.
getName() == mPrimitiveDefPtr->getName()
42 || regex_match(inElement.
getName(), sPrincipalRegEx);
47 return !mPrimitiveDefPtr->findPinIndexByName(inElement.
getName()).isUndefined();
58 PrimitiveElement::StringSet::size_type cfgsCount = cfgs.size();
60 boost::uint32_t elementPinsCount = elementPins.
getSize();
63 if(cfgsCount == 0)
return false;
66 if(elementPinsCount != cfgsCount + 1)
return false;
71 while(pp < pe) {
if(pp->isInput()) inputs.insert(pp->getName()); pp++; }
72 PrimitiveElement::StringSet::size_type inputCount = inputs.size();
75 PrimitiveElement::StringSet::const_iterator ip = inputs.begin();
76 PrimitiveElement::StringSet::const_iterator ie = inputs.end();
77 PrimitiveElement::StringSet::const_iterator cp = cfgs.begin();
78 while(ip != ie)
if(*ip++ != *cp++)
return false;
84 if(regex_match(input, sInvertingInputRegEx)) {
86 mInvertedInputs.insert(&elementPins[pinIndex]);
91 if(inputCount == 1) outIsSwitch =
true;
97 return elementPins.
getSize() == 1 && elementPins[0].getName() ==
"1"
98 && regex_match(inElement.
getName(), sPowerRegEx);
103 return elementPins.
getSize() == 1 && elementPins[0].getName() ==
"0"
104 && regex_match(inElement.
getName(), sGroundRegEx);
108 return regex_match(inConfig, sLUTRegEx);
112 return regex_match(inConfig, sFlopRegEx);
116 return regex_match(inElement.
getName(), sRoutethroughRegEx);
122 const std::string& primitiveDefName = mPrimitiveDefPtr->getName();
123 (void) primitivePins;
124 (void) primitiveDefName;
138 mElements[elementName] = &primitiveElement;
141 if(isPreclassified(primitiveElement)) {
146 if(isPrincipal(primitiveElement)) {
147 mPrincipals[elementName] = &primitiveElement;
152 if(isTerminal(primitiveElement)) {
153 mTerminals[elementName] = &primitiveElement;
158 if(isOrphan(primitiveElement)) {
159 mOrphans[elementName] = &primitiveElement;
164 bool processed =
false;
167 bool isSwitch =
false;
168 if(isMux(primitiveElement, isSwitch)) {
170 mMuxes[elementName] = &primitiveElement;
171 if(isSwitch) mSwitches[elementName] = &primitiveElement;
177 if(isPower(primitiveElement)) {
178 mPower[elementName] = &primitiveElement;
183 if(isGround(primitiveElement)) {
184 mGround[elementName] = &primitiveElement;
191 PrimitiveElement::StringSet::const_iterator cp = cfgs.begin();
192 PrimitiveElement::StringSet::const_iterator ce = cfgs.end();
196 if(regex_match(config, sLUTRegEx)) {
197 mLUTs[elementName] = &primitiveElement;
202 if(isFlop(primitiveElement, config)) {
203 mFlops[elementName] = &primitiveElement;
208 if(processed)
continue;
211 if(isRoutethrough(primitiveElement)) {
212 mRoutethroughs[elementName] = &primitiveElement;
218 mUnprocessed[elementName] = &primitiveElement;
220 debug(primitiveElement);
235 PrimitiveElement::StringSet::const_iterator cp = cfgs.begin();
236 PrimitiveElement::StringSet::const_iterator ce = cfgs.end();
static boost::regex sInvertingInputRegEx
Regular expression for inverting input pins.
const const PrimitiveElementPin * const_iterator
Constant T iterator type.
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.
PinIndex findPinIndexByName(const string &inName) const
Returns the pin index corresponding to the given pin name, or PinIndex::undefined() if the pin name d...
virtual bool isOrphan(const PrimitiveElement &inElement)
Return true if the element is an orphan.
virtual bool isPreclassified(const PrimitiveElement &inElement)
Return true if the element has been preclassified (typically by a subclass).
T * end(void)
Returns the non-constant end iterator.
virtual bool isRoutethrough(const PrimitiveElement &inElementPtr)
Return true if the element is a routethrough.
Header for the PrimitiveStructure class.
static boost::regex sRoutethroughRegEx
Regular expression for routethroughs.
Encapsulation of a pin index in an unsigned 32-bit integer.
virtual bool isGround(const PrimitiveElement &inElement)
Return true if the element is a ground source.
const string & getName(void) const
Returns the name of the element.
void debug(const PrimitiveElement &inPrimitiveElement)
Prints out debugging information for the specified element.
PrimitiveElementPinArray & getPins(void)
Returns a non-constant array of element pins. This function should only be used by the Sites class d...
virtual bool isTerminal(const PrimitiveElement &inElement)
Return true if the element is a terminal.
virtual void initialize(void)
Initialize this object based on the PrimitiveDef information.
virtual bool isPower(const PrimitiveElement &inElement)
Return true if the element is a power source.
static boost::regex sPrincipalRegEx
Regular expression for additional principal elements.
static boost::regex sFlopRegEx
Regular expression for flops.
Encapsulation of a primitive site element. Primitive elements are subcomponents of logic primitive s...
virtual bool isFlop(const PrimitiveElement &inElement, const string &inConfig)
Return true if the element is a flop.
T * begin(void)
Returns the non-constant begin iterator.
std::set< std::string > StringSet
A set of configuration values.
virtual bool isPrincipal(const PrimitiveElement &inElement)
Return true if the element is the principal element (a parent to the orphans).
const StringSet & getCfgs(void) const
Returns the set of allowable configuration values.
virtual bool isMux(const PrimitiveElement &inElement, bool &outIsSwitch)
Return true if the element is a configurable mux.
virtual bool isLUT(const PrimitiveElement &inElement, const string &inConfig)
Return true if the element is a LUT.
uint32_t getSize(void) const
Returns the array size.