torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
torc::physical::XdlUnpack Class Reference

#include <XdlUnpack.hpp>

Public Member Functions

DesignSharedPtr operator() (const DesignSharedPtr &inDesignPtr)
 
void unpack (const Circuit &circuit, CircuitSharedPtr newCircuit)
 
DesignSharedPtr unpack (const Design &design)
 
ModuleSharedPtr unpack (const Module &module)
 
PortSharedPtr unpack (const Port &port)
 
void unpack (Instance &instance, CircuitSharedPtr newCircuit)
 
NetSharedPtr unpack (const Net &net)
 
InstancePinSharedPtr unpack (const InstancePinSharedPtr instancePin, EPinDirection pinDirection, bool comma)
 
Pip unpack (const Pip &pip, bool comma)
 
RoutethroughSharedPtr unpack (const Routethrough &routethrough)
 
void removeExtraElements (PrimitiveSharedPtr primPtr)
 removes extra elements that are needed for unpacking More...
 
void readPrimitives (const char *fileName)
 
bool isExtraMux (string elem)
 

Protected Types

typedef boost::shared_ptr
< torc::physical::Named
NamedSharedPtr
 
typedef boost::shared_ptr
< torc::physical::ConfigMap
ConfigMapSharedPtr
 

Protected Attributes

PrimitiveSetSharedPtr primitives
 

Detailed Description

Definition at line 40 of file XdlUnpack.hpp.

Member Typedef Documentation

Definition at line 83 of file XdlUnpack.hpp.

Definition at line 82 of file XdlUnpack.hpp.

Member Function Documentation

bool torc::physical::XdlUnpack::isExtraMux ( string  elem)
inline

Definition at line 66 of file XdlUnpack.hpp.

66  {
67  char names[1024] ;
68  strcpy(names,extraMuxNames.c_str());
69  string pch;
70  pch = strtok (names," ");
71  while (pch!="END")
72  {
73  if(pch == elem){
74  return true;
75  }
76  pch = strtok (NULL," ");
77  }
78  return false;
79  }
const string extraMuxNames
Definition: XdlUnpack.hpp:35

+ Here is the caller graph for this function:

DesignSharedPtr torc::physical::XdlUnpack::operator() ( const DesignSharedPtr inDesignPtr)
Todo:
Release mutex.

Definition at line 23 of file XdlUnpack.cpp.

23  {
24 
25  // export the design statement
26  DesignSharedPtr designPtr(inDesignPtr);
27  const Design& design = *designPtr;
28  DesignSharedPtr newDesign = unpack(design);
29 
30  return newDesign;
31 
32  /// \todo Release mutex.
33  }
void unpack(const Circuit &circuit, CircuitSharedPtr newCircuit)
Definition: XdlUnpack.cpp:35
boost::shared_ptr< Design > DesignSharedPtr
Shared pointer encapsulation of a Design.

+ Here is the call graph for this function:

void torc::physical::XdlUnpack::readPrimitives ( const char *  fileName)
inline

Definition at line 59 of file XdlUnpack.hpp.

59  {
60  ParsePrimitive parser;
61  primitives = parser.ParsePrimitiveFile(fileName);
62  return;
63  }
PrimitiveSetSharedPtr primitives
Definition: XdlUnpack.hpp:85

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::physical::XdlUnpack::removeExtraElements ( PrimitiveSharedPtr  primPtr)

removes extra elements that are needed for unpacking

Definition at line 649 of file XdlUnpack.cpp.

649  {
651  ElementSharedPtr elemPtr;
652  for(elemIt=primPtr->elementsBegin(); elemIt != primPtr->elementsEnd(); ++elemIt){
653  if(strstr((*elemIt)->getName().c_str(), "USED")!=NULL){
654  primPtr->removeElement(*elemIt);
655  continue;
656  }
657 
658  char names[1024] ;
659  strcpy(names,elementNames.c_str());
660  string pch;
661  pch = strtok (names," ");
662  while (pch!="END")
663  {
664  if(pch == (*elemIt)->getName()){
665  primPtr->removeElement(*elemIt);
666  break;
667  }
668  pch = strtok (NULL," ");
669  }
670  }
671  }
boost::shared_ptr< Element > ElementSharedPtr
Shared pointer encapsulation of a element.
Definition: Element.hpp:119
ElementSharedPtrVector::iterator ElementSharedPtrIterator
Non-constant iterator for Element shared pointers.
Definition: Primitive.hpp:55
const string elementNames
Definition: XdlUnpack.hpp:32

+ Here is the caller graph for this function:

void torc::physical::XdlUnpack::unpack ( const Circuit circuit,
CircuitSharedPtr  newCircuit 
)

Definition at line 35 of file XdlUnpack.cpp.

