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

Physical design exporter for XDL. More...

#include <XdlExporter.hpp>

+ Collaboration diagram for torc::physical::XdlExporter:

Public Member Functions

 XdlExporter (std::ostream &inStream, const std::string &inIndentString="\t")
 Public constructor. More...
 
void operator() (const DesignSharedPtr &inDesignPtr)
 Top level design exporter operator. More...
 
void write (const Circuit &circuit)
 Writes the given Circuit. More...
 
void write (const Design &design)
 Writes the given Design. More...
 
void write (const Module &module)
 Writes the given Module. More...
 
void write (const Port &port)
 Writes the given Port. More...
 
void write (const Instance &instance)
 Writes the given Instance. More...
 
void write (const Net &net)
 Writes the given Net. More...
 
void write (const InstancePin &instancePin, EPinDirection pinDirection, bool comma)
 Writes the given InstancePin, with an optional trailing comma. More...
 
void write (const Pip &pip, bool comma)
 Writes the given pip, with an options trailing comma. More...
 
void write (const Routethrough &routethrough)
 Writes the given Routethrough. More...
 
void write (const ConfigMap &configMap)
 Writes the given ConfigMap. More...
 

Private Member Functions

void indent (void) const
 Indent the current line. More...
 

Private Attributes

std::ostream & mStream
 The output stream. More...
 
int mIndentCount
 The indent count. More...
 
std::string mIndentString
 The indent string. More...
 

Detailed Description

Physical design exporter for XDL.

Definition at line 31 of file XdlExporter.hpp.

Constructor & Destructor Documentation

torc::physical::XdlExporter::XdlExporter ( std::ostream &  inStream,
const std::string &  inIndentString = "\t" 
)
inline

Public constructor.

Parameters
inStreamThe output stream.
inIndentStringThe indent string. The default parameter uses a single tab.

Definition at line 48 of file XdlExporter.hpp.

49  : mStream(inStream), mIndentCount(0), mIndentString(inIndentString) {}
std::ostream & mStream
The output stream.
Definition: XdlExporter.hpp:34
int mIndentCount
The indent count.
Definition: XdlExporter.hpp:36
std::string mIndentString
The indent string.
Definition: XdlExporter.hpp:38

Member Function Documentation

void torc::physical::XdlExporter::indent ( void  ) const
inlineprivate

Indent the current line.

Definition at line 41 of file XdlExporter.hpp.

42  { int count = mIndentCount; while(count--) mStream << mIndentString; }
std::ostream & mStream
The output stream.
Definition: XdlExporter.hpp:34
int mIndentCount
The indent count.
Definition: XdlExporter.hpp:36
std::string mIndentString
The indent string.
Definition: XdlExporter.hpp:38

+ Here is the caller graph for this function:

void torc::physical::XdlExporter::operator() ( const DesignSharedPtr inDesignPtr)

Top level design exporter operator.

Todo:
Acquire mutex.
Todo:
Release mutex.

Definition at line 25 of file XdlExporter.cpp.

25  {
26  // std::cout << "Design " << inDesignPtr->getName() << std::endl;
27  // std::cout << " module count: " << inDesignPtr->getModuleCount() << std::endl;
28  // std::cout << " instance count: " << inDesignPtr->getInstanceCount() << std::endl;
29  // std::cout << " net count: " << inDesignPtr->getNetCount() << std::endl;
30 
31  /// \todo Acquire mutex.
32 
33  // export the design statement
34  DesignSharedPtr designPtr(inDesignPtr);
35  const Design& design = *designPtr;
36  write(design);
37 
38  /// \todo Release mutex.
39  }
void write(const Circuit &circuit)
Writes the given Circuit.
Definition: XdlExporter.cpp:41
boost::shared_ptr< Design > DesignSharedPtr
Shared pointer encapsulation of a Design.

+ Here is the call graph for this function:

void torc::physical::XdlExporter::write ( const Circuit circuit)

Writes the given Circuit.

Definition at line 41 of file XdlExporter.cpp.

