39 using namespace torc::architecture;
45 mDesignPtr->getPackage()
46 + mDesignPtr->getSpeedGrade());
47 mDDBPtr =
new DDB(deviceDesignator);
53 PrimitiveDefArray::const_iterator p = primitiveDefs.begin();
54 PrimitiveDefArray::const_iterator e = primitiveDefs.end();
60 = primitiveStructurePtr->getPrimitiveDefPtr();
63 if(primitiveDefName !=
"IOB" && primitiveDefName !=
"IOBM"
64 && primitiveDefName !=
"IOBS")
65 mPrimitiveStructures[primitiveDefName] = primitiveStructurePtr;
74 std::vector<std::string> inInstanceInputPins,
78 std::vector<torc::physical::InstanceSharedPtr>
83 if(inUsedElements.find(element.
getName()) != inUsedElements.end())
return true;
91 std::vector<std::string>::const_iterator instanceInputit;
94 bool isInverter =
false;
95 bool isInputTerminal =
false;
96 bool isOutputTerminal =
false;
98 if(inPrimitiveStructure.
mTerminals.find(elementName)
102 int primitivePinIndex
105 const PrimitivePin& primitivePin = primitivePins[primitivePinIndex];
107 isInputTerminal = (!primitivePin.
isOutput());
108 isOutputTerminal = (primitivePin.
isOutput());
112 instanceInputit = find(inInstanceInputPins.begin(),
113 inInstanceInputPins.end(), elementName);
114 if(instanceInputit != inInstanceInputPins.end()) {
115 inUsedElements[elementName]
116 = inPrimitiveStructure.
mElements.find(elementName)->second;
125 bool hasConfig = inInstancePtr->getConfig(elementName, cfgName, cfgSetting);
132 if(inPrimitiveStructure.
mMuxes.find(elementName)
133 != inPrimitiveStructure.
mMuxes.end()){
139 = fetchNextElementPins[pinIndex].getPrimitiveConn()
141 invPtr = &fetchNextElementPins[pinIndex];
144 std::set<const PrimitiveElementPin*>::const_iterator it
147 outNetSourcePin = invPtr;
150 outNetSourcePin = muxPtr;
152 = fetchNextElementPins[pinIndex].getPrimitiveConn()
153 ->getSourcePtr()->getElementPtr();
155 return findNextElement(inPrimitiveStructure, nextElement2,
156 inInstancePtr, inUsedElements,
159 outNetSourcePin, outNewInstances,
160 elementToInstanceMap);
169 if(inPrimitiveStructure.
mPower.find(elementName)
170 != inPrimitiveStructure.
mPower.end()){
172 }
else if(inPrimitiveStructure.
mGround.find(elementName)
173 != inPrimitiveStructure.
mGround.end()){
178 if(hasConfig) result =
true;
187 if(!fetchNextElementPin.
isInput())
continue;
189 if(isInverter && (invPtr != fetchNextElementPinPtr))
continue;
198 ->getSourcePtr()->getElementPtr()->getName();
203 bool isPower =
false;
204 if(inPrimitiveStructure.
mPower.find(nextElementName)
205 != inPrimitiveStructure.
mPower.end()){
207 }
else if(inPrimitiveStructure.
mGround.find(nextElementName)
208 != inPrimitiveStructure.
mGround.end()){
211 newNetSourcePin = sourcePtr;
212 found = findNextElement(inPrimitiveStructure, nextElement, inInstancePtr,
213 inUsedElements, inInstanceInputPins,
214 inElementPinsForNet, newNetSourcePin,
215 outNewInstances, elementToInstanceMap);
220 inElementPinsForNet[newNetSourcePin]
221 .push_back(fetchNextElementPinPtr);
223 result |= found && !isPower;
226 if (result && !isOutputTerminal){
228 inUsedElements[elementName] = inPrimitiveStructure.
mElements.find
229 (elementName)->second;
230 string newName = inInstancePtr->getName();
231 newName = newName +
":" + elementName +
":" + cfgName;
233 string typeName = isInverter ?
"INV" : elementName;
238 outNewInstances.push_back(newInstancePtr);
241 newInstancePtr->setConfig(elementName, cfgName, cfgSetting);
243 std::vector<const PrimitiveElement*> >::const_iterator it;
246 if(inPrimitiveStructure.
mFlops.find(elementName)
247 != inPrimitiveStructure.
mFlops.end()
248 || inPrimitiveStructure.
mLUTs.find(elementName)
249 != inPrimitiveStructure.
mLUTs.end()){
253 if(it->first != elementName)
continue;
254 for(std::vector<const PrimitiveElement*>
255 ::const_iterator iter = it->second.begin();
256 iter != it->second.end(); iter++){
260 std::string orphanName = orphan.
getName();
261 std::string orphanCfgName,
263 bool configForOrphan = inInstancePtr
264 ->getConfig(orphanName,
268 newInstancePtr->setConfig(
269 orphanName, orphanCfgName,
274 elementToInstanceMap[elementPtr] = newInstancePtr;
283 = mDesignPtr->instancesBegin();
285 = mDesignPtr->instancesEnd();
292 std::vector<torc::physical::InstanceSharedPtr> oldInstances;
293 std::vector<torc::physical::InstanceSharedPtr> newInstances;
294 std::vector<torc::physical::InstanceSharedPtr>::iterator instIt;
303 CandidateNet::const_iterator it1;
306 NameToElementPtrMap::const_iterator it;
308 ElementPtrToInstancePtrMap::const_iterator elementToInstanceMapit;
309 std::vector<std::string> instanceInputPins;
310 std::vector<std::string> instanceOutputPins;
311 std::vector<std::string> usedPower;
312 std::vector<std::string> usedGround;
316 PrimitiveStructuresSharedPtrMap::const_iterator pos;
318 pos = mPrimitiveStructures.find(instanceType);
319 if(pos != mPrimitiveStructures.end()){
325 if(primitiveDefPtr == 0)
return;
338 Instance::InstancePinSharedPtrConstIterator ipp
339 = instancePtr->pinsBegin();
340 Instance::InstancePinSharedPtrConstIterator ipe
341 = instancePtr->pinsEnd();
347 const std::string& pinName = instancePinPtr->getPinName();
348 netPtr = instancePinPtr->getParentWeakPtr().lock();
354 if(static_cast<boost::int32_t>(pinIndex) < 0)
continue;
355 const PrimitivePin& primitivePin = primitivePins[pinIndex];
357 inputPins.push_back(instancePinPtr);
359 outputPins.push_back(instancePinPtr);
364 InstancePinSharedPtrVector::const_iterator ipp2;
365 InstancePinSharedPtrVector::const_iterator ipe2;
367 ipp2 = inputPins.
begin();
368 ipe2 = inputPins.end();
369 while(ipp2 != ipe2) {
371 instanceInputPins.push_back(instancePinPtr->getPinName());
375 ipp2 = outputPins.begin();
376 ipe2 = outputPins.end();
377 while(ipp2 != ipe2) {
379 instanceOutputPins.push_back(instancePinPtr->getPinName());
380 std::cout <<
" found OUTPUT " << instancePinPtr
381 ->getPinName() << std::endl;
382 std::string outPinName = instancePinPtr->getPinName();
385 = primitiveStructure.
mTerminals.find(outPinName)
388 findNextElement(primitiveStructure, element, instancePtr,
389 usedElements, instanceInputPins,
390 elementPinsForNet, outNetSourcePin,
391 newInstances, elementToInstanceMap);
394 for(it1 = elementPinsForNet.begin();
395 it1 != elementPinsForNet.end(); it1++){
408 terminals.push_back(sourcePinPtr);
411 for(PrimitiveElementPinPtrVector::const_iterator iter
412 = it1->second.begin(); iter
413 != it1->second.end(); iter++){
419 if(primitiveStructure.
mTerminals.find(sinkPinPtr
422 terminals.push_back(sinkPinPtr);
432 if(terminals.size() > 1){
434 +
":" + drivingElementName +
":"
437 for(std::vector<const PrimitiveElementPin*>
438 ::const_iterator iter
440 iter != terminals.end(); iter++){
441 Instance::InstancePinSharedPtrConstIterator
443 ->findPin(torc::physical
444 ::PinName(sourcePinPtr
449 ->getParentWeakPtr().lock();
451 ::InstancePinSharedPtrIterator
456 net->addSource(*netSourceIter);
459 ::InstancePinSharedPtrIterator
464 net->addSink(*netSinkIter);
466 mDesignPtr->removeNet(net2);
471 }
else if(terminals.size() == 1){
472 Instance::InstancePinSharedPtrConstIterator pin
475 (terminals.front()->getName()));
477 net = pinPtr->getParentWeakPtr().lock();
483 std::cout <<
"Adding a new net" << std::endl;
485 +
":" + drivingElementName +
":"
488 mDesignPtr->addNet(net);
492 if(primitiveStructure.
mTerminals.find(sourcePinPtr
496 Instance::InstancePinSharedPtrConstIterator pin1
503 net->removeSink(pin1Ptr);
506 = elementToInstanceMap.find(sourcePinPtr
507 ->getElementPtr())->second;
513 net->addSource(instanceSourcePin);
519 ::const_iterator iter = sinkVector.begin();
520 iter != sinkVector.end(); iter++){
522 ->getElementPtr()->getName())
524 Instance::InstancePinSharedPtrConstIterator
527 ((*iter)->getName()));
530 net->removeSource(pin2Ptr);
536 = elementToInstanceMap.find((*iter)
537 ->getElementPtr())->second;
544 net->addSink(instanceSinkPin);
550 oldInstances.push_back(instancePtr);
557 std::cout <<
"-------------------- NEW INSTANCES -------------------" << std::endl;
558 for(instIt = newInstances.begin(); instIt != newInstances.end(); instIt++){
561 std::cout <<
" " << newInstance.
getName() << std::endl;
562 mDesignPtr->addInstance(newInstancePtr);
564 std::cout <<
"-------------------- OLD INSTANCES -------------------" << std::endl;
565 for(instIt = oldInstances.begin(); instIt != oldInstances.end(); instIt++){
568 std::cout <<
" " << oldInstance.
getName() << std::endl;
569 mDesignPtr->removeInstance(oldInstancePtr);
bool isOutput(void) const
Returns true if this pin is a primitive output.
const const PrimitiveElementPin * const_iterator
Constant T iterator type.
Header for the ConfigMap class.
InstancePinSharedPtrConstIterator sourcesEnd(void) const
Returns the end constant iterator for source instance pins.
Encapsulation of a device designator and its constituent elements.
Device database, including complete wiring and logic support.
bool findNextElement(const PrimitiveStructure &inPrimitiveStructure, const torc::architecture::PrimitiveElement &element, torc::physical::InstanceSharedPtr &inInstancePtr, NameToElementPtrMap &inUsedElements, std::vector< std::string > inInstanceInputPins, CandidateNet &inElementPinsForNet, const torc::architecture::PrimitiveElementPin *&outNetSourcePin, std::vector< torc::physical::InstanceSharedPtr > &outNewInstances, ElementPtrToInstancePtrMap &elementToInstanceMap)
Function to find the next element.
PinIndex findPinIndexByName(const string &inName) const
Returns the pin index corresponding to the given pin name, or PinIndex::undefined() if the pin name d...
const string & getType(void) const
Returns the logic type for this instance.
const PrimitiveDef * getPrimitiveDefPtr(void) const
Returns a pointer to the associated primitive definition.
NameToElementPtrMap mGround
Map of all ground sources.
const PrimitiveConnSharedPtr getPrimitiveConn(void) const
Returns the primitive connection that includes this pin.
Header for the Virtex5PrimitiveStructure class.
Header for the DirectoryTree class.
Encapsulation of a site pin name.
ElementPinPtrSet mInvertedInputs
Set of inverted element input pins.
Header for the Instance class.
Encapsulation of primitive site definition, with associated connections, elements, and pins.
T * end(void)
Returns the non-constant end iterator.
Header for the Sites class.
InstanceSharedPtrVector::const_iterator InstanceSharedPtrConstIterator
Constant iterator to Instance shared pointers.
static NetSharedPtr newNetPtr(const string &inName, ENetType inNetType=eNetTypeNormal)
Create and return a new Net share pointer.
void unpack(void)
Default unpack function.
Header for the DeviceDesignator class.
std::vector< InstancePinSharedPtr > InstancePinSharedPtrVector
Vector of InstancePin shared pointers.
NameToElementPtrMap mElements
Map of all elements.
Header for the PrimitiveStructure class.
NameToElementPtrMap mPower
Map of all power sources.
std::map< const torc::architecture::PrimitiveElement *, torc::physical::InstanceSharedPtr > ElementPtrToInstancePtrMap
Map of Primitive Element Pointer to Instance Shared Pointer.
bool isInput(void) const
Returns true if this pin is a primitive input.
Encapsulation of a pin index in an unsigned 32-bit integer.
boost::shared_ptr< class InstancePin > InstancePinSharedPtr
Shared pointer encapsulation of an InstancePin.
PinIndex findPinIndexByName(const std::string &inName) const
Returns the pin index corresponding to the given pin name, or PinIndex::undefined() if the pin name d...
const string & getName(void) const
Returns the pin name.
const string & getName(void) const
Returns the name of the element.
PrimitiveElementPinArray & getPins(void)
Returns a non-constant array of element pins. This function should only be used by the Sites class d...
NameToElementPtrMap mMuxes
Map of all configurable muxes (including switches and inverters).
const Array< const PrimitiveDef > & getSiteTypes(void) const
Returns the site types for this family.
std::map< const torc::architecture::PrimitiveElementPin *, PrimitiveElementPinPtrVector > CandidateNet
Map of Candidate Nets.
bool isInput(void) const
Returns true if this pin is a primitive input.
std::vector< InstancePinSharedPtr > InstancePinSharedPtrVector
Vector of InstancePin shared pointers.
Physical design instance.
boost::shared_ptr< Net > NetSharedPtr
Site type and population data for the family and the device.
Header for the Design class.
const PrimitiveElement * getElementPtr(void) const
Returns a pointer to the primitive element that owns this pin.
const Array< const Site > & getSites(void) const
Returns the sites for this family.
std::map< std::string, const PrimitiveStructure::PrimitiveElement * > NameToElementPtrMap
Map of Primitive Element Name to Primitive Element.
const string & getName(void) const
Returns the object name.
boost::shared_ptr< Net > NetSharedPtr
Shared pointer encapsulation of a Net.
PrimitivePinArray & getPins(void)
Returns a non-constant array of element pins. This function should only be used by the Sites class d...
virtual void initialize(void)
Initialize this object based on the PrimitiveDef information.
static InstanceSharedPtr newInstancePtr(const string &inName, const string &inType, const string &inTile, const string &inSite, EInstanceBonding inBonding=eInstanceBondingUnknown, InstanceReferenceSharedPtr inInstanceReferencePtr=InstanceReferenceSharedPtr())
Construct and return a new Instance shared pointer.
boost::shared_ptr< Instance > InstanceSharedPtr
Shared pointer encapsulation of an Instance.
Encapsulation of a primitive pin's name and flags. Primitive pins are logic site inputs or outputs...
std::vector< const torc::architecture::PrimitiveElementPin * > PrimitiveElementPinPtrVector
Vector of Primitive Element Pin Pointers.
PrincipalToOrphanPtrMap mPrincipalsToOrphans
Map of principals to orphans.
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...
Encapsulation of a primitive element pin's name, flags, and element pointer. Primitive element pins ...
const PrimitiveDef * mPrimitiveDefPtr
Pointer to the associated primitive definition.
NameToElementPtrMap mTerminals
Map of all terminals.
T * begin(void)
Returns the non-constant begin iterator.
boost::shared_ptr< PrimitiveStructure > PrimitiveStructureSharedPtr
Shared pointer encapsulation of a PrimitiveStructure.
Header for the DDB class.
Encapsulation of the site index, pin name, and pin flags for a package.
static InstancePinSharedPtr newInstancePinPtr(InstanceSharedPtr inInstancePtr, const string &inPinName)
Construct and return a new InstancePin shared pointer.
Header for the Circuit class.
Header for the Factory class.
Header for the XdlImporter class.
Subclass of PrimitiveStructure for Virtex5.
Encapsulation of a static array.
boost::shared_ptr< InstancePin > InstancePinSharedPtr
Shared pointer encapsulation of an InstancePin.
const string & getName(void) const
Returns the name of the primitive.