35  {
36 
37  // export the nets
38  Circuit::NetSharedPtrConstIterator pn = circuit.netsBegin();
39  Circuit::NetSharedPtrConstIterator en = circuit.netsEnd();
40  while(pn < en){
41  NetSharedPtr netPtr = unpack(**pn++);
42  newCircuit->addNet(netPtr);
43  }
44 
45  // export the instances
46  Circuit::InstanceSharedPtrConstIterator pi = circuit.instancesBegin();
47  Circuit::InstanceSharedPtrConstIterator ei = circuit.instancesEnd();
48  while(pi < ei) {
49  unpack(**pi++, newCircuit);
50  }
51  }
InstanceSharedPtrVector::const_iterator InstanceSharedPtrConstIterator
Constant iterator to Instance shared pointers.
Definition: Circuit.hpp:72
boost::shared_ptr< Net > NetSharedPtr
Shared pointer encapsulation of a Net.
void unpack(const Circuit &circuit, CircuitSharedPtr newCircuit)
Definition: XdlUnpack.cpp:35
NetSharedPtrVector::const_iterator NetSharedPtrConstIterator
Constant iterator to Net shared pointers.
Definition: Circuit.hpp:76

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DesignSharedPtr torc::physical::XdlUnpack::unpack ( const Design design)

Definition at line 53 of file XdlUnpack.cpp.

53  {
54  string designName;
55  designName = design.getName();
56  designName += "_unpacked";
57 
58  DesignSharedPtr newDesign = Factory::newDesignPtr (designName, design.getDevice(), "", "", design.getXdlVersion());
59 
60  string deviceName = design.getDevice();
61  deviceName += ".xdlrc";
62  readPrimitives(deviceName.c_str());
63  removeExtraElements(*primitives->findPrimitive("SLICEL"));
64  removeExtraElements(*primitives->findPrimitive("SLICEM"));
65 
66  if(!design.configIsEmpty()) {
67  newDesign->addConfigs(static_cast<const ConfigMap&>(design));
68  }
69 
70  // export the modules
71  Design::ModuleSharedPtrConstIterator p = design.modulesBegin();
72  Design::ModuleSharedPtrConstIterator e = design.modulesEnd();
73  while(p < e){
74  ModuleSharedPtr modulePtr= unpack(**p++);
75  newDesign->addModule(modulePtr);
76  }
77  // export the instances and nets
78  unpack(static_cast<Circuit>(design), static_cast<CircuitSharedPtr>(newDesign));
79 
80  return newDesign;
81 
82  }
void readPrimitives(const char *fileName)
Definition: XdlUnpack.hpp:59
ModuleSharedPtrVector::const_iterator ModuleSharedPtrConstIterator
Constant iterator for Module shared pointers.
boost::shared_ptr< Module > ModuleSharedPtr
Shared pointer encapsulation of a Module.
Definition: Module.hpp:114
PrimitiveSetSharedPtr primitives
Definition: XdlUnpack.hpp:85
void removeExtraElements(PrimitiveSharedPtr primPtr)
removes extra elements that are needed for unpacking
Definition: XdlUnpack.cpp:649
void unpack(const Circuit &circuit, CircuitSharedPtr newCircuit)
Definition: XdlUnpack.cpp:35
boost::shared_ptr< Design > DesignSharedPtr
Shared pointer encapsulation of a Design.
static DesignSharedPtr newDesignPtr(const string &inName, const string &inDevice, const string &inPackage, const string &inSpeedGrade, const string &inXdlVersion)
Create and return a new Design shared pointer.

+ Here is the call graph for this function:

ModuleSharedPtr torc::physical::XdlUnpack::unpack ( const Module module)

Definition at line 84 of file XdlUnpack.cpp.

84  {
85 
86  ModuleSharedPtr newModule = Factory::newModulePtr (module.getName(), module.getAnchor());
87 
88  if(!module.configIsEmpty())
89  {newModule->addConfigs(static_cast<const ConfigMap&>(module)); }
90 
91  // export the ports
92  Module::PortSharedPtrConstIterator p = module.portsBegin();
93  Module::PortSharedPtrConstIterator e = module.portsEnd();
94  while(p < e){
95  PortSharedPtr portPtr = unpack(**p++);
96  newModule->addPort(portPtr);
97  }
98 
99  // export the instances and nets
100  unpack(static_cast<Circuit>(module), static_cast<CircuitSharedPtr>(newModule));
101 
102  return newModule;
103  }
PortSharedPtrVector::const_iterator PortSharedPtrConstIterator
Constant iterator to Port shared pointers.
Definition: Module.hpp:55
boost::shared_ptr< Port > PortSharedPtr
Shared pointer encapsulation of a Port.
boost::shared_ptr< Module > ModuleSharedPtr
Shared pointer encapsulation of a Module.
Definition: Module.hpp:114
void unpack(const Circuit &circuit, CircuitSharedPtr newCircuit)
Definition: XdlUnpack.cpp:35
static ModuleSharedPtr newModulePtr(const string &inName, const string &inAnchor)
Create and return a new Module shared pointer.

+ Here is the call graph for this function:

PortSharedPtr torc::physical::XdlUnpack::unpack ( const Port port)

Definition at line 105 of file XdlUnpack.cpp.

