torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
XdlUnpack.cpp
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 #include "XdlUnpack.hpp"
17 #include "RcFactory.hpp"
18 #include <iostream>
19 
20 namespace torc {
21 namespace physical {
22 
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  }
34 
35  void XdlUnpack::unpack(const Circuit& circuit, CircuitSharedPtr newCircuit ) {
36 
37  // export the nets
40  while(pn < en){
41  NetSharedPtr netPtr = unpack(**pn++);
42  newCircuit->addNet(netPtr);
43  }
44 
45  // export the instances
48  while(pi < ei) {
49  unpack(**pi++, newCircuit);
50  }
51  }
52 
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
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  }
83 
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
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  }
104 
106  InstanceSharedPtr instPtr = port.getInstancePtr().lock();
107  PortSharedPtr newPort = Factory::newPortPtr (port.getName(), instPtr, port.getPinName());
108  return newPort;
109  }
110 
111  void XdlUnpack::unpack(Instance& instance, CircuitSharedPtr newCircuit) {
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  }
593 
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
605  while(sop < soe){
606  InstancePinSharedPtr instPin = unpack(*sop++, ePinDirectionOutpin, --left > 0);
607  newNet->addSource(instPin);
608  }
609  // unpack the sinks
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  }
623 
625  bool comma) {
626 
627  InstancePinSharedPtr instPin = Factory::newInstancePinPtr (instancePinSharedPtr->getInstancePtr().lock(), instancePinSharedPtr->getPinName());
628  return instPin;
629  }
630 
631  Pip XdlUnpack::unpack(const Pip& pip, bool comma) {
632  RoutethroughSharedPtr newRoutethrough;
633  if(pip.isRoutethrough())
634  newRoutethrough = unpack(*pip.getRoutethroughPtr());
635  else
636  newRoutethrough = RoutethroughSharedPtr();
638 
639  return newPip;
640  }
641 
644  routethrough.getSetting(), routethrough.getName(), routethrough.getValue(), routethrough.getInstancePtr(),
645  routethrough.getSourceWireName(), routethrough.getSinkWireName());
646  return newRoutethrough;
647  }
648 
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  }
672 
673 } // namespace physical
674 } // namespace torc
675 
InstancePinSharedPtrConstIterator sinksBegin(void) const
Returns the begin constant iterator for sink instance pins.
void setConfig(const string &inSetting, const Config &inConfig)
Sets the configuration for the given setting.
Definition: ConfigMap.hpp:119
const WireName & getSinkWireName(void) const
Returns the instance sink wire name.
size_t getPipCount(void) const
Returns the number of pips on the net.
InstancePinSharedPtrConstIterator sourcesEnd(void) const
Returns the end constant iterator for source instance pins.
std::vector< InstanceSharedPtr > InstanceSharedPtrVector
Vector of Instance shared pointers.
static PortSharedPtr newPortPtr(const string &inName, InstanceSharedPtr inInstancePtr, const string &inPinName)
Create and return a new Port shared pointer.
PortSharedPtrConstIterator portsEnd(void) const
Returns the end constant iterator for ports.
Definition: Module.hpp:98
void readPrimitives(const char *fileName)
Definition: XdlUnpack.hpp:59
const string & getSetting(void) const
Returns the _ROUTETHROUGH setting.
InstanceReferenceSharedPtr getInstanceReferencePtr(void) const
Returns the instance reference for this instance, if any.
ENetType getNetType(void) const
Returns the net power type. See ENetPowerType.
InstancePinSharedPtrConstIterator sinksEnd(void) const
Returns the end constant iterator for sink instance pins.
const string & getType(void) const
Returns the logic type for this instance.
PortSharedPtrVector::const_iterator PortSharedPtrConstIterator
Constant iterator to Port shared pointers.
Definition: Module.hpp:55
Header for the RcFactory class.
boost::shared_ptr< Primitive > PrimitiveSharedPtr
Shared pointer encapsulation of a Primitive.
Definition: Primitive.hpp:171
bool getConfig(const string &inSetting, Config &outConfig)
Looks up the specified setting in the map.
Definition: ConfigMap.hpp:82
boost::shared_ptr< Port > PortSharedPtr
Shared pointer encapsulation of a Port.
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.
InstanceSharedPtrVector::const_iterator InstanceSharedPtrConstIterator
Constant iterator to Instance shared pointers.
Definition: Circuit.hpp:72
static NetSharedPtr newNetPtr(const string &inName, ENetType inNetType=eNetTypeNormal)
Create and return a new Net share pointer.
Physical netlist design.
Physical design connection-pin pair, suitable for specifying a net endpoint.
const string & getSite(void) const
Returns the placement site for this instance.
PortSharedPtrConstIterator portsBegin(void) const
Returns the begin constant iterator for ports.
Definition: Module.hpp:96
const string & getAnchor(void) const
Returns the anchor instance name for this module.
Definition: Module.hpp:91
ModuleSharedPtrVector::const_iterator ModuleSharedPtrConstIterator
Constant iterator for Module shared pointers.
const PinName & getPinName(void) const
Returns the pin name.
size_t getSinkCount(void) const
Returns the number of sinks on the net.
const ModuleWeakPtr & getModulePtr(void) const
Returns the weak module pointer.
boost::shared_ptr< class InstancePin > InstancePinSharedPtr
Shared pointer encapsulation of an InstancePin.
ModuleSharedPtrConstIterator modulesEnd(void) const
Returns the end constant iterator for modules.
InstancePinSharedPtrConstIterator sourcesBegin(void) const
Returns the begin constant iterator for source instance pins.
const InstanceWeakPtr & getInstancePtr(void) const
Returns the weak instance pointer.
std::string string
const_iterator const_iterator
Constant iterator to {setting,Config} pairs.
Definition: ConfigMap.hpp:52
ModuleSharedPtrConstIterator modulesBegin(void) const
Returns the begin constant iterator for modules.
boost::shared_ptr< Module > ModuleSharedPtr
Shared pointer encapsulation of a Module.
Definition: Module.hpp:114
DesignSharedPtr operator()(const DesignSharedPtr &inDesignPtr)
Definition: XdlUnpack.cpp:23
const_iterator configBegin(void) const
Returns the begin constant iterator for configurations.
Definition: ConfigMap.hpp:58
const WireName & getSinkWireName(void) const
Returns the pip sink wire.
Definition: Pip.hpp:77
ElementSharedPtrVector::iterator ElementSharedPtrIterator
Non-constant iterator for Element shared pointers.
Definition: Primitive.hpp:55
Physical design instance.
Configuration. A {name:value} pair.
Definition: Config.hpp:39
const string elementNames
Definition: XdlUnpack.hpp:32
PrimitiveSetSharedPtr primitives
Definition: XdlUnpack.hpp:85
Physical design net.
NetSharedPtrConstIterator netsEnd(void) const
Returns the end constant iterator for nets.
Definition: Circuit.hpp:209
void removeExtraElements(PrimitiveSharedPtr primPtr)
removes extra elements that are needed for unpacking
Definition: XdlUnpack.cpp:649
bool hasConfig(const string &inSetting) const
Returns true if the specified setting exists in the map.
Definition: ConfigMap.hpp:69
RoutethroughSharedPtr getRoutethroughPtr(void) const
Returns the pip's routethrough pointer.
Definition: Pip.hpp:83
size_t getSourceCount(void) const
Returns the number of sources on the net.
const string & getName(void) const
Returns the object name.
Definition: Named.hpp:51
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.
boost::shared_ptr< Net > NetSharedPtr
Shared pointer encapsulation of a Net.
boost::shared_ptr< Circuit > CircuitSharedPtr
Shared pointer encapsulation of a Circuit.
Definition: Circuit.hpp:219
const WireName & getSourceWireName(void) const
Returns the instance source wire name.
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.
const string & getValue(void) const
Return the configuration value.
Definition: Config.hpp:86
boost::shared_ptr< Instance > InstanceSharedPtr
Shared pointer encapsulation of an Instance.
void unpack(const Circuit &circuit, CircuitSharedPtr newCircuit)
Definition: XdlUnpack.cpp:35
boost::shared_ptr< Design > DesignSharedPtr
Shared pointer encapsulation of a Design.
InstancePinSharedPtrVector::const_iterator InstancePinSharedPtrConstIterator
Constant iterator to InstancePin shared pointer objects.
NetSharedPtrVector::iterator NetSharedPtrIterator
Non-constant iterator to Net shared pointers.
Definition: Circuit.hpp:78
const PinName & getPinName(void) const
Returns the pin name.
const TileName & getTileName(void) const
Returns the pip tile.
Definition: Pip.hpp:73
EPipDirection getDirection(void) const
Returns the pip directionality.
Definition: Pip.hpp:79
const string & getTile(void) const
Returns the placement tile for this instance.
Physical design programmable interconnect point.
Definition: Pip.hpp:34
const WireName & getSourceWireName(void) const
Returns the pip source wire.
Definition: Pip.hpp:75
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.
ConnectionSharedPtrVector::iterator ConnectionSharedPtrIterator
Definition: Element.hpp:55
Configuration setting map.
Definition: ConfigMap.hpp:39
const string & getXdlVersion(void) const
Returns the XDL version for this design.
bool configIsEmpty(void) const
Returns true if the configuration map is empty.
Definition: ConfigMap.hpp:65
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.
const string & getElementName(void) const
Returns the element pointer or NULL.
static ModuleSharedPtr newModulePtr(const string &inName, const string &inAnchor)
Create and return a new Module shared pointer.
Module input or output port.
boost::shared_ptr< PrimitivePin > PrimitivePinSharedPtr
Shared pointer encapsulation of a componenet.
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.
const InstanceWeakPtr & getInstancePtr(void) const
Returns a weak instance pointer.
const string & getDevice(void) const
Returns the target device for this design.
Instantiation of a module instance.
EInstanceBonding getBonding(void) const
Returns the IO bonding for this instance.
Circuit composed of instances and nets.
Definition: Circuit.hpp:46
Hierarchical module.
Definition: Module.hpp:33
const_iterator configEnd(void) const
Returns the end constant iterator for configurations.
Definition: ConfigMap.hpp:60
InstanceSharedPtrConstIterator instancesBegin(void) const
Returns the begin constant iterator for instances.
Definition: Circuit.hpp:197
boost::shared_ptr< InstanceReference > InstanceReferenceSharedPtr
Shared pointer encapsulation of an InstanceReference.
EPinDirection
Enumeration of instance pin directionality.
bool isExtraMux(string elem)
Definition: XdlUnpack.hpp:66
NetSharedPtrVector::const_iterator NetSharedPtrConstIterator
Constant iterator to Net shared pointers.
Definition: Circuit.hpp:76
bool isRoutethrough(void) const
Indicates whether or not the pip has an associated routethrough.
Definition: Pip.hpp:86
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.
NetSharedPtrConstIterator netsBegin(void) const
Returns the begin constant iterator for nets.
Definition: Circuit.hpp:207
const InstanceWeakPtr & getInstancePtr(void) const
Returns the instance weak pointer.
InstanceSharedPtrConstIterator instancesEnd(void) const
Returns the end constant iterator for instances.
Definition: Circuit.hpp:199