41  {
42  // export the instances
43  Circuit::InstanceSharedPtrConstIterator pi = circuit.instancesBegin();
44  Circuit::InstanceSharedPtrConstIterator ei = circuit.instancesEnd();
45  while(pi < ei) write(**pi++);
46 
47  // export the nets
48  Circuit::NetSharedPtrConstIterator pn = circuit.netsBegin();
49  Circuit::NetSharedPtrConstIterator en = circuit.netsEnd();
50  while(pn < en) write(**pn++);
51  }
void write(const Circuit &circuit)
Writes the given Circuit.
Definition: XdlExporter.cpp:41
InstanceSharedPtrVector::const_iterator InstanceSharedPtrConstIterator
Constant iterator to Instance shared pointers.
Definition: Circuit.hpp:72
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:

void torc::physical::XdlExporter::write ( const Design design)

Writes the given Design.

Definition at line 53 of file XdlExporter.cpp.

53  {
54  indent();
55  mStream << "design \"" << design.getName() << "\" " << design.getDevice()
56  << design.getPackage() << design.getSpeedGrade() << " " << design.getXdlVersion();
57  if(!design.configIsEmpty())
58  { mStream << ", "; write(static_cast<const ConfigMap&>(design)); }
59  mStream << ";" << std::endl;
60  // export the modules
61  Design::ModuleSharedPtrConstIterator p = design.modulesBegin();
62  Design::ModuleSharedPtrConstIterator e = design.modulesEnd();
63  while(p < e) write(**p++);
64  // export the instances and nets
65  write(static_cast<Circuit>(design));
66 
67  }
void write(const Circuit &circuit)
Writes the given Circuit.
Definition: XdlExporter.cpp:41
std::ostream & mStream
The output stream.
Definition: XdlExporter.hpp:34
ModuleSharedPtrVector::const_iterator ModuleSharedPtrConstIterator
Constant iterator for Module shared pointers.
void indent(void) const
Indent the current line.
Definition: XdlExporter.hpp:41

+ Here is the call graph for this function:

void torc::physical::XdlExporter::write ( const Module module)

Writes the given Module.

Definition at line 69 of file XdlExporter.cpp.

69  {
70  indent();
71  mStream << "module \"" << module.getName() << "\" \"" << module.getAnchor() << "\"";
72  if(!module.configIsEmpty())
73  { mStream << ", "; write(static_cast<const ConfigMap&>(module)); }
74  mStream << ";" << std::endl;
75  // increment the indent
76  mIndentCount++;
77  // export the ports
78  Module::PortSharedPtrConstIterator p = module.portsBegin();
79  Module::PortSharedPtrConstIterator e = module.portsEnd();
80  while(p < e) write(**p++);
81  // export the instances and nets
82  write(static_cast<Circuit>(module));
83  // decrement the indent
84  mIndentCount--;
85  // close out the module
86  indent();
87  mStream << "endmodule \"" << module.getName() << "\";" << std::endl;
88  }
PortSharedPtrVector::const_iterator PortSharedPtrConstIterator
Constant iterator to Port shared pointers.
Definition: Module.hpp:55
void write(const Circuit &circuit)
Writes the given Circuit.
Definition: XdlExporter.cpp:41
std::ostream & mStream
The output stream.
Definition: XdlExporter.hpp:34
void indent(void) const
Indent the current line.
Definition: XdlExporter.hpp:41
int mIndentCount
The indent count.
Definition: XdlExporter.hpp:36

+ Here is the call graph for this function:

void torc::physical::XdlExporter::write ( const Port port)

Writes the given Port.

Definition at line 90 of file XdlExporter.cpp.

90  {
91  indent();
92  std::string instanceName = port.getInstancePtr().expired()
93  ? "[expired instance]" : port.getInstancePtr().lock()->getName();
94  mStream << "port \"" << port.getName() << "\" \"" << instanceName << "\" \""
95  << port.getPinName() << "\";" << std::endl;
96  }
std::ostream & mStream
The output stream.
Definition: XdlExporter.hpp:34
std::string string
void indent(void) const
Indent the current line.
Definition: XdlExporter.hpp:41

+ Here is the call graph for this function:

void torc::physical::XdlExporter::write ( const Instance instance)

Writes the given Instance.

Definition at line 117 of file XdlExporter.cpp.