105  {
106  InstanceSharedPtr instPtr = port.getInstancePtr().lock();
107  PortSharedPtr newPort = Factory::newPortPtr (port.getName(), instPtr, port.getPinName());
108  return newPort;
109  }
static PortSharedPtr newPortPtr(const string &inName, InstanceSharedPtr inInstancePtr, const string &inPinName)
Create and return a new Port shared pointer.
boost::shared_ptr< Port > PortSharedPtr
Shared pointer encapsulation of a Port.
boost::shared_ptr< Instance > InstanceSharedPtr
Shared pointer encapsulation of an Instance.

+ Here is the call graph for this function:

void torc::physical::XdlUnpack::unpack ( Instance instance,
CircuitSharedPtr  newCircuit 
)

Definition at line 111 of file XdlUnpack.cpp.

111  {
112 
113  // change SLICEL and SLICEM
114  if((instance.getType()=="SLICEL")||(instance.getType()=="SLICEM")){
115  InstanceSharedPtrVector affInstances,bffInstances,cffInstances,dffInstances, xffInstances, yffInstances;
116  InstanceSharedPtrVector alutInstances,blutInstances,clutInstances,dlutInstances,xlutInstances,ylutInstances;
117  ConfigMap instanceConfigs;
118  ConfigMap affConfigs, bffConfigs, cffConfigs, dffConfigs,xffConfigs,yffConfigs;
119  ConfigMap alutConfigs, blutConfigs, clutConfigs, dlutConfigs,xlutConfigs,ylutConfigs;
120  PrimitiveSet::PrimitiveSharedPtrIterator it = primitives->findPrimitive(instance.getType());
121  PrimitiveSharedPtr primitivePtr = *it;
122  ConfigMap::const_iterator p = instance.configBegin();
123  ConfigMap::const_iterator e = instance.configEnd();
124  InstanceReferenceSharedPtr instanceReferencePtr = instance.getInstanceReferencePtr();
125  InstanceReferenceSharedPtr newInstanceReferencePtr;
126 
127  if(instanceReferencePtr.get() != 0) {
128  const InstanceReference& instanceReference = *instanceReferencePtr;
129  std::string instanceName = instanceReference.getInstancePtr().expired()
130  ? "[expired instance]" : instanceReference.getInstancePtr().lock()->getName();
131  newInstanceReferencePtr = Factory::newInstanceReferencePtr (
132  instanceName, instanceReference.getModulePtr().lock(), instanceReference.getInstancePtr().lock());
133  }
134 
135  // Define the instances based on configs
136  while(p != e) {
137  const std::string& setting = p->first;
138 
139  // skip if this is not a valid config
140  if(setting == "_NO_USER_LOGIC")
141  return;
142  Primitive::ElementSharedPtrIterator elemIter = primitivePtr->findElement(setting);
143  if(elemIter == primitivePtr->elementsEnd()){
144  ++p;
145  continue;
146  }
147  string newName = instance.getName();
148 
149  const Config& config = p->second;
150  newName = newName + ":" + setting + ":" + config.getName() ;
151  string typeName;
152 
153  // If this is a configured mux
154  if(isExtraMux(setting)){
155  instanceConfigs.setConfig(setting, config);
156  ++p;
157  continue;
158  }
159  // if this is an inverter
160  if(strstr(setting.c_str(),"INV")!= NULL){
161  if(strstr(config.getValue().c_str() , "_B") == NULL){
162  instanceConfigs.setConfig(setting, config);
163  ++p;
164  continue;
165  }
166  typeName = "INV";
167  instanceConfigs.setConfig(setting, config);
168  }
169  // luts
170  else if((strstr(setting.c_str(),"LUT")!= NULL)|| (setting == "G")|| (setting == "F")){
171  typeName = "LUT";
172  instanceConfigs.setConfig(setting, config);
173  }
174  else if((strstr(setting.c_str(),"AND")!= NULL)){
175  typeName = "AND";
176  instanceConfigs.setConfig(setting, config);
177  }
178  else if((strstr(setting.c_str(),"XOR")!= NULL)){
179  typeName = "XOR";
180  instanceConfigs.setConfig(setting, config);
181  }
182  else if((setting == "AFF") || (setting == "BFF") || (setting == "CFF") || (setting == "DFF") || (setting == "FFX") || (setting == "FFY")){
183  typeName = "DFF";
184  instanceConfigs.setConfig(setting, config);
185  }
186  else if( ( setting == "AFFSR") ||
187  (setting == "AFFINIT") ){
188  affConfigs.setConfig(setting,config);
189  ++p;
190  continue;
191  }
192  else if( ( setting == "BFFSR") ||
193  (setting == "BFFINIT") ){
194  bffConfigs.setConfig(setting,config);
195  ++p;
196  continue;
197  }
198  else if( ( setting == "CFFSR") ||
199  (setting == "CFFINIT") ){
200  cffConfigs.setConfig(setting,config);
201  ++p;
202  continue;
203  }
204  else if( ( setting == "DFFSR") ||
205  (setting == "DFFINIT") ){
206  dffConfigs.setConfig(setting,config);
207  ++p;
208  continue;
209  }
210  else if( ( setting == "FFY_INIT_ATTR") ||
211  (setting == "FFY_SR_ATTR") ){
212  yffConfigs.setConfig(setting,config);
213  ++p;
214  continue;
215  }
216  else if( ( setting == "FFX_INIT_ATTR") ||
217  (setting == "FFX_SR_ATTR") ){
218  xffConfigs.setConfig(setting,config);
219  ++p;
220  continue;
221  }
222  else if(setting == "A6RAMMODE"){
223  alutConfigs.setConfig(setting,config);
224  ++p;
225  continue;
226  }
227  else if(setting == "B6RAMMODE"){
228  blutConfigs.setConfig(setting,config);
229  ++p;
230  continue;
231  }
232  else if(setting == "C6RAMMODE"){
233  clutConfigs.setConfig(setting,config);
234  ++p;
235  continue;
236  }
237  else if(setting == "D6RAMMODE"){
238  dlutConfigs.setConfig(setting,config);
239  ++p;
240  continue;
241  }
242  else if(setting == "D6RAMMODE"){
243  dlutConfigs.setConfig(setting,config);
244  ++p;
245  continue;
246  }
247  else if(setting == "F_ATTR"){
248  xlutConfigs.setConfig(setting,config);
249  ++p;
250  continue;
251  }
252  else if(setting == "G_ATTR"){
253  ylutConfigs.setConfig(setting,config);
254  ++p;
255  continue;
256  }
257  else if((strstr(setting.c_str(), "MUX")!=NULL)||(strstr(setting.c_str(), "CY0")!=NULL)||
258  (setting=="PRECYINIT")){
259  typeName = "MUX";
260  instanceConfigs.setConfig(setting, config);
261  if(isExtraMux(setting)){
262  ++p;
263  continue;
264  }
265  }
266  else if(strstr(setting.c_str(),"SYNC_ATTR")!= NULL){
267  affConfigs.setConfig(setting,config);
268  bffConfigs.setConfig(setting,config);
269  cffConfigs.setConfig(setting,config);
270  dffConfigs.setConfig(setting,config);
271  xffConfigs.setConfig(setting,config);
272  yffConfigs.setConfig(setting,config);
273 
274  ++p;
275  continue;
276  }
277  else if((setting == "_INST_PROP") || (setting == "_ROUTETHROUGH")){
278  ++p;
279  continue;
280  }
281  else{
282  typeName = setting;
283  instanceConfigs.setConfig(setting, config);
284  }
285 
286 
287  InstanceSharedPtr newInst = Factory::newInstancePtr(newName, typeName, "",
288  "", instance.getBonding(), newInstanceReferencePtr);
289  if(typeName == "DFF") {
290  if(setting == "AFF")
291  affInstances.push_back(newInst);
292  else if(setting == "BFF")
293  bffInstances.push_back(newInst);
294  else if(setting == "CFF")
295  cffInstances.push_back(newInst);
296  else if(setting == "DFF")
297  dffInstances.push_back(newInst);
298  else if(setting == "FFX")
299  xffInstances.push_back(newInst);
300  else if(setting == "FFY")
301  yffInstances.push_back(newInst);
302  } else if(typeName == "LUT") {
303  if(setting == "A6LUT")
304  alutInstances.push_back(newInst);
305  else if(setting == "B6LUT")
306  blutInstances.push_back(newInst);
307  else if(setting == "C6LUT")
308  clutInstances.push_back(newInst);
309  else if(setting == "D6LUT")
310  dlutInstances.push_back(newInst);
311  else if(setting == "F")
312  xlutInstances.push_back(newInst);
313  else if(setting == "G")
314  ylutInstances.push_back(newInst);
315  } else if((typeName != "INV") && (typeName != "MUX") && (typeName != "AND") && (typeName != "XOR") && (typeName != "WSGEN")) {
316  newInst->setConfig(p->first, config);
317  }
318  newCircuit->addInstance(newInst);
319  p++;
320  }
321 
322  // set flipflop configs if any
323  for(Circuit::InstanceSharedPtrIterator it = affInstances.begin(); it != affInstances.end(); ++it)
324  (*it)->addConfigs(affConfigs);
325  for(Circuit::InstanceSharedPtrIterator it = bffInstances.begin(); it != bffInstances.end(); ++it)
326  (*it)->addConfigs(bffConfigs);
327  for(Circuit::InstanceSharedPtrIterator it = cffInstances.begin(); it != cffInstances.end(); ++it)
328  (*it)->addConfigs(cffConfigs);
329  for(Circuit::InstanceSharedPtrIterator it = dffInstances.begin(); it != dffInstances.end(); ++it)
330  (*it)->addConfigs(dffConfigs);
331  for(Circuit::InstanceSharedPtrIterator it = xffInstances.begin(); it != xffInstances.end(); ++it)
332  (*it)->addConfigs(xffConfigs);
333  for(Circuit::InstanceSharedPtrIterator it = yffInstances.begin(); it != yffInstances.end(); ++it)
334  (*it)->addConfigs(yffConfigs);
335 
336  // set lut configs if any
337  for(Circuit::InstanceSharedPtrIterator it = alutInstances.begin(); it != alutInstances.end(); ++it)
338  (*it)->addConfigs(alutConfigs);
339  for(Circuit::InstanceSharedPtrIterator it = blutInstances.begin(); it != blutInstances.end(); ++it)
340  (*it)->addConfigs(blutConfigs);
341  for(Circuit::InstanceSharedPtrIterator it = clutInstances.begin(); it != clutInstances.end(); ++it)
342  (*it)->addConfigs(clutConfigs);
343  for(Circuit::InstanceSharedPtrIterator it = dlutInstances.begin(); it != dlutInstances.end(); ++it)
344  (*it)->addConfigs(dlutConfigs);
345  for(Circuit::InstanceSharedPtrIterator it = xlutInstances.begin(); it != xlutInstances.end(); ++it)
346  (*it)->addConfigs(xlutConfigs);
347  for(Circuit::InstanceSharedPtrIterator it = ylutInstances.begin(); it != ylutInstances.end(); ++it)
348  (*it)->addConfigs(ylutConfigs);
349 
350  Circuit::NetSharedPtrConstIterator pn = newCircuit->netsBegin();
351  Circuit::NetSharedPtrConstIterator en = newCircuit->netsEnd();
352  while(pn < en){
353  NetSharedPtr netPtr = *pn++;
354  // Change current nets
355 
356  // change the sources
357 
358  Net::InstancePinSharedPtrIterator sop = netPtr->sourcesBegin();
359  while(sop < netPtr->sourcesEnd()){
360 
361  if((*sop)->getInstancePtr().lock()->getName()==instance.getName()){
362  string pinName = (*sop)->getPinName();
363  netPtr->removeSource(*sop);
364  PrimitivePinSharedPtr pinTmp = *primitivePtr->findPrimitivePin(pinName);
365  ElementSharedPtr elementTmp = *primitivePtr->findElement(pinName);
366  Element::ConnectionSharedPtrIterator cb = elementTmp->connectionsBegin();
367  ConnectionPin pinPtr = * (*cb)->getSource();
368  string newName = instance.getName();
369  Config config;
370  instanceConfigs.getConfig(pinPtr.getElementName(), config);
371 
372  if(isExtraMux(pinPtr.getElementName())){
373  ElementSharedPtr muxElement = *primitivePtr->findElement(pinPtr.getElementName());
374  Element::ConnectionSharedPtrIterator cb1 = muxElement->connectionsBegin();
375  Element::ConnectionSharedPtrIterator ce1 = muxElement->connectionsEnd();
376  while(cb1 < ce1){
377  ConnectionPin pinPtr1 = * (*cb1)->getSink();
378  if(pinPtr1.getPinName()== config.getValue()){
379  pinPtr = * (*cb1)->getSource();
380  instanceConfigs.getConfig(pinPtr.getElementName(),config);
381  break;
382  }
383  ++cb1;
384  }
385  }
386  if(!instanceConfigs.hasConfig(pinPtr.getElementName())){
387  ++sop;
388  continue;
389  }
390  newName = newName + ":" + pinPtr.getElementName()+ ":" +config.getName();
391  InstanceSharedPtr instPtr = *newCircuit->findInstance(newName);
392  InstancePinSharedPtr instPin = Factory::newInstancePinPtr (instPtr, pinPtr.getPinName());
393  netPtr->addSource(instPin);
394  sop = netPtr->sourcesBegin();
395  }
396  else
397  ++sop;
398  }
399 
400  // change the sinks
401 
402  Net::InstancePinSharedPtrIterator sip = netPtr->sinksBegin();
403  while(sip != netPtr->sinksEnd()){
404  if((*sip)->getInstancePtr().lock()->getName()==instance.getName()){
405  string pinName = (*sip)->getPinName();
406 
407  netPtr->removeSink(*sip);
408  PrimitivePinSharedPtr pinTmp = *primitivePtr->findPrimitivePin(pinName);
409  ElementSharedPtr elementTmp = *primitivePtr->findElement(pinName);
410  Element::ConnectionSharedPtrIterator cb = elementTmp->connectionsBegin();
411  Element::ConnectionSharedPtrIterator ce = elementTmp->connectionsEnd();
412  while(cb < ce){
413  ConnectionPin pinPtr = * (*cb)->getSink();
414  if(!instanceConfigs.hasConfig(pinPtr.getElementName())){
415  ++cb;
416  continue;
417  }
418 
419  Config config;
420  instanceConfigs.getConfig(pinPtr.getElementName(),config);
421  if(isExtraMux(pinPtr.getElementName()) || (strstr(pinPtr.getElementName().c_str() , "INV")!=NULL && strstr(config.getValue().c_str(), "_B")==NULL)){
422 
423  if(config.getValue() != pinPtr.getPinName()){
424  ++cb;
425  continue;
426  }
427  ElementSharedPtr muxElement = *primitivePtr->findElement(pinPtr.getElementName());
428  Element::ConnectionSharedPtrIterator cb1 = muxElement->connectionsBegin();
429  Element::ConnectionSharedPtrIterator ce1 = muxElement->connectionsEnd();
430  while(cb1 < ce1){
431  ConnectionPin pinPtr1 = * (*cb1)->getSource();
432  if(pinPtr1.getElementName()== muxElement->getName()){
433  pinPtr = * (*cb1)->getSink();
434  if(!instanceConfigs.getConfig(pinPtr.getElementName(),config)){
435  ++cb1;
436  continue;
437  }
438 
439  if(isExtraMux(pinPtr.getElementName()) || (strstr(pinPtr.getElementName().c_str() , "INV")!=NULL && strstr(config.getValue().c_str(), "_B")==NULL)){
440 
441  if(config.getValue() != pinPtr.getPinName()){
442  ++cb1;
443  continue;
444  }
445  muxElement = *primitivePtr->findElement(pinPtr.getElementName());
446  cb1 = muxElement->connectionsBegin();
447  ce1 = muxElement->connectionsEnd();
448  continue;
449  }
450  string newName = instance.getName();
451  newName = newName + ":" + pinPtr.getElementName() + ":" + config.getName();
452 
453  InstanceSharedPtr instPtr = *newCircuit->findInstance(newName);
454  InstancePinSharedPtr instPin = Factory::newInstancePinPtr (instPtr, pinPtr.getPinName());
455  netPtr->addSink(instPin);
456  }
457  ++cb1;
458  }
459  }
460  else{
461 
462  string newName = instance.getName();
463  newName = newName + ":" + pinPtr.getElementName() + ":" + config.getName();
464 
465  InstanceSharedPtr instPtr = *newCircuit->findInstance(newName);
466  InstancePinSharedPtr instPin = Factory::newInstancePinPtr (instPtr, pinPtr.getPinName());
467  netPtr->addSink(instPin);
468  }
469  ++cb;
470  }
471  sip = netPtr->sinksBegin();
472  }
473  else
474  ++sip;
475  }
476 
477  }
478 
479  // add new nets
480  p = instanceConfigs.configBegin();
481  e = instanceConfigs.configEnd();
482  while(p != e) {
483  const std::string& setting = p->first;
484  Config config=p->second;
485  if(isExtraMux(setting)|| (strstr(setting.c_str() , "INV")!=NULL && strstr(config.getValue().c_str(), "_B")==NULL)){
486  ++p;
487  continue;
488  }
489  string instName = instance.getName();
490  instName = instName + ":" + setting + ":" +config.getName();
491 
492  ElementSharedPtr elemPtr = * primitivePtr->findElement(setting);
493  Element::ConnectionSharedPtrIterator cb = elemPtr->connectionsBegin();
494  Element::ConnectionSharedPtrIterator ce = elemPtr->connectionsEnd();
495  while(cb != ce){
496  ConnectionPin srcPtr = * (*cb)->getSource();
497  ConnectionPin sinkPtr = * (*cb)->getSink();
498  if(srcPtr.getElementName() == elemPtr->getName()){
499  string netName = instName;
500  netName += ":" + srcPtr.getPinName();
501  if(instanceConfigs.hasConfig(sinkPtr.getElementName())){
502  if(isExtraMux(sinkPtr.getElementName())){
503  Config config;
504  instanceConfigs.getConfig(sinkPtr.getElementName(),config);
505  if(config.getValue() != sinkPtr.getPinName()){
506  ++cb;
507  continue;
508  }
509  ElementSharedPtr muxElement = *primitivePtr->findElement(sinkPtr.getElementName());
510  Element::ConnectionSharedPtrIterator cb1 = muxElement->connectionsBegin();
511  Element::ConnectionSharedPtrIterator ce1 = muxElement->connectionsEnd();
512  while(cb1 < ce1){
513  ConnectionPin pinPtr1 = * (*cb1)->getSource();
514  if(pinPtr1.getElementName()== muxElement->getName()){
515  sinkPtr = * (*cb1)->getSink();
516  instanceConfigs.getConfig(sinkPtr.getElementName(),config);
517  break;
518  }
519  ++cb1;
520  }
521  }
522  if(isExtraMux(sinkPtr.getElementName())){
523  Config config;
524  instanceConfigs.getConfig(sinkPtr.getElementName(),config);
525  if(config.getValue() != sinkPtr.getPinName()){
526  ++cb;
527  continue;
528  }
529  ElementSharedPtr muxElement = *primitivePtr->findElement(sinkPtr.getElementName());
530  Element::ConnectionSharedPtrIterator cb1 = muxElement->connectionsBegin();
531  Element::ConnectionSharedPtrIterator ce1 = muxElement->connectionsEnd();
532  while(cb1 < ce1){
533  ConnectionPin pinPtr1 = * (*cb1)->getSource();
534  if(pinPtr1.getElementName()== muxElement->getName()){
535  sinkPtr = * (*cb1)->getSink();
536  instanceConfigs.getConfig(sinkPtr.getElementName(),config);
537  break;
538  }
539  ++cb1;
540  }
541  }
542  if(!instanceConfigs.hasConfig(sinkPtr.getElementName())){
543  ++cb;
544  continue;
545  }
546  Circuit::NetSharedPtrIterator netIt = newCircuit->findNet(netName);
547  if(netIt == newCircuit->netsEnd()){
548  NetSharedPtr newNet = Factory::newNetPtr (netName);
549  InstanceSharedPtr instPtr = *newCircuit->findInstance(instName);
550  InstancePinSharedPtr instPin = Factory::newInstancePinPtr (instPtr, srcPtr.getPinName());
551  newNet->addSource(instPin);
552  newCircuit->addNet(newNet);
553  netIt = newCircuit->findNet(netName);
554  }
555  Config config;
556  instanceConfigs.getConfig(sinkPtr.getElementName(),config);
557  string sinkInstName = instance.getName()+":"+sinkPtr.getElementName()+":"+config.getName();
558  InstanceSharedPtr instPtr = *newCircuit->findInstance(sinkInstName);
559  InstancePinSharedPtr instPin = Factory::newInstancePinPtr (instPtr, sinkPtr.getPinName());
560  (*netIt)->addSink(instPin);
561 
562  }
563  }
564  ++cb;
565  }
566  ++p;
567  }
568 
569 
570  return;
571  }
572 
573  InstanceReferenceSharedPtr instanceReferencePtr = instance.getInstanceReferencePtr();
574  InstanceReferenceSharedPtr newInstanceReferencePtr;
575  if(instanceReferencePtr.get() != 0) {
576  const InstanceReference& instanceReference = *instanceReferencePtr;
577  std::string instanceName = instanceReference.getInstancePtr().expired()
578  ? "[expired instance]" : instanceReference.getInstancePtr().lock()->getName();
579  newInstanceReferencePtr = Factory::newInstanceReferencePtr (
580  instanceName, instanceReference.getModulePtr().lock(), instanceReference.getInstancePtr().lock());
581  }
582  string typeName;
583  typeName = instance.getType();
584 
585  InstanceSharedPtr newInst = Factory::newInstancePtr(instance.getName(), typeName, instance.getTile(),
586  instance.getSite(), instance.getBonding(), newInstanceReferencePtr);
587  if(!instance.configIsEmpty())
588  { newInst->addConfigs(static_cast<const ConfigMap&>(instance)); }
589 
590  newCircuit->addInstance(newInst);
591 
592  }
std::vector< InstanceSharedPtr > InstanceSharedPtrVector
Vector of Instance shared pointers.
boost::shared_ptr< Primitive > PrimitiveSharedPtr
Shared pointer encapsulation of a Primitive.
Definition: Primitive.hpp:171
boost::shared_ptr< Element > ElementSharedPtr
Shared pointer encapsulation of a element.
Definition: Element.hpp:119
InstancePinSharedPtrVector::iterator InstancePinSharedPtrIterator
Non-constant iterator to InstancePin shared pointer objects.
static NetSharedPtr newNetPtr(const string &inName, ENetType inNetType=eNetTypeNormal)
Create and return a new Net share pointer.
boost::shared_ptr< class InstancePin > InstancePinSharedPtr
Shared pointer encapsulation of an InstancePin.
std::string string
const_iterator const_iterator
Constant iterator to {setting,Config} pairs.
Definition: ConfigMap.hpp:52
ElementSharedPtrVector::iterator ElementSharedPtrIterator
Non-constant iterator for Element shared pointers.
Definition: Primitive.hpp:55
PrimitiveSetSharedPtr primitives
Definition: XdlUnpack.hpp:85
boost::shared_ptr< Net > NetSharedPtr
Shared pointer encapsulation of a Net.
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.
NetSharedPtrVector::iterator NetSharedPtrIterator
Non-constant iterator to Net shared pointers.
Definition: Circuit.hpp:78
ConnectionSharedPtrVector::iterator ConnectionSharedPtrIterator
Definition: Element.hpp:55
PrimitiveSharedPtrVector::iterator PrimitiveSharedPtrIterator
Non-constant iterator for Primitive shared pointers.
static InstancePinSharedPtr newInstancePinPtr(InstanceSharedPtr inInstancePtr, const string &inPinName)
Construct and return a new InstancePin shared pointer.
boost::shared_ptr< PrimitivePin > PrimitivePinSharedPtr
Shared pointer encapsulation of a componenet.
boost::shared_ptr< InstanceReference > InstanceReferenceSharedPtr
Shared pointer encapsulation of an InstanceReference.
bool isExtraMux(string elem)
Definition: XdlUnpack.hpp:66
NetSharedPtrVector::const_iterator NetSharedPtrConstIterator
Constant iterator to Net shared pointers.
Definition: Circuit.hpp:76
InstanceSharedPtrVector::iterator InstanceSharedPtrIterator
Non-constant iterator to Instance shared pointers.
Definition: Circuit.hpp:74
static InstanceReferenceSharedPtr newInstanceReferencePtr(const string &inInstantiationName, ModuleSharedPtr inModulePtr, InstanceSharedPtr inInstancePtr)
Create and return a new InstanceReference shared pointer.

