torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Decompiler.hpp
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 #ifndef TORC_GENERIC_EDIF_DECOMPILER_HPP
17 #define TORC_GENERIC_EDIF_DECOMPILER_HPP
18 
19 #include <iostream>
20 
22 #include "torc/generic/Error.hpp"
26 
27 namespace torc {
28 namespace generic {
29 
30 /**
31  * This class generates an EDIF 2 0 0 file from an existing class hierarchy. It writes to a stream,
32  * so this can be used to write to any stream including string streams.
33  */
34 class Decompiler : public ObjectVisitor {
35 public:
36  void visit(Root& inroot) throw (Error);
37 
38  void visit(Design& inDesign) throw (Error);
39 
40  void visit(Library& inlibrary) throw (Error);
41 
42  void visit(Cell& incell) throw (Error);
43 
44  void visit(View& inview) throw (Error);
45 
46  void visit(ScalarPort& inscalarPort) throw (Error);
47 
48  void visit(VectorPort& invectorPort) throw (Error);
49 
50  void visit(VectorPortBit& inportBit) throw (Error);
51 
52  void visit(PortBundle& inportBundle) throw (Error);
53 
54  void visit(ScalarNet& inscalarNet) throw (Error);
55 
56  void visit(VectorNet& invectorNet) throw (Error);
57 
58  void visit(VectorNetBit& innetBit) throw (Error);
59 
60  void visit(NetBundle& innetBundle) throw (Error);
61 
62  void visit(SingleInstance& insingleInstance) throw (Error);
63 
64  void visit(InstanceArray& ininstanceArray) throw (Error);
65 
66  void visit(InstanceArrayMember& ininstanceArray) throw (Error);
67 
68  void visit(ScalarPortReference& inScalarPortRef) throw (Error);
69 
70  void visit(VectorPortReference& inVectorPortRef) throw (Error);
71 
72  void visit(VectorPortBitReference& inVectorPortBitRef) throw (Error);
73 
74  void visit(PortBundleReference& inPortBundleRef) throw (Error);
75 
76  void visit(SingleParameter& insingleParameter) throw (Error);
77 
78  void visit(ParameterArray& inparamArray) throw (Error);
79 
80  void visit(ParameterArrayElement& inParamArrayElement) throw (Error);
81 
82  void visit(Property& inProperty) throw (Error);
83 
84  void visit(PortList& inPortList) throw (Error);
85 
86  void visit(PortListAlias& inPortListAlias) throw (Error);
87 
88  void visit(Status& inStatus) throw (Error);
89 
90  void visit(Permutable& inPermutable) throw (Error);
91 
92  void visit(InterfaceJoinedInfo& inInterfaceJoinedInfo) throw (Error);
93 
94  void visit(SimulationInfo& simuInfo) throw (Error);
95 
96  void visit(Simulate& simulate) throw (Error);
97 
98  void visit(Apply& apply) throw (Error);
99 
100  void visit(LogicalResponse& logicalResponse) throw (Error);
101 
102  void visit(LogicValue& logicVal) throw (Error);
103 
104  void visit(LogicElement& logicElement) throw (Error);
105 
106  void visit(WaveValue& waveValue) throw (Error);
107 
108  void visit(Timing& timing) throw (Error);
109 
110  void visit(Event& event) throw (Error);
111 
112  void visit(ForbiddenEvent& forbiddenevent) throw (Error);
113 
114  void printValueType(const Value& value) throw (Error);
115 
116  void printValue(const Value& value) throw (Error);
117 
118  void printUnit(const Unit unit) throw (Error);
119 
120  void printDerivation(const Derivation derivation) throw (Error);
121 
122  void printArray(const std::vector<size_t>& outVector, size_t depth,
123  std::vector<ParameterSharedPtr>::iterator& itStart,
124  std::vector<ParameterSharedPtr>::iterator& itEnd) throw (Error);
125 
126  void printPortAttributes(const PortAttributesSharedPtr& inAttrib) throw (Error);
127 
128  void printNetAttributes(const NetAttributesSharedPtr& inAttrib) throw (Error);
129 
131 
132  void printLogicValueAttributes(const LogicValueAttributesSharedPtr& inAttrib) throw (Error);
133 
134  void printUserData(std::list<std::string> inElements) throw (Error);
135 
136  void printComments(std::vector<std::string>& inElements) throw (Error);
137  /**
138  * Convenience wrapper function to call decompile()
139  */
140  void operator()() throw (Error);
141 
142  /**
143  * Decompile the tree.
144  *
145  * @param[in] root Root of the OM tree.
146  */
147  void decompile() throw (Error);
148 
149  inline size_t getIndentation() const;
150 
151  void setIndentation(size_t inIndentation);
152 
153  Decompiler(const RootSharedPtr& inRoot, std::ostream& outStream = std::cout);
154 
155  Decompiler(const Decompiler& inSource);
156 
157  ~Decompiler() throw ();
158 
159  Decompiler& operator=(const Decompiler& inSource);
160 
161 private:
163  std::ostream& mOut;
169  size_t mIndentation;
171 };
172 
173 inline size_t Decompiler::getIndentation() const {
174  return mIndentation;
175 }
176 
177 } // namespace generic
178 } // namespace torc
179 
180 #endif // TORC_GENERIC_EDIF_DECOMPILER_HPP
Represents an EDIF cell.
Definition: Cell.hpp:55
Represents a bit of a net array.
Represents areference to a standalone port.
void setIndentation(size_t inIndentation)
Represents a reference to a port array.
void printUserData(std::list< std::string > inElements)
This class is used within simulate to describe input stimuli and expected responces over a certain ti...
Definition: Apply.hpp:37
Represents a bundle of ports.
Definition: PortBundle.hpp:44
boost::shared_ptr< NetAttributes > NetAttributesSharedPtr
Represents and EDIF View.
Definition: View.hpp:61
Represents a bit of a port.
Decompiler & operator=(const Decompiler &inSource)
void printComments(std::vector< std::string > &inElements)
void printViewInterfaceAttributes(const InterfaceAttributesSharedPtr &inAttrib)
Represents a member of an instance array.
void printDerivation(const Derivation derivation)
An EDIF cell library.
Definition: Library.hpp:60
Permutable is used to describe a relationship in which ports are interchangeable. ...
Definition: Permutable.hpp:40
Represents a single instance of the view of a cell.
VisitorApplier< Decompiler > mApplier
Definition: Decompiler.hpp:170
Decompiler(const RootSharedPtr &inRoot, std::ostream &outStream=std::cout)
This class is used to hold all information about the logic values used within a library.
This class is used within simulationInfo construct to define a logic value to use for modeling in the...
Definition: LogicValue.hpp:42
boost::shared_ptr< PortAttributes > PortAttributesSharedPtr
size_t getIndentation() const
Definition: Decompiler.hpp:173
The Error object thrown by different methods of EdifOM.
Definition: Error.hpp:41
Represents a port array.
Definition: VectorPort.hpp:45
Represents a parameter array.
void printUnit(const Unit unit)
Represents a net array.
Definition: VectorNet.hpp:42
Represents a standalone port.
Definition: ScalarPort.hpp:42
Represents the Interface joining information.
This class is used to provide a set of path delays or timing constrains (forbidden events) ...
Definition: Timing.hpp:40
void visit(Root &inroot)
Definition: Decompiler.cpp:178
Represents an array of instances.
Represents a standalone net.
Definition: ScalarNet.hpp:42
ForbiddenEvent class lists events which are forbidden during a period of times which is specified by ...
Represents different logic elements which holds array of logic values.
void printValueType(const Value &value)
boost::shared_ptr< InterfaceAttributes > InterfaceAttributesSharedPtr
Represents an ordered list of port references with a name aliased.
Represents a reference to a bit of a port.
Represents an ordered list of port references.
Definition: PortList.hpp:43
Root of the EDIF Object Model.
Definition: Root.hpp:66
This class is used to model logicInput/logicOutput construct. This class holds information of logical...
This class is used within simulate to describe input stimuli and expected responces over a certain ti...
Definition: WaveValue.hpp:35
Represents a bundle of nets.
Definition: NetBundle.hpp:43
void printArray(const std::vector< size_t > &outVector, size_t depth, std::vector< ParameterSharedPtr >::iterator &itStart, std::vector< ParameterSharedPtr >::iterator &itEnd)
Event is used to describe an event on a port or a net using logic state transitions. Events can also be described for unordered groups of ports or nets using portGroup or netGroup. An ordered list of ports may also be used using a portList.
Definition: Event.hpp:45
void printValue(const Value &value)
boost::shared_ptr< LogicValueAttributes > LogicValueAttributesSharedPtr
void printLogicValueAttributes(const LogicValueAttributesSharedPtr &inAttrib)
void printNetAttributes(const NetAttributesSharedPtr &inAttrib)
This class is to model simulate construct which is a named collection of simulation stimulus and resp...
Definition: Simulate.hpp:46
Represents EDIF status construct.
Definition: Status.hpp:42
Represents a reference to a bundle of ports.
void printPortAttributes(const PortAttributesSharedPtr &inAttrib)
boost::shared_ptr< Root > RootSharedPtr