00001
00002 #if !defined(oagFpgaModGraph_P)
00003 #define oagFpgaModGraph_P
00004
00005 #include <stdlib.h>
00006
00007 #include "oaDesignDB.h"
00008 #include "oagFpgaModRef.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
00045
00046
00047
00048 class ModGraph {
00049
00050
00051 private:
00052
00053 ModGraph();
00054
00055
00056 public:
00057
00058
00059
00060
00061
00062
00065
00066 static ModRef getNull(oa::oaModule *module) {
00076 return ModRef(RtlGraph::getNull(), module);
00077 }
00078 static inline bool isNull(ModRef x) {
00084 return RtlGraph::isNull(x.ref);
00085 }
00086 static inline ModRef constantOne(oa::oaModule *module) {
00090 return ModRef(getGraph(module)->constantOne(), module);
00091 }
00092 static inline ModRef constantZero(oa::oaModule *module) {
00096 return ModRef(getGraph(module)->constantZero(), module);
00097 }
00098
00099
00106
00107
00108
00112
00113
00114
00118
00119
00120
00124
00125
00131
00132
00133
00139
00140
00141
00142
00143
00147
00148
00156
00157
00158
00162
00163
00164
00165
00166
00167 static void setTerminalDriver(ModRef terminal, ModRef driver);
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00181
00182 static inline RtlNode::FuncType getNodeType(ModRef x) {
00186 return getGraph(x)->getNodeType(x.ref);
00187 }
00188
00189 static inline RtlNode::OptType getNodeOptType(ModRef x) {
00193 return getGraph(x)->getNodeOptType(x.ref);
00194 }
00195
00196 static inline RtlNode::SeqType getNodeSeqType(ModRef x) {
00200 return getGraph(x)->getNodeSeqType(x.ref);
00201 }
00202 static inline int getNumOutputBits(ModRef x) {
00205 return getGraph(x)->getNumOutputBits(x.ref);
00206 }
00207 static inline BBRef getPrimaryBBID(ModRef x) {
00210 return getGraph(x)->getPrimaryBBID(x.ref);
00211 }
00212
00213
00214
00215 static ModRef getTerminalDriver(ModRef terminal) {
00227 return ModRef(getGraph(terminal)->getTerminalDriver(terminal.ref), terminal.module);
00228 }
00229 static bool isTerminal(ModRef x) {
00233 return getGraph(x)->isTerminal(x.ref);
00234 }
00235 static bool isFunctional(ModRef x) {
00237
00240 return getGraph(x)->isFunctional(x.ref);
00241 }
00242
00243 static ModRef getNextState(ModRef sequential) {
00250 return ModRef(getGraph(sequential)->getNextState(sequential.ref), sequential.module);
00251 }
00252 static bool isSequential(ModRef x) {
00256 return getGraph(x)->isSequential(x.ref);
00257 }
00258
00259
00266
00267
00268
00269
00273
00274
00275
00282
00283
00284
00291
00292
00293
00294
00295 static list<ModRef> getFanin(ModRef x);
00296 static list<ModRef> getFanout(ModRef x);
00297 static void getFanout(ModRef x, list<ModRef> &result);
00298 static inline bool hasFanout(ModRef x) {
00303 return getGraph(x)->hasFanout(x.ref);
00304 }
00305
00309
00310 static ModRef prepareNetToBBConnection(oa::oaModBitNet *net);
00311 static oa::oaModBitNet * getNetToBBConnection(ModRef ref);
00312 static ModRef getNetToBBConnection(oa::oaModBitNet *net);
00313 static void setNetToBBConnection(oa::oaModBitNet *net, ModRef ref);
00314 static void removeNetToBBConnection(oa::oaModBitNet *net);
00315
00316 static oa::oaModBitNet * findDriverOfEquivalentNets(oa::oaModBitNet *net);
00317
00318 static void connectEquivalentNetsInGraph(oa::oaModule *module);
00319
00323
00324 static bool hasCombinationalCycle(oa::oaModule *module);
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334 static void getTransitiveFanin(ModRef x, list<ModRef> &transitiveFanin,
00335 bool includeRoots = true, bool crossSequential = false);
00336 static void getTransitiveFanin(ModRef x, vector<ModRef> &transitiveFanin,
00337 bool includeRoots = true, bool crossSequential = false);
00338 static void getTransitiveFanin(list<ModRef> x, list<ModRef> &transitiveFanin,
00339 bool includeRoots = true, bool crossSequential = false);
00340 static void getTransitiveFanin(list<ModRef> x, vector<ModRef> &transitiveFanin,
00341 bool includeRoots = true, bool crossSequential = false);
00342
00343 static void getTransitiveFanout(ModRef x, list<ModRef> &transitiveFanout,
00344 bool includeRoots = true, bool crossSequential = false);
00345 static void getTransitiveFanout(ModRef x, vector<ModRef> &transitiveFanout,
00346 bool includeRoots = true, bool crossSequential = false);
00347 static void getTransitiveFanout(list<ModRef> x, list<ModRef> &transitiveFanout,
00348 bool includeRoots = true, bool crossSequential = false);
00349 static void getTransitiveFanout(list<ModRef> x, vector<ModRef> &transitiveFanout,
00350 bool includeRoots = true, bool crossSequential = false);
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00364
00365
00366
00367
00368
00375
00376
00377
00385
00386
00387
00388
00389
00390
00394
00395
00396
00397
00398
00399
00400
00401 static void getOutputs(oa::oaModule *module, list<ModRef> &result);
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00425
00426
00436
00437
00438
00446
00447
00448
00452
00453
00454
00455
00457
00458 public:
00459
00460 static inline RtlGraph * getGraph(oa::oaDesign *design) {
00467 return &(Manager::get(design)->bbg);
00468 }
00469 static inline RtlGraph * getGraph(oa::oaModule *module) {
00477 return &(Manager::get(module->getDesign())->bbg);
00478 }
00479 static inline RtlGraph * getGraph(const ModRef &x) {
00482 return &(Manager::get(x.module->getDesign())->bbg);
00483 }
00484
00485 static void failIfInDifferentModules(oa::oaModule *x, oa::oaModule *y);
00486 static void failIfInDifferentModules(ModRef x, ModRef y) {
00490 failIfInDifferentModules(x.module, y.module);
00491 }
00492
00493 static oa::oaModule* convertModRefListToRefList(const list<ModRef> & source,
00494 list<BBRef> & result);
00495 static void convertRefListToModRefList(const list<BBRef> & source,
00496 oa::oaModule *module,
00497 list<ModRef> & result);
00498 static void convertRefVectorToModRefVector(const vector<BBRef> & source,
00499 oa::oaModule *module,
00500 vector<ModRef> & result);
00501 };
00502
00503 }
00504
00505 #endif