+ Here is the call graph for this function:

NetSharedPtr torc::physical::XdlUnpack::unpack ( const Net net)

Definition at line 594 of file XdlUnpack.cpp.

594  {
595 
596  NetSharedPtr newNet = Factory::newNetPtr (net.getName(), net.getNetType());
597 
598 
599  size_t left = net.getSourceCount() + net.getSinkCount() + net.getPipCount()
600  + (net.configIsEmpty() ? 0 : 1);
601 
602  // unpack the sources
603  Net::InstancePinSharedPtrConstIterator sop = net.sourcesBegin();
604  Net::InstancePinSharedPtrConstIterator soe = net.sourcesEnd();
605  while(sop < soe){
606  InstancePinSharedPtr instPin = unpack(*sop++, ePinDirectionOutpin, --left > 0);
607  newNet->addSource(instPin);
608  }
609  // unpack the sinks
610  Net::InstancePinSharedPtrConstIterator sip = net.sinksBegin();
611  Net::InstancePinSharedPtrConstIterator sie = net.sinksEnd();
612  while(sip < sie) {
613  InstancePinSharedPtr instPin = unpack(*sip++, ePinDirectionInpin, --left > 0);
614  newNet->addSink(instPin);
615  }
616 
617  // unpack the config string if there is one
618  if(!net.configIsEmpty()) {
619  newNet->addConfigs(static_cast<const ConfigMap&>(net));
620  }
621  return newNet;
622  }
static NetSharedPtr newNetPtr(const string &inName, ENetType inNetType=eNetTypeNormal)
Create and return a new Net share pointer.
boost::shared_ptr< class InstancePin > InstancePinSharedPtr
Shared pointer encapsulation of an InstancePin.
boost::shared_ptr< Net > NetSharedPtr
Shared pointer encapsulation of a Net.
void unpack(const Circuit &circuit, CircuitSharedPtr newCircuit)
Definition: XdlUnpack.cpp:35
InstancePinSharedPtrVector::const_iterator InstancePinSharedPtrConstIterator
Constant iterator to InstancePin shared pointer objects.

