00001
00002 #include "oagFpga.h"
00003 #include "oagFpgaAiModGraph.h"
00004 #include <set>
00005
00006 #include "oagFpgaDebug.h"
00007
00008 namespace oagFpga {
00009
00010
00011
00012
00013
00018
00019
00020 inline void
00021 AiModGraph::failIfInDifferentModules(oa::oaModule *x, oa::oaModule *y) {
00022 if (x != y) {
00023 cerr << "ERROR: Expected AiModRefs that refer to nodes in the same module" << endl;
00024 QUIT_ON_ERROR;
00025 }
00026 }
00027
00028
00029
00030
00031
00037
00038
00039 void
00040 AiModGraph::convertRefListToAiModRefList(const list<oagAi::Ref> & source,
00041 oa::oaModule *module,
00042 list<AiModRef> & result) {
00043 for(list<oagAi::Ref>::const_iterator it = source.begin(); it != source.end(); ++it) {
00044 result.push_back(AiModRef(*it, module));
00045 }
00046 }
00047
00048
00049
00050
00051
00056
00057
00058 oa::oaModule*
00059 AiModGraph::convertAiModRefListToRefList(const list<AiModRef> & source,
00060 list<oagAi::Ref> & result) {
00061 if (source.empty()) return NULL;
00062 oa::oaModule *module = source.front().module;
00063 for(list<AiModRef>::const_iterator it = source.begin(); it != source.end(); ++it) {
00064 assert(it->module == module);
00065 result.push_back(it->ref);
00066 }
00067 return module;
00068 }
00069
00070
00071
00072
00073
00079
00080
00081 void
00082 AiModGraph::convertRefVectorToAiModRefVector(const vector<oagAi::Ref> & source,
00083 oa::oaModule *module,
00084 vector<AiModRef> & result) {
00085 result.reserve(source.size());
00086 for(vector<oagAi::Ref>::const_iterator it = source.begin(); it != source.end(); ++it) {
00087 result.push_back(AiModRef(*it, module));
00088 }
00089 }
00090
00091
00092
00093
00094
00103
00104
00105 AiModRef
00106 AiModGraph::newAnd(AiModRef x, AiModRef y) {
00107 failIfInDifferentModules(x,y);
00108
00109 return AiModRef(getGraph(x)->newAnd(x.ref, y.ref), x.module);
00110 }
00111
00112
00113
00114
00126
00127
00128 AiModRef
00129 AiModGraph::andOf(AiModRef x, AiModRef y) {
00130 failIfInDifferentModules(x,y);
00131
00132 return AiModRef(getGraph(x)->andOf(x.ref, y.ref), x.module);
00133 }
00134
00135
00136
00137
00146
00147
00148 void
00149 AiModGraph::setTerminalDriver(AiModRef terminal, AiModRef driver) {
00150 failIfInDifferentModules(terminal, driver);
00151
00152 getGraph(terminal)->setTerminalDriver(terminal.ref, driver.ref);
00153 }
00154
00155
00156
00157
00158
00166
00167
00168 void
00169 AiModGraph::setAndLeft(AiModRef x, AiModRef left) {
00170 failIfInDifferentModules(x,left);
00171
00172 getGraph(x)->setAndLeft(x.ref, left.ref);
00173 }
00174
00175
00176
00177
00178
00186
00187
00188 void
00189 AiModGraph::setAndRight(AiModRef x, AiModRef right) {
00190 failIfInDifferentModules(x,right);
00191
00192 getGraph(x)->setAndRight(x.ref, right.ref);
00193 }
00194
00195
00196
00197
00198
00206
00207
00208 void
00209 AiModGraph::setNextState(AiModRef sequential, AiModRef nextState) {
00210 failIfInDifferentModules(sequential, nextState);
00211
00212 getGraph(sequential)->setNextState(sequential.ref, nextState.ref);
00213 }
00214
00215
00216
00217
00218
00228
00229
00230 void
00231 AiModGraph::resubstitute(AiModRef original, AiModRef replacement) {
00232 failIfInDifferentModules(original, replacement);
00233
00234 getGraph(original)->resubstitute(original.ref, replacement.ref);
00235 }
00236
00237
00238
00239
00240
00251
00252
00253 void
00254 AiModGraph::resubstitute(AiModRef original, AiModRef replacement, AiModRef target) {
00255 failIfInDifferentModules(original, replacement);
00256 failIfInDifferentModules(original, target);
00257
00258 getGraph(original)->resubstitute(original.ref, replacement.ref, target.ref);
00259 }
00260
00261
00262
00263
00264
00271
00272
00273 void
00274 AiModGraph::detach(AiModRef x) {
00275
00276 getGraph(x)->detach(x.ref);
00277 }
00278
00279
00280
00281
00289
00290
00291 bool
00292 AiModGraph::hasCombinationalCycle(oa::oaModule *module) {
00293 return getGraph(module)->hasCombinationalCycle();
00294 }
00295
00296
00297
00298
00313
00314
00315 AiModGraph::CutSet
00316 AiModGraph::enumerateKfeasibleCuts(AiModRef x, unsigned int maxCutSize,
00317 int maxCutCount, int maxCutDepth,
00318 bool includeConstantNode) {
00319 oagAi::Graph::CutSet *source = getGraph(x)->enumerateKfeasibleCuts(x.ref,
00320 maxCutSize, maxCutCount, maxCutDepth,
00321 includeConstantNode);
00322
00323
00324 CutSet result;
00325 for(oagAi::Graph::CutSet::iterator setIter = source->begin(); setIter != source->end(); ++setIter) {
00326 Cut resultCut;
00327 for(oagAi::Graph::Cut::iterator cutIter = setIter->begin(); cutIter != setIter->end(); ++cutIter) {
00328 resultCut.insert(AiModRef(*cutIter, x.module));
00329 }
00330 result.push_back(resultCut);
00331 }
00332 return result;
00333 }
00334
00335
00336
00337
00338
00342
00343
00344 void
00345 AiModGraph::clearKfeasibleCuts(oa::oaModule *module) {
00346 getGraph(module)->clearKfeasibleCuts();
00347 }
00348
00349
00350
00351
00352
00359
00360
00361 list<AiModRef>
00362 AiModGraph::getFanout(AiModRef x) {
00363 list<AiModRef> result;
00364 convertRefListToAiModRefList(getGraph(x)->getFanout(x.ref), x.module, result);
00365 return result;
00366 }
00367
00368
00369
00370
00371
00378
00379
00380 void
00381 AiModGraph::getFanout(AiModRef x, list<AiModRef> &result) {
00382 convertRefListToAiModRefList(getGraph(x)->getFanout(x.ref), x.module, result);
00383 }
00384
00385
00386
00387
00388
00401
00402
00403 void
00404 AiModGraph::getTransitiveFanin(AiModRef x, list<AiModRef> &transitiveFanin,
00405 bool includeRoots, bool crossSequential) {
00406 list<oagAi::Ref> flatResult;
00407 getGraph(x)->getTransitiveFanin(x.ref, flatResult,
00408 includeRoots, crossSequential);
00409 convertRefListToAiModRefList(flatResult, x.module, transitiveFanin);
00410 }
00411
00412
00413
00414
00415
00428
00429
00430 void
00431 AiModGraph::getTransitiveFanout(AiModRef x, list<AiModRef> &transitiveFanout,
00432 bool includeRoots, bool crossSequential) {
00433 list<oagAi::Ref> flatResult;
00434 getGraph(x)->getTransitiveFanout(x.ref, flatResult,
00435 includeRoots, crossSequential);
00436 convertRefListToAiModRefList(flatResult, x.module, transitiveFanout);
00437 }
00438
00439
00440
00441
00442
00455
00456
00457 void
00458 AiModGraph::getTransitiveFanin(AiModRef x, vector<AiModRef> &transitiveFanin,
00459 bool includeRoots, bool crossSequential) {
00460 vector<oagAi::Ref> flatResult;
00461 getGraph(x)->getTransitiveFanin(x.ref, flatResult,
00462 includeRoots, crossSequential);
00463 convertRefVectorToAiModRefVector(flatResult, x.module, transitiveFanin);
00464 }
00465
00466
00467
00468
00469
00482
00483
00484 void
00485 AiModGraph::getTransitiveFanout(AiModRef x, vector<AiModRef> &transitiveFanout,
00486 bool includeRoots, bool crossSequential) {
00487 vector<oagAi::Ref> flatResult;
00488 getGraph(x)->getTransitiveFanout(x.ref, flatResult,
00489 includeRoots, crossSequential);
00490 convertRefVectorToAiModRefVector(flatResult, x.module, transitiveFanout);
00491 }
00492
00493
00494
00495
00496
00509
00510
00511 void
00512 AiModGraph::getTransitiveFanin(list<AiModRef> x, list<AiModRef> &transitiveFanin,
00513 bool includeRoots, bool crossSequential) {
00514 if (x.empty()) return;
00515 list<oagAi::Ref> flatInput;
00516 oa::oaModule *module = convertAiModRefListToRefList(x, flatInput);
00517 list<oagAi::Ref> flatResult;
00518 getGraph(module)->getTransitiveFanin(flatInput, flatResult,
00519 includeRoots, crossSequential);
00520 convertRefListToAiModRefList(flatResult, module, transitiveFanin);
00521 }
00522
00523
00524
00525
00526
00539
00540
00541 void
00542 AiModGraph::getTransitiveFanout(list<AiModRef> x, list<AiModRef> &transitiveFanout,
00543 bool includeRoots, bool crossSequential) {
00544 if (x.empty()) return;
00545 list<oagAi::Ref> flatInput;
00546 oa::oaModule *module = convertAiModRefListToRefList(x, flatInput);
00547 list<oagAi::Ref> flatResult;
00548 getGraph(module)->getTransitiveFanout(flatInput, flatResult,
00549 includeRoots, crossSequential);
00550 convertRefListToAiModRefList(flatResult, module, transitiveFanout);
00551 }
00552
00553
00554
00555
00556
00569
00570
00571 void
00572 AiModGraph::getTransitiveFanin(list<AiModRef> x, vector<AiModRef> &transitiveFanin,
00573 bool includeRoots, bool crossSequential) {
00574 if (x.empty()) return;
00575 list<oagAi::Ref> flatInput;
00576 oa::oaModule *module = convertAiModRefListToRefList(x, flatInput);
00577 vector<oagAi::Ref> flatResult;
00578 getGraph(module)->getTransitiveFanin(flatInput, flatResult,
00579 includeRoots, crossSequential);
00580 convertRefVectorToAiModRefVector(flatResult, module, transitiveFanin);
00581 }
00582
00583
00584
00585
00586
00599
00600
00601 void
00602 AiModGraph::getTransitiveFanout(list<AiModRef> x, vector<AiModRef> &transitiveFanout,
00603 bool includeRoots, bool crossSequential) {
00604 if (x.empty()) return;
00605 list<oagAi::Ref> flatInput;
00606 oa::oaModule *module = convertAiModRefListToRefList(x, flatInput);
00607 vector<oagAi::Ref> flatResult;
00608 getGraph(module)->getTransitiveFanout(flatInput, flatResult,
00609 includeRoots, crossSequential);
00610 convertRefVectorToAiModRefVector(flatResult, module, transitiveFanout);
00611 }
00612
00613
00614
00615
00616
00621
00622
00623 void
00624 AiModGraph::getFaninRoots(AiModRef x, list<AiModRef> &faninRoots) {
00625 list<oagAi::Ref> flatResult;
00626 getGraph(x)->getFaninRoots(x.ref, flatResult);
00627
00628 convertRefListToAiModRefList(flatResult, x.module, faninRoots);
00629 }
00630
00631
00632
00633
00634
00639
00640
00641 void
00642 AiModGraph::getFanoutRoots(AiModRef x, list<AiModRef> &fanoutRoots) {
00643 list<oagAi::Ref> flatResult;
00644 getGraph(x)->getFanoutRoots(x.ref, flatResult);
00645
00646 convertRefListToAiModRefList(flatResult, x.module, fanoutRoots);
00647 }
00648
00649
00650
00651
00652
00657
00658
00659 bool
00660 AiModGraph::testEquivalence(AiModRef x, AiModRef y) {
00661 failIfInDifferentModules(x,y);
00662
00663 return getGraph(x)->testEquivalence(x.ref, y.ref);
00664 }
00665
00666
00667
00668
00669
00673
00674
00675 void
00676 AiModGraph::setEquivalent(AiModRef x, AiModRef y) {
00677 failIfInDifferentModules(x,y);
00678
00679 getGraph(x)->setEquivalent(x.ref, y.ref);
00680 }
00681
00682
00683
00684
00685
00693
00694
00695 void
00696 AiModGraph::getEquivalents(AiModRef x, list<AiModRef> & result) {
00697 list<oagAi::Ref> flatResult;
00698 getGraph(x)->getEquivalents(x.ref, flatResult);
00699
00700 convertRefListToAiModRefList(flatResult, x.module, result);
00701 }
00702
00703
00704
00705
00706
00711
00712
00713 void
00714 AiModGraph::getFanoutOfEquivalentNodes(AiModRef x, list<AiModRef> &result) {
00715 list<oagAi::Ref> flatResult;
00716 getGraph(x)->getFanoutOfEquivalentNodes(x.ref, flatResult);
00717
00718 convertRefListToAiModRefList(flatResult, x.module, result);
00719 }
00720
00721
00722
00723
00724
00734
00735
00736 AiModRef
00737 AiModGraph::prepareNetToAiConnection(oa::oaModBitNet *net) {
00738 Manager *manager = Manager::get(net->getDesign());
00739 return AiModRef(manager->prepareNetToAiConnection(net), net->getModule());
00740 }
00741
00742
00743
00744
00745
00750
00751
00752 oa::oaModBitNet *
00753 AiModGraph::getNetToAiConnection(AiModRef x) {
00754 Manager *manager = Manager::get(x.module->getDesign());
00755 return manager->getNetToAiConnection(x.ref);
00756 }
00757
00758
00759
00760
00761
00766
00767
00768 AiModRef
00769 AiModGraph::getNetToAiConnection(oa::oaModBitNet *net) {
00770 Manager *manager = Manager::get(net->getDesign());
00771 return AiModRef(manager->getNetToAiConnection(net), net->getModule());
00772 }
00773
00774
00775
00776
00777
00782
00783
00784 void
00785 AiModGraph::setNetToAiConnection(oa::oaModBitNet *net, AiModRef x) {
00786 failIfInDifferentModules(net->getModule(), x.module);
00787
00788 Manager *manager = Manager::get(x.module->getDesign());
00789 manager->setNetToAiConnection(net, x.ref);
00790 }
00791
00792
00793
00794
00795
00799
00800
00801 void
00802 AiModGraph::removeNetToAiConnection(oa::oaModBitNet *net) {
00803 Manager *manager = Manager::get(net->getDesign());
00804 manager->removeNetToAiConnection(net);
00805 }
00806
00807
00808
00809
00810
00820
00821
00822 void
00823 AiModGraph::getOutputs(oa::oaModule *module, list<AiModRef> &result) {
00824 assert(module);
00825 oa::oaModTerm *term;
00826 oa::oaIter<oa::oaModTerm> termIter(module->getTerms(oacTermIterSingleBit));
00827 while((term = termIter.getNext())) {
00828 if(term->getTermType() == oa::oacOutputTermType) {
00829 result.push_back(prepareNetToAiConnection(toBitNet(term->getNet())));
00830 }
00831 }
00832 }
00833
00834
00835
00836
00837
00847
00848
00849 void
00850 AiModGraph::getInputs(oa::oaModule *module, list<AiModRef> &result) {
00851 assert(module);
00852 oa::oaModTerm *term;
00853 oa::oaIter<oa::oaModTerm> termIter(module->getTerms(oacTermIterSingleBit));
00854 while((term = termIter.getNext())) {
00855 if(term->getTermType() == oa::oacInputTermType) {
00856 result.push_back(prepareNetToAiConnection(toBitNet(term->getNet())));
00857 }
00858 }
00859 }
00860
00861
00862
00863
00864
00869
00870
00871 void
00872 AiModGraph::getAllNodes(oa::oaModule *module, list<AiModRef> &result) {
00873 assert(module);
00874
00875
00876 list<oagAi::Ref> flatResult;
00877 getGraph(module)->getAll(flatResult);
00878 convertRefListToAiModRefList(flatResult, module, result);
00879
00880 }
00881
00882
00883
00884
00885
00890
00891
00892 void
00893 AiModGraph::getLocalStates(oa::oaModule *module, list<AiModRef> &result) {
00894 assert(module);
00895
00896
00897 list<oagAi::Ref> flatResult;
00898 getGraph(module)->getAllSequential(flatResult);
00899 convertRefListToAiModRefList(flatResult, module, result);
00900 }
00901
00902
00903
00904
00905
00916
00917
00918 void
00919 AiModGraph::getAllConnections(oa::oaModBitNet *net,
00920 set<oa::oaModBitNet*> &connectedNets,
00921 set<AiModRef> &connectedRefs,
00922 bool searchForwardThroughGraph,
00923 bool searchBackwardThroughGraph,
00924 bool searchThroughEquivNets,
00925 bool searchThroughEquivRefs,
00926 bool includeSelf) {
00927 assert(net);
00928
00929
00930 if (connectedNets.find(net) == connectedNets.end()) {
00931 connectedNets.insert(net);
00932 } else {
00933 return;
00934 }
00935
00936
00937 getAllConnections(getNetToAiConnection(net), connectedNets, connectedRefs,
00938 searchForwardThroughGraph, searchBackwardThroughGraph,
00939 searchThroughEquivNets, searchThroughEquivRefs, true);
00940
00941
00942 if (searchThroughEquivNets) {
00943 oa::oaModBitNet *equivNet;
00944 oa::oaIter<oa::oaModBitNet> equivIter(net->getEquivalentNets());
00945 while((equivNet = equivIter.getNext())) {
00946 getAllConnections(equivNet, connectedNets, connectedRefs,
00947 searchForwardThroughGraph, searchBackwardThroughGraph,
00948 searchThroughEquivNets, searchThroughEquivRefs, true);
00949 }
00950 }
00951
00952
00953 if (!includeSelf) {
00954 connectedNets.erase(net);
00955 }
00956 }
00957
00958
00959
00960
00961
00965
00974
00975
00976 void
00977 AiModGraph::getAllConnections(AiModRef x,
00978 set<oa::oaModBitNet*> &connectedNets,
00979 set<AiModRef> &connectedRefs,
00980 bool searchForwardThroughGraph,
00981 bool searchBackwardThroughGraph,
00982 bool searchThroughEquivNets,
00983 bool searchThroughEquivRefs,
00984 bool includeSelf) {
00985 if (isNull(x)) {
00986 return;
00987 }
00988
00989
00990 if (connectedRefs.find(x) == connectedRefs.end()) {
00991 connectedRefs.insert(x);
00992 } else {
00993 return;
00994 }
00995
00996
00997 if (isTerminal(x) && !isInverted(x)) {
00998 oa::oaModBitNet *net;
00999 if ((net = getNetToAiConnection(x))) {
01000 getAllConnections(net, connectedNets, connectedRefs,
01001 searchForwardThroughGraph, searchBackwardThroughGraph,
01002 searchThroughEquivNets, searchThroughEquivRefs, true);
01003 }
01004 }
01005
01006
01007 if (searchBackwardThroughGraph) {
01008
01009 if (isTerminal(x)) {
01010 AiModRef driver = getTerminalDriver(x);
01011 driver = isInverted(x) ? notOf(driver) : driver;
01012 getAllConnections(driver, connectedNets, connectedRefs,
01013 searchForwardThroughGraph, searchBackwardThroughGraph,
01014 searchThroughEquivNets, searchThroughEquivRefs, true);
01015 }
01016 }
01017
01018
01019 if (searchForwardThroughGraph) {
01020
01021 list<AiModRef> fanoutList;
01022 getFanout(x, fanoutList);
01023 while(!fanoutList.empty()) {
01024 AiModRef fanout(fanoutList.front());
01025 fanoutList.pop_front();
01026 if(isTerminal(fanout)) {
01027 fanout = isInverted(x) ? notOf(fanout) : fanout;
01028 fanout = isInverted(getTerminalDriver(fanout)) ? notOf(fanout) : fanout;
01029 getAllConnections(fanout, connectedNets, connectedRefs,
01030 searchForwardThroughGraph, searchBackwardThroughGraph,
01031 searchThroughEquivNets, searchThroughEquivRefs, true);
01032 }
01033 }
01034 }
01035
01036
01037 if (searchThroughEquivRefs) {
01038 list<AiModRef> equivList;
01039 getEquivalents(x, equivList);
01040 while(!equivList.empty()) {
01041 AiModRef equiv(equivList.front());
01042 equivList.pop_front();
01043 getAllConnections(equiv, connectedNets, connectedRefs,
01044 searchForwardThroughGraph, searchBackwardThroughGraph,
01045 searchThroughEquivNets, searchThroughEquivRefs, true);
01046 }
01047 }
01048
01049
01050 if (!includeSelf) {
01051 connectedRefs.erase(x);
01052 }
01053 }
01054
01055
01056
01057
01058
01070
01071
01072 oa::oaModBitNet *
01073 AiModGraph::findDriverOfEquivalentNets(oa::oaModBitNet *net) {
01074 assert(net);
01075
01076
01077 if (net->getEquivalentNets().isEmpty()) {
01078 return NULL;
01079 }
01080
01081
01082 AiModRef termRef = getNetToAiConnection(net);
01083 if (!isNull(termRef) && !isNull(getTerminalDriver(termRef))) {
01084 return NULL;
01085 }
01086
01087
01088 oa::oaModBitNet *equivNet;
01089 oa::oaIter<oa::oaModBitNet> equivNetIter(net->getEquivalentNets());
01090
01091 DEBUG_PRINT("Equivalent set : ");
01092 while ((equivNet = equivNetIter.getNext())) {
01093 assert(equivNet);
01094
01095 oa::oaString netString;
01096 equivNet->getName(oa::oaVerilogNS(), netString);
01097 DEBUG_PRINTMORE(netString << " ");
01098
01099
01100 AiModRef termRef = getNetToAiConnection(equivNet);
01101 if (!isNull(termRef) && !isNull(getTerminalDriver(termRef))) {
01102
01103 AiModRef driverRef = termRef;
01104 while(true) {
01105 oa::oaModBitNet *net2 = getNetToAiConnection(driverRef);
01106 if (net2 && net2 == net) {
01107
01108 return NULL;
01109 }
01110 driverRef = getTerminalDriver(driverRef);
01111 if (isNull(driverRef) || !isTerminal(driverRef)) {
01112 break;
01113 }
01114 }
01115 return equivNet;
01116 }
01117
01118
01119 oa::oaModTerm *term;
01120 oa::oaIter<oa::oaModTerm> termIter(equivNet->getTerms(oacTermIterSingleBit));
01121 while((term = termIter.getNext())) {
01122 assert(term);
01123 if(term->getTermType() == oa::oacInputTermType) {
01124 return equivNet;
01125 }
01126 }
01127 }
01128 DEBUG_PRINTMORE("\n");
01129
01130
01131
01132
01133
01134
01135
01136
01137
01138
01139
01140 return NULL;
01141 }
01142
01143
01144
01145
01146
01177
01178 void
01179 AiModGraph::connectEquivalentNetsInGraph(oa::oaModule *module) {
01180 assert(module);
01181
01182 oa::oaModNet *net;
01183 oa::oaIter<oa::oaModNet> netIter(module->getNets(oacNetIterSingleBit));
01184 while((net = netIter.getNext())) {
01185 oa::oaModBitNet *bitNet = toBitNet(net);
01186 assert(bitNet);
01187 AiModRef termNode = getNetToAiConnection(bitNet);
01188 assert(!isNull(termNode));
01189 if (!isNull(getTerminalDriver(termNode))) {
01190 continue;
01191 }
01192
01193 oa::oaModBitNet *driverNet = findDriverOfEquivalentNets(bitNet);
01194
01195 if (driverNet) {
01196 AiModRef driver = getNetToAiConnection(driverNet);
01197 #if defined(DEBUG)
01198 cout << "Moving equivalent nets to graph : node ";
01199 termNode.printName(false);
01200 cout << " was ";
01201 getTerminalDriver(termNode).printName();
01202 cout << " is now driven by ";
01203 driver.printName(true);
01204 cout << endl;
01205 #endif
01206 setTerminalDriver(termNode, driver);
01207 }
01208 }
01209 }
01210
01211
01212
01213
01214
01216
01217
01218 void
01219 AiModGraph::print(oa::oaModule *module) {
01220 assert(module);
01221
01222 list<AiModRef> all;
01223 getAllNodes(module, all);
01224 for(list<AiModRef>::iterator it = all.begin(); it!=all.end(); it++) {
01225 it->print();
01226 }
01227 }
01228
01229
01230
01231
01232
01236
01237
01238 void
01239 AiModRef::print(bool lineFeed) {
01240 const int TYPE_COL_WIDTH = 4;
01241 const int MODULE_COL_WIDTH = 20;
01242 const int REF_COL_WIDTH = 5;
01243
01244 oa::oaString modString;
01245 if (!module) {
01246 modString = "(null)";
01247 } else {
01248 module->getName(oa::oaVerilogNS(), modString);
01249 }
01250
01251 if (AiModGraph::getNodeType(*this) == oagAi::Node::AND) {
01252 cout.width(TYPE_COL_WIDTH);
01253 cout << "AND ";
01254 cout.width(MODULE_COL_WIDTH);
01255 cout << modString << ".";
01256 cout.width(REF_COL_WIDTH);
01257 cout << ref << " :\t";
01258 cout << AiModGraph::getAndLeft(*this).ref << ", " << AiModGraph::getAndRight(*this).ref;
01259 } else if (AiModGraph::getNodeType(*this) == oagAi::Node::SEQUENTIAL) {
01260 cout.width(TYPE_COL_WIDTH);
01261 cout << "SEQ ";
01262 cout.width(MODULE_COL_WIDTH);
01263 cout << modString << ".";
01264 cout.width(REF_COL_WIDTH);
01265 cout << ref << " :\t";
01266 cout << AiModGraph::getNextState(*this).ref;
01267 } else if (AiModGraph::getNodeType(*this) == oagAi::Node::CONSTANT0) {
01268 cout.width(TYPE_COL_WIDTH);
01269 cout << "ZRO ";
01270 cout.width(MODULE_COL_WIDTH);
01271 cout << modString << ".";
01272 cout.width(REF_COL_WIDTH);
01273 cout << ref << " :\t";
01274 } else if (AiModGraph::getNodeType(*this) == oagAi::Node::TERMINAL) {
01275 cout.width(TYPE_COL_WIDTH);
01276 cout << "TRM ";
01277 cout.width(MODULE_COL_WIDTH);
01278 cout << modString << ".";
01279 cout.width(REF_COL_WIDTH);
01280 cout << ref << " :\t";
01281 cout << AiModGraph::getTerminalDriver(*this).ref;
01282 cout << " net= ";
01283 oa::oaModBitNet *net = AiModGraph::getNetToAiConnection(*this);
01284 if (net) {
01285 oa::oaString netString;
01286 net->getName(oa::oaVerilogNS(), netString);
01287 cout << netString;
01288 } else {
01289 cout << "*none*";
01290 }
01291 } else if (AiModGraph::getNodeType(*this) == oagAi::Node::NONE) {
01292 cout.width(TYPE_COL_WIDTH);
01293 cout << "NUL ";
01294 cout.width(MODULE_COL_WIDTH);
01295 cout << modString << ".";
01296 cout.width(REF_COL_WIDTH);
01297 cout << ref << " :\t";
01298 }
01299
01300 if (AiModGraph::isInverted(*this)) {
01301 cout << " (inverted)";
01302 }
01303
01304 if (lineFeed) {
01305 cout << endl;
01306 }
01307 }
01308
01309
01310
01311
01312
01316
01317
01318 void
01319 AiModRef::printName(bool lineFeed) {
01320
01321 oa::oaString modString;
01322 if (!module) {
01323 modString = "(null)";
01324 } else {
01325 module->getName(oa::oaVerilogNS(), modString);
01326 }
01327
01328 cout << modString << "." << ref;
01329
01330 if (lineFeed) {
01331 cout << endl;
01332 }
01333 }
01334
01335
01336
01337
01338
01351
01352
01353 void
01354 AiModGraph::getFaninCone(AiModRef x, const list<AiModRef> &coneRoots,
01355 list<AiModRef> &transitiveFanin, bool includeRoots) {
01356
01357 list<oagAi::Ref> flatCut;
01358 oa::oaModule *module = convertAiModRefListToRefList(coneRoots, flatCut);
01359 assert(coneRoots.empty() || module == x.module);
01360 list<oagAi::Ref> flatResult;
01361 getGraph(x.module)->getFaninCone(x.ref, flatCut, flatResult, includeRoots);
01362 convertRefListToAiModRefList(flatResult, x.module, transitiveFanin);
01363 }
01364
01365
01366
01367
01368
01381
01382
01383 void
01384 AiModGraph::getFanoutCone(AiModRef x, const list<AiModRef> &coneRoots,
01385 list<AiModRef> &transitiveFanout, bool includeRoots) {
01386
01387 list<oagAi::Ref> flatCut;
01388 oa::oaModule *module = convertAiModRefListToRefList(coneRoots, flatCut);
01389 assert(module == x.module);
01390 list<oagAi::Ref> flatResult;
01391 getGraph(x.module)->getFanoutCone(x.ref, flatCut, flatResult, includeRoots);
01392 convertRefListToAiModRefList(flatResult, x.module, transitiveFanout);
01393 }
01394
01395 }