117  {
118  indent();
119  mStream << "inst \"" << instance.getName() << "\" \"" << instance.getType() << "\", ";
120  const std::string& site = instance.getSite();
121  std::string tile = instance.getTile();
122  EInstanceBonding bonding = instance.getBonding();
123  if(site.empty()) {
124  mStream << "unplaced";
125  // bonding may be specified for unplaced IOBs, but is ignored for unplaced instances of
126  // other types, and is illegal for placed instances of any type
127  if(bonding != eInstanceBondingUnknown) {
128  mStream << " " << (bonding == eInstanceBondingUnbonded ? "unbonded" : "bonded");
129  }
130  } else {
131  if(tile.empty()) tile = "unknown";
132  mStream << "placed " << tile << " " << site;
133  }
134  InstanceReferenceSharedPtr instanceReferencePtr = instance.getInstanceReferencePtr();
135  if(instanceReferencePtr.get() != 0) {
136  const InstanceReference& instanceReference = *instanceReferencePtr;
137  std::string moduleName = instanceReference.getModulePtr().expired()
138  ? "[expired module]" : instanceReference.getModulePtr().lock()->getName();
139  std::string instanceName = instanceReference.getInstancePtr().expired()
140  ? "[expired instance]" : instanceReference.getInstancePtr().lock()->getName();
141  mStream << ", module \"" << instanceReference.getInstantiationName() << "\" \""
142  << moduleName << "\" \"" << instanceName << "\"";
143  }
144  if(!instance.configIsEmpty())
145  { mStream << ", "; write(static_cast<const ConfigMap&>(instance)); }
146  mStream << ";" << std::endl;
147  }
EInstanceBonding
Enumeration of pad bonding types.
void write(const Circuit &circuit)
Writes the given Circuit.
Definition: XdlExporter.cpp:41
std::ostream & mStream
The output stream.
Definition: XdlExporter.hpp:34
std::string string
void indent(void) const
Indent the current line.
Definition: XdlExporter.hpp:41
boost::shared_ptr< InstanceReference > InstanceReferenceSharedPtr
Shared pointer encapsulation of an InstanceReference.

+ Here is the call graph for this function:

void torc::physical::XdlExporter::write ( const Net net)

Writes the given Net.

Definition at line 149 of file XdlExporter.cpp.

149  {
150  indent();
151  // write the header
152  mStream << "net \"" << net.getName() << "\"";
153  switch(net.getNetType()) {
154  case eNetTypePower: mStream << " power"; break;
155  case eNetTypeGround: mStream << " ground"; break;
156  default: break;
157  }
158  size_t left = net.getSourceCount() + net.getSinkCount() + net.getPipCount()
159  + (net.configIsEmpty() ? 0 : 1);
160  bool empty = (left == 0);
161  mStream << (empty ? "" : ",") << std::endl;
162  // write the sources
163  Net::InstancePinSharedPtrConstIterator sop = net.sourcesBegin();
164  Net::InstancePinSharedPtrConstIterator soe = net.sourcesEnd();
165  while(sop < soe) write(**sop++, ePinDirectionOutpin, --left > 0);
166  // write the sinks
167  Net::InstancePinSharedPtrConstIterator sip = net.sinksBegin();
168  Net::InstancePinSharedPtrConstIterator sie = net.sinksEnd();
169  while(sip < sie) write(**sip++, ePinDirectionInpin, --left > 0);
170  // write the pips
171  Net::PipConstIterator pip = net.pipsBegin();
172  Net::PipConstIterator pie = net.pipsEnd();
173  while(pip < pie) write(*pip++, --left > 0);
174  // write the config string if there is one
175  if(!net.configIsEmpty()) {
176  indent();
178  write(static_cast<const ConfigMap&>(net));
179  mStream << std::endl;
180  }
181  // indent before the closing semicolon if the net was not completely empty
182  if(!empty) { indent(); mStream << mIndentString; }
183  mStream << ";" << std::endl;
184  }
void write(const Circuit &circuit)
Writes the given Circuit.
Definition: XdlExporter.cpp:41
std::ostream & mStream
The output stream.
Definition: XdlExporter.hpp:34
PipVector::const_iterator PipConstIterator
Constant iterator to Pip objects.
void indent(void) const
Indent the current line.
Definition: XdlExporter.hpp:41
InstancePinSharedPtrVector::const_iterator InstancePinSharedPtrConstIterator
Constant iterator to InstancePin shared pointer objects.
std::string mIndentString
The indent string.
Definition: XdlExporter.hpp:38

+ Here is the call graph for this function:

void torc::physical::XdlExporter::write ( const InstancePin instancePin,
EPinDirection  pinDirection,
bool  comma 
)

Writes the given InstancePin, with an optional trailing comma.

Definition at line 186 of file XdlExporter.cpp.

187  {
188  indent();
189  std::string instanceName = instancePin.getInstancePtr().expired()
190  ? "[expired instance]" : instancePin.getInstancePtr().lock()->getName();
191  mStream << mIndentString << (pinDirection == ePinDirectionInpin ? "inpin" : "outpin")
192  << " \"" << instanceName << "\" " << instancePin.getPinName() << (comma ? "," : "")
193  << std::endl;
194  }
std::ostream & mStream
The output stream.
Definition: XdlExporter.hpp:34
std::string string
void indent(void) const
Indent the current line.
Definition: XdlExporter.hpp:41
std::string mIndentString
The indent string.
Definition: XdlExporter.hpp:38

+ Here is the call graph for this function:

void torc::physical::XdlExporter::write ( const Pip pip,
bool  comma 
)

Writes the given pip, with an options trailing comma.

Definition at line 196 of file XdlExporter.cpp.

196  {
197  indent();
199  << "pip " << pip.getTileName() << " " << pip.getSourceWireName()
200  << " " << pip.getDirectionString() << " " << pip.getSinkWireName()
201  << (comma ? "," : "");
202  if(pip.isRoutethrough()) write(*pip.getRoutethroughPtr());
203  mStream << std::endl;
204  }
void write(const Circuit &circuit)
Writes the given Circuit.
Definition: XdlExporter.cpp:41
std::ostream & mStream
The output stream.
Definition: XdlExporter.hpp:34
void indent(void) const
Indent the current line.
Definition: XdlExporter.hpp:41
std::string mIndentString
The indent string.
Definition: XdlExporter.hpp:38

+ Here is the call graph for this function:

void torc::physical::XdlExporter::write ( const Routethrough routethrough)

Writes the given Routethrough.

Definition at line 206 of file XdlExporter.cpp.

206  {
207  std::string instanceName = routethrough.getInstancePtr().expired()
208  ? "[expired instance]" : routethrough.getInstancePtr().lock()->getName();
209  mStream << " # " << routethrough.getSetting() << ":" << routethrough.getName() << ":"
210  << routethrough.getValue() << " \"" << instanceName << "\" "
211  << routethrough.getSourceWireName() << " -> " << routethrough.getSinkWireName();
212  }
std::ostream & mStream
The output stream.
Definition: XdlExporter.hpp:34
std::string string

+ Here is the call graph for this function:

void torc::physical::XdlExporter::write ( const ConfigMap configMap)

Writes the given ConfigMap.

Definition at line 98 of file XdlExporter.cpp.

98  {
99  // nothing to do if the configMap is empty
100  if(configMap.configIsEmpty()) return;
101  // write the config keyword and double quotes
102  mStream << "cfg \"";
103  // iterate through the config settings
104  ConfigMap::const_iterator p = configMap.configBegin();
105  ConfigMap::const_iterator e = configMap.configEnd();
106  while(p != e) {
107  const std::string& setting = p->first;
108  const Config& config = p->second;
109  mStream << setting << ":" << config.getName() << ":" << config.getValue();
110  p++;
111  if(p != e) mStream << " ";
112  }
113  // close the double quotes
114  mStream << "\"";
115  }
std::ostream & mStream
The output stream.
Definition: XdlExporter.hpp:34
std::string string
const_iterator const_iterator
Constant iterator to {setting,Config} pairs.
Definition: ConfigMap.hpp:52

+ Here is the call graph for this function:

Field Documentation

int torc::physical::XdlExporter::mIndentCount
private

The indent count.

Definition at line 36 of file XdlExporter.hpp.

std::string torc::physical::XdlExporter::mIndentString
private

The indent string.

Definition at line 38 of file XdlExporter.hpp.

std::ostream& torc::physical::XdlExporter::mStream
private

The output stream.

Definition at line 34 of file XdlExporter.hpp.


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