+ Here is the call graph for this function:

InstancePinSharedPtr torc::physical::XdlUnpack::unpack ( const InstancePinSharedPtr  instancePin,
EPinDirection  pinDirection,
bool  comma 
)

Definition at line 624 of file XdlUnpack.cpp.

625  {
626 
627  InstancePinSharedPtr instPin = Factory::newInstancePinPtr (instancePinSharedPtr->getInstancePtr().lock(), instancePinSharedPtr->getPinName());
628  return instPin;
629  }
boost::shared_ptr< class InstancePin > InstancePinSharedPtr
Shared pointer encapsulation of an InstancePin.
static InstancePinSharedPtr newInstancePinPtr(InstanceSharedPtr inInstancePtr, const string &inPinName)
Construct and return a new InstancePin shared pointer.

+ Here is the call graph for this function:

Pip torc::physical::XdlUnpack::unpack ( const Pip pip,
bool  comma 
)

Definition at line 631 of file XdlUnpack.cpp.

631  {
632  RoutethroughSharedPtr newRoutethrough;
633  if(pip.isRoutethrough())
634  newRoutethrough = unpack(*pip.getRoutethroughPtr());
635  else
636  newRoutethrough = RoutethroughSharedPtr();
637  Pip newPip = Factory::newPip(pip.getTileName(), pip.getSourceWireName(), pip.getSinkWireName(), pip.getDirection(), RoutethroughSharedPtr());
638 
639  return newPip;
640  }
static torc::physical::Pip newPip(const string &inTileName, const string &inSourceWireName, const string &inSinkWireName, EPipDirection inPipDirection, RoutethroughSharedPtr inRoutethroughPtr=RoutethroughSharedPtr())
Construct a pip and return it.
void unpack(const Circuit &circuit, CircuitSharedPtr newCircuit)
Definition: XdlUnpack.cpp:35
boost::shared_ptr< Routethrough > RoutethroughSharedPtr
Shared pointer encapsulation of a Routethrough.

+ Here is the call graph for this function:

RoutethroughSharedPtr torc::physical::XdlUnpack::unpack ( const Routethrough routethrough)

Definition at line 642 of file XdlUnpack.cpp.

642  {
644  routethrough.getSetting(), routethrough.getName(), routethrough.getValue(), routethrough.getInstancePtr(),
645  routethrough.getSourceWireName(), routethrough.getSinkWireName());
646  return newRoutethrough;
647  }
boost::shared_ptr< Routethrough > RoutethroughSharedPtr
Shared pointer encapsulation of a Routethrough.
static RoutethroughSharedPtr newRoutethroughPtr(const string &inSetting, const string &inName, const string &inValue, const InstanceWeakPtr &inInstancePtr, const string &inSourceWireName, const string &inSinkWireName)
Construct and return a new Routethrough shared pointer.

+ Here is the call graph for this function:

Field Documentation

PrimitiveSetSharedPtr torc::physical::XdlUnpack::primitives
protected

Definition at line 85 of file XdlUnpack.hpp.


The documentation for this class was generated from the following files: