/**CFile**************************************************************** FileName [abc.c] SystemName [ABC: Logic synthesis and verification system.] PackageName [Network and node package.] Synopsis [Command file.] Author [Alan Mishchenko] Affiliation [UC Berkeley] Date [Ver. 1.0. Started - June 20, 2005.] Revision [$Id: abc.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] ***********************************************************************/ #include "abc.h" #include "mainInt.h" #include "fraig.h" #include "fxu.h" #include "fpga.h" #include "pga.h" #include "cut.h" #include "seq.h" //////////////////////////////////////////////////////////////////////// /// DECLARATIONS /// //////////////////////////////////////////////////////////////////////// static int Abc_CommandPrintStats ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandPrintExdc ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandPrintIo ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandPrintLatch ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandPrintFanio ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandPrintFactor ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandPrintLevel ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandPrintSupport ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandPrintSymms ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandPrintUnate ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandPrintAuto ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandPrintKMap ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandPrintGates ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandPrintSharing ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandShowBdd ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandShowCut ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandShowAig ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandShowNtk ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandCollapse ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandStrash ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandBalance ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandRenode ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandCleanup ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandSweep ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandFastExtract ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandDisjoint ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandRewrite ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandRefactor ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandRestructure ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandLogic ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandMiter ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandFrames ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandSop ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandBdd ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandReorder ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandMuxes ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandSat ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandExtSeqDcs ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandOneOutput ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandOneNode ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandShortNames ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandExdcFree ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandExdcGet ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandExdcSet ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandCut ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandXyz ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandEspresso ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandTest ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandFraig ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandFraigTrust ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandFraigStore ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandFraigRestore ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandFraigClean ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandFraigSweep ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandMap ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandUnmap ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAttach ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandSuperChoice ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandFpga ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandPga ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandScut ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandInit ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandPipe ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandSeq ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandUnseq ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandRetime ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandSeqFpga ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandSeqMap ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandSeqSweep ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandSeqCleanup ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandCec ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandSec ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandProve ( Abc_Frame_t * pAbc, int argc, char ** argv ); //////////////////////////////////////////////////////////////////////// /// FUNCTION DEFINITIONS /// //////////////////////////////////////////////////////////////////////// /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ void Abc_Init( Abc_Frame_t * pAbc ) { // Abc_NtkBddImplicationTest(); Cmd_CommandAdd( pAbc, "Printing", "print_stats", Abc_CommandPrintStats, 0 ); Cmd_CommandAdd( pAbc, "Printing", "print_exdc", Abc_CommandPrintExdc, 0 ); Cmd_CommandAdd( pAbc, "Printing", "print_io", Abc_CommandPrintIo, 0 ); Cmd_CommandAdd( pAbc, "Printing", "print_latch", Abc_CommandPrintLatch, 0 ); Cmd_CommandAdd( pAbc, "Printing", "print_fanio", Abc_CommandPrintFanio, 0 ); Cmd_CommandAdd( pAbc, "Printing", "print_factor", Abc_CommandPrintFactor, 0 ); Cmd_CommandAdd( pAbc, "Printing", "print_level", Abc_CommandPrintLevel, 0 ); Cmd_CommandAdd( pAbc, "Printing", "print_supp", Abc_CommandPrintSupport, 0 ); Cmd_CommandAdd( pAbc, "Printing", "print_symm", Abc_CommandPrintSymms, 0 ); Cmd_CommandAdd( pAbc, "Printing", "print_unate", Abc_CommandPrintUnate, 0 ); Cmd_CommandAdd( pAbc, "Printing", "print_auto", Abc_CommandPrintAuto, 0 ); Cmd_CommandAdd( pAbc, "Printing", "print_kmap", Abc_CommandPrintKMap, 0 ); Cmd_CommandAdd( pAbc, "Printing", "print_gates", Abc_CommandPrintGates, 0 ); Cmd_CommandAdd( pAbc, "Printing", "print_sharing", Abc_CommandPrintSharing, 0 ); Cmd_CommandAdd( pAbc, "Printing", "show_bdd", Abc_CommandShowBdd, 0 ); Cmd_CommandAdd( pAbc, "Printing", "show_cut", Abc_CommandShowCut, 0 ); Cmd_CommandAdd( pAbc, "Printing", "show_aig", Abc_CommandShowAig, 0 ); Cmd_CommandAdd( pAbc, "Printing", "show_ntk", Abc_CommandShowNtk, 0 ); Cmd_CommandAdd( pAbc, "Synthesis", "collapse", Abc_CommandCollapse, 1 ); Cmd_CommandAdd( pAbc, "Synthesis", "strash", Abc_CommandStrash, 1 ); Cmd_CommandAdd( pAbc, "Synthesis", "balance", Abc_CommandBalance, 1 ); Cmd_CommandAdd( pAbc, "Synthesis", "renode", Abc_CommandRenode, 1 ); Cmd_CommandAdd( pAbc, "Synthesis", "cleanup", Abc_CommandCleanup, 1 ); Cmd_CommandAdd( pAbc, "Synthesis", "sweep", Abc_CommandSweep, 1 ); Cmd_CommandAdd( pAbc, "Synthesis", "fx", Abc_CommandFastExtract, 1 ); Cmd_CommandAdd( pAbc, "Synthesis", "dsd", Abc_CommandDisjoint, 1 ); Cmd_CommandAdd( pAbc, "Synthesis", "rewrite", Abc_CommandRewrite, 1 ); Cmd_CommandAdd( pAbc, "Synthesis", "refactor", Abc_CommandRefactor, 1 ); Cmd_CommandAdd( pAbc, "Synthesis", "restructure", Abc_CommandRestructure, 1 ); // Cmd_CommandAdd( pAbc, "Various", "logic", Abc_CommandLogic, 1 ); Cmd_CommandAdd( pAbc, "Various", "miter", Abc_CommandMiter, 1 ); Cmd_CommandAdd( pAbc, "Various", "frames", Abc_CommandFrames, 1 ); Cmd_CommandAdd( pAbc, "Various", "sop", Abc_CommandSop, 0 ); Cmd_CommandAdd( pAbc, "Various", "bdd", Abc_CommandBdd, 0 ); Cmd_CommandAdd( pAbc, "Various", "reorder", Abc_CommandReorder, 0 ); Cmd_CommandAdd( pAbc, "Various", "muxes", Abc_CommandMuxes, 1 ); Cmd_CommandAdd( pAbc, "Various", "sat", Abc_CommandSat, 0 ); Cmd_CommandAdd( pAbc, "Various", "ext_seq_dcs", Abc_CommandExtSeqDcs, 0 ); Cmd_CommandAdd( pAbc, "Various", "cone", Abc_CommandOneOutput, 1 ); Cmd_CommandAdd( pAbc, "Various", "node", Abc_CommandOneNode, 1 ); Cmd_CommandAdd( pAbc, "Various", "short_names", Abc_CommandShortNames, 0 ); Cmd_CommandAdd( pAbc, "Various", "exdc_free", Abc_CommandExdcFree, 1 ); Cmd_CommandAdd( pAbc, "Various", "exdc_get", Abc_CommandExdcGet, 1 ); Cmd_CommandAdd( pAbc, "Various", "exdc_set", Abc_CommandExdcSet, 1 ); Cmd_CommandAdd( pAbc, "Various", "cut", Abc_CommandCut, 0 ); Cmd_CommandAdd( pAbc, "Various", "xyz", Abc_CommandXyz, 1 ); Cmd_CommandAdd( pAbc, "Various", "espresso", Abc_CommandEspresso, 1 ); Cmd_CommandAdd( pAbc, "Various", "test", Abc_CommandTest, 0 ); Cmd_CommandAdd( pAbc, "Fraiging", "fraig", Abc_CommandFraig, 1 ); Cmd_CommandAdd( pAbc, "Fraiging", "fraig_trust", Abc_CommandFraigTrust, 1 ); Cmd_CommandAdd( pAbc, "Fraiging", "fraig_store", Abc_CommandFraigStore, 0 ); Cmd_CommandAdd( pAbc, "Fraiging", "fraig_restore", Abc_CommandFraigRestore, 1 ); Cmd_CommandAdd( pAbc, "Fraiging", "fraig_clean", Abc_CommandFraigClean, 0 ); Cmd_CommandAdd( pAbc, "Fraiging", "fraig_sweep", Abc_CommandFraigSweep, 1 ); Cmd_CommandAdd( pAbc, "SC mapping", "map", Abc_CommandMap, 1 ); Cmd_CommandAdd( pAbc, "SC mapping", "unmap", Abc_CommandUnmap, 1 ); Cmd_CommandAdd( pAbc, "SC mapping", "attach", Abc_CommandAttach, 1 ); Cmd_CommandAdd( pAbc, "SC mapping", "sc", Abc_CommandSuperChoice, 1 ); Cmd_CommandAdd( pAbc, "FPGA mapping", "fpga", Abc_CommandFpga, 1 ); Cmd_CommandAdd( pAbc, "FPGA mapping", "pga", Abc_CommandPga, 1 ); Cmd_CommandAdd( pAbc, "Sequential", "scut", Abc_CommandScut, 0 ); Cmd_CommandAdd( pAbc, "Sequential", "init", Abc_CommandInit, 1 ); Cmd_CommandAdd( pAbc, "Sequential", "pipe", Abc_CommandPipe, 1 ); Cmd_CommandAdd( pAbc, "Sequential", "seq", Abc_CommandSeq, 1 ); Cmd_CommandAdd( pAbc, "Sequential", "unseq", Abc_CommandUnseq, 1 ); Cmd_CommandAdd( pAbc, "Sequential", "retime", Abc_CommandRetime, 1 ); Cmd_CommandAdd( pAbc, "Sequential", "sfpga", Abc_CommandSeqFpga, 1 ); Cmd_CommandAdd( pAbc, "Sequential", "smap", Abc_CommandSeqMap, 1 ); Cmd_CommandAdd( pAbc, "Sequential", "ssweep", Abc_CommandSeqSweep, 1 ); Cmd_CommandAdd( pAbc, "Sequential", "scleanup", Abc_CommandSeqCleanup, 1 ); Cmd_CommandAdd( pAbc, "Verification", "cec", Abc_CommandCec, 0 ); Cmd_CommandAdd( pAbc, "Verification", "sec", Abc_CommandSec, 0 ); Cmd_CommandAdd( pAbc, "Verification", "prove", Abc_CommandProve, 1 ); // Rwt_Man4ExploreStart(); // Map_Var3Print(); // Map_Var4Test(); } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ void Abc_End() { Abc_NtkFraigStoreClean(); // Rwt_Man4ExplorePrint(); } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandPrintStats( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk; bool fShort; int c; int fFactor; pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set the defaults fShort = 1; fFactor = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "sfh" ) ) != EOF ) { switch ( c ) { case 's': fShort ^= 1; break; case 'f': fFactor ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( Abc_FrameReadErr(pAbc), "Empty network.\n" ); return 1; } Abc_NtkPrintStats( pOut, pNtk, fFactor ); return 0; usage: fprintf( pErr, "usage: print_stats [-fh]\n" ); fprintf( pErr, "\t prints the network statistics\n" ); fprintf( pErr, "\t-f : toggles printing the literal count in the factored forms [default = %s]\n", fFactor? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandPrintExdc( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk, * pNtkTemp; double Percentage; bool fShort; int c; int fPrintDc; extern double Abc_NtkSpacePercentage( Abc_Obj_t * pNode ); pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set the defaults fShort = 1; fPrintDc = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "sdh" ) ) != EOF ) { switch ( c ) { case 's': fShort ^= 1; break; case 'd': fPrintDc ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( Abc_FrameReadErr(pAbc), "Empty network.\n" ); return 1; } if ( pNtk->pExdc == NULL ) { fprintf( Abc_FrameReadErr(pAbc), "Network has no EXDC.\n" ); return 1; } if ( fPrintDc ) { if ( !Abc_NtkIsStrash(pNtk->pExdc) ) { pNtkTemp = Abc_NtkStrash(pNtk->pExdc, 0, 0); Percentage = Abc_NtkSpacePercentage( Abc_ObjChild0( Abc_NtkPo(pNtkTemp, 0) ) ); Abc_NtkDelete( pNtkTemp ); } else Percentage = Abc_NtkSpacePercentage( Abc_ObjChild0( Abc_NtkPo(pNtk->pExdc, 0) ) ); printf( "EXDC network statistics: " ); printf( "(" ); if ( Percentage > 0.05 && Percentage < 99.95 ) printf( "%.2f", Percentage ); else if ( Percentage > 0.000005 && Percentage < 99.999995 ) printf( "%.6f", Percentage ); else printf( "%f", Percentage ); printf( " %% don't-cares)\n" ); } else printf( "EXDC network statistics: \n" ); Abc_NtkPrintStats( pOut, pNtk->pExdc, 0 ); return 0; usage: fprintf( pErr, "usage: print_exdc [-dh]\n" ); fprintf( pErr, "\t prints the EXDC network statistics\n" ); fprintf( pErr, "\t-d : toggles printing don't-care percentage [default = %s]\n", fPrintDc? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandPrintIo( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk; Abc_Obj_t * pNode; int c; pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) { switch ( c ) { case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( argc > globalUtilOptind + 1 ) { fprintf( pErr, "Wrong number of auguments.\n" ); goto usage; } if ( argc == globalUtilOptind + 1 ) { pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] ); if ( pNode == NULL ) { fprintf( pErr, "Cannot find node \"%s\".\n", argv[globalUtilOptind] ); return 1; } Abc_NodePrintFanio( pOut, pNode ); return 0; } // print the nodes Abc_NtkPrintIo( pOut, pNtk ); return 0; usage: fprintf( pErr, "usage: print_io [-h] \n" ); fprintf( pErr, "\t prints the PIs/POs or fanins/fanouts of a node\n" ); fprintf( pErr, "\t-h : print the command usage\n"); fprintf( pErr, "\tnode : the node to print fanins/fanouts\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandPrintLatch( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk; int c; pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) { switch ( c ) { case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } // print the nodes Abc_NtkPrintLatch( pOut, pNtk ); return 0; usage: fprintf( pErr, "usage: print_latch [-h]\n" ); fprintf( pErr, "\t prints information about latches\n" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandPrintFanio( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk; int c; pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) { switch ( c ) { case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } // print the nodes Abc_NtkPrintFanio( pOut, pNtk ); return 0; usage: fprintf( pErr, "usage: print_fanio [-h]\n" ); fprintf( pErr, "\t prints the statistics about fanins/fanouts of all nodes\n" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandPrintFactor( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk; Abc_Obj_t * pNode; int c; int fUseRealNames; pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults fUseRealNames = 1; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "nh" ) ) != EOF ) { switch ( c ) { case 'n': fUseRealNames ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( !Abc_NtkIsSopLogic(pNtk) ) { fprintf( pErr, "Printing factored forms can be done for SOP networks.\n" ); return 1; } if ( argc > globalUtilOptind + 1 ) { fprintf( pErr, "Wrong number of auguments.\n" ); goto usage; } if ( argc == globalUtilOptind + 1 ) { pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] ); if ( pNode == NULL ) { fprintf( pErr, "Cannot find node \"%s\".\n", argv[globalUtilOptind] ); return 1; } Abc_NodePrintFactor( pOut, pNode, fUseRealNames ); return 0; } // print the nodes Abc_NtkPrintFactor( pOut, pNtk, fUseRealNames ); return 0; usage: fprintf( pErr, "usage: print_factor [-nh] \n" ); fprintf( pErr, "\t prints the factored forms of nodes\n" ); fprintf( pErr, "\t-n : toggles real/dummy fanin names [default = %s]\n", fUseRealNames? "real": "dummy" ); fprintf( pErr, "\t-h : print the command usage\n"); fprintf( pErr, "\tnode : (optional) one node to consider\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandPrintLevel( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk; Abc_Obj_t * pNode; int c; int fListNodes; int fProfile; pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults fListNodes = 0; fProfile = 1; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "nph" ) ) != EOF ) { switch ( c ) { case 'n': fListNodes ^= 1; break; case 'p': fProfile ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( !fProfile && !Abc_NtkIsStrash(pNtk) ) { fprintf( pErr, "This command works only for AIGs (run \"strash\").\n" ); return 1; } if ( argc > globalUtilOptind + 1 ) { fprintf( pErr, "Wrong number of auguments.\n" ); goto usage; } if ( argc == globalUtilOptind + 1 ) { pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] ); if ( pNode == NULL ) { fprintf( pErr, "Cannot find node \"%s\".\n", argv[globalUtilOptind] ); return 1; } Abc_NodePrintLevel( pOut, pNode ); return 0; } // process all COs Abc_NtkPrintLevel( pOut, pNtk, fProfile, fListNodes ); return 0; usage: fprintf( pErr, "usage: print_level [-nph] \n" ); fprintf( pErr, "\t prints information about node level and cone size\n" ); fprintf( pErr, "\t-n : toggles printing nodes by levels [default = %s]\n", fListNodes? "yes": "no" ); fprintf( pErr, "\t-p : toggles printing level profile [default = %s]\n", fProfile? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); fprintf( pErr, "\tnode : (optional) one node to consider\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandPrintSupport( Abc_Frame_t * pAbc, int argc, char ** argv ) { Vec_Ptr_t * vSuppFun; FILE * pOut, * pErr; Abc_Ntk_t * pNtk; int c; int fVerbose; extern Vec_Ptr_t * Sim_ComputeFunSupp( Abc_Ntk_t * pNtk, int fVerbose ); extern void Abc_NtkPrintStrSupports( Abc_Ntk_t * pNtk ); pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults fVerbose = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF ) { switch ( c ) { case 'v': fVerbose ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } // print support information Abc_NtkPrintStrSupports( pNtk ); return 0; if ( !Abc_NtkIsComb(pNtk) ) { fprintf( pErr, "This command works only for combinational networks.\n" ); return 1; } if ( !Abc_NtkIsStrash(pNtk) ) { fprintf( pErr, "This command works only for AIGs (run \"strash\").\n" ); return 1; } vSuppFun = Sim_ComputeFunSupp( pNtk, fVerbose ); free( vSuppFun->pArray[0] ); Vec_PtrFree( vSuppFun ); return 0; usage: fprintf( pErr, "usage: print_supp [-vh]\n" ); fprintf( pErr, "\t prints the supports of the CO nodes\n" ); fprintf( pErr, "\t-v : enable verbose output [default = %s].\n", fVerbose? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandPrintSymms( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk; int c; int fUseBdds; int fNaive; int fVerbose; extern void Abc_NtkSymmetries( Abc_Ntk_t * pNtk, int fUseBdds, int fNaive, int fVerbose ); pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults fUseBdds = 0; fNaive = 0; fVerbose = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "bnvh" ) ) != EOF ) { switch ( c ) { case 'b': fUseBdds ^= 1; break; case 'n': fNaive ^= 1; break; case 'v': fVerbose ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( !Abc_NtkIsComb(pNtk) ) { fprintf( pErr, "This command works only for combinational networks.\n" ); return 1; } if ( !Abc_NtkIsStrash(pNtk) ) { fprintf( pErr, "This command works only for AIGs (run \"strash\").\n" ); return 1; } Abc_NtkSymmetries( pNtk, fUseBdds, fNaive, fVerbose ); return 0; usage: fprintf( pErr, "usage: print_symm [-nbvh]\n" ); fprintf( pErr, "\t computes symmetries of the PO functions\n" ); fprintf( pErr, "\t-b : toggle BDD-based or SAT-based computations [default = %s].\n", fUseBdds? "BDD": "SAT" ); fprintf( pErr, "\t-n : enable naive BDD-based computation [default = %s].\n", fNaive? "yes": "no" ); fprintf( pErr, "\t-v : enable verbose output [default = %s].\n", fVerbose? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandPrintUnate( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk; int c; int fUseBdds; int fUseNaive; int fVerbose; extern void Abc_NtkPrintUnate( Abc_Ntk_t * pNtk, int fUseBdds, int fUseNaive, int fVerbose ); pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults fUseBdds = 1; fUseNaive = 0; fVerbose = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "bnvh" ) ) != EOF ) { switch ( c ) { case 'b': fUseBdds ^= 1; break; case 'n': fUseNaive ^= 1; break; case 'v': fVerbose ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( !Abc_NtkIsStrash(pNtk) ) { fprintf( pErr, "This command works only for AIGs (run \"strash\").\n" ); return 1; } Abc_NtkPrintUnate( pNtk, fUseBdds, fUseNaive, fVerbose ); return 0; usage: fprintf( pErr, "usage: print_unate [-bnvh]\n" ); fprintf( pErr, "\t computes unate variables of the PO functions\n" ); fprintf( pErr, "\t-b : toggle BDD-based or SAT-based computations [default = %s].\n", fUseBdds? "BDD": "SAT" ); fprintf( pErr, "\t-n : toggle naive BDD-based computation [default = %s].\n", fUseNaive? "yes": "no" ); fprintf( pErr, "\t-v : enable verbose output [default = %s].\n", fVerbose? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandPrintAuto( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk; int c; int Output; int fNaive; int fVerbose; extern void Abc_NtkAutoPrint( Abc_Ntk_t * pNtk, int Output, int fNaive, int fVerbose ); pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults Output = -1; fNaive = 0; fVerbose = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "Onvh" ) ) != EOF ) { switch ( c ) { case 'O': if ( globalUtilOptind >= argc ) { fprintf( pErr, "Command line switch \"-O\" should be followed by an integer.\n" ); goto usage; } Output = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( Output < 0 ) goto usage; break; case 'n': fNaive ^= 1; break; case 'v': fVerbose ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( !Abc_NtkIsStrash(pNtk) ) { fprintf( pErr, "This command works only for AIGs (run \"strash\").\n" ); return 1; } Abc_NtkAutoPrint( pNtk, Output, fNaive, fVerbose ); return 0; usage: fprintf( pErr, "usage: print_auto [-O num] [-nvh]\n" ); fprintf( pErr, "\t computes autosymmetries of the PO functions\n" ); fprintf( pErr, "\t-O num : (optional) the 0-based number of the output [default = all]\n"); fprintf( pErr, "\t-n : enable naive BDD-based computation [default = %s].\n", fNaive? "yes": "no" ); fprintf( pErr, "\t-v : enable verbose output [default = %s].\n", fVerbose? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandPrintKMap( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk; Abc_Obj_t * pNode; int c; int fUseRealNames; extern void Abc_NodePrintKMap( Abc_Obj_t * pNode, int fUseRealNames ); pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults fUseRealNames = 1; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "nh" ) ) != EOF ) { switch ( c ) { case 'n': fUseRealNames ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( !Abc_NtkIsBddLogic(pNtk) ) { fprintf( pErr, "Visualizing Karnaugh map works for BDD logic networks (run \"bdd\").\n" ); return 1; } if ( argc > globalUtilOptind + 1 ) { fprintf( pErr, "Wrong number of auguments.\n" ); goto usage; } if ( argc == globalUtilOptind ) { pNode = Abc_ObjFanin0( Abc_NtkPo(pNtk, 0) ); if ( !Abc_ObjIsNode(pNode) ) { fprintf( pErr, "The driver \"%s\" of the first PO is not an internal node.\n", Abc_ObjName(pNode) ); return 1; } } else { pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] ); if ( pNode == NULL ) { fprintf( pErr, "Cannot find node \"%s\".\n", argv[globalUtilOptind] ); return 1; } } Abc_NodePrintKMap( pNode, fUseRealNames ); return 0; usage: fprintf( pErr, "usage: print_kmap [-nh] \n" ); fprintf( pErr, " shows the truth table of the node\n" ); fprintf( pErr, "\t-n : toggles real/dummy fanin names [default = %s]\n", fUseRealNames? "real": "dummy" ); fprintf( pErr, "\t-h : print the command usage\n"); fprintf( pErr, "\tnode : the node to consider (default = the driver of the first PO)\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandPrintGates( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk; int c; int fUseLibrary; extern void Abc_NtkPrintGates( Abc_Ntk_t * pNtk, int fUseLibrary ); pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults fUseLibrary = 1; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "lh" ) ) != EOF ) { switch ( c ) { case 'l': fUseLibrary ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( Abc_NtkHasAig(pNtk) ) { fprintf( pErr, "Printing gates does not work for AIGs and sequential AIGs.\n" ); return 1; } Abc_NtkPrintGates( pNtk, fUseLibrary ); return 0; usage: fprintf( pErr, "usage: print_gates [-lh]\n" ); fprintf( pErr, "\t prints statistics about gates used in the network\n" ); fprintf( pErr, "\t-l : used library gate names (if mapped) [default = %s]\n", fUseLibrary? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandPrintSharing( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk; int c; int fUseLibrary; extern void Abc_NtkPrintSharing( Abc_Ntk_t * pNtk ); pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults fUseLibrary = 1; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "lh" ) ) != EOF ) { switch ( c ) { case 'l': fUseLibrary ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( Abc_NtkIsSeq(pNtk) ) { fprintf( pErr, "Printing logic sharing does not work for sequential AIGs.\n" ); return 1; } Abc_NtkPrintSharing( pNtk ); return 0; usage: fprintf( pErr, "usage: print_sharing [-h]\n" ); fprintf( pErr, "\t prints the number of shared nodes in the TFO cones of the COs\n" ); // fprintf( pErr, "\t-l : used library gate names (if mapped) [default = %s]\n", fUseLibrary? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandShowBdd( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk; Abc_Obj_t * pNode; int c; extern void Abc_NodeShowBdd( Abc_Obj_t * pNode ); pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) { switch ( c ) { case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( !Abc_NtkIsBddLogic(pNtk) ) { fprintf( pErr, "Visualizing BDDs can only be done for logic BDD networks (run \"bdd\").\n" ); return 1; } if ( argc > globalUtilOptind + 1 ) { fprintf( pErr, "Wrong number of auguments.\n" ); goto usage; } if ( argc == globalUtilOptind ) { pNode = Abc_ObjFanin0( Abc_NtkPo(pNtk, 0) ); if ( !Abc_ObjIsNode(pNode) ) { fprintf( pErr, "The driver \"%s\" of the first PO is not an internal node.\n", Abc_ObjName(pNode) ); return 1; } } else { pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] ); if ( pNode == NULL ) { fprintf( pErr, "Cannot find node \"%s\".\n", argv[globalUtilOptind] ); return 1; } } Abc_NodeShowBdd( pNode ); return 0; usage: fprintf( pErr, "usage: show_bdd [-h] \n" ); fprintf( pErr, " visualizes the BDD of a node using DOT and GSVIEW\n" ); #ifdef WIN32 fprintf( pErr, " \"dot.exe\" and \"gsview32.exe\" should be set in the paths\n" ); fprintf( pErr, " (\"gsview32.exe\" may be in \"C:\\Program Files\\Ghostgum\\gsview\\\")\n" ); #endif fprintf( pErr, "\tnode : the node to consider [default = the driver of the first PO]\n"); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandShowCut( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk; Abc_Obj_t * pNode; int c; int nNodeSizeMax; int nConeSizeMax; extern void Abc_NodeShowCut( Abc_Obj_t * pNode, int nNodeSizeMax, int nConeSizeMax ); pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults nNodeSizeMax = 10; nConeSizeMax = ABC_INFINITY; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "NCh" ) ) != EOF ) { switch ( c ) { case 'N': if ( globalUtilOptind >= argc ) { fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" ); goto usage; } nNodeSizeMax = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( nNodeSizeMax < 0 ) goto usage; break; case 'C': if ( globalUtilOptind >= argc ) { fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" ); goto usage; } nConeSizeMax = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( nConeSizeMax < 0 ) goto usage; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( !Abc_NtkIsStrash(pNtk) ) { fprintf( pErr, "Visualizing cuts only works for AIGs (run \"strash\").\n" ); return 1; } if ( argc != globalUtilOptind + 1 ) { fprintf( pErr, "Wrong number of auguments.\n" ); goto usage; } pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] ); if ( pNode == NULL ) { fprintf( pErr, "Cannot find node \"%s\".\n", argv[globalUtilOptind] ); return 1; } Abc_NodeShowCut( pNode, nNodeSizeMax, nConeSizeMax ); return 0; usage: fprintf( pErr, "usage: show_cut [-N num] [-C num] [-h] \n" ); fprintf( pErr, " visualizes the cut of a node using DOT and GSVIEW\n" ); #ifdef WIN32 fprintf( pErr, " \"dot.exe\" and \"gsview32.exe\" should be set in the paths\n" ); fprintf( pErr, " (\"gsview32.exe\" may be in \"C:\\Program Files\\Ghostgum\\gsview\\\")\n" ); #endif fprintf( pErr, "\t-N num : the max size of the cut to be computed [default = %d]\n", nNodeSizeMax ); fprintf( pErr, "\t-C num : the max support of the containing cone [default = %d]\n", nConeSizeMax ); fprintf( pErr, "\tnode : the node to consider\n"); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandShowAig( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk; int c; int fMulti; extern void Abc_NtkShowAig( Abc_Ntk_t * pNtk ); extern void Abc_NtkShowMulti( Abc_Ntk_t * pNtk ); pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults fMulti = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "mh" ) ) != EOF ) { switch ( c ) { case 'm': fMulti ^= 1; break; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( !Abc_NtkHasAig(pNtk) ) { fprintf( pErr, "Visualizing networks other than AIGs can be done using command \"show_ntk\".\n" ); return 1; } if ( fMulti && !Abc_NtkIsStrash(pNtk) ) { fprintf( pErr, "Visualizing multi-input ANDs cannot be done for sequential network (run \"unseq\").\n" ); return 1; } if ( !fMulti ) Abc_NtkShowAig( pNtk ); else Abc_NtkShowMulti( pNtk ); return 0; usage: fprintf( pErr, "usage: show_aig [-h]\n" ); fprintf( pErr, " visualizes the AIG with choices using DOT and GSVIEW\n" ); #ifdef WIN32 fprintf( pErr, " \"dot.exe\" and \"gsview32.exe\" should be set in the paths\n" ); fprintf( pErr, " (\"gsview32.exe\" may be in \"C:\\Program Files\\Ghostgum\\gsview\\\")\n" ); #endif fprintf( pErr, "\t-m : toggles visualization of multi-input ANDs [default = %s].\n", fMulti? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandShowNtk( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk; int c; int fGateNames; extern void Abc_NtkShow( Abc_Ntk_t * pNtk, int fGateNames ); pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults fGateNames = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "gh" ) ) != EOF ) { switch ( c ) { case 'g': fGateNames ^= 1; break; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( Abc_NtkHasAig(pNtk) ) { fprintf( pErr, "Visualizing AIG can only be done using command \"show_aig\".\n" ); return 1; } Abc_NtkShow( pNtk, fGateNames ); return 0; usage: fprintf( pErr, "usage: show_ntk [-gh]\n" ); fprintf( pErr, " visualizes the network structure using DOT and GSVIEW\n" ); #ifdef WIN32 fprintf( pErr, " \"dot.exe\" and \"gsview32.exe\" should be set in the paths\n" ); fprintf( pErr, " (\"gsview32.exe\" may be in \"C:\\Program Files\\Ghostgum\\gsview\\\")\n" ); #endif fprintf( pErr, "\t-g : toggles printing gate names for mapped network [default = %s].\n", fGateNames? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandCollapse( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk, * pNtkRes; int c; pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) { switch ( c ) { case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( !Abc_NtkIsLogic(pNtk) && !Abc_NtkIsStrash(pNtk) ) { fprintf( pErr, "Can only collapse a logic network or an AIG.\n" ); return 1; } // get the new network if ( Abc_NtkIsStrash(pNtk) ) pNtkRes = Abc_NtkCollapse( pNtk, 1 ); else { pNtk = Abc_NtkStrash( pNtk, 0, 0 ); pNtkRes = Abc_NtkCollapse( pNtk, 1 ); Abc_NtkDelete( pNtk ); } if ( pNtkRes == NULL ) { fprintf( pErr, "Collapsing has failed.\n" ); return 1; } // replace the current network Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); return 0; usage: fprintf( pErr, "usage: collapse [-h]\n" ); fprintf( pErr, "\t collapses the network by constructing global BDDs\n" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandStrash( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk, * pNtkRes; int c; int fAllNodes; int fCleanup; pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults fAllNodes = 0; fCleanup = 1; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "ach" ) ) != EOF ) { switch ( c ) { case 'a': fAllNodes ^= 1; break; case 'c': fCleanup ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } // get the new network pNtkRes = Abc_NtkStrash( pNtk, fAllNodes, fCleanup ); if ( pNtkRes == NULL ) { fprintf( pErr, "Strashing has failed.\n" ); return 1; } // replace the current network Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); return 0; usage: fprintf( pErr, "usage: strash [-ach]\n" ); fprintf( pErr, "\t transforms combinational logic into an AIG\n" ); fprintf( pErr, "\t-a : toggles between using all nodes and DFS nodes [default = %s]\n", fAllNodes? "all": "DFS" ); fprintf( pErr, "\t-c : toggles cleanup to remove the dagling AIG nodes [default = %s]\n", fCleanup? "all": "DFS" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandBalance( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk, * pNtkRes, * pNtkTemp; int c; bool fDuplicate; bool fSelective; bool fUpdateLevel; pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults fDuplicate = 0; fSelective = 0; fUpdateLevel = 1; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "ldsh" ) ) != EOF ) { switch ( c ) { case 'l': fUpdateLevel ^= 1; break; case 'd': fDuplicate ^= 1; break; case 's': fSelective ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( Abc_NtkIsSeq(pNtk) ) { fprintf( pErr, "Balancing cannot be applied to a sequential AIG.\n" ); return 1; } // get the new network if ( Abc_NtkIsStrash(pNtk) ) { pNtkRes = Abc_NtkBalance( pNtk, fDuplicate, fSelective, fUpdateLevel ); } else { pNtkTemp = Abc_NtkStrash( pNtk, 0, 0 ); if ( pNtkTemp == NULL ) { fprintf( pErr, "Strashing before balancing has failed.\n" ); return 1; } pNtkRes = Abc_NtkBalance( pNtkTemp, fDuplicate, fSelective, fUpdateLevel ); Abc_NtkDelete( pNtkTemp ); } // check if balancing worked if ( pNtkRes == NULL ) { fprintf( pErr, "Balancing has failed.\n" ); return 1; } // replace the current network Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); return 0; usage: fprintf( pErr, "usage: balance [-ldsh]\n" ); fprintf( pErr, "\t transforms the current network into a well-balanced AIG\n" ); fprintf( pErr, "\t-l : toggle minimizing the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" ); fprintf( pErr, "\t-d : toggle duplication of logic [default = %s]\n", fDuplicate? "yes": "no" ); fprintf( pErr, "\t-s : toggle duplication on the critical paths [default = %s]\n", fSelective? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandRenode( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk, * pNtkRes; int nThresh, nFaninMax, c; int fCnf; int fMulti; int fSimple; pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults nThresh = 1; nFaninMax = 20; fCnf = 0; fMulti = 0; fSimple = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "TFmcsh" ) ) != EOF ) { switch ( c ) { case 'T': if ( globalUtilOptind >= argc ) { fprintf( pErr, "Command line switch \"-T\" should be followed by an integer.\n" ); goto usage; } nThresh = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( nThresh < 0 ) goto usage; break; case 'F': if ( globalUtilOptind >= argc ) { fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" ); goto usage; } nFaninMax = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( nFaninMax < 0 ) goto usage; break; case 'c': fCnf ^= 1; break; case 'm': fMulti ^= 1; break; case 's': fSimple ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( !Abc_NtkIsStrash(pNtk) ) { fprintf( pErr, "Cannot renode a network that is not an AIG (run \"strash\").\n" ); return 1; } // get the new network pNtkRes = Abc_NtkRenode( pNtk, nThresh, nFaninMax, fCnf, fMulti, fSimple ); if ( pNtkRes == NULL ) { fprintf( pErr, "Renoding has failed.\n" ); return 1; } // replace the current network Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); return 0; usage: fprintf( pErr, "usage: renode [-T num] [-F num] [-cmsh]\n" ); fprintf( pErr, "\t transforms an AIG into a logic network by creating larger nodes\n" ); fprintf( pErr, "\t-F num : the maximum fanin size after renoding [default = %d]\n", nFaninMax ); fprintf( pErr, "\t-T num : the threshold for AIG node duplication [default = %d]\n", nThresh ); fprintf( pErr, "\t (an AIG node is the root of a new node after renoding\n" ); fprintf( pErr, "\t if this leads to duplication of no more than %d AIG nodes,\n", nThresh ); fprintf( pErr, "\t that is, if [(numFanouts(Node)-1) * size(MFFC(Node))] <= %d)\n", nThresh ); fprintf( pErr, "\t-m : creates multi-input AND graph [default = %s]\n", fMulti? "yes": "no" ); fprintf( pErr, "\t-s : creates a simple AIG (no renoding) [default = %s]\n", fSimple? "yes": "no" ); fprintf( pErr, "\t-c : performs renoding to derive the CNF [default = %s]\n", fCnf? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandCleanup( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk; int c; pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) { switch ( c ) { case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( Abc_NtkIsStrash(pNtk) ) { fprintf( pErr, "Cleanup cannot be performed on the AIG.\n" ); return 1; } // modify the current network Abc_NtkCleanup( pNtk, 1 ); return 0; usage: fprintf( pErr, "usage: cleanup [-h]\n" ); fprintf( pErr, "\t removes dangling nodes\n" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandSweep( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk; int c; pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) { switch ( c ) { case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( !Abc_NtkIsSopLogic(pNtk) && !Abc_NtkIsBddLogic(pNtk) ) { fprintf( pErr, "Sweep cannot be performed on an AIG or a mapped network (run \"unmap\").\n" ); return 1; } // modify the current network Abc_NtkSweep( pNtk, 0 ); return 0; usage: fprintf( pErr, "usage: sweep [-h]\n" ); fprintf( pErr, "\t removes dangling nodes; propagates constant, buffers, inverters\n" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandFastExtract( Abc_Frame_t * pAbc, int argc, char ** argv ) { Abc_Ntk_t * pNtk; FILE * pOut, * pErr; Fxu_Data_t * p = NULL; int c; extern bool Abc_NtkFastExtract( Abc_Ntk_t * pNtk, Fxu_Data_t * p ); extern void Abc_NtkFxuFreeInfo( Fxu_Data_t * p ); pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // allocate the structure p = ALLOC( Fxu_Data_t, 1 ); memset( p, 0, sizeof(Fxu_Data_t) ); // set the defaults p->nPairsMax = 30000; p->nNodesExt = 10000; p->fOnlyS = 0; p->fOnlyD = 0; p->fUse0 = 0; p->fUseCompl = 1; p->fVerbose = 0; Extra_UtilGetoptReset(); while ( (c = Extra_UtilGetopt(argc, argv, "LNsdzcvh")) != EOF ) { switch (c) { case 'L': if ( globalUtilOptind >= argc ) { fprintf( pErr, "Command line switch \"-L\" should be followed by an integer.\n" ); goto usage; } p->nPairsMax = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( p->nPairsMax < 0 ) goto usage; break; case 'N': if ( globalUtilOptind >= argc ) { fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" ); goto usage; } p->nNodesExt = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( p->nNodesExt < 0 ) goto usage; break; case 's': p->fOnlyS ^= 1; break; case 'd': p->fOnlyD ^= 1; break; case 'z': p->fUse0 ^= 1; break; case 'c': p->fUseCompl ^= 1; break; case 'v': p->fVerbose ^= 1; break; case 'h': goto usage; break; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); Abc_NtkFxuFreeInfo( p ); return 1; } if ( Abc_NtkNodeNum(pNtk) == 0 ) { fprintf( pErr, "The network does not have internal nodes.\n" ); Abc_NtkFxuFreeInfo( p ); return 1; } if ( !Abc_NtkIsLogic(pNtk) ) { fprintf( pErr, "Fast extract can only be applied to a logic network (run \"renode\").\n" ); Abc_NtkFxuFreeInfo( p ); return 1; } // the nodes to be merged are linked into the special linked list Abc_NtkFastExtract( pNtk, p ); Abc_NtkFxuFreeInfo( p ); return 0; usage: fprintf( pErr, "usage: fx [-N num] [-L num] [-sdzcvh]\n"); fprintf( pErr, "\t performs unate fast extract on the current network\n"); fprintf( pErr, "\t-N num : the maximum number of divisors to extract [default = %d]\n", p->nNodesExt ); fprintf( pErr, "\t-L num : the maximum number of cube pairs to consider [default = %d]\n", p->nPairsMax ); fprintf( pErr, "\t-s : use only single-cube divisors [default = %s]\n", p->fOnlyS? "yes": "no" ); fprintf( pErr, "\t-d : use only double-cube divisors [default = %s]\n", p->fOnlyD? "yes": "no" ); fprintf( pErr, "\t-z : use zero-weight divisors [default = %s]\n", p->fUse0? "yes": "no" ); fprintf( pErr, "\t-c : use complement in the binary case [default = %s]\n", p->fUseCompl? "yes": "no" ); fprintf( pErr, "\t-v : print verbose information [default = %s]\n", p->fVerbose? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); Abc_NtkFxuFreeInfo( p ); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandDisjoint( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk, * pNtkRes, * pNtkNew; int fGlobal, fRecursive, fVerbose, fPrint, fShort, c; extern Abc_Ntk_t * Abc_NtkDsdGlobal( Abc_Ntk_t * pNtk, bool fVerbose, bool fPrint, bool fShort ); extern int Abc_NtkDsdLocal( Abc_Ntk_t * pNtk, bool fVerbose, bool fRecursive ); pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults fGlobal = 1; fRecursive = 0; fVerbose = 0; fPrint = 0; fShort = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "grvpsh" ) ) != EOF ) { switch ( c ) { case 'g': fGlobal ^= 1; break; case 'r': fRecursive ^= 1; break; case 'v': fVerbose ^= 1; break; case 'p': fPrint ^= 1; break; case 's': fShort ^= 1; break; case 'h': goto usage; break; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( fGlobal ) { // fprintf( stdout, "Performing DSD of global functions of the network.\n" ); // get the new network if ( !Abc_NtkIsStrash(pNtk) ) { pNtkNew = Abc_NtkStrash( pNtk, 0, 0 ); pNtkRes = Abc_NtkDsdGlobal( pNtkNew, fVerbose, fPrint, fShort ); Abc_NtkDelete( pNtkNew ); } else { pNtkRes = Abc_NtkDsdGlobal( pNtk, fVerbose, fPrint, fShort ); } if ( pNtkRes == NULL ) { fprintf( pErr, "Global DSD has failed.\n" ); return 1; } // replace the current network Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); } else if ( fRecursive ) { if ( !Abc_NtkIsBddLogic( pNtk ) ) { fprintf( pErr, "This command is only applicable to logic BDD networks.\n" ); return 1; } fprintf( stdout, "Performing recursive DSD and MUX decomposition of local functions.\n" ); if ( !Abc_NtkDsdLocal( pNtk, fVerbose, fRecursive ) ) fprintf( pErr, "Recursive DSD has failed.\n" ); } else { if ( !Abc_NtkIsBddLogic( pNtk ) ) { fprintf( pErr, "This command is only applicable to logic BDD networks (run \"bdd\").\n" ); return 1; } fprintf( stdout, "Performing simple non-recursive DSD of local functions.\n" ); if ( !Abc_NtkDsdLocal( pNtk, fVerbose, fRecursive ) ) fprintf( pErr, "Simple DSD of local functions has failed.\n" ); } return 0; usage: fprintf( pErr, "usage: dsd [-grvpsh]\n" ); fprintf( pErr, "\t decomposes the network using disjoint-support decomposition\n" ); fprintf( pErr, "\t-g : toggle DSD of global and local functions [default = %s]\n", fGlobal? "global": "local" ); fprintf( pErr, "\t-r : toggle recursive DSD/MUX and simple DSD [default = %s]\n", fRecursive? "recursive DSD/MUX": "simple DSD" ); fprintf( pErr, "\t-v : prints DSD statistics and runtime [default = %s]\n", fVerbose? "yes": "no" ); fprintf( pErr, "\t-p : prints DSD structure to the standard output [default = %s]\n", fPrint? "yes": "no" ); fprintf( pErr, "\t-s : use short PI names when printing DSD structure [default = %s]\n", fShort? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandRewrite( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk; int c; bool fUpdateLevel; bool fPrecompute; bool fUseZeros; bool fVerbose; // external functions extern void Rwr_Precompute(); extern int Abc_NtkRewrite( Abc_Ntk_t * pNtk, int fUpdateLevel, int fUseZeros, int fVerbose ); pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults fUpdateLevel = 1; fPrecompute = 0; fUseZeros = 0; fVerbose = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "lxzvh" ) ) != EOF ) { switch ( c ) { case 'l': fUpdateLevel ^= 1; break; case 'x': fPrecompute ^= 1; break; case 'z': fUseZeros ^= 1; break; case 'v': fVerbose ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( fPrecompute ) { Rwr_Precompute(); return 0; } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( !Abc_NtkIsStrash(pNtk) ) { fprintf( pErr, "This command can only be applied to an AIG (run \"strash\").\n" ); return 1; } if ( Abc_NtkGetChoiceNum(pNtk) ) { fprintf( pErr, "AIG resynthesis cannot be applied to AIGs with choice nodes.\n" ); return 1; } // modify the current network if ( !Abc_NtkRewrite( pNtk, fUpdateLevel, fUseZeros, fVerbose ) ) { fprintf( pErr, "Rewriting has failed.\n" ); return 1; } return 0; usage: fprintf( pErr, "usage: rewrite [-lzvh]\n" ); fprintf( pErr, "\t performs technology-independent rewriting of the AIG\n" ); fprintf( pErr, "\t-l : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" ); fprintf( pErr, "\t-z : toggle using zero-cost replacements [default = %s]\n", fUseZeros? "yes": "no" ); fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandRefactor( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk; int c; int nNodeSizeMax; int nConeSizeMax; bool fUpdateLevel; bool fUseZeros; bool fUseDcs; bool fVerbose; extern int Abc_NtkRefactor( Abc_Ntk_t * pNtk, int nNodeSizeMax, int nConeSizeMax, bool fUpdateLevel, bool fUseZeros, bool fUseDcs, bool fVerbose ); pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults nNodeSizeMax = 10; nConeSizeMax = 16; fUpdateLevel = 1; fUseZeros = 0; fUseDcs = 0; fVerbose = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "NClzdvh" ) ) != EOF ) { switch ( c ) { case 'N': if ( globalUtilOptind >= argc ) { fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" ); goto usage; } nNodeSizeMax = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( nNodeSizeMax < 0 ) goto usage; break; case 'C': if ( globalUtilOptind >= argc ) { fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" ); goto usage; } nConeSizeMax = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( nConeSizeMax < 0 ) goto usage; break; case 'l': fUpdateLevel ^= 1; break; case 'z': fUseZeros ^= 1; break; case 'd': fUseDcs ^= 1; break; case 'v': fVerbose ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( !Abc_NtkIsStrash(pNtk) ) { fprintf( pErr, "This command can only be applied to an AIG (run \"strash\").\n" ); return 1; } if ( Abc_NtkGetChoiceNum(pNtk) ) { fprintf( pErr, "AIG resynthesis cannot be applied to AIGs with choice nodes.\n" ); return 1; } if ( fUseDcs && nNodeSizeMax >= nConeSizeMax ) { fprintf( pErr, "For don't-care to work, containing cone should be larger than collapsed node.\n" ); return 1; } // modify the current network if ( !Abc_NtkRefactor( pNtk, nNodeSizeMax, nConeSizeMax, fUpdateLevel, fUseZeros, fUseDcs, fVerbose ) ) { fprintf( pErr, "Refactoring has failed.\n" ); return 1; } return 0; usage: fprintf( pErr, "usage: refactor [-N num] [-C num] [-lzdvh]\n" ); fprintf( pErr, "\t performs technology-independent refactoring of the AIG\n" ); fprintf( pErr, "\t-N num : the max support of the collapsed node [default = %d]\n", nNodeSizeMax ); fprintf( pErr, "\t-C num : the max support of the containing cone [default = %d]\n", nConeSizeMax ); fprintf( pErr, "\t-l : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" ); fprintf( pErr, "\t-z : toggle using zero-cost replacements [default = %s]\n", fUseZeros? "yes": "no" ); fprintf( pErr, "\t-d : toggle using don't-cares [default = %s]\n", fUseDcs? "yes": "no" ); fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandRestructure( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk; int c; int nCutMax; bool fUpdateLevel; bool fUseZeros; bool fVerbose; extern int Abc_NtkRestructure( Abc_Ntk_t * pNtk, int nCutMax, bool fUpdateLevel, bool fUseZeros, bool fVerbose ); pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults nCutMax = 5; fUpdateLevel = 0; fUseZeros = 0; fVerbose = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "Klzvh" ) ) != EOF ) { switch ( c ) { case 'K': if ( globalUtilOptind >= argc ) { fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" ); goto usage; } nCutMax = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( nCutMax < 0 ) goto usage; break; case 'l': fUpdateLevel ^= 1; break; case 'z': fUseZeros ^= 1; break; case 'v': fVerbose ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( nCutMax < 4 || nCutMax > CUT_SIZE_MAX ) { fprintf( pErr, "Can only compute the cuts for %d <= K <= %d.\n", 4, CUT_SIZE_MAX ); return 1; } if ( !Abc_NtkIsStrash(pNtk) ) { fprintf( pErr, "This command can only be applied to an AIG (run \"strash\").\n" ); return 1; } if ( Abc_NtkGetChoiceNum(pNtk) ) { fprintf( pErr, "AIG resynthesis cannot be applied to AIGs with choice nodes.\n" ); return 1; } // modify the current network if ( !Abc_NtkRestructure( pNtk, nCutMax, fUpdateLevel, fUseZeros, fVerbose ) ) { fprintf( pErr, "Refactoring has failed.\n" ); return 1; } return 0; usage: fprintf( pErr, "usage: restructure [-K num] [-lzvh]\n" ); fprintf( pErr, "\t performs technology-independent restructuring of the AIG\n" ); fprintf( pErr, "\t-K num : the max cut size (%d <= num <= %d) [default = %d]\n", CUT_SIZE_MIN, CUT_SIZE_MAX, nCutMax ); fprintf( pErr, "\t-l : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" ); fprintf( pErr, "\t-z : toggle using zero-cost replacements [default = %s]\n", fUseZeros? "yes": "no" ); fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandLogic( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk, * pNtkRes; int c; pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) { switch ( c ) { case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( !Abc_NtkIsNetlist( pNtk ) ) { fprintf( pErr, "This command is only applicable to netlists.\n" ); return 1; } // get the new network pNtkRes = Abc_NtkNetlistToLogic( pNtk ); if ( pNtkRes == NULL ) { fprintf( pErr, "Converting to a logic network has failed.\n" ); return 1; } // replace the current network Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); return 0; usage: fprintf( pErr, "usage: logic [-h]\n" ); fprintf( pErr, "\t transforms a netlist into a logic network\n" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandMiter( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk, * pNtk1, * pNtk2, * pNtkRes; int fDelete1, fDelete2; char ** pArgvNew; int nArgcNew; int c; int fCheck; int fComb; pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults fComb = 1; fCheck = 1; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF ) { switch ( c ) { case 'c': fComb ^= 1; break; default: goto usage; } } pArgvNew = argv + globalUtilOptind; nArgcNew = argc - globalUtilOptind; if ( !Abc_NtkPrepareTwoNtks( pErr, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) ) return 1; // compute the miter pNtkRes = Abc_NtkMiter( pNtk1, pNtk2, fComb ); if ( fDelete1 ) Abc_NtkDelete( pNtk1 ); if ( fDelete2 ) Abc_NtkDelete( pNtk2 ); // get the new network if ( pNtkRes == NULL ) { fprintf( pErr, "Miter computation has failed.\n" ); return 1; } // replace the current network Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); return 0; usage: fprintf( pErr, "usage: miter [-ch] \n" ); fprintf( pErr, "\t computes the miter of the two circuits\n" ); fprintf( pErr, "\t-c : computes combinational miter (latches as POs) [default = %s]\n", fComb? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); fprintf( pErr, "\tfile1 : (optional) the file with the first network\n"); fprintf( pErr, "\tfile2 : (optional) the file with the second network\n"); fprintf( pErr, "\t if no files are given, uses the current network and its spec\n"); fprintf( pErr, "\t if one file is given, uses the current network and the file\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandFrames( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk, * pNtkTemp, * pNtkRes; int fInitial; int nFrames; int c; pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults fInitial = 0; nFrames = 5; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "Fih" ) ) != EOF ) { switch ( c ) { case 'F': if ( globalUtilOptind >= argc ) { fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" ); goto usage; } nFrames = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( nFrames <= 0 ) goto usage; break; case 'i': fInitial ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } // get the new network if ( !Abc_NtkIsStrash(pNtk) ) { pNtkTemp = Abc_NtkStrash( pNtk, 0, 0 ); pNtkRes = Abc_NtkFrames( pNtkTemp, nFrames, fInitial ); Abc_NtkDelete( pNtkTemp ); } else pNtkRes = Abc_NtkFrames( pNtk, nFrames, fInitial ); if ( pNtkRes == NULL ) { fprintf( pErr, "Unrolling the network has failed.\n" ); return 1; } // replace the current network Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); return 0; usage: fprintf( pErr, "usage: frames [-F num] [-ih]\n" ); fprintf( pErr, "\t unrolls the network for a number of time frames\n" ); fprintf( pErr, "\t-F num : the number of frames to unroll [default = %d]\n", nFrames ); fprintf( pErr, "\t-i : toggles initializing the first frame [default = %s]\n", fInitial? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandSop( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk; int c; pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) { switch ( c ) { case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } // get the new network if ( !Abc_NtkIsBddLogic(pNtk) ) { fprintf( pErr, "Converting to SOP is possible when node functions are BDDs.\n" ); return 1; } if ( !Abc_NtkBddToSop( pNtk ) ) { fprintf( pErr, "Converting to SOP has failed.\n" ); return 1; } return 0; usage: fprintf( pErr, "usage: sop [-h]\n" ); fprintf( pErr, "\t converts node functions from BDD to SOP\n" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandBdd( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk; int c; pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) { switch ( c ) { case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( !Abc_NtkIsSopLogic(pNtk) ) { fprintf( pErr, "Converting to BDD is possible when node functions are SOPs.\n" ); return 1; } if ( !Abc_NtkSopToBdd( pNtk ) ) { fprintf( pErr, "Converting to BDD has failed.\n" ); return 1; } return 0; usage: fprintf( pErr, "usage: bdd [-h]\n" ); fprintf( pErr, "\t converts node functions from SOP to BDD\n" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandReorder( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk; int c; int fVerbose; extern void Abc_NtkBddReorder( Abc_Ntk_t * pNtk, int fVerbose ); pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults fVerbose = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF ) { switch ( c ) { case 'v': fVerbose ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } // get the new network if ( !Abc_NtkIsBddLogic(pNtk) ) { fprintf( pErr, "Variable reordering is possible when node functions are BDDs (run \"bdd\").\n" ); return 1; } Abc_NtkBddReorder( pNtk, fVerbose ); return 0; usage: fprintf( pErr, "usage: reorder [-vh]\n" ); fprintf( pErr, "\t reorders local functions of the nodes using sifting\n" ); fprintf( pErr, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandMuxes( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk, * pNtkRes; int c; pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) { switch ( c ) { case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( !Abc_NtkIsBddLogic(pNtk) ) { fprintf( pErr, "Only a BDD logic network can be converted to MUXes.\n" ); return 1; } // get the new network pNtkRes = Abc_NtkBddToMuxes( pNtk ); if ( pNtkRes == NULL ) { fprintf( pErr, "Converting to MUXes has failed.\n" ); return 1; } // replace the current network Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); return 0; usage: fprintf( pErr, "usage: muxes [-h]\n" ); fprintf( pErr, "\t converts the current network by a network derived by\n" ); fprintf( pErr, "\t replacing all nodes by DAGs isomorphic to the local BDDs\n" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandSat( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk; int c; int RetValue; int fVerbose; int nConfLimit; int nImpLimit; int clk; pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults fVerbose = 0; nConfLimit = 100000; nImpLimit = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "CIvh" ) ) != EOF ) { switch ( c ) { case 'C': if ( globalUtilOptind >= argc ) { fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" ); goto usage; } nConfLimit = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( nConfLimit < 0 ) goto usage; break; case 'I': if ( globalUtilOptind >= argc ) { fprintf( pErr, "Command line switch \"-I\" should be followed by an integer.\n" ); goto usage; } nImpLimit = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( nImpLimit < 0 ) goto usage; break; case 'v': fVerbose ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( Abc_NtkLatchNum(pNtk) > 0 ) { fprintf( stdout, "Currently can only solve the miter for combinational circuits.\n" ); return 0; } if ( Abc_NtkIsSeq(pNtk) ) { fprintf( stdout, "This command cannot be applied to the sequential AIG.\n" ); return 0; } if ( Abc_NtkIsStrash(pNtk) ) { clk = clock(); RetValue = Abc_NtkMiterSat( pNtk, nConfLimit, nImpLimit, fVerbose ); if ( RetValue == -1 ) printf( "UNDECIDED " ); else if ( RetValue == 0 ) printf( "SATISFIABLE " ); else printf( "UNSATISFIABLE " ); //printf( "\n" ); PRT( "Time", clock() - clk ); } else { Abc_Ntk_t * pTemp; pTemp = Abc_NtkStrash( pNtk, 0, 0 ); clk = clock(); RetValue = Abc_NtkMiterSat( pTemp, nConfLimit, nImpLimit, fVerbose ); if ( RetValue == -1 ) printf( "UNDECIDED " ); else if ( RetValue == 0 ) printf( "SATISFIABLE " ); else printf( "UNSATISFIABLE " ); //printf( "\n" ); PRT( "Time", clock() - clk ); Abc_NtkDelete( pTemp ); } return 0; usage: fprintf( pErr, "usage: sat [-C num] [-I num] [-vh]\n" ); fprintf( pErr, "\t solves the combinational miter\n" ); fprintf( pErr, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfLimit ); fprintf( pErr, "\t-I num : limit on the number of implications [default = %d]\n", nImpLimit ); fprintf( pErr, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandExtSeqDcs( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk; int c; int fVerbose; extern int Abc_NtkExtractSequentialDcs( Abc_Ntk_t * pNet, bool fVerbose ); pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults fVerbose = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF ) { switch ( c ) { case 'v': fVerbose ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( Abc_NtkLatchNum(pNtk) == 0 ) { fprintf( stdout, "The current network has no latches.\n" ); return 0; } if ( !Abc_NtkIsStrash(pNtk) ) { fprintf( stdout, "Extracting sequential don't-cares works only for AIGs (run \"strash\").\n" ); return 0; } if ( !Abc_NtkExtractSequentialDcs( pNtk, fVerbose ) ) { fprintf( stdout, "Extracting sequential don't-cares has failed.\n" ); return 1; } return 0; usage: fprintf( pErr, "usage: ext_seq_dcs [-vh]\n" ); fprintf( pErr, "\t create EXDC network using unreachable states\n" ); fprintf( pErr, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandOneOutput( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk, * pNtkRes; Abc_Obj_t * pNode, * pNodeCo; int c; int fUseAllCis; int fUseMffc; int Output; pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults fUseAllCis = 0; fUseMffc = 0; Output = -1; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "Omah" ) ) != EOF ) { switch ( c ) { case 'O': if ( globalUtilOptind >= argc ) { fprintf( pErr, "Command line switch \"-O\" should be followed by an integer.\n" ); goto usage; } Output = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( Output < 0 ) goto usage; break; case 'm': fUseMffc ^= 1; case 'a': fUseAllCis ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( !Abc_NtkIsLogic(pNtk) && !Abc_NtkIsStrash(pNtk) ) { fprintf( pErr, "Currently can only be applied to the logic network or an AIG.\n" ); return 1; } if ( argc > globalUtilOptind + 1 ) { fprintf( pErr, "Wrong number of auguments.\n" ); goto usage; } if ( argc == globalUtilOptind + 1 ) { pNodeCo = Abc_NtkFindCo( pNtk, argv[globalUtilOptind] ); pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] ); if ( pNode == NULL ) { fprintf( pErr, "Cannot find node \"%s\".\n", argv[globalUtilOptind] ); return 1; } if ( fUseMffc ) pNtkRes = Abc_NtkCreateMffc( pNtk, pNode, argv[globalUtilOptind] ); else pNtkRes = Abc_NtkCreateCone( pNtk, pNode, argv[globalUtilOptind], fUseAllCis ); } else { if ( Output == -1 ) { fprintf( pErr, "The node is not specified.\n" ); return 1; } if ( Output >= Abc_NtkCoNum(pNtk) ) { fprintf( pErr, "The 0-based output number (%d) is larger than the number of outputs (%d).\n", Output, Abc_NtkCoNum(pNtk) ); return 1; } pNodeCo = Abc_NtkCo( pNtk, Output ); if ( fUseMffc ) pNtkRes = Abc_NtkCreateMffc( pNtk, Abc_ObjFanin0(pNodeCo), Abc_ObjName(pNodeCo) ); else pNtkRes = Abc_NtkCreateCone( pNtk, Abc_ObjFanin0(pNodeCo), Abc_ObjName(pNodeCo), fUseAllCis ); } if ( pNodeCo && Abc_ObjFaninC0(pNodeCo) ) printf( "The extracted cone represents the complement function of the CO.\n" ); if ( pNtkRes == NULL ) { fprintf( pErr, "Writing the logic cone of one node has failed.\n" ); return 1; } // replace the current network Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); return 0; usage: fprintf( pErr, "usage: cone [-O num] [-amh] \n" ); fprintf( pErr, "\t replaces the current network by one logic cone\n" ); fprintf( pErr, "\t-a : toggle writing all CIs or structral support only [default = %s]\n", fUseAllCis? "all": "structural" ); fprintf( pErr, "\t-m : toggle writing only MFFC or complete TFI cone [default = %s]\n", fUseMffc? "MFFC": "TFI cone" ); fprintf( pErr, "\t-h : print the command usage\n"); fprintf( pErr, "\t-O num : (optional) the 0-based number of the CO to extract\n"); fprintf( pErr, "\tname : (optional) the name of the node to extract\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandOneNode( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk, * pNtkRes; Abc_Obj_t * pNode; int c; pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) { switch ( c ) { case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( !Abc_NtkIsLogic(pNtk) ) { fprintf( pErr, "Currently can only be applied to a logic network.\n" ); return 1; } if ( argc != globalUtilOptind + 1 ) { fprintf( pErr, "Wrong number of auguments.\n" ); goto usage; } pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] ); if ( pNode == NULL ) { fprintf( pErr, "Cannot find node \"%s\".\n", argv[globalUtilOptind] ); return 1; } pNtkRes = Abc_NtkCreateFromNode( pNtk, pNode ); // pNtkRes = Abc_NtkDeriveFromBdd( pNtk->pManFunc, pNode->pData, NULL, NULL ); if ( pNtkRes == NULL ) { fprintf( pErr, "Splitting one node has failed.\n" ); return 1; } // replace the current network Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); return 0; usage: fprintf( pErr, "usage: node [-h] \n" ); fprintf( pErr, "\t replaces the current network by the network composed of one node\n" ); fprintf( pErr, "\t-h : print the command usage\n"); fprintf( pErr, "\tname : the node name\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandShortNames( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk; int c; pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) { switch ( c ) { case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } Abc_NtkShortNames( pNtk ); return 0; usage: fprintf( pErr, "usage: short_names [-h]\n" ); fprintf( pErr, "\t replaces PI/PO/latch names by short char strings\n" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandExdcFree( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk, * pNtkRes; int c; pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) { switch ( c ) { case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( pNtk->pExdc == NULL ) { fprintf( pErr, "The network has no EXDC.\n" ); return 1; } Abc_NtkDelete( pNtk->pExdc ); pNtk->pExdc = NULL; // replace the current network pNtkRes = Abc_NtkDup( pNtk ); Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); return 0; usage: fprintf( pErr, "usage: exdc_free [-h]\n" ); fprintf( pErr, "\t frees the EXDC network of the current network\n" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandExdcGet( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk, * pNtkRes; int c; pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) { switch ( c ) { case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( pNtk->pExdc == NULL ) { fprintf( pErr, "The network has no EXDC.\n" ); return 1; } // replace the current network pNtkRes = Abc_NtkDup( pNtk->pExdc ); Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); return 0; usage: fprintf( pErr, "usage: exdc_get [-h]\n" ); fprintf( pErr, "\t replaces the current network by the EXDC of the current network\n" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandExdcSet( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr, * pFile; Abc_Ntk_t * pNtk, * pNtkNew, * pNtkRes; char * FileName; int c; pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) { switch ( c ) { case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( argc != globalUtilOptind + 1 ) { goto usage; } // get the input file name FileName = argv[globalUtilOptind]; if ( (pFile = fopen( FileName, "r" )) == NULL ) { fprintf( pAbc->Err, "Cannot open input file \"%s\". ", FileName ); if ( FileName = Extra_FileGetSimilarName( FileName, ".mv", ".blif", ".pla", ".eqn", ".bench" ) ) fprintf( pAbc->Err, "Did you mean \"%s\"?", FileName ); fprintf( pAbc->Err, "\n" ); return 1; } fclose( pFile ); // set the new network pNtkNew = Io_Read( FileName, 1 ); if ( pNtkNew == NULL ) { fprintf( pAbc->Err, "Reading network from file has failed.\n" ); return 1; } // replace the EXDC if ( pNtk->pExdc ) { Abc_NtkDelete( pNtk->pExdc ); pNtk->pExdc = NULL; } pNtkRes = Abc_NtkDup( pNtk ); pNtkRes->pExdc = pNtkNew; // replace the current network Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); return 0; usage: fprintf( pErr, "usage: exdc_set [-h] \n" ); fprintf( pErr, "\t sets the network from file as EXDC for the current network\n" ); fprintf( pErr, "\t-h : print the command usage\n"); fprintf( pErr, "\t : file with the new EXDC network\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandCut( Abc_Frame_t * pAbc, int argc, char ** argv ) { Cut_Params_t Params, * pParams = &Params; Cut_Man_t * pCutMan; Cut_Oracle_t * pCutOracle; FILE * pOut, * pErr; Abc_Ntk_t * pNtk; int c; int fOracle; extern Cut_Man_t * Abc_NtkCuts( Abc_Ntk_t * pNtk, Cut_Params_t * pParams ); extern void Abc_NtkCutsOracle( Abc_Ntk_t * pNtk, Cut_Oracle_t * pCutOracle ); pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults fOracle = 0; memset( pParams, 0, sizeof(Cut_Params_t) ); pParams->nVarsMax = 5; // the max cut size ("k" of the k-feasible cuts) pParams->nKeepMax = 1000; // the max number of cuts kept at a node pParams->fTruth = 0; // compute truth tables pParams->fFilter = 1; // filter dominated cuts pParams->fDrop = 0; // drop cuts on the fly pParams->fMulti = 0; // use multi-input AND-gates pParams->fVerbose = 0; // the verbosiness flag Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "KMtfdmvoh" ) ) != EOF ) { switch ( c ) { case 'K': if ( globalUtilOptind >= argc ) { fprintf( pErr, "Command line switch \"-K\" should be followed by an integer.\n" ); goto usage; } pParams->nVarsMax = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( pParams->nVarsMax < 0 ) goto usage; break; case 'M': if ( globalUtilOptind >= argc ) { fprintf( pErr, "Command line switch \"-M\" should be followed by an integer.\n" ); goto usage; } pParams->nKeepMax = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( pParams->nKeepMax < 0 ) goto usage; break; case 't': pParams->fTruth ^= 1; break; case 'f': pParams->fFilter ^= 1; break; case 'd': pParams->fDrop ^= 1; break; case 'm': pParams->fMulti ^= 1; break; case 'v': pParams->fVerbose ^= 1; break; case 'o': fOracle ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( !Abc_NtkIsStrash(pNtk) ) { fprintf( pErr, "Cut computation is available only for AIGs (run \"strash\").\n" ); return 1; } if ( pParams->nVarsMax < CUT_SIZE_MIN || pParams->nVarsMax > CUT_SIZE_MAX ) { fprintf( pErr, "Can only compute the cuts for %d <= K <= %d.\n", CUT_SIZE_MIN, CUT_SIZE_MAX ); return 1; } if ( fOracle ) pParams->fRecord = 1; pCutMan = Abc_NtkCuts( pNtk, pParams ); Cut_ManPrintStats( pCutMan ); if ( fOracle ) pCutOracle = Cut_OracleStart( pCutMan ); Cut_ManStop( pCutMan ); if ( fOracle ) { Abc_NtkCutsOracle( pNtk, pCutOracle ); Cut_OracleStop( pCutOracle ); } return 0; usage: fprintf( pErr, "usage: cut [-K num] [-M num] [-tfdmvh]\n" ); fprintf( pErr, "\t computes k-feasible cuts for the AIG\n" ); fprintf( pErr, "\t-K num : max number of leaves (%d <= num <= %d) [default = %d]\n", CUT_SIZE_MIN, CUT_SIZE_MAX, pParams->nVarsMax ); fprintf( pErr, "\t-M num : max number of cuts stored at a node [default = %d]\n", pParams->nKeepMax ); fprintf( pErr, "\t-t : toggle truth table computation [default = %s]\n", pParams->fTruth? "yes": "no" ); fprintf( pErr, "\t-f : toggle filtering of duplicated/dominated [default = %s]\n", pParams->fFilter? "yes": "no" ); fprintf( pErr, "\t-d : toggle dropping when fanouts are done [default = %s]\n", pParams->fDrop? "yes": "no" ); fprintf( pErr, "\t-m : toggle computing only factor-cuts [default = %s]\n", pParams->fMulti? "yes": "no" ); fprintf( pErr, "\t-v : toggle printing verbose information [default = %s]\n", pParams->fVerbose? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandScut( Abc_Frame_t * pAbc, int argc, char ** argv ) { Cut_Params_t Params, * pParams = &Params; Cut_Man_t * pCutMan; FILE * pOut, * pErr; Abc_Ntk_t * pNtk; int c; extern Cut_Man_t * Abc_NtkSeqCuts( Abc_Ntk_t * pNtk, Cut_Params_t * pParams ); pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults memset( pParams, 0, sizeof(Cut_Params_t) ); pParams->nVarsMax = 5; // the max cut size ("k" of the k-feasible cuts) pParams->nKeepMax = 1000; // the max number of cuts kept at a node pParams->fTruth = 0; // compute truth tables pParams->fFilter = 1; // filter dominated cuts pParams->fSeq = 1; // compute sequential cuts pParams->fVerbose = 0; // the verbosiness flag Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "KMtvh" ) ) != EOF ) { switch ( c ) { case 'K': if ( globalUtilOptind >= argc ) { fprintf( pErr, "Command line switch \"-K\" should be followed by an integer.\n" ); goto usage; } pParams->nVarsMax = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( pParams->nVarsMax < 0 ) goto usage; break; case 'M': if ( globalUtilOptind >= argc ) { fprintf( pErr, "Command line switch \"-M\" should be followed by an integer.\n" ); goto usage; } pParams->nKeepMax = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( pParams->nKeepMax < 0 ) goto usage; break; case 't': pParams->fTruth ^= 1; break; case 'v': pParams->fVerbose ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( !Abc_NtkIsSeq(pNtk) ) { fprintf( pErr, "Sequential cuts can be computed for sequential AIGs (run \"seq\").\n" ); return 1; } if ( pParams->nVarsMax < CUT_SIZE_MIN || pParams->nVarsMax > CUT_SIZE_MAX ) { fprintf( pErr, "Can only compute the cuts for %d <= K <= %d.\n", CUT_SIZE_MIN, CUT_SIZE_MAX ); return 1; } pCutMan = Abc_NtkSeqCuts( pNtk, pParams ); Cut_ManPrintStats( pCutMan ); Cut_ManStop( pCutMan ); return 0; usage: fprintf( pErr, "usage: scut [-K num] [-M num] [-tvh]\n" ); fprintf( pErr, "\t computes k-feasible cuts for the sequential AIG\n" ); fprintf( pErr, "\t-K num : max number of leaves (%d <= num <= %d) [default = %d]\n", CUT_SIZE_MIN, CUT_SIZE_MAX, pParams->nVarsMax ); fprintf( pErr, "\t-M num : max number of cuts stored at a node [default = %d]\n", pParams->nKeepMax ); fprintf( pErr, "\t-t : toggle truth table computation [default = %s]\n", pParams->fTruth? "yes": "no" ); fprintf( pErr, "\t-v : toggle printing verbose information [default = %s]\n", pParams->fVerbose? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandXyz( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk, * pNtkRes; int c; int fVerbose; int fUseInvs; int nFaninMax; extern Abc_Ntk_t * Abc_NtkXyz( Abc_Ntk_t * pNtk, int nFaninMax, bool fUseEsop, bool fUseSop, bool fUseInvs, bool fVerbose ); pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults fVerbose = 0; fUseInvs = 1; nFaninMax = 128; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "Nivh" ) ) != EOF ) { switch ( c ) { case 'N': if ( globalUtilOptind >= argc ) { fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" ); goto usage; } nFaninMax = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( nFaninMax < 0 ) goto usage; break; case 'i': fUseInvs ^= 1; break; case 'v': fVerbose ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( !Abc_NtkIsStrash(pNtk) ) { fprintf( pErr, "Only works for strashed networks.\n" ); return 1; } // run the command // pNtkRes = Abc_NtkXyz( pNtk, nFaninMax, 1, 0, fUseInvs, fVerbose ); pNtkRes = NULL; if ( pNtkRes == NULL ) { fprintf( pErr, "Command has failed.\n" ); return 0; } // replace the current network Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); return 0; usage: fprintf( pErr, "usage: xyz [-N num] [-ivh]\n" ); fprintf( pErr, "\t specilized AND/OR/EXOR decomposition\n" ); fprintf( pErr, "\t-N num : maximum number of inputs [default = %d]\n", nFaninMax ); fprintf( pErr, "\t-i : toggle the use of interters [default = %s]\n", fUseInvs? "yes": "no" ); fprintf( pErr, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandEspresso( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk; int c; int fVerbose; extern void Abc_NtkEspresso( Abc_Ntk_t * pNtk, int fVerbose ); pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults fVerbose = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF ) { switch ( c ) { case 'v': fVerbose ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( !Abc_NtkIsLogic(pNtk) ) { fprintf( pErr, "SOP minimization is possible for logic networks (run \"renode\").\n" ); return 1; } Abc_NtkEspresso( pNtk, fVerbose ); return 0; usage: fprintf( pErr, "usage: espresso [-vh]\n" ); fprintf( pErr, "\t minimizes SOPs of the local functions using Espresso\n" ); fprintf( pErr, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk, * pNtkRes; int c; extern Abc_Ntk_t * Abc_NtkNewAig( Abc_Ntk_t * pNtk ); pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) { switch ( c ) { case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( Abc_NtkIsSeq(pNtk) ) { fprintf( pErr, "Only works for non-sequential networks.\n" ); return 1; } // Abc_NtkTestEsop( pNtk ); // Abc_NtkTestSop( pNtk ); // printf( "This command is currently not used.\n" ); // run the command // pNtkRes = Abc_NtkMiterForCofactors( pNtk, 0, 0, -1 ); pNtkRes = Abc_NtkNewAig( pNtk ); // pNtkRes = NULL; if ( pNtkRes == NULL ) { fprintf( pErr, "Command has failed.\n" ); return 1; } // replace the current network Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); return 0; usage: fprintf( pErr, "usage: test [-h]\n" ); fprintf( pErr, "\t testbench for new procedures\n" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandFraig( Abc_Frame_t * pAbc, int argc, char ** argv ) { char Buffer[100]; Fraig_Params_t Params, * pParams = &Params; FILE * pOut, * pErr; Abc_Ntk_t * pNtk, * pNtkRes; int fAllNodes; int fExdc; int c; pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults fExdc = 0; fAllNodes = 0; memset( pParams, 0, sizeof(Fraig_Params_t) ); pParams->nPatsRand = 2048; // the number of words of random simulation info pParams->nPatsDyna = 2048; // the number of words of dynamic simulation info pParams->nBTLimit = 99; // the max number of backtracks to perform pParams->fFuncRed = 1; // performs only one level hashing pParams->fFeedBack = 1; // enables solver feedback pParams->fDist1Pats = 1; // enables distance-1 patterns pParams->fDoSparse = 0; // performs equiv tests for sparse functions pParams->fChoicing = 0; // enables recording structural choices pParams->fTryProve = 0; // tries to solve the final miter pParams->fVerbose = 0; // the verbosiness flag pParams->fVerboseP = 0; // the verbosiness flag Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "RDBrscpvaeh" ) ) != EOF ) { switch ( c ) { case 'R': if ( globalUtilOptind >= argc ) { fprintf( pErr, "Command line switch \"-R\" should be followed by an integer.\n" ); goto usage; } pParams->nPatsRand = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( pParams->nPatsRand < 0 ) goto usage; break; case 'D': if ( globalUtilOptind >= argc ) { fprintf( pErr, "Command line switch \"-D\" should be followed by an integer.\n" ); goto usage; } pParams->nPatsDyna = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( pParams->nPatsDyna < 0 ) goto usage; break; case 'B': if ( globalUtilOptind >= argc ) { fprintf( pErr, "Command line switch \"-B\" should be followed by an integer.\n" ); goto usage; } pParams->nBTLimit = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( pParams->nBTLimit < 0 ) goto usage; break; case 'r': pParams->fFuncRed ^= 1; break; case 's': pParams->fDoSparse ^= 1; break; case 'c': pParams->fChoicing ^= 1; break; case 'p': pParams->fTryProve ^= 1; break; case 'v': pParams->fVerbose ^= 1; break; case 'a': fAllNodes ^= 1; break; case 'e': fExdc ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( !Abc_NtkIsLogic(pNtk) && !Abc_NtkIsStrash(pNtk) ) { fprintf( pErr, "Can only fraig a logic network or an AIG.\n" ); return 1; } // report the proof pParams->fVerboseP = pParams->fTryProve; // get the new network if ( Abc_NtkIsStrash(pNtk) ) pNtkRes = Abc_NtkFraig( pNtk, &Params, fAllNodes, fExdc ); else { pNtk = Abc_NtkStrash( pNtk, fAllNodes, !fAllNodes ); pNtkRes = Abc_NtkFraig( pNtk, &Params, fAllNodes, fExdc ); Abc_NtkDelete( pNtk ); } if ( pNtkRes == NULL ) { fprintf( pErr, "Fraiging has failed.\n" ); return 1; } if ( pParams->fTryProve ) // report the result Abc_NtkMiterReport( pNtkRes ); // replace the current network Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); return 0; usage: sprintf( Buffer, "%d", pParams->nBTLimit ); fprintf( pErr, "usage: fraig [-R num] [-D num] [-B num] [-rscpvah]\n" ); fprintf( pErr, "\t transforms a logic network into a functionally reduced AIG\n" ); fprintf( pErr, "\t-R num : number of random patterns (127 < num < 32769) [default = %d]\n", pParams->nPatsRand ); fprintf( pErr, "\t-D num : number of systematic patterns (127 < num < 32769) [default = %d]\n", pParams->nPatsDyna ); fprintf( pErr, "\t-B num : number of backtracks for one SAT problem [default = %s]\n", pParams->nBTLimit==-1? "infinity" : Buffer ); fprintf( pErr, "\t-r : toggle functional reduction [default = %s]\n", pParams->fFuncRed? "yes": "no" ); fprintf( pErr, "\t-s : toggle considering sparse functions [default = %s]\n", pParams->fDoSparse? "yes": "no" ); fprintf( pErr, "\t-c : toggle accumulation of choices [default = %s]\n", pParams->fChoicing? "yes": "no" ); fprintf( pErr, "\t-p : toggle proving the final miter [default = %s]\n", pParams->fTryProve? "yes": "no" ); fprintf( pErr, "\t-v : toggle verbose output [default = %s]\n", pParams->fVerbose? "yes": "no" ); fprintf( pErr, "\t-e : toggle functional sweeping using EXDC [default = %s]\n", fExdc? "yes": "no" ); fprintf( pErr, "\t-a : toggle between all nodes and DFS nodes [default = %s]\n", fAllNodes? "all": "dfs" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandFraigTrust( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk, * pNtkRes; int c; int fDuplicate; pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults fDuplicate = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF ) { switch ( c ) { case 'd': fDuplicate ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } // get the new network pNtkRes = Abc_NtkFraigTrust( pNtk ); if ( pNtkRes == NULL ) { fprintf( pErr, "Fraiging in the trust mode has failed.\n" ); return 1; } // replace the current network Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); return 0; usage: fprintf( pErr, "usage: fraig_trust [-h]\n" ); fprintf( pErr, "\t transforms the current network into an AIG assuming it is FRAIG with choices\n" ); // fprintf( pErr, "\t-d : toggle duplication of logic [default = %s]\n", fDuplicate? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandFraigStore( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk; int c; int fDuplicate; pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults fDuplicate = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF ) { switch ( c ) { case 'd': fDuplicate ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } // get the new network if ( !Abc_NtkFraigStore( pNtk ) ) { fprintf( pErr, "Fraig storing has failed.\n" ); return 1; } return 0; usage: fprintf( pErr, "usage: fraig_store [-h]\n" ); fprintf( pErr, "\t saves the current network in the AIG database\n" ); // fprintf( pErr, "\t-d : toggle duplication of logic [default = %s]\n", fDuplicate? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandFraigRestore( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk, * pNtkRes; int c; int fDuplicate; pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults fDuplicate = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF ) { switch ( c ) { case 'd': fDuplicate ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } // get the new network pNtkRes = Abc_NtkFraigRestore(); if ( pNtkRes == NULL ) { fprintf( pErr, "Fraig restoring has failed.\n" ); return 1; } // replace the current network Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); return 0; usage: fprintf( pErr, "usage: fraig_restore [-h]\n" ); fprintf( pErr, "\t makes the current network by fraiging the AIG database\n" ); // fprintf( pErr, "\t-d : toggle duplication of logic [default = %s]\n", fDuplicate? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandFraigClean( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk; int c; int fDuplicate; pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults fDuplicate = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF ) { switch ( c ) { case 'd': fDuplicate ^= 1; break; case 'h': goto usage; default: goto usage; } } Abc_NtkFraigStoreClean(); return 0; usage: fprintf( pErr, "usage: fraig_clean [-h]\n" ); fprintf( pErr, "\t cleans the internal FRAIG storage\n" ); // fprintf( pErr, "\t-d : toggle duplication of logic [default = %s]\n", fDuplicate? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandFraigSweep( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk; int c; int fUseInv; int fExdc; int fVerbose; extern bool Abc_NtkFraigSweep( Abc_Ntk_t * pNtk, int fUseInv, int fExdc, int fVerbose ); pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults fUseInv = 1; fExdc = 0; fVerbose = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "ievh" ) ) != EOF ) { switch ( c ) { case 'i': fUseInv ^= 1; break; case 'e': fExdc ^= 1; break; case 'v': fVerbose ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( Abc_NtkIsStrash(pNtk) ) { fprintf( pErr, "Cannot sweep AIGs (use \"fraig\").\n" ); return 1; } if ( !Abc_NtkIsLogic(pNtk) ) { fprintf( pErr, "Transform the current network into a logic network.\n" ); return 1; } // modify the current network if ( !Abc_NtkFraigSweep( pNtk, fUseInv, fExdc, fVerbose ) ) { fprintf( pErr, "Sweeping has failed.\n" ); return 1; } return 0; usage: fprintf( pErr, "usage: fraig_sweep [-evh]\n" ); fprintf( pErr, "\t performs technology-dependent sweep\n" ); fprintf( pErr, "\t-e : toggle functional sweeping using EXDC [default = %s]\n", fExdc? "yes": "no" ); fprintf( pErr, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandMap( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk, * pNtkRes; char Buffer[100]; double DelayTarget; int fRecovery; int fSweep; int fSwitching; int fVerbose; int c; extern Abc_Ntk_t * Abc_NtkMap( Abc_Ntk_t * pNtk, double DelayTarget, int fRecovery, int fSwitching, int fVerbose ); extern bool Abc_NtkFraigSweep( Abc_Ntk_t * pNtk, int fUseInv, int fExdc, int fVerbose ); pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults DelayTarget =-1; fRecovery = 1; fSweep = 1; fSwitching = 0; fVerbose = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "Daspvh" ) ) != EOF ) { switch ( c ) { case 'D': if ( globalUtilOptind >= argc ) { fprintf( pErr, "Command line switch \"-D\" should be followed by a floating point number.\n" ); goto usage; } DelayTarget = (float)atof(argv[globalUtilOptind]); globalUtilOptind++; if ( DelayTarget <= 0.0 ) goto usage; break; case 'a': fRecovery ^= 1; break; case 's': fSweep ^= 1; break; case 'p': fSwitching ^= 1; break; case 'v': fVerbose ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( Abc_NtkIsSeq(pNtk) ) { fprintf( pErr, "Cannot map a sequential AIG.\n" ); return 1; } if ( !Abc_NtkIsStrash(pNtk) ) { pNtk = Abc_NtkStrash( pNtk, 0, 0 ); if ( pNtk == NULL ) { fprintf( pErr, "Strashing before mapping has failed.\n" ); return 1; } pNtk = Abc_NtkBalance( pNtkRes = pNtk, 0, 0, 1 ); Abc_NtkDelete( pNtkRes ); if ( pNtk == NULL ) { fprintf( pErr, "Balancing before mapping has failed.\n" ); return 1; } fprintf( pOut, "The network was strashed and balanced before mapping.\n" ); // get the new network pNtkRes = Abc_NtkMap( pNtk, DelayTarget, fRecovery, fSwitching, fVerbose ); if ( pNtkRes == NULL ) { Abc_NtkDelete( pNtk ); fprintf( pErr, "Mapping has failed.\n" ); return 1; } Abc_NtkDelete( pNtk ); } else { // get the new network pNtkRes = Abc_NtkMap( pNtk, DelayTarget, fRecovery, fSwitching, fVerbose ); if ( pNtkRes == NULL ) { fprintf( pErr, "Mapping has failed.\n" ); return 1; } } if ( fSweep ) Abc_NtkFraigSweep( pNtkRes, 0, 0, 0 ); // replace the current network Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); return 0; usage: if ( DelayTarget == -1 ) sprintf( Buffer, "not used" ); else sprintf( Buffer, "%.3f", DelayTarget ); fprintf( pErr, "usage: map [-D float] [-aspvh]\n" ); fprintf( pErr, "\t performs standard cell mapping of the current network\n" ); fprintf( pErr, "\t-D float : sets the global required times [default = %s]\n", Buffer ); fprintf( pErr, "\t-a : toggles area recovery [default = %s]\n", fRecovery? "yes": "no" ); fprintf( pErr, "\t-s : toggles sweep after mapping [default = %s]\n", fSweep? "yes": "no" ); fprintf( pErr, "\t-p : optimizes power by minimizing switching [default = %s]\n", fSwitching? "yes": "no" ); fprintf( pErr, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandUnmap( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk; int c; extern int Abc_NtkUnmap( Abc_Ntk_t * pNtk ); pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) { switch ( c ) { case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( !Abc_NtkHasMapping(pNtk) ) { fprintf( pErr, "Cannot unmap the network that is not mapped.\n" ); return 1; } // get the new network if ( !Abc_NtkUnmap( pNtk ) ) { fprintf( pErr, "Unmapping has failed.\n" ); return 1; } return 0; usage: fprintf( pErr, "usage: unmap [-h]\n" ); fprintf( pErr, "\t replaces the library gates by the logic nodes represented using SOPs\n" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandAttach( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk; int c; extern int Abc_NtkUnmap( Abc_Ntk_t * pNtk ); pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) { switch ( c ) { case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( !Abc_NtkIsSopLogic(pNtk) ) { fprintf( pErr, "Can only attach gates if the nodes have SOP representations.\n" ); return 1; } // get the new network if ( !Abc_NtkAttach( pNtk ) ) { fprintf( pErr, "Attaching gates has failed.\n" ); return 1; } return 0; usage: fprintf( pErr, "usage: attach [-h]\n" ); fprintf( pErr, "\t replaces the SOP functions by the gates from the library\n" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandSuperChoice( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk, * pNtkRes; int c; extern Abc_Ntk_t * Abc_NtkSuperChoice( Abc_Ntk_t * pNtk ); pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) { switch ( c ) { case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( !Abc_NtkIsStrash(pNtk) ) { fprintf( pErr, "Superchoicing works only for the AIG representation (run \"strash\").\n" ); return 1; } // get the new network pNtkRes = Abc_NtkSuperChoice( pNtk ); if ( pNtkRes == NULL ) { fprintf( pErr, "Superchoicing has failed.\n" ); return 1; } // replace the current network Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); return 0; usage: fprintf( pErr, "usage: sc [-h]\n" ); fprintf( pErr, "\t performs superchoicing\n" ); fprintf( pErr, "\t (accumulate: \"r file.blif; rsup; b; sc; f -ac; wb file_sc.blif\")\n" ); fprintf( pErr, "\t (map without supergate library: \"r file_sc.blif; ft; map\")\n" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandFpga( Abc_Frame_t * pAbc, int argc, char ** argv ) { char Buffer[100]; FILE * pOut, * pErr; Abc_Ntk_t * pNtk, * pNtkRes; int c; int fRecovery; int fSwitching; int fVerbose; float DelayTarget; extern Abc_Ntk_t * Abc_NtkFpga( Abc_Ntk_t * pNtk, float DelayTarget, int fRecovery, int fSwitching, int fVerbose ); pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults fRecovery = 1; fSwitching = 0; fVerbose = 0; DelayTarget =-1; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "apvhD" ) ) != EOF ) { switch ( c ) { case 'a': fRecovery ^= 1; break; case 'p': fSwitching ^= 1; break; case 'v': fVerbose ^= 1; break; case 'h': goto usage; case 'D': if ( globalUtilOptind >= argc ) { fprintf( pErr, "Command line switch \"-D\" should be followed by a floating point number.\n" ); goto usage; } DelayTarget = (float)atof(argv[globalUtilOptind]); globalUtilOptind++; if ( DelayTarget <= 0.0 ) goto usage; break; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( Abc_NtkIsSeq(pNtk) ) { fprintf( pErr, "Cannot FPGA map a sequential AIG.\n" ); return 1; } if ( !Abc_NtkIsStrash(pNtk) ) { // strash and balance the network pNtk = Abc_NtkStrash( pNtk, 0, 0 ); if ( pNtk == NULL ) { fprintf( pErr, "Strashing before FPGA mapping has failed.\n" ); return 1; } pNtk = Abc_NtkBalance( pNtkRes = pNtk, 0, 0, 1 ); Abc_NtkDelete( pNtkRes ); if ( pNtk == NULL ) { fprintf( pErr, "Balancing before FPGA mapping has failed.\n" ); return 1; } fprintf( pOut, "The network was strashed and balanced before FPGA mapping.\n" ); // get the new network pNtkRes = Abc_NtkFpga( pNtk, DelayTarget, fRecovery, fSwitching, fVerbose ); if ( pNtkRes == NULL ) { Abc_NtkDelete( pNtk ); fprintf( pErr, "FPGA mapping has failed.\n" ); return 1; } Abc_NtkDelete( pNtk ); } else { // get the new network pNtkRes = Abc_NtkFpga( pNtk, DelayTarget, fRecovery, fSwitching, fVerbose ); if ( pNtkRes == NULL ) { fprintf( pErr, "FPGA mapping has failed.\n" ); return 1; } } // replace the current network Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); return 0; usage: if ( DelayTarget == -1 ) sprintf( Buffer, "not used" ); else sprintf( Buffer, "%.2f", DelayTarget ); fprintf( pErr, "usage: fpga [-D float] [-apvh]\n" ); fprintf( pErr, "\t performs FPGA mapping of the current network\n" ); fprintf( pErr, "\t-a : toggles area recovery [default = %s]\n", fRecovery? "yes": "no" ); fprintf( pErr, "\t-p : optimizes power by minimizing switching activity [default = %s]\n", fSwitching? "yes": "no" ); fprintf( pErr, "\t-D : sets the required time for the mapping [default = %s]\n", Buffer ); fprintf( pErr, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" ); fprintf( pErr, "\t-h : prints the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandPga( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk, * pNtkRes; Pga_Params_t Params, * pParams = &Params; int c; extern Abc_Ntk_t * Abc_NtkPga( Pga_Params_t * pParams ); pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults memset( pParams, 0, sizeof(Pga_Params_t) ); pParams->pNtk = pNtk; pParams->pLutLib = Abc_FrameReadLibLut(); pParams->fAreaFlow = 1; pParams->fArea = 1; pParams->fSwitching = 0; pParams->fDropCuts = 0; pParams->fVerbose = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "fapdvh" ) ) != EOF ) { switch ( c ) { case 'f': pParams->fAreaFlow ^= 1; break; case 'a': pParams->fArea ^= 1; break; case 'p': pParams->fSwitching ^= 1; break; case 'd': pParams->fDropCuts ^= 1; break; case 'v': pParams->fVerbose ^= 1; break; case 'h': default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } printf( "This command is not yet implemented.\n" ); return 0; if ( !Abc_NtkIsStrash(pNtk) ) { // strash and balance the network pNtk = Abc_NtkStrash( pNtk, 0, 0 ); if ( pNtk == NULL ) { fprintf( pErr, "Strashing before FPGA mapping has failed.\n" ); return 1; } pNtk = Abc_NtkBalance( pNtkRes = pNtk, 0, 0, 1 ); Abc_NtkDelete( pNtkRes ); if ( pNtk == NULL ) { fprintf( pErr, "Balancing before FPGA mapping has failed.\n" ); return 1; } fprintf( pOut, "The network was strashed and balanced before FPGA mapping.\n" ); // get the new network pNtkRes = Abc_NtkPga( pParams ); if ( pNtkRes == NULL ) { Abc_NtkDelete( pNtk ); fprintf( pErr, "FPGA mapping has failed.\n" ); return 1; } Abc_NtkDelete( pNtk ); } else { // get the new network pNtkRes = Abc_NtkPga( pParams ); if ( pNtkRes == NULL ) { fprintf( pErr, "FPGA mapping has failed.\n" ); return 1; } } // replace the current network Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); return 0; usage: fprintf( pErr, "usage: pga [-fapdvh]\n" ); fprintf( pErr, "\t performs FPGA mapping of the current network\n" ); fprintf( pErr, "\t-f : toggles area flow recovery [default = %s]\n", pParams->fAreaFlow? "yes": "no" ); fprintf( pErr, "\t-a : toggles area recovery [default = %s]\n", pParams->fArea? "yes": "no" ); fprintf( pErr, "\t-p : optimizes power by minimizing switching activity [default = %s]\n", pParams->fSwitching? "yes": "no" ); fprintf( pErr, "\t-d : toggles dropping cuts to save memory [default = %s]\n", pParams->fDropCuts? "yes": "no" ); fprintf( pErr, "\t-v : toggles verbose output [default = %s]\n", pParams->fVerbose? "yes": "no" ); fprintf( pErr, "\t-h : prints the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandInit( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk; Abc_Obj_t * pObj; int c, i; int fZeros; int fOnes; int fRandom; int fDontCare; pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults fZeros = 0; fOnes = 0; fRandom = 0; fDontCare = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "zordh" ) ) != EOF ) { switch ( c ) { case 'z': fZeros ^= 1; break; case 'o': fOnes ^= 1; break; case 'r': fRandom ^= 1; break; case 'd': fDontCare ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( Abc_NtkIsSeq(pNtk) ) { fprintf( pErr, "Does not work for a sequentail AIG (run \"unseq\").\n" ); return 1; } if ( Abc_NtkIsComb(pNtk) ) { fprintf( pErr, "The current network is combinational.\n" ); return 0; } if ( fZeros ) { Abc_NtkForEachLatch( pNtk, pObj, i ) Abc_LatchSetInit0( pObj ); } else if ( fOnes ) { Abc_NtkForEachLatch( pNtk, pObj, i ) Abc_LatchSetInit1( pObj ); } else if ( fRandom ) { Abc_NtkForEachLatch( pNtk, pObj, i ) if ( rand() & 1 ) Abc_LatchSetInit1( pObj ); else Abc_LatchSetInit0( pObj ); } else if ( fDontCare ) { Abc_NtkForEachLatch( pNtk, pObj, i ) Abc_LatchSetInitDc( pObj ); } else printf( "The initial states remain unchanged.\n" ); return 0; usage: fprintf( pErr, "usage: init [-zordh]\n" ); fprintf( pErr, "\t resets initial states of all latches\n" ); fprintf( pErr, "\t-z : set zeros initial states [default = %s]\n", fZeros? "yes": "no" ); fprintf( pErr, "\t-o : set ones initial states [default = %s]\n", fOnes? "yes": "no" ); fprintf( pErr, "\t-d : set don't-care initial states [default = %s]\n", fDontCare? "yes": "no" ); fprintf( pErr, "\t-r : set random initial states [default = %s]\n", fRandom? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandPipe( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk; int c; int nLatches; extern void Abc_NtkLatchPipe( Abc_Ntk_t * pNtk, int nLatches ); pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults nLatches = 5; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "Lh" ) ) != EOF ) { switch ( c ) { case 'L': if ( globalUtilOptind >= argc ) { fprintf( pErr, "Command line switch \"-L\" should be followed by a positive integer.\n" ); goto usage; } nLatches = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( nLatches < 0 ) goto usage; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( Abc_NtkIsSeq(pNtk) ) { fprintf( pErr, "Does not work for a sequentail AIG (run \"unseq\").\n" ); return 1; } if ( Abc_NtkIsComb(pNtk) ) { fprintf( pErr, "The current network is combinational.\n" ); return 1; } // update the network Abc_NtkLatchPipe( pNtk, nLatches ); return 0; usage: fprintf( pErr, "usage: pipe [-L num] [-h]\n" ); fprintf( pErr, "\t inserts the given number of latches at each PI for pipelining\n" ); fprintf( pErr, "\t-L num : the number of latches to insert [default = %d]\n", nLatches ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandSeq( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk, * pNtkRes; int c; pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) { switch ( c ) { case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( Abc_NtkIsSeq(pNtk) ) { fprintf( pErr, "The current network is already a sequential AIG.\n" ); return 1; } if ( Abc_NtkLatchNum(pNtk) == 0 ) { fprintf( pErr, "The network has no latches.\n" ); return 0; } if ( !Abc_NtkIsStrash(pNtk) ) { fprintf( pErr, "Conversion to sequential AIG works only for combinational AIGs (run \"strash\").\n" ); return 1; } // get the new network pNtkRes = Abc_NtkAigToSeq( pNtk ); if ( pNtkRes == NULL ) { fprintf( pErr, "Converting to sequential AIG has failed.\n" ); return 1; } // replace the current network Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); return 0; usage: fprintf( pErr, "usage: seq [-h]\n" ); fprintf( pErr, "\t converts AIG into sequential AIG\n" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandUnseq( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk, * pNtkRes; int c; int fShare; pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults fShare = 1; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "sh" ) ) != EOF ) { switch ( c ) { case 's': fShare ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( !Abc_NtkIsSeq(pNtk) ) { fprintf( pErr, "Conversion to combinational AIG works only for sequential AIG (run \"seq\").\n" ); return 1; } // share the latches on the fanout edges // if ( fShare ) // Seq_NtkShareFanouts(pNtk); // get the new network pNtkRes = Abc_NtkSeqToLogicSop( pNtk ); if ( pNtkRes == NULL ) { fprintf( pErr, "Converting sequential AIG into an SOP logic network has failed.\n" ); return 1; } // replace the current network Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); return 0; usage: fprintf( pErr, "usage: unseq [-sh]\n" ); fprintf( pErr, "\t converts sequential AIG into an SOP logic network\n" ); fprintf( pErr, "\t-s : toggle sharing latches [default = %s]\n", fShare? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandRetime( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk, * pNtkRes, * pNtkTemp; int c, nMaxIters; int fForward; int fBackward; int fInitial; int fVerbose; pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults fForward = 0; fBackward = 0; fInitial = 1; fVerbose = 0; nMaxIters = 15; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "Ifbivh" ) ) != EOF ) { switch ( c ) { case 'I': if ( globalUtilOptind >= argc ) { fprintf( pErr, "Command line switch \"-I\" should be followed by a positive integer.\n" ); goto usage; } nMaxIters = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( nMaxIters < 0 ) goto usage; break; case 'f': fForward ^= 1; break; case 'b': fBackward ^= 1; break; case 'i': fInitial ^= 1; break; case 'v': fVerbose ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( !Abc_NtkIsSeq(pNtk) && Abc_NtkLatchNum(pNtk) == 0 ) { fprintf( pErr, "The network has no latches. Retiming is not performed.\n" ); return 0; } if ( Abc_NtkHasAig(pNtk) ) { // quit if there are choice nodes if ( Abc_NtkGetChoiceNum(pNtk) ) { fprintf( pErr, "Currently cannot retime networks with choice nodes.\n" ); return 0; } if ( Abc_NtkIsStrash(pNtk) ) pNtkRes = Abc_NtkAigToSeq(pNtk); else pNtkRes = Abc_NtkDup(pNtk); // retime the network if ( fForward ) Seq_NtkSeqRetimeForward( pNtkRes, fInitial, fVerbose ); else if ( fBackward ) Seq_NtkSeqRetimeBackward( pNtkRes, fInitial, fVerbose ); else Seq_NtkSeqRetimeDelay( pNtkRes, nMaxIters, fInitial, fVerbose ); // if the network is an AIG, convert the result into an AIG if ( Abc_NtkIsStrash(pNtk) ) { pNtkRes = Abc_NtkSeqToLogicSop( pNtkTemp = pNtkRes ); Abc_NtkDelete( pNtkTemp ); pNtkRes = Abc_NtkStrash( pNtkTemp = pNtkRes, 0, 0 ); Abc_NtkDelete( pNtkTemp ); } } else pNtkRes = Seq_NtkRetime( pNtk, nMaxIters, fInitial, fVerbose ); // replace the network if ( pNtkRes == NULL ) { fprintf( pErr, "Retiming has failed.\n" ); return 0; } // replace the current network Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); return 0; usage: fprintf( pErr, "usage: retime [-I num] [-fbih]\n" ); fprintf( pErr, "\t retimes the current network using Pan's delay-optimal retiming\n" ); fprintf( pErr, "\t-I num : max number of iterations of l-value computation [default = %d]\n", nMaxIters ); fprintf( pErr, "\t-f : toggle forward retiming (for AIGs) [default = %s]\n", fForward? "yes": "no" ); fprintf( pErr, "\t-b : toggle backward retiming (for AIGs) [default = %s]\n", fBackward? "yes": "no" ); fprintf( pErr, "\t-i : toggle computation of initial state [default = %s]\n", fInitial? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandSeqFpga( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk, * pNtkNew, * pNtkRes; int c, nMaxIters; int fVerbose; pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults nMaxIters = 15; fVerbose = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "Ivh" ) ) != EOF ) { switch ( c ) { case 'I': if ( globalUtilOptind >= argc ) { fprintf( pErr, "Command line switch \"-I\" should be followed by a positive integer.\n" ); goto usage; } nMaxIters = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( nMaxIters < 0 ) goto usage; break; case 'v': fVerbose ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( Abc_NtkHasAig(pNtk) ) { /* // quit if there are choice nodes if ( Abc_NtkGetChoiceNum(pNtk) ) { fprintf( pErr, "Currently cannot map/retime networks with choice nodes.\n" ); return 0; } */ if ( Abc_NtkIsStrash(pNtk) ) pNtkNew = Abc_NtkAigToSeq(pNtk); else pNtkNew = Abc_NtkDup(pNtk); } else { // strash and balance the network pNtkNew = Abc_NtkStrash( pNtk, 0, 0 ); if ( pNtkNew == NULL ) { fprintf( pErr, "Strashing before FPGA mapping/retiming has failed.\n" ); return 1; } pNtkNew = Abc_NtkBalance( pNtkRes = pNtkNew, 0, 0, 1 ); Abc_NtkDelete( pNtkRes ); if ( pNtkNew == NULL ) { fprintf( pErr, "Balancing before FPGA mapping has failed.\n" ); return 1; } // convert into a sequential AIG pNtkNew = Abc_NtkAigToSeq( pNtkRes = pNtkNew ); Abc_NtkDelete( pNtkRes ); if ( pNtkNew == NULL ) { fprintf( pErr, "Converting into a seq AIG before FPGA mapping/retiming has failed.\n" ); return 1; } fprintf( pOut, "The network was strashed and balanced before FPGA mapping/retiming.\n" ); } // get the new network pNtkRes = Seq_NtkFpgaMapRetime( pNtkNew, nMaxIters, fVerbose ); if ( pNtkRes == NULL ) { // fprintf( pErr, "Sequential FPGA mapping has failed.\n" ); Abc_NtkDelete( pNtkNew ); return 0; } Abc_NtkDelete( pNtkNew ); // replace the current network Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); return 0; usage: fprintf( pErr, "usage: sfpga [-I num] [-vh]\n" ); fprintf( pErr, "\t performs integrated sequential FPGA mapping/retiming\n" ); fprintf( pErr, "\t-I num : max number of iterations of l-value computation [default = %d]\n", nMaxIters ); fprintf( pErr, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandSeqMap( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk, * pNtkNew, * pNtkRes; int c, nMaxIters; int fVerbose; pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults nMaxIters = 15; fVerbose = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "Ivh" ) ) != EOF ) { switch ( c ) { case 'I': if ( globalUtilOptind >= argc ) { fprintf( pErr, "Command line switch \"-I\" should be followed by a positive integer.\n" ); goto usage; } nMaxIters = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( nMaxIters < 0 ) goto usage; break; case 'v': fVerbose ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( Abc_NtkHasAig(pNtk) ) { /* // quit if there are choice nodes if ( Abc_NtkGetChoiceNum(pNtk) ) { fprintf( pErr, "Currently cannot map/retime networks with choice nodes.\n" ); return 0; } */ if ( Abc_NtkIsStrash(pNtk) ) pNtkNew = Abc_NtkAigToSeq(pNtk); else pNtkNew = Abc_NtkDup(pNtk); } else { // strash and balance the network pNtkNew = Abc_NtkStrash( pNtk, 0, 0 ); if ( pNtkNew == NULL ) { fprintf( pErr, "Strashing before SC mapping/retiming has failed.\n" ); return 1; } pNtkNew = Abc_NtkBalance( pNtkRes = pNtkNew, 0, 0, 1 ); Abc_NtkDelete( pNtkRes ); if ( pNtkNew == NULL ) { fprintf( pErr, "Balancing before SC mapping/retiming has failed.\n" ); return 1; } // convert into a sequential AIG pNtkNew = Abc_NtkAigToSeq( pNtkRes = pNtkNew ); Abc_NtkDelete( pNtkRes ); if ( pNtkNew == NULL ) { fprintf( pErr, "Converting into a seq AIG before SC mapping/retiming has failed.\n" ); return 1; } fprintf( pOut, "The network was strashed and balanced before SC mapping/retiming.\n" ); } // get the new network pNtkRes = Seq_MapRetime( pNtkNew, nMaxIters, fVerbose ); if ( pNtkRes == NULL ) { // fprintf( pErr, "Sequential FPGA mapping has failed.\n" ); Abc_NtkDelete( pNtkNew ); return 0; } Abc_NtkDelete( pNtkNew ); // replace the current network Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); return 0; usage: fprintf( pErr, "usage: smap [-I num] [-vh]\n" ); fprintf( pErr, "\t performs integrated sequential standard-cell mapping/retiming\n" ); fprintf( pErr, "\t-I num : max number of iterations of l-value computation [default = %d]\n", nMaxIters ); fprintf( pErr, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandSeqSweep( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk, * pNtkRes; int c; int nFrames; int fExdc; int fImp; int fVerbose; extern Abc_Ntk_t * Abc_NtkVanEijk( Abc_Ntk_t * pNtk, int nFrames, int fExdc, int fVerbose ); extern Abc_Ntk_t * Abc_NtkVanImp( Abc_Ntk_t * pNtk, int nFrames, int fExdc, int fVerbose ); pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults nFrames = 1; fExdc = 1; fImp = 0; fVerbose = 1; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "Feivh" ) ) != EOF ) { switch ( c ) { case 'F': if ( globalUtilOptind >= argc ) { fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" ); goto usage; } nFrames = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( nFrames <= 0 ) goto usage; break; case 'e': fExdc ^= 1; break; case 'i': fImp ^= 1; break; case 'v': fVerbose ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( Abc_NtkIsSeq(pNtk) ) { fprintf( pErr, "Sequential sweep works only for combinational networks (run \"unseq\").\n" ); return 1; } if ( Abc_NtkIsComb(pNtk) ) { fprintf( pErr, "The network is combinational (run \"fraig\" or \"fraig_sweep\").\n" ); return 1; } if ( !Abc_NtkIsStrash(pNtk) ) { fprintf( pErr, "Sequential sweep works only for structurally hashed networks (run \"strash\").\n" ); return 1; } // get the new network if ( fImp ) pNtkRes = Abc_NtkVanImp( pNtk, nFrames, fExdc, fVerbose ); else pNtkRes = Abc_NtkVanEijk( pNtk, nFrames, fExdc, fVerbose ); if ( pNtkRes == NULL ) { fprintf( pErr, "Sequential FPGA mapping has failed.\n" ); return 1; } // replace the current network Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); return 0; usage: fprintf( pErr, "usage: ssweep [-F num] [-eivh]\n" ); fprintf( pErr, "\t performs sequential sweep using van Eijk's method\n" ); fprintf( pErr, "\t-F num : number of time frames in the base case [default = %d]\n", nFrames ); fprintf( pErr, "\t-e : toggle writing EXDC network [default = %s]\n", fExdc? "yes": "no" ); fprintf( pErr, "\t-i : toggle computing implications [default = %s]\n", fImp? "yes": "no" ); fprintf( pErr, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandSeqCleanup( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk; int c; pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) { switch ( c ) { case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( !Abc_NtkIsSeq(pNtk) ) { fprintf( pErr, "Only works for sequential AIGs.\n" ); return 1; } // modify the current network Seq_NtkCleanup( pNtk, 1 ); return 0; usage: fprintf( pErr, "usage: scleanup [-h]\n" ); fprintf( pErr, "\t performs sequential cleanup\n" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandCec( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk, * pNtk1, * pNtk2; int fDelete1, fDelete2; char ** pArgvNew; int nArgcNew; int c; int fSat; int fVerbose; int nSeconds; int nConfLimit; int nImpLimit; extern void Abc_NtkCecSat( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nConfLimit, int nImpLimit ); extern void Abc_NtkCecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nSeconds, int fVerbose ); pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults fSat = 0; fVerbose = 0; nSeconds = 20; nConfLimit = 10000; nImpLimit = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "TCIsvh" ) ) != EOF ) { switch ( c ) { case 'T': if ( globalUtilOptind >= argc ) { fprintf( pErr, "Command line switch \"-T\" should be followed by an integer.\n" ); goto usage; } nSeconds = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( nSeconds < 0 ) goto usage; break; case 'C': if ( globalUtilOptind >= argc ) { fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" ); goto usage; } nConfLimit = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( nConfLimit < 0 ) goto usage; break; case 'I': if ( globalUtilOptind >= argc ) { fprintf( pErr, "Command line switch \"-I\" should be followed by an integer.\n" ); goto usage; } nImpLimit = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( nImpLimit < 0 ) goto usage; break; case 's': fSat ^= 1; break; case 'v': fVerbose ^= 1; break; default: goto usage; } } pArgvNew = argv + globalUtilOptind; nArgcNew = argc - globalUtilOptind; if ( !Abc_NtkPrepareTwoNtks( pErr, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) ) return 1; // perform equivalence checking if ( fSat ) Abc_NtkCecSat( pNtk1, pNtk2, nConfLimit, nImpLimit ); else Abc_NtkCecFraig( pNtk1, pNtk2, nSeconds, fVerbose ); if ( fDelete1 ) Abc_NtkDelete( pNtk1 ); if ( fDelete2 ) Abc_NtkDelete( pNtk2 ); return 0; usage: fprintf( pErr, "usage: cec [-T num] [-C num] [-I num] [-svh] \n" ); fprintf( pErr, "\t performs combinational equivalence checking\n" ); fprintf( pErr, "\t-T num : approximate runtime limit in seconds [default = %d]\n", nSeconds ); fprintf( pErr, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfLimit ); fprintf( pErr, "\t-I num : limit on the number of implications [default = %d]\n", nImpLimit ); fprintf( pErr, "\t-s : toggle \"SAT only\" and \"FRAIG + SAT\" [default = %s]\n", fSat? "SAT only": "FRAIG + SAT" ); fprintf( pErr, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); fprintf( pErr, "\tfile1 : (optional) the file with the first network\n"); fprintf( pErr, "\tfile2 : (optional) the file with the second network\n"); fprintf( pErr, "\t if no files are given, uses the current network and its spec\n"); fprintf( pErr, "\t if one file is given, uses the current network and the file\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandSec( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk, * pNtk1, * pNtk2; int fDelete1, fDelete2; char ** pArgvNew; int nArgcNew; int c; int fSat; int fVerbose; int nFrames; int nSeconds; int nConfLimit; int nImpLimit; extern void Abc_NtkSecSat( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nConfLimit, int nImpLimit, int nFrames ); extern void Abc_NtkSecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nSeconds, int nFrames, int fVerbose ); pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults fSat = 0; fVerbose = 0; nFrames = 3; nSeconds = 20; nConfLimit = 10000; nImpLimit = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "FTCIsvh" ) ) != EOF ) { switch ( c ) { case 'F': if ( globalUtilOptind >= argc ) { fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" ); goto usage; } nFrames = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( nFrames <= 0 ) goto usage; break; case 'T': if ( globalUtilOptind >= argc ) { fprintf( pErr, "Command line switch \"-T\" should be followed by an integer.\n" ); goto usage; } nSeconds = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( nSeconds < 0 ) goto usage; break; case 'C': if ( globalUtilOptind >= argc ) { fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" ); goto usage; } nConfLimit = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( nConfLimit < 0 ) goto usage; break; case 'I': if ( globalUtilOptind >= argc ) { fprintf( pErr, "Command line switch \"-I\" should be followed by an integer.\n" ); goto usage; } nImpLimit = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( nImpLimit < 0 ) goto usage; break; case 'v': fVerbose ^= 1; break; case 's': fSat ^= 1; break; default: goto usage; } } pArgvNew = argv + globalUtilOptind; nArgcNew = argc - globalUtilOptind; if ( !Abc_NtkPrepareTwoNtks( pErr, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) ) return 1; // perform equivalence checking if ( fSat ) Abc_NtkSecSat( pNtk1, pNtk2, nConfLimit, nImpLimit, nFrames ); else Abc_NtkSecFraig( pNtk1, pNtk2, nSeconds, nFrames, fVerbose ); if ( fDelete1 ) Abc_NtkDelete( pNtk1 ); if ( fDelete2 ) Abc_NtkDelete( pNtk2 ); return 0; usage: fprintf( pErr, "usage: sec [-F num] [-T num] [-C num] [-I num] [-svh] \n" ); fprintf( pErr, "\t performs bounded sequential equivalence checking\n" ); fprintf( pErr, "\t-s : toggle \"SAT only\" and \"FRAIG + SAT\" [default = %s]\n", fSat? "SAT only": "FRAIG + SAT" ); fprintf( pErr, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); fprintf( pErr, "\t-F num : the number of time frames to use [default = %d]\n", nFrames ); fprintf( pErr, "\t-T num : approximate runtime limit in seconds [default = %d]\n", nSeconds ); fprintf( pErr, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfLimit ); fprintf( pErr, "\t-I num : limit on the number of implications [default = %d]\n", nImpLimit ); fprintf( pErr, "\tfile1 : (optional) the file with the first network\n"); fprintf( pErr, "\tfile2 : (optional) the file with the second network\n"); fprintf( pErr, "\t if no files are given, uses the current network and its spec\n"); fprintf( pErr, "\t if one file is given, uses the current network and the file\n"); return 1; } /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_CommandProve( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNtk, * pNtkTemp; int c; int RetValue; int fVerbose; int fRewrite; int fFraig; int nConfLimit; int nImpLimit; int clk; pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set defaults fVerbose = 0; fRewrite = 1; fFraig = 1; nConfLimit = 300000; nImpLimit = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "CIrfvh" ) ) != EOF ) { switch ( c ) { case 'C': if ( globalUtilOptind >= argc ) { fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" ); goto usage; } nConfLimit = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( nConfLimit < 0 ) goto usage; break; case 'I': if ( globalUtilOptind >= argc ) { fprintf( pErr, "Command line switch \"-I\" should be followed by an integer.\n" ); goto usage; } nImpLimit = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( nImpLimit < 0 ) goto usage; break; case 'r': fRewrite ^= 1; break; case 'f': fFraig ^= 1; break; case 'v': fVerbose ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); return 1; } if ( Abc_NtkLatchNum(pNtk) > 0 ) { fprintf( stdout, "Currently can only solve the miter for combinational circuits.\n" ); return 0; } if ( Abc_NtkCoNum(pNtk) != 1 ) { fprintf( stdout, "Currently can only solve the miter with one output.\n" ); return 0; } if ( Abc_NtkIsSeq(pNtk) ) { fprintf( stdout, "This command cannot be applied to the sequential AIG.\n" ); return 0; } clk = clock(); if ( Abc_NtkIsStrash(pNtk) ) pNtkTemp = Abc_NtkDup( pNtk ); else pNtkTemp = Abc_NtkStrash( pNtk, 0, 0 ); RetValue = Abc_NtkMiterProve( &pNtkTemp, nConfLimit, nImpLimit, fRewrite, fFraig, fVerbose ); if ( RetValue == -1 ) printf( "UNDECIDED " ); else if ( RetValue == 0 ) printf( "SATISFIABLE " ); else printf( "UNSATISFIABLE " ); //printf( "\n" ); PRT( "Time", clock() - clk ); // replace the current network Abc_FrameReplaceCurrentNetwork( pAbc, pNtkTemp ); return 0; usage: fprintf( pErr, "usage: prove [-C num] [-I num] [-rfvh]\n" ); fprintf( pErr, "\t solves combinational miter by rewriting, FRAIGing, and SAT\n" ); fprintf( pErr, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfLimit ); fprintf( pErr, "\t-I num : limit on the number of implications [default = %d]\n", nImpLimit ); fprintf( pErr, "\t-r : toggle the use of rewriting [default = %s]\n", fRewrite? "yes": "no" ); fprintf( pErr, "\t-f : toggle the use of FRAIGing [default = %s]\n", fFraig? "yes": "no" ); fprintf( pErr, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } //////////////////////////////////////////////////////////////////////// /// END OF FILE /// ////////////////////////////////////////////////////////////////////////