📄 oaverilogcmptermstest.cpp
字号:
// *****************************************************************************// *****************************************************************************// oaVerilogOutCmpTermsTest.cpp//// This file contains the implementation of the oaVerilogOutCmpTermsTest class.//// *****************************************************************************// Except as specified in the OpenAccess terms of use of Cadence or Silicon// Integration Initiative, this material may not be copied, modified,// re-published, uploaded, executed, or istributed in any way, in any medium,// in whole or in part, without prior written permission from Cadence.//// Copyright 2003-2005 Cadence Design Systems, Inc.// All Rights Reserved.//// $Author: shaun $// $Revision: 1.2 $// $Date: 2005/08/06 15:11:23 $// $State: Exp $// *****************************************************************************// *****************************************************************************#include "oaVerilogOutTest.h"#include "oaVerilogCmpTerms.h"#include "oaVerilogCmpTerms.inl"// *****************************************************************************// oaVerilogCmpTermsTest::oaVerilogCmpTermsTest()//// This is the constructor for the oaVerilogCmpTermsTest class.// *****************************************************************************oaVerilogCmpTermsTest::oaVerilogCmpTermsTest(const oaString &name): oaVerilogOutTest(name), numCases(8){ // Low instTerms and terms should always be sorted before high instTerms // and terms. When making edits to the terms and instTerms, be careful to // preserve this ordering: always remove the positions from the high // set first and always clear the interface bits from the high group first. lowTermStr.setSize(numCases); lowTermStr[0] = "a"; lowTermStr[1] = "b[0:1]"; lowTermStr[2] = "c[2:0]"; lowTermStr[3] = "d[0:1]"; lowTermStr[4] = "e[0]"; lowTermStr[5] = "f[0]"; lowTermStr[6] = "g[0]"; lowTermStr[7] = "i,j"; lowTermStr.setNumElements(numCases); highTermStr.setSize(numCases); highTermStr[0] = "z"; highTermStr[1] = "y[0:1]"; highTermStr[2] = "x[2:0]"; highTermStr[3] = "w[0:1]"; highTermStr[4] = "v[0]"; highTermStr[5] = "u[0]"; highTermStr[6] = "t[0]"; highTermStr[7] = "r,q"; highTermStr.setNumElements(numCases); lowInstTermStr.setSize(numCases); lowInstTermStr[0] = "a"; lowInstTermStr[1] = "b[0:1]"; lowInstTermStr[2] = "c[2:0]"; lowInstTermStr[3] = "d[0:1]"; lowInstTermStr[4] = "e[0]"; lowInstTermStr[5] = "f[0]"; lowInstTermStr[6] = "g[0]"; lowInstTermStr[7] = "h[0:1]"; lowTermStr.setNumElements(numCases); highInstTermStr.setSize(numCases); highInstTermStr[0] = "z"; highInstTermStr[1] = "y[0:1]"; highInstTermStr[2] = "x[2:0]"; highInstTermStr[3] = "w[0:1]"; highInstTermStr[4] = "v[0]"; highInstTermStr[5] = "u[0]"; highInstTermStr[6] = "t[0]"; highInstTermStr[7] = "s[0:1]"; lowInstTermStr.setNumElements(numCases);}// *****************************************************************************// oaVerilogCmpTermsTest::test()//// This function is the main entry point for the test.// *****************************************************************************oaBooleanoaVerilogCmpTermsTest::test(){ preTest(); openOutputFile(); buildData(); oaString myLibNameStr(getName() + "Lib"); oaScalarName myLibName(vns, myLibNameStr); oaLib *lib = oaLib::find(myLibName); MsgAdapter msgs; msgs.setOutFile(NULL); try { oaScalarName cellName(vns, "top"); oaScalarName viewName(vns, "netlist"); oaDesign *d = oaDesign::open(myLibName, cellName, viewName, 'r'); oaModule *m = d->getTopModule(); // Compare terminals in which both terminals have a position. compareTerms(m); // Remove the positions on the high terminals and retest. oaIter<oaModTerm> termIter(m->getTerms()); while (oaModTerm *term = termIter.getNext()) { if (term->getPosition() >= numCases) { term->unsetPosition(); } } compareTerms(m); // Remove the positions on the all terminals and retest. termIter.reset(); while (oaModTerm *term = termIter.getNext()) { term->unsetPosition(); } // Clear the isInterface bit on the high terminals and retest. for (oaUInt4 i = 0; i < numCases; i++) { oaModTerm *term = oaModTerm::find(m, oaName(ns, highTermStr[i])); term->setIsInterface(false); } compareTerms(m); // Clear the isInterface bit on all terminals and retest. termIter.reset(); while (oaModTerm *term = termIter.getNext()) { term->setIsInterface(false); } compareTerms(m); // Compare instTerms by position. compareInstTerms(oaModInst::find(m, oaSimpleName(ns, "byPos"))); // Compare instTerms by name. oaModInst *byName = oaModInst::find(m, oaSimpleName(ns, "byName")); compareInstTerms(byName); // Remove the positions of the high terms in the master and compare // the instTerms by name again. oaModule *master = oaModule::find(d, oaScalarName(ns, "leaf")); for (oaUInt4 j = 0; j < numCases; j++) { oaModTerm *term = oaModTerm::find(master, oaName(ns, highInstTermStr[j])); term->unsetPosition(); } compareInstTerms(byName); // Remove the positions of all terms in the master and compare the // instTerms by name again. for (oaUInt4 k = 0; k < numCases; k++) { oaModTerm *term = oaModTerm::find(master, oaName(ns, lowInstTermStr[k])); term->unsetPosition(); } compareInstTerms(byName); // Clear the isInterface bit of the high terms in the master and compare // instTerms by name again. for (oaUInt4 n = 0; n < numCases; n++) { oaModTerm *term = oaModTerm::find(master, oaName(ns, highInstTermStr[n])); term->setIsInterface(false); } compareInstTerms(byName); // Clear the isInterface bit of all the terms in the master and compare // instTerms by name again. for (oaUInt4 p = 0; p < numCases; p++) { oaModTerm *term = oaModTerm::find(master, oaName(ns, lowInstTermStr[p])); term->setIsInterface(false); } compareInstTerms(byName); } catch(oaException &oaErr) { logPrint("ERROR: %s\n", (const char*) oaErr.getMsg()); result = false; } catch(...) { logPrint("ERROR: Caught an unhandled exception.\n"); result = false; } cleanup(myLibNameStr); closeOutputFile(); return result;}// *****************************************************************************// oaVerilogCmpTermsTest::compareTerms()//// This function compares the terminals in the given module.// *****************************************************************************voidoaVerilogCmpTermsTest::compareTerms(oaModule *m){ oaArray<oaModTerm*> lowTerm(numCases); oaArray<oaModTerm*> highTerm(numCases); for (oaUInt4 i = 0; i < numCases; i++) { lowTerm[i] = oaModTerm::find(m, oaName(ns, lowTermStr[i])); highTerm[i] = oaModTerm::find(m, oaName(ns, highTermStr[i])); } lowTerm.setNumElements(numCases); highTerm.setNumElements(numCases); ((oaModBusTerm*) lowTerm[3])->getDef()->setBitOrder(oacNoneBitOrder); ((oaModBusTerm*) highTerm[3])->getDef()->setBitOrder(oacNoneBitOrder); CmpTerms cmp; for (oaUInt4 j = 0; j < numCases; j++) { for (oaUInt4 k = 0; k < numCases; k++) { verify(cmp(lowTerm[j], highTerm[k]) == true); verify(cmp(highTerm[k], lowTerm[j]) == false); } }}// *****************************************************************************// oaVerilogCmpTermsTest::compareInstTerms()//// This function compares the instTerms of the given instance.// *****************************************************************************voidoaVerilogCmpTermsTest::compareInstTerms(oaModInst *inst){ oaArray<oaModInstTerm*> lowInstTerm(numCases); oaArray<oaModInstTerm*> highInstTerm(numCases); for (oaUInt4 i = 0; i < numCases; i++) { if (inst->usesTermPositions()) { lowInstTerm[i] = oaModInstTerm::find(inst, i); highInstTerm[i] = oaModInstTerm::find(inst, i + numCases); } else { oaName lowN(ns, lowInstTermStr[i]); oaName highN(ns, highInstTermStr[i]); lowInstTerm[i] = oaModInstTerm::find(inst, lowN); highInstTerm[i] = oaModInstTerm::find(inst, highN); } } lowInstTerm.setNumElements(numCases); highInstTerm.setNumElements(numCases); if (inst->usesTermPositions()) { oaModBusTerm *term; oaUInt4 pos; pos = lowInstTerm[3]->getTermPosition(); term = (oaModBusTerm*) oaModTerm::find(inst->getMasterModule(), pos); term->getDef()->setBitOrder(oacNoneBitOrder); pos = highInstTerm[3]->getTermPosition(); term = (oaModBusTerm*) oaModTerm::find(inst->getMasterModule(), pos); term->getDef()->setBitOrder(oacNoneBitOrder); } else { ((oaModBusTerm*) lowInstTerm[3]->getTerm())->getDef()->setBitOrder(oacNoneBitOrder); ((oaModBusTerm*) highInstTerm[3]->getTerm())->getDef()->setBitOrder(oacNoneBitOrder); } CmpInstTerms cmp; for (oaUInt4 j = 0; j < numCases; j++) { for (oaUInt4 k = 0; k < numCases; k++) { verify(cmp(lowInstTerm[j], highInstTerm[k]) == true); verify(cmp(highInstTerm[k], lowInstTerm[j]) == false); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -