00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef HAVE_CONFIG_H
00017 #include "torc/generic/config.h"
00018 #endif
00019
00020 #include "torc/generic/decompiler/Decompiler.hpp"
00021 #include "torc/generic/om/PortAttributes.hpp"
00022 #include "torc/generic/om/NetAttributes.hpp"
00023 #include "torc/generic/om/TimeStamp.hpp"
00024 #include "torc/generic/om/Written.hpp"
00025 #include "torc/generic/om/InterfaceAttributes.hpp"
00026 #include "torc/generic/om/LogicValueAttributes.hpp"
00027 #include "torc/generic/om/PathDelay.hpp"
00028
00029 namespace {
00030
00031 using namespace torc::generic;
00032 typedef std::vector< LibrarySharedPtr > Libraries;
00033 typedef std::vector< CellSharedPtr > Cells;
00034 typedef std::vector< ViewSharedPtr > Views;
00035 typedef std::vector< InstanceSharedPtr > Instances;
00036
00037 std::string
00038 trimLeading( const std::string &inBuffer ) {
00039 const size_t beginStr = inBuffer.find_first_of("(");
00040 if(beginStr != std::string::npos)
00041 {
00042 const size_t endStr = inBuffer.find_last_of(")");
00043 const size_t range = endStr - beginStr + 1;
00044 return inBuffer.substr(beginStr, range);
00045 }
00046 return std::string();
00047 }
00048
00049
00050 std::string
00051 trimLeadingSpaces( const std::string &inBuffer ) {
00052
00053 const size_t startpos = inBuffer.find_first_not_of(" \t");
00054 if( std::string::npos != startpos ) {
00055 return inBuffer.substr( startpos, std::string::npos );
00056 }
00057 return std::string();
00058 }
00059
00060 struct CircularDependencyResolver {
00061
00062 enum PrintType
00063 {
00064 ePrintTypeExtern,
00065 ePrintTypeConcrete
00066 };
00067
00068 void
00069 resolve( const RootSharedPtr &inRoot )
00070 {
00071 SymTab<std::string, PrintType, true> discoveredLibs;
00072 Libraries libs;
00073 inRoot->getLibraries( libs );
00074 for( Libraries::iterator lib = libs.begin();
00075 lib != libs.end(); ++lib )
00076 {
00077 if( (*lib)->getIsExtern() )
00078 {
00079 PrintType type;
00080 if( !discoveredLibs.get((*lib)->getName(), type) )
00081 {
00082
00083 mExterns.push_back( *lib );
00084 discoveredLibs.set( (*lib)->getName(),
00085 ePrintTypeExtern );
00086 }
00087 continue;
00088
00089
00090 }
00091 discoveredLibs.set( (*lib)->getName(),
00092 ePrintTypeConcrete );
00093 mConcreteLibs.push_back( *lib );
00094 Cells cells;
00095 (*lib)->getCells( cells );
00096 for( Cells::iterator cell = cells.begin();
00097 cell != cells.end(); ++cell )
00098 {
00099 Views views;
00100 (*cell)->getViews( views );
00101 for( Views::iterator view = views.begin();
00102 view != views.end(); ++view )
00103 {
00104 Instances instances;
00105 (*view)->getInstances( instances );
00106 for( Instances::iterator inst
00107 = instances.begin();
00108 inst != instances.end(); ++inst )
00109 {
00110 switch( (*inst)->getCompositionType() )
00111 {
00112 case eCompositionTypeScalar:
00113 {
00114 checkLib( *inst, discoveredLibs );
00115 break;
00116 }
00117 case eCompositionTypeVector:
00118 {
00119 Instances children;
00120 (*inst)->getChildren( children );
00121 for( Instances::iterator c
00122 = children.begin();
00123 c != children.end(); ++c )
00124 {
00125 checkLib( *c, discoveredLibs );
00126 }
00127 break;
00128 }
00129 default:
00130 {
00131 }
00132 }
00133 }
00134 }
00135 }
00136 }
00137 }
00138
00139 void
00140 checkLib( const InstanceSharedPtr &inInst,
00141 SymTab<std::string, PrintType, true> &inDiscoveredLibs)
00142 {
00143 ViewSharedPtr iV = inInst->getMaster();
00144 LibrarySharedPtr targetL
00145 = iV->getParent()->getParent();
00146 PrintType type;
00147 if( !inDiscoveredLibs.get( targetL->getName(), type ) )
00148 {
00149 mExterns.push_back( targetL );
00150 inDiscoveredLibs.set( targetL->getName(),
00151 ePrintTypeExtern );
00152
00153
00154 }
00155 }
00156 std::vector< LibrarySharedPtr > mExterns;
00157 std::vector< LibrarySharedPtr > mConcreteLibs;
00158 };
00159
00160 class Indenter {
00161 public:
00162 size_t
00163 getIndentation() const throw();
00164
00165 Indenter( Decompiler &inPrinter,
00166 bool inChangeIndentation = true );
00167 ~Indenter();
00168
00169 private:
00170 Decompiler &mPrinter;
00171 bool mChangeIndentation;
00172 };
00173
00174 size_t
00175 Indenter::getIndentation() const throw()
00176 {
00177 return mPrinter.getIndentation();
00178 }
00179
00180 Indenter::Indenter( Decompiler &inPrinter,
00181 bool inChangeIndentation)
00182 : mPrinter( inPrinter ),
00183 mChangeIndentation( inChangeIndentation ) {
00184 size_t indentation = getIndentation();
00185 indentation += (mChangeIndentation) ? 4 : 0;
00186 mPrinter.setIndentation( indentation );
00187 }
00188
00189 Indenter::~Indenter()
00190 {
00191 size_t indentation = getIndentation();
00192 indentation -= (mChangeIndentation) ? 4 : 0;
00193 mPrinter.setIndentation( indentation );
00194 }
00195
00196 }
00197
00198 namespace std
00199 {
00200
00201 std::ostream &
00202 operator<<( std::ostream &outStream, const Indenter &indent )
00203 {
00204 for( size_t i = 0; i < indent.getIndentation(); i++ )
00205 {
00206 outStream<<" ";
00207 }
00208 return outStream;
00209 }
00210
00211 }
00212
00213 namespace torc {
00214
00215 namespace generic {
00216
00217
00218 void
00219 Decompiler::visit( Root &root ) throw(Error)
00220 try
00221 {
00222 CircularDependencyResolver resolver;
00223 resolver.resolve( root.getSharedThis() );
00224 if( !root.getOriginalName().empty() )
00225 {
00226 mOut << "(edif (rename " << root.getName() << " "
00227 << "\"" << root.getOriginalName() << "\"" << ")" << std::endl;
00228 }
00229 else
00230 {
00231 mOut << "(edif " << root.getName() << std::endl;
00232 }
00233 mOut << " (edifVersion " << (int32_t)root.getVersion().mFirst << " "
00234 << (int32_t)root.getVersion().mSecond << " "
00235 << (int32_t)root.getVersion().mThird << ")" << std::endl;
00236 mOut << " (edifLevel " << root.getLevel() << ")" << std::endl;
00237 mOut << " (keywordMap (keywordLevel 0" << "))";
00238
00239
00240 std::vector< std::string > comments = root.getComments();
00241 printComments( comments );
00242
00243 root.applyOnAllStatuses( mApplier );
00244
00245 mIsExternContext = true;
00246 std::for_each( resolver.mExterns.begin(), resolver.mExterns.end(),
00247 mApplier );
00248 mIsExternContext = false;
00249
00250 std::for_each( resolver.mConcreteLibs.begin(),
00251 resolver.mConcreteLibs.end(), mApplier );
00252 root.applyOnAllDesigns( mApplier );
00253
00254 std::list< std::string > elements;
00255 root.getUserData( elements );
00256 printUserData( elements );
00257
00258 mOut << std::endl << ")" << std::endl;
00259 }
00260 catch( Error &e )
00261 {
00262 e.setCurrentLocation( __FUNCTION__, __FILE__, __LINE__ );
00263 throw;
00264 }
00265
00266
00267 void
00268 Decompiler::visit( Design &design ) throw(Error)
00269 try
00270 {
00271 Indenter indent(*this);
00272 if( !design.getOriginalName().empty() )
00273 {
00274 mOut << std::endl << indent << "(design "
00275 << "(rename " << design.getName() << " "
00276 << "\"" << design.getOriginalName() << "\"" << ")";
00277 }
00278 else
00279 {
00280 mOut << std::endl << indent << "(design "
00281 << design.getName();
00282 }
00283 mOut << std::endl << indent << " (cellRef " << design.getCellRefName()
00284 << " (libraryRef " << design.getLibraryRefName() << "))";
00285
00286
00287 std::vector< std::string > comments = design.getComments();
00288 printComments( comments );
00289
00290 design.applyOnAllStatuses( mApplier );
00291 design.applyOnAllProperties( mApplier );
00292
00293 std::list< std::string > elements;
00294 design.getUserData( elements );
00295 printUserData( elements );
00296
00297 mOut << std::endl << indent << ")";
00298 }
00299 catch( Error &e )
00300 {
00301 e.setCurrentLocation( __FUNCTION__, __FILE__, __LINE__ );
00302 throw;
00303 }
00304
00305
00306
00307 void
00308 Decompiler::visit( Library &library ) throw(Error)
00309 try
00310 {
00311 Indenter indent(*this);
00312 if( mIsExternContext || library.getIsExtern() )
00313 {
00314 if( !library.getOriginalName().empty() )
00315 {
00316 mOut << std::endl << indent << "(external ";
00317 mOut << std::endl << indent << " (rename " << library.getName() << " "
00318 << "\"" <<library.getOriginalName() << "\"" << ")";
00319 }
00320 else
00321 {
00322 mOut << std::endl << indent << "(external " << library.getName();
00323 }
00324 }
00325 else
00326 {
00327 if( !library.getOriginalName().empty() )
00328 {
00329 mOut << std::endl << indent << "(library ";
00330 mOut << std::endl << indent << " (rename " << library.getName() << " "
00331 << "\"" << library.getOriginalName() << "\"" << ")";
00332 }
00333 else
00334 {
00335 mOut << std::endl << indent << "(library " << library.getName();
00336 }
00337 }
00338 mOut << std::endl << indent << " (ediflevel " << library.getLevel() << ")"
00339 << " (technology (numberDefinition";
00340
00341 std::map<Unit,ScaleFactor> outScaleFactors;
00342 outScaleFactors = library.getScaleFactors();
00343 std::map<Unit,ScaleFactor>::iterator it = outScaleFactors.begin();
00344 for(; it != outScaleFactors.end(); ++it )
00345 {
00346 Unit unit = (*it).first;
00347 ScaleFactor scale = (*it).second;
00348 mOut << std::endl << indent << " (scale ";
00349 printValue( Value(Value::eValueTypeNumber, scale.getSiValue()) );
00350 printValue( Value(Value::eValueTypeNumber, scale.getEdifValue()) );
00351 printUnit( unit );
00352 mOut << ")";
00353 }
00354 mOut << ")";
00355
00356 SimulationInfoSharedPtr simuInfo = library.getSimulationInfo();
00357 if( simuInfo )
00358 {
00359 simuInfo->accept( *this );
00360 }
00361 mOut << ")";
00362
00363
00364 std::vector< std::string > comments = library.getComments();
00365 printComments( comments );
00366
00367 library.applyOnAllStatuses( mApplier );
00368
00369 std::list< std::string > elements;
00370 library.getUserData( elements );
00371 printUserData( elements );
00372
00373 library.applyOnAllCells( mApplier );
00374 mOut << std::endl << indent<< ")";
00375 }
00376 catch( Error &e )
00377 {
00378 e.setCurrentLocation( __FUNCTION__, __FILE__, __LINE__ );
00379 throw;
00380 }
00381
00382
00383 void
00384 Decompiler::visit( Cell &cell ) throw(Error)
00385 try
00386 {
00387 Indenter indent(*this);
00388 std::string cellType;
00389 switch( cell.getType() )
00390 {
00391 case Cell::eTypeTie:
00392 {
00393 cellType = "TIE";
00394 break;
00395 }
00396 case Cell::eTypeRipper:
00397 {
00398 cellType = "RIPPER";
00399 break;
00400 }
00401 case Cell::eTypeGeneric:
00402 {
00403 cellType = "GENERIC";
00404 break;
00405 }
00406 default:
00407 {
00408 }
00409 }
00410 if( !cell.getOriginalName().empty() )
00411 {
00412 mOut << std::endl << indent << "(cell ";
00413 mOut << std::endl << indent << " (rename " << cell.getName() << " "
00414 << "\"" << cell.getOriginalName() << "\"" << ")";
00415 }
00416 else
00417 {
00418 mOut << std::endl << indent << "(cell " << cell.getName();
00419 }
00420 mOut << std::endl << indent << " (cellType " << cellType << ")";
00421
00422
00423 std::vector< std::string > comments = cell.getComments();
00424 printComments( comments );
00425
00426 cell.applyOnAllStatuses( mApplier );
00427
00428 std::list< std::string > elements;
00429 cell.getUserData( elements );
00430 printUserData( elements );
00431
00432 cell.applyOnAllViews( mApplier );
00433 cell.applyOnAllProperties( mApplier );
00434 mOut << std::endl << indent << ")";
00435 }
00436 catch( Error &e )
00437 {
00438 e.setCurrentLocation( __FUNCTION__, __FILE__, __LINE__ );
00439 throw;
00440 }
00441
00442
00443 void
00444 Decompiler::visit( View &view ) throw(Error)
00445 try
00446 {
00447 Indenter indent(*this);
00448 std::string viewType;
00449 switch( view.getType() )
00450 {
00451 case View::eTypeMaskLayout:
00452 {
00453 viewType = "MASKLAYOUT";
00454 break;
00455 }
00456 case View::eTypePCBLayout:
00457 {
00458 viewType = "PCBLAYOUT";
00459 break;
00460 }
00461 case View::eTypeNetlist:
00462 {
00463 viewType = "NETLIST";
00464 break;
00465 }
00466 case View::eTypeSchematic:
00467 {
00468 viewType = "SCHEMATIC";
00469 break;
00470 }
00471 case View::eTypeSymbolic:
00472 {
00473 viewType = "SYMBOLIC";
00474 break;
00475 }
00476 case View::eTypeBehavior:
00477 {
00478 viewType = "BEHAVIOR";
00479 break;
00480 }
00481 case View::eTypeLogicModel:
00482 {
00483 viewType = "LOGICMODEL";
00484 break;
00485 }
00486 case View::eTypeDocument:
00487 {
00488 viewType = "DOCUMENT";
00489 break;
00490 }
00491 case View::eTypeGraphic:
00492 {
00493 viewType = "GRAPHIC";
00494 break;
00495 }
00496 case View::eTypeStranger:
00497 {
00498 viewType = "STRANGER";
00499 break;
00500 }
00501 }
00502 if( !view.getOriginalName().empty() )
00503 {
00504 mOut << std::endl << indent << "(view ";
00505 mOut << std::endl << indent << " (rename " << view.getName()
00506 << " " << "\"" << view.getOriginalName() << "\"" << ")";
00507 }
00508 else
00509 {
00510 mOut << std::endl << indent << "(view " << view.getName();
00511 }
00512 mOut << std::endl << indent <<" (viewType " << viewType << ")";
00513
00514 if( View::eTypeNetlist
00515 != view.getType())
00516 {
00517 mOut<< view.getNonNetlistViewData();
00518 return;
00519 }
00520
00521 mOut << std::endl << indent <<" (interface ";
00522 mIsJoiningContext = false;
00523 view.applyOnAllPorts( mApplier );
00524 printViewInterfaceAttributes( view.getInterfaceAttributes() );
00525 typedef std::map< std::string,ParameterSharedPtr > Params;
00526 ParameterMapSharedPtr params
00527 = view.getParameters();
00528 ParameterContext context = view.getParameterContext();
00529 Params paramMap;
00530 params->getAllParameters( context, paramMap );
00531 for( Params::iterator it = paramMap.begin();
00532 it != paramMap.end(); it++ )
00533 {
00534 (*it).second->accept( *this );
00535 }
00536 mIsJoiningContext = true;
00537 view.applyOnAllPermutables( mApplier );
00538 view.applyOnAllInterfaceJoinedInfos( mApplier );
00539 mOut << std::endl << indent <<" )";
00540 view.applyOnAllProperties( mApplier );
00541
00542
00543 std::vector< std::string > comments = view.getComments();
00544 printComments( comments );
00545
00546 view.applyOnAllStatuses( mApplier );
00547
00548 std::list< std::string > elements;
00549 view.getUserData( elements );
00550 printUserData( elements );
00551
00552 if( !mIsExternContext )
00553 {
00554
00555 std::vector< InstanceSharedPtr > instVec;
00556 view.getInstances(instVec);
00557
00558 std::vector< NetSharedPtr > netVec;
00559 view.getNets(netVec);
00560
00561 if(!instVec.empty() || !netVec.empty()) {
00562 mOut << std::endl << indent <<" (contents ";
00563
00564 mIsJoiningContext = false;
00565 view.applyOnAllInstances( mApplier );
00566
00567 if( NULL != view.getSimulate() )
00568 {
00569 view.getSimulate()->accept( *this );
00570 }
00571
00572
00573 mIsJoiningContext = true;
00574 view.applyOnAllNets( mApplier );
00575
00576 if( NULL != view.getTiming() )
00577 {
00578 view.getTiming()->accept( *this );
00579 }
00580
00581 mOut << std::endl << indent <<" )";
00582 }
00583 }
00584 mOut << std::endl << indent<< ")";
00585 }
00586 catch( Error &e )
00587 {
00588 e.setCurrentLocation( __FUNCTION__, __FILE__, __LINE__ );
00589 throw;
00590 }
00591
00592
00593 void
00594 Decompiler::visit( ScalarPort &port ) throw(Error)
00595 try
00596 {
00597 Indenter indent( *this );
00598 if( !mIsJoiningContext )
00599 {
00600 if( !port.getOriginalName().empty() )
00601 {
00602 mOut << std::endl << indent << "(port ";
00603 mOut << std::endl << indent << " (rename " << port.getName() << " "
00604 << "\"" << port.getOriginalName() << "\"" << ")";
00605 }
00606 else
00607 {
00608 mOut << std::endl << indent << "(port " << port.getName();
00609 }
00610 switch( port.getDirection() )
00611 {
00612 case ePortDirectionIn:
00613 {
00614 mOut << std::endl << indent << " (direction INPUT)";
00615 break;
00616 }
00617 case ePortDirectionOut:
00618 {
00619 mOut << std::endl << indent << " (direction OUTPUT)";
00620 break;
00621 }
00622 case ePortDirectionInOut:
00623 {
00624 mOut << std::endl << indent << " (direction INOUT)";
00625 break;
00626 }
00627 default:
00628 {
00629 }
00630 }
00631 printPortAttributes( port.getAttributes() );
00632
00633
00634 std::vector< std::string > comments = port.getComments();
00635 printComments( comments );
00636
00637 std::list< std::string > elements;
00638 port.getUserData( elements );
00639 printUserData( elements );
00640
00641 port.applyOnAllProperties( mApplier );
00642 mOut << std::endl << indent << ")";
00643 }
00644 else
00645 {
00646 mOut << std::endl << indent << "(portRef " << port.getName();
00647 PortSharedPtr parentCol = port.getParentCollection();
00648 if( parentCol )
00649 {
00650 parentCol->accept( *this );
00651 }
00652 mOut << ")";
00653 }
00654 }
00655 catch( Error &e )
00656 {
00657 e.setCurrentLocation( __FUNCTION__, __FILE__, __LINE__ );
00658 throw;
00659 }
00660
00661
00662 void
00663 Decompiler::visit( ScalarPortReference &portRef ) throw(Error)
00664 try
00665 {
00666 Indenter indent(*this);
00667 if( mIsJoiningContext )
00668 {
00669 mOut << std::endl << indent << "(portRef " << portRef.getName();
00670 PortReferenceSharedPtr parentCol
00671 = portRef.getParentCollection();
00672 if( parentCol )
00673 {
00674 parentCol->accept( *this );
00675 }
00676 else
00677 {
00678 if( !mIsPortInstanceContext )
00679 {
00680 portRef.getParent()->accept( *this );
00681 }
00682 }
00683 mOut << ")";
00684 }
00685 else
00686 {
00687 }
00688 }
00689 catch( Error &e )
00690 {
00691 e.setCurrentLocation( __FUNCTION__, __FILE__, __LINE__ );
00692 throw;
00693 }
00694
00695
00696 void
00697 Decompiler::visit( VectorPort &port ) throw(Error)
00698 try
00699 {
00700 Indenter indent(*this);
00701 if( mIsJoiningContext )
00702 {
00703 mOut<< std::endl << indent <<"(portRef "<<port.getName();
00704 PortSharedPtr parentCol = port.getParentCollection();
00705 if( parentCol )
00706 {
00707 parentCol->accept( *this );
00708 }
00709 mOut<<")";
00710 }
00711 else
00712 {
00713 if( !port.getOriginalName().empty() )
00714 {
00715 mOut << std::endl << indent << "(port ";
00716 mOut << std::endl << indent << " (array (rename " << port.getName() << " "
00717 << "\"" << port.getOriginalName() << "\"" << ")" << " ";
00718 }
00719 else
00720 {
00721 mOut << std::endl << indent << "(port (array " << port.getName() << " ";
00722 }
00723 std::vector<size_t> limits;
00724 port.getLimits( limits );
00725 copy( limits.begin(), limits.end(),
00726 std::ostream_iterator<size_t>( mOut, " " ) );
00727 mOut<< ")";
00728 switch( port.getDirection() )
00729 {
00730 case ePortDirectionIn:
00731 {
00732 mOut << std::endl << indent << " (direction INPUT)";
00733 break;
00734 }
00735 case ePortDirectionOut:
00736 {
00737 mOut << std::endl << indent << " (direction OUTPUT)";
00738 break;
00739 }
00740 case ePortDirectionInOut:
00741 {
00742 mOut << std::endl << indent << " (direction INOUT)";
00743 break;
00744 }
00745 default:
00746 {
00747 }
00748
00749 }
00750 printPortAttributes( port.getAttributes() );
00751
00752
00753 std::vector< std::string > comments = port.getComments();
00754 printComments( comments );
00755
00756 std::list< std::string > elements;
00757 port.getUserData( elements );
00758 printUserData( elements );
00759
00760 port.applyOnAllProperties( mApplier );
00761 mOut << std::endl << indent << ")";
00762 }
00763 }
00764 catch( Error &e )
00765 {
00766 e.setCurrentLocation( __FUNCTION__, __FILE__, __LINE__ );
00767 throw;
00768 }
00769
00770
00771 void
00772 Decompiler::visit( VectorPortReference &portRef ) throw(Error)
00773 try
00774 {
00775 Indenter indent(*this);
00776 if( mIsJoiningContext )
00777 {
00778 mOut << std::endl << indent <<"(portRef " <<portRef.getName()<<" ";
00779 PortReferenceSharedPtr parentCol
00780 = portRef.getParentCollection();
00781 if( parentCol )
00782 {
00783 parentCol->accept( *this );
00784 }
00785 else
00786 {
00787 if( !mIsPortInstanceContext )
00788 {
00789 portRef.getParent()->accept( *this );
00790 }
00791 }
00792 mOut<<")";
00793 }
00794 else
00795 {
00796 }
00797 }
00798 catch( Error &e )
00799 {
00800 e.setCurrentLocation( __FUNCTION__, __FILE__, __LINE__ );
00801 throw;
00802 }
00803
00804
00805 void
00806 Decompiler::visit( VectorPortBit &bit ) throw(Error)
00807 try
00808 {
00809 Indenter indent(*this);
00810 if( mIsJoiningContext )
00811 {
00812 PortSharedPtr parent
00813 = bit.getParentCollection();
00814 mOut<< std::endl << indent << "(portRef (member " <<parent->getName()<<" ";
00815 copy(bit.getIndices().begin(), bit.getIndices().end(),
00816 std::ostream_iterator<size_t>(mOut, " "));
00817 mOut<<")";
00818 PortSharedPtr parentCol
00819 = parent->getParentCollection();
00820 if( parentCol )
00821 {
00822 parentCol->accept( *this );
00823 }
00824 mOut<<")";
00825 bit.applyOnAllProperties( mApplier );
00826 }
00827 else
00828 {
00829 }
00830 }
00831 catch( Error &e )
00832 {
00833 e.setCurrentLocation( __FUNCTION__, __FILE__, __LINE__ );
00834 throw;
00835 }
00836
00837
00838 void
00839 Decompiler::visit( VectorPortBitReference &bitRef ) throw(Error)
00840 try
00841 {
00842 Indenter indent(*this);
00843 if( mIsJoiningContext )
00844 {
00845 PortReferenceSharedPtr parent
00846 = bitRef.getParentCollection();
00847 mOut<< std::endl << indent << "(portRef (member " <<parent->getName()<<" ";
00848 copy(bitRef.getIndices().begin(),
00849 bitRef.getIndices().end(),
00850 std::ostream_iterator<size_t>(mOut, " "));
00851 mOut<<")";
00852 PortReferenceSharedPtr parentCol
00853 = parent->getParentCollection();
00854 if( parentCol )
00855 {
00856 parentCol->accept( *this );
00857 }
00858 else
00859 {
00860 if( !mIsPortInstanceContext )
00861 {
00862 parent->getParent()->accept( *this );
00863 }
00864 }
00865 mOut<<")";
00866 }
00867 else
00868 {
00869 }
00870 }
00871 catch( Error &e )
00872 {
00873 e.setCurrentLocation( __FUNCTION__, __FILE__, __LINE__ );
00874 throw;
00875 }
00876
00877
00878 void
00879 Decompiler::visit( PortBundle &port ) throw(Error)
00880 try
00881 {
00882 Indenter indent(*this);
00883 if( mIsJoiningContext )
00884 {
00885 if( mIsPermutableContext )
00886 {
00887 mOut << std::endl << indent << "(portRef " << port.getName();
00888 }
00889 else
00890 {
00891 mOut<< " (portRef "<<port.getName();
00892 }
00893 PortSharedPtr parentCol
00894 = port.getParentCollection();
00895 if( parentCol )
00896 {
00897 parentCol->accept( *this );
00898 }
00899 mOut<<")";
00900 }
00901 else
00902 {
00903 if( !port.getOriginalName().empty() )
00904 {
00905 mOut << std::endl << indent << "(portBundle ";
00906 mOut << std::endl << indent << " (rename " << port.getName() << " "
00907 << "\"" << port.getOriginalName() << "\"" << ")";
00908 }
00909 else
00910 {
00911 mOut << std::endl << indent << "(portBundle " << port.getName();
00912 }
00913 {
00914 Indenter subIndent( *this );
00915 mOut << std::endl << subIndent << "(listOfPorts ";
00916 port.applyOnAllChildren( mApplier );
00917 mOut << std::endl << subIndent << ")";
00918 }
00919
00920
00921 std::vector< std::string > comments = port.getComments();
00922 printComments( comments );
00923
00924 std::list< std::string > elements;
00925 port.getUserData( elements );
00926 printUserData( elements );
00927
00928 mOut << std::endl << indent << ")";
00929 }
00930 port.applyOnAllProperties( mApplier );
00931 }
00932 catch( Error &e )
00933 {
00934 e.setCurrentLocation( __FUNCTION__, __FILE__, __LINE__ );
00935 throw;
00936 }
00937
00938
00939 void
00940 Decompiler::visit( PortBundleReference &portRef ) throw(Error)
00941 try
00942 {
00943 Indenter indent(*this);
00944 mOut<< std::endl << indent <<"(portRef " <<portRef.getName()<<" ";
00945 PortReferenceSharedPtr parentCol
00946 = portRef.getParentCollection();
00947 if( parentCol )
00948 {
00949 parentCol->accept( *this );
00950 }
00951 else
00952 {
00953 portRef.getParent()->accept( *this );
00954 }
00955 mOut<<")";
00956 }
00957 catch( Error &e )
00958 {
00959 e.setCurrentLocation( __FUNCTION__, __FILE__, __LINE__ );
00960 throw;
00961 }
00962
00963
00964 void
00965 Decompiler::visit( SingleInstance &instance ) throw(Error)
00966 try
00967 {
00968
00969 if( mIsJoiningContext )
00970 {
00971 mOut<< " (instanceRef " << instance.getName() << ")";
00972 }
00973 else
00974 {
00975 Indenter indent( *this );
00976 if( !instance.getOriginalName().empty() )
00977 {
00978 mOut << std::endl << indent << "(instance ";
00979 mOut << std::endl << indent << " (rename " << instance.getName() << " "
00980 << "\"" << instance.getOriginalName() << "\"" << ")";
00981 }
00982 else
00983 {
00984 mOut << std::endl << indent << "(instance " << instance.getName();
00985 }
00986 mOut << std::endl << indent << " (viewRef " << instance.getMaster()->getName()
00987 << " (cellRef " << instance.getMaster()->getParent()->getName()
00988 << " (libraryRef " << instance.getMaster()->getParent()->getParent()->getName()
00989 << ")))";
00990
00991 if( !instance.getDesignator().empty() )
00992 {
00993 mOut << std::endl << indent << " (designator "
00994 << "\"" << instance.getDesignator() << "\"" << ")";
00995 }
00996
00997 if( NULL != instance.getTiming() )
00998 {
00999 instance.getTiming()->accept( *this );
01000 }
01001
01002
01003 std::vector< std::string > comments = instance.getComments();
01004 printComments( comments );
01005
01006 std::list< std::string > elements;
01007 instance.getUserData( elements );
01008 printUserData( elements );
01009
01010 mParamAssignContext = true;
01011 typedef std::map< std::string,ParameterSharedPtr > Params;
01012 ParameterMapSharedPtr params
01013 = instance.getParameters();
01014 ParameterContext context = instance.getParameterContext();
01015 params->applyOnOverriddenParameters( context, mApplier );
01016 mParamAssignContext = false;
01017 instance.applyOnAllProperties( mApplier );
01018 std::vector<PortReferenceSharedPtr> portRefs;
01019 instance.getPortReferences( portRefs );
01020 for( std::vector<PortReferenceSharedPtr>::iterator portRef
01021 = portRefs.begin(); portRef != portRefs.end(); ++ portRef )
01022 {
01023 PortAttributesSharedPtr attribs = (*portRef)->getAttributes();
01024 if( attribs )
01025 {
01026 mOut << std::endl << indent <<" (portInstance ";
01027 mIsPortInstanceContext = true;
01028 mIsJoiningContext = true;
01029 (*portRef)->accept( *this );
01030 mIsJoiningContext = false;
01031 mIsPortInstanceContext = false;
01032 printPortAttributes( attribs );
01033 mOut << std::endl << indent <<" )";
01034 }
01035 }
01036 mOut << std::endl << indent << ")";
01037 }
01038 }
01039 catch( Error &e )
01040 {
01041 e.setCurrentLocation( __FUNCTION__, __FILE__, __LINE__ );
01042 throw;
01043 }
01044
01045
01046 void
01047 Decompiler::visit( ScalarNet &net ) throw(Error)
01048 try
01049 {
01050 Indenter indent(*this);
01051 if( mIsJoiningContext )
01052 {
01053 if( !net.getOriginalName().empty() )
01054 {
01055 mOut << std::endl << indent << "(net ";
01056 mOut << std::endl <<indent << " (rename " << net.getName() << " "
01057 << "\"" << net.getOriginalName() << "\"" << ")";
01058 }
01059 else
01060 {
01061 mOut << std::endl << indent << "(net " << net.getName();
01062 }
01063
01064 mOut << std::endl << indent << " (joined ";
01065 mIsJoiningContext = true;
01066 net.applyOnAllConnectedPorts( mApplier );
01067 net.applyOnAllConnectedPortRefs( mApplier );
01068 net.applyOnAllConnectedPortLists( mApplier );
01069 mOut << std::endl << indent << " )";
01070
01071 printNetAttributes( net.getAttributes() );
01072
01073
01074 std::vector< std::string > comments = net.getComments();
01075 printComments( comments );
01076
01077 std::list< std::string > elements;
01078 net.getUserData( elements );
01079 printUserData( elements );
01080
01081 net.applyOnAllSubnets( mApplier );
01082 net.applyOnAllProperties( mApplier );
01083 mOut << std::endl << indent << ")";
01084 }
01085 else
01086 {
01087 mOut << std::endl << indent << "(netRef " << net.getName();
01088 NetSharedPtr parentCol = net.getParentCollection();
01089 if( parentCol )
01090 {
01091 parentCol->accept( *this );
01092 }
01093 mOut << ")";
01094 }
01095 }
01096 catch( Error &e )
01097 {
01098 e.setCurrentLocation( __FUNCTION__, __FILE__, __LINE__ );
01099 throw;
01100 }
01101
01102
01103 void
01104 Decompiler::visit( NetBundle &net ) throw(Error)
01105 try
01106 {
01107 Indenter indent(*this);
01108 if( mIsJoiningContext )
01109 {
01110 if( !net.getOriginalName().empty() )
01111 {
01112 mOut << std::endl << indent << "(netbundle ";
01113 mOut << std::endl << indent << " (rename " << net.getName() << " "
01114 << "\"" << net.getOriginalName() << "\"" << ")";
01115 }
01116 else
01117 {
01118 mOut << std::endl << indent << "(netbundle " << net.getName();
01119 }
01120 mOut << std::endl << indent << " (listOfNets ";
01121 net.applyOnAllSubnets( mApplier );
01122 net.applyOnAllChildren( mApplier );
01123 net.applyOnAllConnectedPorts( mApplier );
01124 net.applyOnAllConnectedPortRefs( mApplier );
01125 net.applyOnAllConnectedPortLists( mApplier );
01126
01127 mOut << std::endl << indent << " )";
01128
01129
01130 std::vector< std::string > comments = net.getComments();
01131 printComments( comments );
01132
01133 std::list< std::string > elements;
01134 net.getUserData( elements );
01135 printUserData( elements );
01136
01137 net.applyOnAllProperties( mApplier );
01138 mOut << std::endl << indent << ")";
01139 }
01140 else
01141 {
01142 mOut << std::endl << indent << "(netRef " << net.getName();
01143 NetSharedPtr parentCol = net.getParentCollection();
01144 if( parentCol )
01145 {
01146 parentCol->accept( *this );
01147 }
01148 mOut << ")";
01149 }
01150 }
01151 catch( Error &e )
01152 {
01153 e.setCurrentLocation( __FUNCTION__, __FILE__, __LINE__ );
01154 throw;
01155 }
01156
01157
01158 void
01159 Decompiler::visit( VectorNet &net ) throw(Error)
01160 try
01161 {
01162 Indenter indent(*this);
01163 if( mIsJoiningContext )
01164 {
01165 if( !net.getOriginalName().empty() )
01166 {
01167 mOut << std::endl << indent << "(net ";
01168 mOut << std::endl << indent << " (array (rename " << net.getName() << " "
01169 << "\"" << net.getOriginalName() << "\"" << ")" << " ";
01170 }
01171 else
01172 {
01173 mOut << std::endl << indent << "(net (array " << net.getName() << " ";
01174 }
01175 std::vector<size_t> limits;
01176 net.getLimits( limits );
01177 copy( limits.begin(), limits.end(),
01178 std::ostream_iterator<size_t>( mOut, " " ) );
01179 mOut<<")";
01180
01181 mOut<< std::endl << indent << " (joined";
01182 mIsJoiningContext = true;
01183 net.applyOnAllConnectedPorts( mApplier );
01184 net.applyOnAllConnectedPortRefs( mApplier );
01185 net.applyOnAllConnectedPortLists( mApplier );
01186 mOut<< std::endl << indent << " )";
01187
01188 printNetAttributes( net.getAttributes() );
01189
01190
01191 std::vector< std::string > comments = net.getComments();
01192 printComments( comments );
01193
01194 std::list< std::string > elements;
01195 net.getUserData( elements );
01196 printUserData( elements );
01197
01198 net.applyOnAllSubnets( mApplier );
01199 net.applyOnAllProperties( mApplier );
01200 mOut<< std::endl << indent << ")";
01201 }
01202 else
01203 {
01204 mOut << std::endl << indent << "(netRef " << net.getName();
01205 NetSharedPtr parentCol = net.getParentCollection();
01206 if( parentCol )
01207 {
01208 parentCol->accept( *this );
01209 }
01210 mOut << ")";
01211 }
01212
01213 }
01214 catch( Error &e )
01215 {
01216 e.setCurrentLocation( __FUNCTION__, __FILE__, __LINE__ );
01217 throw;
01218 }
01219
01220
01221 void
01222 Decompiler::visit( VectorNetBit &net ) throw(Error)
01223 try
01224 {
01225
01226 #if 0
01227 mOut << " VectorNetBit name : " << net.getName() << std::endl;
01228 mOut << " Size : " << net.getSize() << std::endl;
01229 net.applyOnAllSubnets( mApplier );
01230 net.applyOnAllConnectedPorts( mApplier );
01231 net.applyOnAllConnectedPortRefs( mApplier );
01232 net.applyOnAllProperties( mApplier );
01233 #endif
01234
01235
01236 }
01237 catch( Error &e )
01238 {
01239 e.setCurrentLocation( __FUNCTION__, __FILE__, __LINE__ );
01240 throw;
01241 }
01242
01243
01244 void
01245 Decompiler::visit( InstanceArray &instanceArray ) throw(Error)
01246 try
01247 {
01248 Indenter indent(*this);
01249 if( !instanceArray.getOriginalName().empty() )
01250 {
01251 mOut << std::endl << indent << "(instance ";
01252 mOut << std::endl << indent << " (array (rename " << instanceArray.getName() << " "
01253 << "\"" << instanceArray.getOriginalName() << "\"" << ")" << " ";
01254 }
01255 else
01256 {
01257 mOut<< std::endl << indent << "(instance (array " << instanceArray.getName() << " ";
01258 }
01259 std::vector<size_t> limits;
01260 instanceArray.getLimits( limits );
01261 copy( limits.begin(), limits.end(),
01262 std::ostream_iterator<size_t>( mOut, " " ) );
01263 mOut << ")";
01264 mOut << std::endl << indent << " (viewRef " << instanceArray.getMaster()->getName()
01265 << " (cellRef " << instanceArray.getMaster()->getParent()->getName()
01266 << " (libraryRef " << instanceArray.getMaster()->getParent()->getParent()->getName()
01267 << ")))";
01268
01269 if( !instanceArray.getDesignator().empty() )
01270 {
01271 mOut << std::endl << indent << " (designator "
01272 << "\"" << instanceArray.getDesignator() << "\"" << ")";
01273 }
01274
01275
01276 std::vector< std::string > comments = instanceArray.getComments();
01277 printComments( comments );
01278
01279 std::list< std::string > elements;
01280 instanceArray.getUserData( elements );
01281 printUserData( elements );
01282
01283 mParamAssignContext = true;
01284 typedef std::map< std::string,ParameterSharedPtr > Params;
01285 ParameterMapSharedPtr params
01286 = instanceArray.getParameters();
01287 ParameterContext context = instanceArray.getParameterContext();
01288 params->applyOnOverriddenParameters( context, mApplier );
01289 mParamAssignContext = false;
01290 instanceArray.applyOnAllProperties( mApplier );
01291 mOut << std::endl << indent << ")";
01292 }
01293 catch( Error &e )
01294 {
01295 e.setCurrentLocation( __FUNCTION__, __FILE__, __LINE__ );
01296 throw;
01297 }
01298
01299
01300 void
01301 Decompiler::visit( InstanceArrayMember &instance ) throw(Error)
01302 try
01303 {
01304 if( mIsJoiningContext )
01305 {
01306 mOut<<"(instanceRef (member "
01307 <<instance.getParentCollection()->getName()
01308 <<" ";
01309 copy(instance.getIndices().begin(),
01310 instance.getIndices().end(),
01311 std::ostream_iterator<size_t>(mOut, " "));
01312 mOut<<"))";
01313 }
01314 else
01315 {
01316 }
01317 }
01318 catch( Error &e )
01319 {
01320 e.setCurrentLocation( __FUNCTION__, __FILE__, __LINE__ );
01321 throw;
01322 }
01323
01324
01325 void
01326 Decompiler::visit(SingleParameter &inSingleParameter) throw(Error)
01327 try
01328 {
01329 Indenter indent(*this);
01330 if( !mParamAssignContext )
01331 {
01332 if( !inSingleParameter.getOriginalName().empty() )
01333 {
01334 mOut << std::endl << indent << "(parameter ";
01335 mOut << std::endl << indent << " (rename " << inSingleParameter.getName() << " "
01336 << "\"" << inSingleParameter.getOriginalName() << "\"" << ")";
01337 }
01338 else
01339 {
01340 mOut << std::endl << indent << "(parameter " << inSingleParameter.getName() << " ";
01341 }
01342 printValueType ( inSingleParameter.getValue() );
01343 printValue( inSingleParameter.getValue() );
01344 mOut << ")";
01345 printUnit( inSingleParameter.getUnit() );
01346 mOut << ")";
01347 }
01348 else
01349 {
01350 mOut << std::endl << indent << " (parameterAssign "
01351 << inSingleParameter.getName() << " ";
01352 printValueType(inSingleParameter.getValue());
01353 printValue(inSingleParameter.getValue());
01354 mOut << "))";
01355 }
01356 }
01357 catch( Error &e )
01358 {
01359 e.setCurrentLocation(
01360 __FUNCTION__, __FILE__, __LINE__ );
01361 throw;
01362 }
01363
01364
01365 void
01366 Decompiler::visit(ParameterArray &inparamArray) throw(Error)
01367 try
01368 {
01369 Indenter indent(*this);
01370 if( !mParamAssignContext )
01371 {
01372 if( !inparamArray.getOriginalName().empty() )
01373 {
01374 mOut << std::endl << indent << "(parameter ";
01375 mOut << std::endl << indent << " (array (rename " << inparamArray.getName() << " "
01376 << "\"" << inparamArray.getOriginalName() << "\"" << ")" << " ";
01377 }
01378 else
01379 {
01380 mOut<< std::endl << indent << "(parameter (array " << inparamArray.getName() << " ";
01381 }
01382 std::vector<size_t> limits;
01383 inparamArray.getLimits( limits );
01384 copy( limits.begin(), limits.end(),
01385 std::ostream_iterator<size_t>( mOut, " " ) );
01386 mOut << ")" << std::endl << indent << " ";
01387 std::vector< ParameterSharedPtr > children;
01388 inparamArray.getChildren( children );
01389 std::vector< ParameterSharedPtr >::iterator start = children.begin();
01390 std::vector< ParameterSharedPtr >::iterator end = children.end();
01391 printValueType((*start)->getValue());
01392 printArray( limits , limits.size(), start, end );
01393 mOut << ")";
01394 printUnit( inparamArray.getUnit() );
01395 mOut << std::endl << indent << ")";
01396 }
01397 else
01398 {
01399 mOut << std::endl << indent << " (parameterAssign "<<inparamArray.getName();
01400 std::vector< ParameterSharedPtr > children;
01401 inparamArray.getChildren( children );
01402 if( !children.empty() )
01403 {
01404 std::vector<size_t> limits;
01405 inparamArray.getLimits( limits );
01406 std::vector< ParameterSharedPtr >::iterator start = children.begin();
01407 std::vector< ParameterSharedPtr >::iterator end = children.end();
01408 mOut << std::endl << indent << " ";
01409 printValueType((*start)->getValue());
01410 printArray( limits , limits.size(), start, end );
01411 mOut << ")";
01412 mOut << std::endl << indent << " )";
01413 }
01414 }
01415 }
01416 catch( Error &e )
01417 {
01418 e.setCurrentLocation(
01419 __FUNCTION__, __FILE__, __LINE__ );
01420 throw;
01421 }
01422
01423 void
01424 Decompiler::visit(
01425 ParameterArrayElement &bit) throw(Error)
01426 try
01427 {
01428 printValue( bit.getValue() );
01429 printUnit( bit.getUnit() );
01430 mOut<<" ";
01431 }
01432 catch( Error &e )
01433 {
01434 e.setCurrentLocation(
01435 __FUNCTION__, __FILE__, __LINE__ );
01436 throw;
01437 }
01438
01439
01440 void
01441 Decompiler::visit(Property &inProperty) throw(Error)
01442 try
01443 {
01444 Indenter indent( *this );
01445 if( !inProperty.getOriginalName().empty() )
01446 {
01447 mOut << std::endl << indent << "(property ";
01448 mOut << std::endl << indent << " (rename " << inProperty.getName() << " "
01449 << "\"" << inProperty.getOriginalName() << "\"" << ")";
01450 }
01451 else
01452 {
01453 mOut << std::endl << indent << "(property "<<inProperty.getName();
01454 }
01455 printValueType( inProperty.getValue() );
01456 printValue( inProperty.getValue() );
01457 mOut << ")";
01458
01459 if( !inProperty.getOwner().empty() )
01460 {
01461 mOut << std::endl << indent << " (owner "
01462 << "\"" << inProperty.getOwner() << "\"" << ")";
01463 }
01464
01465
01466 std::vector< std::string > comments = inProperty.getComments();
01467 printComments( comments );
01468
01469 inProperty.applyOnAllChildren( mApplier );
01470 mOut << ")";
01471 }
01472 catch( Error &e )
01473 {
01474 e.setCurrentLocation(
01475 __FUNCTION__, __FILE__, __LINE__ );
01476 throw;
01477 }
01478
01479
01480 void
01481 Decompiler::visit(PortList &inPortList) throw(Error)
01482 try
01483 {
01484 Indenter indent( *this );
01485 if( mIsJoiningContext )
01486 {
01487 std::list< PortList::PortListElement > elements;
01488 inPortList.getChildren( elements );
01489 mOut<< std::endl << indent<< "(portList ";
01490 for( std::list< PortList::PortListElement >::iterator it
01491 = elements.begin(); it != elements.end(); ++it )
01492 {
01493 switch( (*it).getType() )
01494 {
01495 case PortList::PortListElement::eElementTypePort:
01496 {
01497 (*it).getPort()->accept( *this );
01498 break;
01499 }
01500 case PortList::PortListElement::eElementTypePortReference:
01501 {
01502 (*it).getPortReference()->accept( *this );
01503 break;
01504 }
01505 }
01506 }
01507 mOut << std::endl << indent<<")";
01508 }
01509 else
01510 {
01511 }
01512 }
01513 catch( Error &e )
01514 {
01515 e.setCurrentLocation(
01516 __FUNCTION__, __FILE__, __LINE__ );
01517 throw;
01518 }
01519
01520
01521 void
01522 Decompiler::visit(PortListAlias &inPortListAlias) throw(Error)
01523 try
01524 {
01525 Indenter indent( *this );
01526 mOut << std::endl << indent << "(portListAlias "
01527 << inPortListAlias.getName();
01528 mIsJoiningContext = true;
01529 inPortListAlias.getPortList()->accept( *this );
01530 mOut << std::endl << indent << ")";
01531 }
01532 catch( Error &e )
01533 {
01534 e.setCurrentLocation(
01535 __FUNCTION__, __FILE__, __LINE__ );
01536 throw;
01537 }
01538
01539 void
01540 Decompiler::visit(Status &status) throw(Error)
01541 try
01542 {
01543 Indenter indent( *this );
01544 mOut << std::endl << indent << "(status ";
01545 std::vector< WrittenSharedPtr > elements;
01546 status.getWrittens( elements );
01547
01548 for( std::vector< WrittenSharedPtr >::iterator it
01549 = elements.begin(); it != elements.end(); ++it )
01550 {
01551 mOut << std::endl << indent << " (written ";
01552 mOut << std::endl << indent << " (timeStamp ";
01553 WrittenSharedPtr written = *it;
01554 TimeStamp timestamp = written->getTimeStamp();
01555 mOut << timestamp.getYear() << " "
01556 << timestamp.getMonth() << " "
01557 << timestamp.getDay() << " "
01558 << timestamp.getHour() << " "
01559 << timestamp.getMinute() << " "
01560 << timestamp.getSecond() << ")";
01561 if( !written->getAuthorName().empty() )
01562 {
01563 mOut << std::endl << indent << " (author "
01564 << "\"" << written->getAuthorName() << "\"" << ")";
01565 }
01566 if( !written->getProgramName().empty() )
01567 {
01568 mOut << std::endl << indent << " (program "
01569 << "\"" << written->getProgramName() << "\"";
01570 if( !written->getProgramVersion().empty() )
01571 {
01572 mOut << std::endl << indent << " (version "
01573 << "\"" << written->getProgramVersion() << "\"" << ")";
01574 }
01575 mOut << ")";
01576 }
01577
01578 if( !written->getDataOriginLocationName().empty() )
01579 {
01580 mOut << std::endl << indent << " (dataOrigin "
01581 << "\"" << written->getDataOriginLocationName() << "\"";
01582 if( !written->getDataOriginVersion().empty() )
01583 {
01584 mOut << std::endl << indent << " (version "
01585 << "\"" << written->getDataOriginVersion() << "\"" << ")";
01586 }
01587 mOut << ")";
01588 }
01589
01590
01591 std::vector< std::string > comments = written->getComments();
01592 printComments( comments );
01593
01594 std::list< std::string > userDatas;
01595 written->getUserData( userDatas );
01596 printUserData( userDatas );
01597
01598 written->applyOnAllProperties( mApplier );
01599
01600 mOut << std::endl << indent<< " )";
01601 }
01602
01603 std::vector< std::string > comments = status.getComments();
01604 printComments( comments );
01605
01606 std::list< std::string > userDatas;
01607 status.getUserData( userDatas );
01608 printUserData( userDatas );
01609
01610 mOut << std::endl << indent<<")";
01611 }
01612 catch( Error &e )
01613 {
01614 e.setCurrentLocation(
01615 __FUNCTION__, __FILE__, __LINE__ );
01616 throw;
01617 }
01618
01619
01620 void
01621 Decompiler::visit(Permutable &inPermutable) throw(Error)
01622 try
01623 {
01624 mIsPermutableContext = true;
01625 Indenter indent( *this );
01626 if( mIsJoiningContext )
01627 {
01628 std::vector< PortSharedPtr > outPorts;
01629 inPermutable.getPorts( outPorts );
01630 if( !inPermutable.getIsNonPermutable() ) {
01631 mOut << std::endl << indent << "(permutable ";
01632 }
01633 else {
01634 mOut << std::endl << indent << "(nonPermutable ";
01635 }
01636 std::vector< PortSharedPtr >::const_iterator port = outPorts.begin();
01637 std::vector< PortSharedPtr >::const_iterator end = outPorts.end();
01638 for(;port != end; ++port)
01639 {
01640 (*port)->accept( *this );
01641 }
01642 inPermutable.applyOnAllChildren( mApplier );
01643 mOut << std::endl << indent << ")";
01644 }
01645 else
01646 {
01647 }
01648 mIsPermutableContext = false;
01649 }
01650 catch( Error &e )
01651 {
01652 e.setCurrentLocation(
01653 __FUNCTION__, __FILE__, __LINE__ );
01654 throw;
01655 }
01656
01657
01658 void
01659 Decompiler::visit(InterfaceJoinedInfo & inInterfaceJoinedInfo) throw(Error)
01660 try
01661 {
01662 mIsPermutableContext = true;
01663 Indenter indent( *this );
01664 if( mIsJoiningContext )
01665 {
01666 std::string joinedType;
01667 switch( inInterfaceJoinedInfo.getJoinedType() )
01668 {
01669 case InterfaceJoinedInfo::eJoinedTypeJoin:
01670 {
01671 joinedType = "joined";
01672 break;
01673 }
01674 case InterfaceJoinedInfo::eJoinedTypeWeak:
01675 {
01676 joinedType = "weakJoined";
01677 break;
01678 }
01679 case InterfaceJoinedInfo::eJoinedTypeMust:
01680 {
01681 joinedType = "mustJoin";
01682 break;
01683 }
01684 }
01685 mOut << std::endl << indent << "(" << joinedType;
01686 std::list< PortSharedPtr > outPorts;
01687 inInterfaceJoinedInfo.getPorts( outPorts );
01688
01689 if( !outPorts.empty() )
01690 {
01691 std::list< PortSharedPtr >::const_iterator port = outPorts.begin();
01692 std::list< PortSharedPtr >::const_iterator end = outPorts.end();
01693 for(;port != end; ++port)
01694 {
01695 (*port)->accept( *this );
01696 }
01697 }
01698
01699 std::list< PortListSharedPtr > outPortLists;
01700 inInterfaceJoinedInfo.getPortLists( outPortLists );
01701 if( !outPortLists.empty() )
01702 {
01703 std::list< PortListSharedPtr >::const_iterator portList = outPortLists.begin();
01704 std::list< PortListSharedPtr >::const_iterator end = outPortLists.end();
01705 for(;portList != end; ++portList)
01706 {
01707 (*portList)->accept( *this );
01708 }
01709 }
01710
01711 inInterfaceJoinedInfo.applyOnAllChildren( mApplier );
01712 mOut << std::endl << indent << ")";
01713 }
01714 else
01715 {
01716 }
01717 mIsPermutableContext = false;
01718 }
01719 catch( Error &e )
01720 {
01721 e.setCurrentLocation(
01722 __FUNCTION__, __FILE__, __LINE__ );
01723 throw;
01724 }
01725
01726
01727 void
01728 Decompiler::visit( SimulationInfo &simuInfo ) throw(Error)
01729 try
01730 {
01731 Indenter indent(*this);
01732 mOut << std::endl << indent << "(simulationInfo";
01733 simuInfo.applyOnAllLogicValues( mApplier );
01734
01735
01736 std::vector< std::string > comments = simuInfo.getComments();
01737 printComments( comments );
01738
01739
01740 std::list< std::string > elements;
01741 simuInfo.getUserData( elements );
01742 printUserData( elements );
01743
01744 mOut << std::endl << indent << ")";
01745 }
01746 catch( Error &e )
01747 {
01748 e.setCurrentLocation( __FUNCTION__, __FILE__, __LINE__ );
01749 throw;
01750 }
01751
01752
01753 void
01754 Decompiler::visit( Simulate &simulate ) throw(Error)
01755 try
01756 {
01757 Indenter indent(*this);
01758 if( !simulate.getOriginalName().empty() )
01759 {
01760 mOut << std::endl << indent << "(simulate (rename " << simulate.getName() << " "
01761 << "\"" << simulate.getOriginalName() << "\"" << ")";
01762 }
01763 else
01764 {
01765 mOut << std::endl << indent << "(simulate " << simulate.getName();
01766 }
01767
01768 simulate.applyOnAllPortListAlias( mApplier );
01769 simulate.applyOnAllWaveValues( mApplier );
01770
01771 std::vector< ApplySharedPtr > outAllApply;
01772 simulate.getAllApply( outAllApply );
01773 std::vector< ApplySharedPtr >::iterator it = outAllApply.begin();
01774 for( ; it != outAllApply.end(); it++ )
01775 {
01776 (*it)->accept( *this );
01777 }
01778
01779
01780 std::vector< std::string > comments = simulate.getComments();
01781 printComments( comments );
01782
01783
01784 std::list< std::string > elements;
01785 simulate.getUserData( elements );
01786 printUserData( elements );
01787
01788 mOut << std::endl << indent << ")";
01789 }
01790 catch( Error &e )
01791 {
01792 e.setCurrentLocation( __FUNCTION__, __FILE__, __LINE__ );
01793 throw;
01794 }
01795
01796
01797 void
01798 Decompiler::visit( Apply & apply ) throw(Error)
01799 try
01800 {
01801 Indenter indent(*this);
01802 mOut << std::endl << indent << "(apply "
01803 << "(cycle " << apply.getNoOfCycle()
01804 << " (duration ";
01805 printValue( apply.getCycleDuration() );
01806 mOut << "))";
01807
01808 std::list< LogicalResponseSharedPtr > outLogicResponces;
01809 apply.getLogicResponses( outLogicResponces );
01810 std::list< LogicalResponseSharedPtr >::iterator logicIt
01811 = outLogicResponces.begin();
01812 for( ; logicIt != outLogicResponces.end(); logicIt++ )
01813 {
01814 (*logicIt)->accept( *this );
01815 }
01816
01817
01818 std::vector< std::string > comments = apply.getComments();
01819 printComments( comments );
01820
01821
01822 std::list< std::string > elements;
01823 apply.getUserData( elements );
01824 printUserData( elements );
01825
01826 mOut << std::endl << indent << ")";
01827 }
01828 catch( Error &e )
01829 {
01830 e.setCurrentLocation( __FUNCTION__, __FILE__, __LINE__ );
01831 throw;
01832 }
01833
01834
01835 void
01836 Decompiler::visit( LogicalResponse & logicalResponse ) throw(Error)
01837 try
01838 {
01839 Indenter indent(*this);
01840 std::string responseType;
01841 switch( logicalResponse.getResponseType() )
01842 {
01843 case LogicalResponse::eResponseTypeInput:
01844 {
01845 responseType = "logicInput";
01846 break;
01847 }
01848 case LogicalResponse::eResponseTypeOutput:
01849 {
01850 responseType = "logicOutput";
01851 break;
01852 }
01853 }
01854 mOut << std::endl << indent << "(" << responseType;
01855 if( NULL != logicalResponse.getConnectedPort() )
01856 {
01857 mOut << " " << logicalResponse.getConnectedPort()->getName();
01858 }
01859 if( NULL != logicalResponse.getConnectedPortListAlias() )
01860 {
01861 mOut << " " << logicalResponse.getConnectedPortListAlias()->getName();
01862 }
01863 if( NULL != logicalResponse.getConnectedPortList() )
01864 {
01865 logicalResponse.getConnectedPortList()->accept( *this );
01866 }
01867 LogicElementSharedPtr logicElement
01868 = logicalResponse.getLogicWaveForm();
01869 if( logicElement )
01870 {
01871 logicElement->accept( *this );
01872 }
01873 mOut << ")";
01874 }
01875 catch( Error &e )
01876 {
01877 e.setCurrentLocation( __FUNCTION__, __FILE__, __LINE__ );
01878 throw;
01879 }
01880
01881
01882 void
01883 Decompiler::visit( LogicElement &logicElem ) throw(Error)
01884 try
01885 {
01886 Indenter indent(*this);
01887 std::string type;
01888 std::string logicValueName;
01889 switch( logicElem.getType() )
01890 {
01891 case LogicElement::eTypeSingle:
01892 {
01893 type = "";
01894 logicValueName = logicElem.getName();
01895 break;
01896 }
01897 case LogicElement::eTypeList:
01898 {
01899 type = "logicList";
01900 break;
01901 }
01902 case LogicElement::eTypeOneOf:
01903 {
01904 type = "logicOneOf";
01905 break;
01906 }
01907 case LogicElement::eTypeWaveForm:
01908 {
01909 type = "logicWaveForm";
01910 break;
01911 }
01912 case LogicElement::eTypeIgnored:
01913 {
01914 type = "ignore";
01915 break;
01916 }
01917 case LogicElement::eTypeTransition:
01918 {
01919 type = "transition";
01920 break;
01921 }
01922 case LogicElement::eTypeBecomes:
01923 {
01924 type = "becomes";
01925 break;
01926 }
01927 }
01928
01929 if( LogicElement::eTypeSingle == logicElem.getType() )
01930 {
01931 mOut << " " << logicValueName;
01932 }
01933 else
01934 {
01935 mOut << std::endl << indent << "(" << type;
01936 logicElem.applyOnAllChildren( mApplier );
01937 mOut << ")";
01938 }
01939 }
01940 catch( Error &e )
01941 {
01942 e.setCurrentLocation( __FUNCTION__, __FILE__, __LINE__ );
01943 throw;
01944 }
01945
01946
01947 void
01948 Decompiler::visit(WaveValue & waveValue) throw(Error)
01949 try
01950 {
01951 Indenter indent(*this);
01952 mOut << std::endl << indent << "(waveValue "
01953 << waveValue.getName() << " ";
01954 printValue( waveValue.getDeltaTimeDuration() );
01955 if( NULL != waveValue.getLogicWaveform() )
01956 {
01957 waveValue.getLogicWaveform()->accept( *this );
01958 }
01959 mOut << ")";
01960 }
01961 catch( Error &e )
01962 {
01963 e.setCurrentLocation( __FUNCTION__, __FILE__, __LINE__ );
01964 throw;
01965 }
01966
01967
01968 void
01969 Decompiler::visit( LogicValue &logicVal ) throw(Error)
01970 try
01971 {
01972 Indenter indent(*this);
01973 if( !logicVal.getOriginalName().empty() )
01974 {
01975 mOut << std::endl << indent << "(logicValue ";
01976 mOut << std::endl << indent << " (rename " << logicVal.getName() << " "
01977 << "\"" << logicVal.getOriginalName() << "\"" << ")";
01978 }
01979 else
01980 {
01981 mOut << std::endl << indent << "(logicValue " << logicVal.getName();
01982 }
01983
01984
01985
01986 printLogicValueAttributes( logicVal.getAttributes() );
01987
01988
01989 std::vector< std::string > comments = logicVal.getComments();
01990 printComments( comments );
01991
01992
01993 std::list< std::string > elements;
01994 logicVal.getUserData( elements );
01995 printUserData( elements );
01996
01997 mOut << std::endl << indent << ")";
01998 }
01999 catch( Error &e )
02000 {
02001 e.setCurrentLocation( __FUNCTION__, __FILE__, __LINE__ );
02002 throw;
02003 }
02004
02005
02006 void
02007 Decompiler::visit( Timing & timing ) throw(Error)
02008 try
02009 {
02010 Indenter indent(*this);
02011 mOut << std::endl << indent << "(timing " << std::endl;
02012 mOut << indent;
02013 printDerivation( timing.getDerivation() );
02014
02015 std::list< PathDelaySharedPtr > outPathDelays;
02016 timing.getPathDelays( outPathDelays );
02017 std::list< PathDelaySharedPtr >::iterator pathDelayIt
02018 = outPathDelays.begin();
02019 for( ; pathDelayIt != outPathDelays.end(); pathDelayIt ++ )
02020 {
02021 mOut << indent <<" (pathDelay " << std::endl;
02022 mOut << indent <<" (delay ";
02023 PathDelaySharedPtr pathDelay = *pathDelayIt;
02024 Value::MiNoMax mnm = pathDelay->getDelay();
02025 Value val( Value::eValueTypeMiNoMax, mnm );
02026 printValue( val );
02027 mOut<< ")" << std::endl;
02028
02029
02030 std::list< EventSharedPtr > outEvents;
02031 pathDelay->getEvents( outEvents );
02032 std::list< EventSharedPtr >::iterator eventIt
02033 = outEvents.begin();
02034 for( ; eventIt != outEvents.end(); eventIt ++ )
02035 {
02036 mOut << " ";
02037 (*eventIt)->accept( *this );
02038 }
02039 mOut << indent <<" )" << std::endl;
02040 }
02041
02042
02043 std::list< ForbiddenEventSharedPtr > outForbiddentEvents;
02044 timing.getForbiddentEvents( outForbiddentEvents );
02045 std::list< ForbiddenEventSharedPtr >::iterator forbiddentEventIt
02046 = outForbiddentEvents.begin();
02047 for( ; forbiddentEventIt != outForbiddentEvents.end(); forbiddentEventIt ++ )
02048 {
02049 (*forbiddentEventIt)->accept( *this );
02050 }
02051
02052
02053 std::vector< std::string > comments = timing.getComments();
02054 printComments( comments );
02055
02056
02057 std::list< std::string > elements;
02058 timing.getUserData( elements );
02059 printUserData( elements );
02060
02061 mOut << std::endl << indent << ")";
02062 }
02063 catch( Error &e )
02064 {
02065 e.setCurrentLocation( __FUNCTION__, __FILE__, __LINE__ );
02066 throw;
02067 }
02068
02069
02070 void
02071 Decompiler::visit(Event & event ) throw(Error)
02072 try
02073 {
02074 Indenter indent(*this);
02075 std::string type;
02076 switch( event.getType() )
02077 {
02078 case Event::eTypeEvent:
02079 {
02080 type = "(event";
02081 break;
02082 }
02083 case Event::eTypeOffsetEvent:
02084 {
02085 type = "(offsetEvent (event";
02086 break;
02087 }
02088 }
02089
02090 mOut << indent << type ;
02091
02092
02093 mIsJoiningContext = true;
02094 std::list< PortElement > outPortElements;
02095 event.getPortElements( outPortElements );
02096 std::list< PortElement >::const_iterator portElem = outPortElements.begin();
02097 std::list< PortElement >::const_iterator end = outPortElements.end();
02098 if( outPortElements.size() > 1 )
02099 {
02100 (*this).setIndentation( (*this).getIndentation() + 8);
02101 mOut << std::endl << indent <<"(portGroup";
02102 }
02103 if( outPortElements.size() == 1 )
02104 {
02105 (*this).setIndentation( (*this).getIndentation() + 4);
02106 }
02107
02108 for(;portElem != end; ++portElem)
02109 {
02110 switch( (*portElem).getType() )
02111 {
02112 case PortElement::eElementTypePort:
02113 {
02114 (*portElem).getPort()->accept( *this );
02115 break;
02116 }
02117 case PortElement::eElementTypePortReference:
02118 {
02119 (*portElem).getPortReference()->accept( *this );
02120 break;
02121 }
02122 }
02123 }
02124
02125 if( outPortElements.size() > 1 )
02126 {
02127 mOut << ")";
02128 (*this).setIndentation( (*this).getIndentation() - 8);
02129 }
02130 if( outPortElements.size() == 1 )
02131 {
02132 (*this).setIndentation( (*this).getIndentation() - 4);
02133 }
02134
02135 if( NULL != event.getPortList() )
02136 {
02137 (*this).setIndentation( (*this).getIndentation() + 4);
02138 event.getPortList()->accept( *this );
02139 (*this).setIndentation( (*this).getIndentation() - 4);
02140 }
02141
02142 mIsJoiningContext = false;
02143 std::list< NetSharedPtr > outNets;
02144 event.getNets( outNets );
02145 std::list< NetSharedPtr >::const_iterator net = outNets.begin();
02146 if( outNets.size() > 1 )
02147 {
02148 (*this).setIndentation( (*this).getIndentation() + 8);
02149 mOut << std::endl << indent <<"(netGroup";
02150 }
02151 if( outNets.size() == 1 )
02152 {
02153 (*this).setIndentation( (*this).getIndentation() + 4);
02154 }
02155
02156 for(; net != outNets.end(); ++net)
02157 {
02158 (*net)->accept( *this );
02159 }
02160
02161 if( outNets.size() > 1 )
02162 {
02163 mOut << ")";
02164 (*this).setIndentation( (*this).getIndentation() - 8);
02165 }
02166 if( outNets.size() == 1 )
02167 {
02168 (*this).setIndentation( (*this).getIndentation() - 4);
02169 }
02170
02171
02172 if( NULL != event.getTransition() )
02173 {
02174 (*this).setIndentation( (*this).getIndentation() + 4);
02175 event.getTransition()->accept( *this );
02176 (*this).setIndentation( (*this).getIndentation() - 4);
02177 }
02178
02179 switch( event.getType() )
02180 {
02181 case Event::eTypeEvent:
02182 {
02183 mOut<<")" << std::endl;
02184 break;
02185 }
02186 case Event::eTypeOffsetEvent:
02187 {
02188 mOut<<") ";
02189 printValue( event.getOffsetTime() );
02190 mOut<<")" << std::endl;
02191 break;
02192 }
02193 }
02194 }
02195 catch( Error &e )
02196 {
02197 e.setCurrentLocation( __FUNCTION__, __FILE__, __LINE__ );
02198 throw;
02199 }
02200
02201
02202 void
02203 Decompiler::visit(ForbiddenEvent & forbiddenevent ) throw(Error)
02204 try
02205 {
02206 Indenter indent(*this);
02207 mOut << indent << "(forbiddenEvent" << std::endl;
02208 mOut << indent << " (timeInterval" << std::endl;
02209 if( NULL != forbiddenevent.getStartTimeInterval() )
02210 {
02211 mOut << " ";
02212 forbiddenevent.getStartTimeInterval()->accept( *this );
02213 }
02214 if( NULL != forbiddenevent.getEndTimeInterval() )
02215 {
02216 mOut << " ";
02217 forbiddenevent.getEndTimeInterval()->accept( *this );
02218 }
02219 else
02220 {
02221 mOut << " ";
02222 mOut << indent << " (duration ";
02223 printValue( forbiddenevent.getDuration() );
02224 mOut << ")" << std::endl;
02225 }
02226 mOut << indent << " )" << std::endl;
02227
02228 std::list< EventSharedPtr > outEvents;
02229 forbiddenevent.getEvents( outEvents );
02230 std::list< EventSharedPtr >::iterator eventIt
02231 = outEvents.begin();
02232 for( ; eventIt != outEvents.end(); eventIt ++ )
02233 {
02234 (*eventIt)->accept( *this );
02235 }
02236 mOut << indent << ")";
02237 }
02238 catch( Error &e )
02239 {
02240 e.setCurrentLocation( __FUNCTION__, __FILE__, __LINE__ );
02241 throw;
02242 }
02243
02244
02245 void
02246 Decompiler::printUserData( std::list< std::string > inElements) throw(Error)
02247 try
02248 {
02249 Indenter indent( *this );
02250 if( !inElements.empty() ) {
02251 for( std::list< std::string >::iterator it
02252 = inElements.begin(); it != inElements.end(); ++it )
02253 {
02254 mOut << std::endl << indent << "(userData " << trimLeadingSpaces(*it);
02255 }
02256 }
02257 }
02258 catch( Error &e )
02259 {
02260 e.setCurrentLocation(
02261 __FUNCTION__, __FILE__, __LINE__ );
02262 throw;
02263 }
02264
02265
02266 void
02267 Decompiler::printComments( std::vector< std::string > & inElements) throw(Error)
02268 {
02269 try
02270 {
02271 Indenter indent( *this );
02272 if( !inElements.empty() ) {
02273 for( std::vector< std::string >::iterator it
02274 = inElements.begin(); it != inElements.end(); ++it )
02275 {
02276 mOut << std::endl << indent << "(comment "
02277 << "\"" << trimLeadingSpaces(*it) << "\"" << ")";
02278 }
02279 }
02280 }
02281 catch( Error &e )
02282 {
02283 e.setCurrentLocation(
02284 __FUNCTION__, __FILE__, __LINE__ );
02285 throw;
02286 }
02287 }
02288 void
02289 Decompiler::printValueType( const Value &value ) throw(Error)
02290 {
02291 switch( value.getType() )
02292 {
02293 case Value::eValueTypeBoolean:
02294 {
02295 mOut<< " (boolean ";
02296 break;
02297 }
02298 case Value::eValueTypeInteger:
02299 {
02300 mOut<< " (integer ";
02301 break;
02302 }
02303 case Value::eValueTypeMiNoMax:
02304 {
02305 mOut<<" (minomax ";
02306 break;
02307 }
02308 case Value::eValueTypeNumber:
02309 {
02310 mOut<< " (number ";
02311 break;
02312 }
02313 case Value::eValueTypePoint:
02314 {
02315 mOut<<" (point ";
02316 break;
02317 }
02318 case Value::eValueTypeString:
02319 {
02320 mOut<<" (string ";
02321 break;
02322 }
02323 default:
02324 {
02325 }
02326 }
02327 }
02328
02329 void
02330 Decompiler::printValue( const Value &value ) throw(Error)
02331 {
02332 if( !value.getIsSet() )
02333 {
02334 return;
02335 }
02336 switch( value.getType() )
02337 {
02338 case Value::eValueTypeBoolean:
02339 {
02340 mOut<< ((value.get<Value::Boolean>())?"(true)":"(false)");
02341 break;
02342 }
02343 case Value::eValueTypeInteger:
02344 {
02345 mOut<< value.get<Value::Integer>();
02346 break;
02347 }
02348 case Value::eValueTypeMiNoMax:
02349 {
02350 Value::MiNoMax mnm = value.get<Value::MiNoMax>();
02351 mOut<<"(mnm ";
02352 if( !mnm.getMinUndefined() )
02353 {
02354 Value val( Value::eValueTypeNumber, mnm.getMin() );
02355 printValue( val );
02356 mOut<<" ";
02357 }
02358 else
02359 {
02360 mOut<<"(undefined) ";
02361 }
02362
02363 Value val( Value::eValueTypeNumber, mnm.getNominal() );
02364 printValue( val );
02365 mOut<<" ";
02366
02367 if( !mnm.getMinUndefined() )
02368 {
02369 Value val( Value::eValueTypeNumber, mnm.getMax() );
02370 printValue( val );
02371 }
02372 else
02373 {
02374 mOut<<"(undefined)";
02375 }
02376 mOut<<")";
02377 break;
02378 }
02379 case Value::eValueTypeNumber:
02380 {
02381 Value::Number num = value.get<Value::Number>();
02382 mOut<< "(e " << num.getMantissa() << " " << num.getExponent() << ")";
02383 break;
02384 }
02385 case Value::eValueTypePoint:
02386 {
02387 Value::Point pt = value.get<Value::Point>();
02388 mOut<< "(pt " << pt.getX()<<" "<<pt.getY() <<")";
02389 break;
02390 }
02391 case Value::eValueTypeString:
02392 {
02393 mOut<< "\"" << value.get<Value::String>() << "\"";
02394 break;
02395 }
02396 default:
02397 {
02398 }
02399 }
02400 }
02401
02402 void
02403 Decompiler::printUnit( const Unit unit ) throw(Error)
02404 {
02405 switch( unit )
02406 {
02407 case eUnitAngle:
02408 {
02409 mOut<< " (unit ANGLE )";
02410 break;
02411 }
02412 case eUnitCapacitance:
02413 {
02414 mOut<< " (unit CAPACITANCE )";
02415 break;
02416 }
02417 case eUnitConductance:
02418 {
02419 mOut<< " (unit CONDUCTANCE )";
02420 break;
02421 }
02422 case eUnitCharge:
02423 {
02424 mOut<< " (unit CHARGE )";
02425 break;
02426 }
02427 case eUnitCurrent:
02428 {
02429 mOut<< " (unit CURRENT )";
02430 break;
02431 }
02432 case eUnitDistance:
02433 {
02434 mOut<< " (unit DISTANCE )";
02435 break;
02436 }
02437 case eUnitEnergy:
02438 {
02439 mOut<< " (unit ENERGY )";
02440 break;
02441 }
02442 case eUnitFlux:
02443 {
02444 mOut<< " (unit FLUX )";
02445 break;
02446 }
02447 case eUnitFrequency:
02448 {
02449 mOut<< " (unit FREQUENCY )";
02450 break;
02451 }
02452 case eUnitInductance:
02453 {
02454 mOut<< " (unit INDUCTANCE )";
02455 break;
02456 }
02457 case eUnitMass:
02458 {
02459 mOut<< " (unit MASS )";
02460 break;
02461 }
02462 case eUnitPower:
02463 {
02464 mOut<< " (unit POWER )";
02465 break;
02466 }
02467 case eUnitResistance:
02468 {
02469 mOut<< " (unit RESISTANCE )";
02470 break;
02471 }
02472 case eUnitTemperature:
02473 {
02474 mOut<< " (unit TEMPERATURE )";
02475 break;
02476 }
02477 case eUnitTime:
02478 {
02479 mOut<< " (unit TIME )";
02480 break;
02481 }
02482 case eUnitVoltage:
02483 {
02484 mOut<< " (unit VOLTAGE )";
02485 break;
02486 }
02487 default:
02488 {
02489 }
02490 }
02491 }
02492
02493 void
02494 Decompiler::printDerivation( const Derivation derivation ) throw(Error)
02495 {
02496 mOut<<" (derivation ";
02497 switch( derivation )
02498 {
02499 case eDerivationCalculated:
02500 {
02501 mOut<<"CALCULATED";
02502 break;
02503 }
02504 case eDerivationMeasured:
02505 {
02506 mOut<<"MEASURED";
02507 break;
02508 }
02509 case eDerivationRequired:
02510 {
02511 mOut<<"REQUIRED";
02512 break;
02513 }
02514 default:
02515 {
02516 }
02517 }
02518 mOut<<")"<<std::endl;
02519 }
02520
02521 void
02522 Decompiler::printArray(const std::vector<size_t> &outVector, size_t depth,
02523 std::vector< ParameterSharedPtr >::iterator &itStart,
02524 std::vector< ParameterSharedPtr >::iterator &itEnd) throw (Error)
02525 {
02526 Indenter indent(*this);
02527
02528 size_t array_size = outVector.size();
02529 for(size_t i = 0; i < outVector.at(array_size - depth); i++)
02530 {
02531 if( depth == 1 )
02532 {
02533 printValue((*itStart)->getValue());
02534 mOut << " ";
02535 if( itStart != itEnd)
02536 {
02537 ++itStart;
02538 }
02539 }
02540 else
02541 {
02542 mOut << std::endl << indent << " ";
02543 printValueType((*itStart)->getValue());
02544 printArray( outVector, depth -1, itStart, itEnd );
02545 mOut << ")";
02546 }
02547 }
02548 }
02549
02550 void
02551 Decompiler::printPortAttributes(
02552 const PortAttributesSharedPtr &inAttrib ) throw(Error) {
02553 if( !inAttrib )
02554 return;
02555
02556 Indenter indent(*this);
02557 try
02558 {
02559 {
02560 Value unused = inAttrib->getUnused();
02561 if( unused.getIsSet() )
02562 {
02563 mOut << std::endl
02564 << indent << "(unused)";
02565 }
02566 }
02567 {
02568 Value designator = inAttrib->getDesignator();
02569 if( designator.getIsSet() )
02570 {
02571 mOut << std::endl
02572 << indent << "(designator "
02573 << "\"" << designator.get<Value::String>()<< "\"" << ")";
02574 }
02575 }
02576 {
02577 Value val = inAttrib->getDcFaninLoad();
02578 if( val.getIsSet() )
02579 {
02580 mOut << std::endl
02581 << indent << "(dcFaninLoad ";
02582 printValue( val );
02583 mOut << ")";
02584 }
02585 }
02586 {
02587 Value val = inAttrib->getDcFanoutLoad();
02588 if( val.getIsSet() )
02589 {
02590 mOut << std::endl
02591 << indent << "(dcFanoutLoad ";
02592 printValue( val );
02593 mOut << ")";
02594 }
02595 }
02596 {
02597 Value val = inAttrib->getDcMaxFanin();
02598 if( val.getIsSet() )
02599 {
02600 mOut << std::endl
02601 << indent << "(dcMaxFanin ";
02602 printValue( val );
02603 mOut << ")";
02604 }
02605 }
02606 {
02607 Value val = inAttrib->getDcMaxFanout();
02608 if( val.getIsSet() )
02609 {
02610 mOut << std::endl
02611 << indent << "(dcMaxFanout ";
02612 printValue( val );
02613 mOut << ")";
02614 }
02615 }
02616 {
02617 Value val = inAttrib->getAcLoad();
02618 if( val.getIsSet() )
02619 {
02620 mOut << std::endl
02621 << indent << "(acLoad ";
02622 printValue( val );
02623 mOut << ")";
02624 }
02625 }
02626 if( inAttrib->getIsPortDelaySet() )
02627 {
02628 PortDelay delay = inAttrib->getPortDelay();
02629 mOut << std::endl
02630 << indent <<"(portDelay "<<std::endl;
02631 mOut << indent;
02632 printDerivation( delay.getDerivation() );
02633 switch( delay.getType() )
02634 {
02635 case PortDelay::eTypeDelay:
02636 {
02637 mOut << indent<<" (delay ";
02638 Value::MiNoMax mnm = delay.getDelay();
02639 Value val( Value::eValueTypeMiNoMax, mnm );
02640 printValue( val );
02641 mOut<<")";
02642 break;
02643 }
02644 case PortDelay::eTypeLoadDelay:
02645 {
02646 mOut << indent<<" (loadDelay ";
02647 {
02648 Value::MiNoMax mnm = delay.getDelay();
02649 Value val( Value::eValueTypeMiNoMax, mnm );
02650 printValue( val );
02651 }
02652 {
02653 Value::MiNoMax mnm = delay.getAcLoad();
02654 Value val( Value::eValueTypeMiNoMax, mnm );
02655 printValue( val );
02656 }
02657 mOut<<")";
02658 break;
02659 }
02660 }
02661
02662 if( NULL != delay.getTransition() )
02663 {
02664 delay.getTransition()->accept( *this );
02665 }
02666 mOut << ")";
02667 }
02668 }
02669 catch( Error &e )
02670 {
02671 e.setCurrentLocation(
02672 __FUNCTION__, __FILE__, __LINE__ );
02673 throw;
02674 }
02675 }
02676
02677 void
02678 Decompiler::printNetAttributes(
02679 const NetAttributesSharedPtr &inAttrib ) throw(Error) {
02680 if( !inAttrib )
02681 return;
02682
02683 Indenter indent(*this);
02684 try
02685 {
02686 (*this).setIndentation( (*this).getIndentation() - 2);
02687 if( inAttrib->getIsCriticalitySet() )
02688 {
02689 int32_t criticality = inAttrib->getCriticality();
02690 mOut << std::endl
02691 << indent <<"(criticality " << criticality << ")";
02692 }
02693 if( inAttrib->getIsNetDelaySet() )
02694 {
02695 NetDelay netDelay = inAttrib->getNetDelay();
02696 mOut << std::endl
02697 << indent <<"(netDelay "<<std::endl;
02698 mOut << indent;
02699 printDerivation( netDelay.getDerivation() );
02700
02701 mOut << indent<<" (delay ";
02702 Value::MiNoMax mnm = netDelay.getDelay();
02703 Value val( Value::eValueTypeMiNoMax, mnm );
02704 printValue( val );
02705 mOut<<")";
02706
02707
02708 if( NULL != netDelay.getTransition() )
02709 {
02710 netDelay.getTransition()->accept( *this );
02711 }
02712 mOut << std::endl << indent << ")";
02713 }
02714 (*this).setIndentation( (*this).getIndentation() + 2);
02715 }
02716 catch( Error &e )
02717 {
02718 e.setCurrentLocation(
02719 __FUNCTION__, __FILE__, __LINE__ );
02720 throw;
02721 }
02722 }
02723
02724 void
02725 Decompiler::printViewInterfaceAttributes(
02726 const InterfaceAttributesSharedPtr &inAttrib ) throw(Error) {
02727 if( !inAttrib )
02728 return;
02729
02730 Indenter indent(*this);
02731 try
02732 {
02733 if( !inAttrib->getDesignator().empty() )
02734 {
02735 mOut << std::endl << indent << " (designator "
02736 << "\"" << inAttrib->getDesignator() << "\"" << ")";
02737 }
02738
02739 if( NULL != inAttrib->getSimulate() )
02740 {
02741 (*this).setIndentation( (*this).getIndentation() - 4);
02742 inAttrib->getSimulate()->accept( *this );
02743 (*this).setIndentation( (*this).getIndentation() + 4);
02744 }
02745
02746 if( NULL != inAttrib->getTiming() )
02747 {
02748 (*this).setIndentation( (*this).getIndentation() - 4);
02749 inAttrib->getTiming()->accept( *this );
02750 (*this).setIndentation( (*this).getIndentation() + 4);
02751 }
02752
02753
02754 std::vector< std::string > comments = inAttrib->getComments();
02755 printComments( comments );
02756
02757 std::list< std::string > userDatas;
02758 inAttrib->getUserData( userDatas );
02759 printUserData( userDatas );
02760 }
02761 catch( Error &e )
02762 {
02763 e.setCurrentLocation(
02764 __FUNCTION__, __FILE__, __LINE__ );
02765 throw;
02766 }
02767 }
02768
02769
02770 void
02771 Decompiler::printLogicValueAttributes(
02772 const LogicValueAttributesSharedPtr &inAttrib ) throw(Error) {
02773
02774 if( !inAttrib )
02775 return;
02776
02777 Indenter indent(*this);
02778 try
02779 {
02780 {
02781 if( inAttrib->getIsVoltageMapSet() )
02782 {
02783 Value::MiNoMax mnm = inAttrib->getVoltageMap();
02784 Value val( Value::eValueTypeMiNoMax, mnm );
02785 mOut << std::endl << indent << "(voltageMap ";
02786 printValue( val );
02787 mOut << ")";
02788 }
02789 }
02790 {
02791 if( inAttrib->getIsCurrentMapSet() )
02792 {
02793 Value::MiNoMax mnm = inAttrib->getCurrentMap();
02794 Value val( Value::eValueTypeMiNoMax, mnm );
02795 mOut << std::endl << indent << "(currentMap ";
02796 printValue( val );
02797 mOut << ")";
02798 }
02799 }
02800 {
02801 if( inAttrib->getIsBooleanMapSet() )
02802 {
02803 Value::Boolean boolean = inAttrib->getBooleanMap();
02804 Value val( Value::eValueTypeBoolean, boolean );
02805 mOut << std::endl << indent << "(booleanMap ";
02806 printValue( val );
02807 mOut << ")";
02808 }
02809 }
02810 {
02811 LogicValueSharedPtr logicVal = inAttrib->getWeakLogicValue();
02812 if( logicVal )
02813 {
02814 mOut << std::endl << indent << "(weak "
02815 << logicVal->getName() << ")";
02816 }
02817 }
02818 {
02819 LogicValueSharedPtr logicVal = inAttrib->getStrongLogicValue();
02820 if( logicVal )
02821 {
02822 mOut << std::endl << indent << "(strong "
02823 << logicVal->getName() << ")";
02824 }
02825 }
02826 {
02827 std::list< LogicValueSharedPtr > outLogicValues;
02828 inAttrib->getCompoundLogicValues( outLogicValues );
02829 if( !outLogicValues.empty() )
02830 {
02831 mOut << std::endl << indent << "(compound";
02832 std::list< LogicValueSharedPtr >::iterator it
02833 = outLogicValues.begin();
02834 for(; it != outLogicValues.end(); it++ )
02835 {
02836 mOut << " " << (*it)->getName();
02837 }
02838 mOut << ")";
02839 }
02840 else
02841 {
02842 }
02843 }
02844 {
02845 std::list< LogicValueSharedPtr > outLogicValues;
02846 inAttrib->getDominatedLogicValues( outLogicValues );
02847 if( !outLogicValues.empty() )
02848 {
02849 mOut << std::endl << indent << "(dominates";
02850 std::list< LogicValueSharedPtr >::iterator it
02851 = outLogicValues.begin();
02852 for(; it != outLogicValues.end(); it++ )
02853 {
02854 mOut << " " << (*it)->getName();
02855 }
02856 mOut << ")";
02857 }
02858 else
02859 {
02860 }
02861 }
02862 {
02863 std::list< LogicValueSharedPtr > outLogicValues;
02864 inAttrib->getResolvedLogicValues( outLogicValues );
02865 if( !outLogicValues.empty() )
02866 {
02867 mOut << std::endl << indent << "(resolves";
02868 std::list< LogicValueSharedPtr >::iterator it
02869 = outLogicValues.begin();
02870 for(; it != outLogicValues.end(); it++ )
02871 {
02872 mOut << " " << (*it)->getName();
02873 }
02874 mOut << ")";
02875 }
02876 else
02877 {
02878 }
02879 }
02880 {
02881 bool isolated = inAttrib->getIsIsolated();
02882 if( isolated )
02883 {
02884 mOut << std::endl
02885 << indent << "(isolated)";
02886 }
02887 }
02888 {
02889 typedef LogicValueAttributes::LogicMap LogicMap;
02890 std::list<LogicMap* > outLogicMaps;
02891 inAttrib->getLogicMaps( outLogicMaps );
02892 if( !outLogicMaps.empty() )
02893 {
02894 std::list<LogicMap* >::iterator it
02895 = outLogicMaps.begin();
02896
02897 for(; it != outLogicMaps.end(); it++ )
02898 {
02899 if( (*it)->mLogicMapType ==
02900 LogicMap::eLogicMapTypeInput )
02901 {
02902 mOut << std::endl << indent
02903 << "(logicMapInput ";
02904 }
02905 else
02906 {
02907 mOut << std::endl << indent
02908 << "(logicMapOutput ";
02909 }
02910 mOut << "(logicRef " << (*it)->mLogicRef;
02911 mOut << " (libraryRef " << (*it)->mLibraryRef << ")";
02912 mOut << "))";
02913 }
02914 }
02915 else
02916 {
02917 }
02918 }
02919 }
02920 catch( Error &e )
02921 {
02922 e.setCurrentLocation(
02923 __FUNCTION__, __FILE__, __LINE__ );
02924 throw;
02925 }
02926 }
02927 void
02928 Decompiler::operator()() throw(Error)
02929 try
02930 {
02931 decompile();
02932 }
02933 catch( Error &e )
02934 {
02935 e.setCurrentLocation(
02936 __FUNCTION__, __FILE__, __LINE__ );
02937 throw;
02938 }
02939
02940
02941
02942
02943
02944
02945 void
02946 Decompiler::decompile() throw(Error) {
02947 try
02948 {
02949 mRoot->accept( *this );
02950 }
02951 catch( Error &e )
02952 {
02953 e.setCurrentLocation(
02954 __FUNCTION__, __FILE__, __LINE__ );
02955 throw;
02956 }
02957 }
02958
02959 void
02960 Decompiler::setIndentation( size_t inIndentation ) throw()
02961 {
02962 mIndentation = inIndentation;
02963 }
02964
02965 Decompiler::Decompiler(const RootSharedPtr &inRoot,
02966 std::ostream &outStream)
02967 :mRoot( inRoot ),
02968 mOut( outStream ),
02969 mIsJoiningContext( false ),
02970 mIsPermutableContext( false ),
02971 mIsExternContext( false ),
02972 mParamAssignContext( false ),
02973 mIsPortInstanceContext( false ),
02974 mIndentation( 0 ),
02975 mApplier(*this){
02976 }
02977
02978 Decompiler::~Decompiler() throw() {
02979 }
02980
02981 Decompiler::Decompiler(
02982 const Decompiler & inSource)
02983 :mRoot( inSource.mRoot ),
02984 mOut( inSource.mOut ),
02985 mIsJoiningContext( inSource.mIsJoiningContext ),
02986 mIsExternContext( inSource.mIsExternContext ),
02987 mParamAssignContext( inSource.mParamAssignContext ),
02988 mIsPortInstanceContext( inSource.mIsPortInstanceContext ),
02989 mIndentation( inSource.mIndentation ),
02990 mApplier(*this) {
02991 }
02992
02993 Decompiler &
02994 Decompiler::operator=(const Decompiler & inSource) {
02995 if( this != &inSource )
02996 {
02997 mRoot = inSource.mRoot;
02998 mIsJoiningContext = inSource.mIsJoiningContext;
02999 mIsExternContext = inSource.mIsExternContext;
03000 mParamAssignContext = inSource.mParamAssignContext;
03001 mIsPortInstanceContext = inSource.mIsPortInstanceContext;
03002 mIndentation = inSource.mIndentation;
03003 }
03004 return *this;
03005 }
03006
03007 }
03008
03009 }