00001
00002 #if !defined(oagFpgaOccGraph_P)
00003 #define oagFpgaOccGraph_P
00004
00005 #include <stdlib.h>
00006
00007 #include "oaDesignDB.h"
00008 #include "oagFpgaOccRef.h"
00009 #include "oagFpgaManager.h"
00010 #include "oagFpgaRtlGraph.h"
00011 #include <list>
00012 #include <set>
00013
00014 using namespace std;
00015
00016 namespace oagFpga {
00017
00018
00019
00020
00046
00047
00048 class OccGraph {
00049
00050 private:
00051
00052 OccGraph();
00053
00054
00055 public:
00056
00057 typedef set<OccRef> Cut;
00058 typedef list<Cut> CutSet;
00059
00062
00063 static OccRef getNull(oa::oaOccurrence *occurrence) {
00071 return OccRef(RtlGraph::getNull(), occurrence);
00072 }
00073 static inline bool isNull(OccRef x) {
00077 return x.occurrence == NULL || RtlGraph::isNull(x.ref);
00078 }
00079 static inline OccRef constantOne(oa::oaOccurrence *occurrence) {
00083 return OccRef(getGraph(occurrence)->constantOne(), occurrence);
00084 }
00085 static inline OccRef constantZero(oa::oaOccurrence *occurrence) {
00089 return OccRef(getGraph(occurrence)->constantZero(), occurrence);
00090 }
00091
00092
00099
00100
00101
00105
00106
00107
00111
00112
00113
00114
00118
00119 static inline RtlNode::Type getNodeType(OccRef x) {
00123 return getGraph(x)->getNodeType(x.ref);
00124 }
00125
00126
00127 static OccRef getTerminalDriver(OccRef terminal,
00128 bool searchThroughHierarchy = false);
00129 static inline bool isTerminal(OccRef terminal) {
00133 return getGraph(terminal)->isTerminal(terminal.ref);
00134 }
00135
00136 static inline OccRef getNextState(OccRef sequential) {
00143 assert(isSequential(sequential));
00144 return OccRef(getGraph(sequential)->getNextState(sequential.ref), sequential.occurrence);
00145 }
00146 static inline bool isSequential(OccRef sequential) {
00150 return getGraph(sequential)->isSequential(sequential.ref);
00151 }
00152
00153
00160
00161
00162
00163
00167
00168
00169
00173
00174
00175
00176
00177 static void getFanout(OccRef x, list<OccRef> &result);
00178 static inline bool hasFanout(OccRef x) {
00184 return getGraph(x)->hasFanout(x.ref);
00185 }
00186
00190
00191
00192 static oa::oaOccBitNet * getNetToBBConnection(OccRef ref);
00193 static OccRef getNetToBBConnection(oa::oaOccBitNet *net);
00194
00195 static void getNetToBBAllEquivConnections(OccRef ref,
00196 list<oa::oaOccBitNet *> &result);
00197
00201
00202 static void getOutputs(oa::oaOccurrence *top, list<OccRef> &result);
00203 static void getOutputs(oa::oaOccurrence *top, list<oa::oaOccBitNet*> &result);
00204 static void getInputs(oa::oaOccurrence *top, list<OccRef> &result);
00205 static void getInputs(oa::oaOccurrence *top, list<oa::oaOccBitNet*> &result);
00206 static void getStates(oa::oaOccurrence *top, list<OccRef> &result);
00207 static void getLocalStates(oa::oaOccurrence *top, list<OccRef> &result);
00208 static void getConstants(oa::oaOccurrence *top, list<OccRef> &zeros,
00209 list<OccRef> &ones);
00210
00211 static void getAllConnections(oa::oaOccBitNet *net,
00212 set<oa::oaOccBitNet*> &connectedNets,
00213 set<OccRef> &connectedRefs,
00214 bool searchForwardThroughGraph = true,
00215 bool searchBackwardThroughGraph = true,
00216 bool searchThroughHierarchy = true,
00217 bool searchThroughEquivNets = true,
00218 bool searchThroughEquivRefs = false,
00219 bool includeSelf = true);
00220 static void getAllConnections(OccRef x,
00221 set<oa::oaOccBitNet*> &connectedNets,
00222 set<OccRef> &connectedRefs,
00223 bool searchForwardThroughGraph = true,
00224 bool searchBackwardThroughGraph = true,
00225 bool searchThroughHierarchy = true,
00226 bool searchThroughEquivNets = true,
00227 bool searchThroughEquivRefs = false,
00228 bool includeSelf = true);
00229
00233
00234
00235
00236
00237
00238
00239 static void getTransitiveFanin(OccRef x, list<OccRef> &transitiveFanin);
00240 static void getTransitiveFanout(OccRef x, list<OccRef> &transitiveFanout);
00241
00242
00243
00244
00248
00249
00250
00251
00252
00253
00255
00256
00257 private:
00258
00259 static inline RtlGraph * getGraph(oa::oaOccurrence *occurrence) {
00267 return &(Manager::get(occurrence->getModule()->getDesign())->bbg);
00268 }
00269 static inline RtlGraph * getGraph(const OccRef &x) {
00272 return &(Manager::get(x.occurrence->getModule()->getDesign())->bbg);
00273 }
00274
00275 static void convertRefListToOccRefList(const list<BBRef> &source,
00276 oa::oaOccurrence *occurrence,
00277 list<OccRef> &result);
00278 };
00279
00280 }
00281
00282 #endif