From b79f37ae57c891640240f1b5a39c70d58f75d8ac Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Fri, 22 Apr 2022 15:18:49 -0700 Subject: Experiments with word-level data structures. --- src/base/wln/wlnCom.c | 172 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 171 insertions(+), 1 deletion(-) (limited to 'src/base/wln/wlnCom.c') diff --git a/src/base/wln/wlnCom.c b/src/base/wln/wlnCom.c index a010c7c2..dcf12229 100644 --- a/src/base/wln/wlnCom.c +++ b/src/base/wln/wlnCom.c @@ -28,6 +28,9 @@ ABC_NAMESPACE_IMPL_START //////////////////////////////////////////////////////////////////////// static int Abc_CommandYosys ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandGraft ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandHierarchy ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandCollapse ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandSolve ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandPrint ( Abc_Frame_t * pAbc, int argc, char ** argv ); @@ -53,7 +56,10 @@ static inline void Wln_AbcUpdateRtl( Abc_Frame_t * pAbc, Rtl_Lib_t * pLib void Wln_Init( Abc_Frame_t * pAbc ) { Cmd_CommandAdd( pAbc, "Word level", "%yosys", Abc_CommandYosys, 0 ); - Cmd_CommandAdd( pAbc, "Word level", "%solve", Abc_CommandSolve, 0 ); + Cmd_CommandAdd( pAbc, "Word level", "%graft", Abc_CommandGraft, 0 ); + Cmd_CommandAdd( pAbc, "Word level", "%hierarchy", Abc_CommandHierarchy, 0 ); + Cmd_CommandAdd( pAbc, "Word level", "%collapse", Abc_CommandCollapse, 0 ); + //Cmd_CommandAdd( pAbc, "Word level", "%solve", Abc_CommandSolve, 0 ); Cmd_CommandAdd( pAbc, "Word level", "%print", Abc_CommandPrint, 0 ); } @@ -202,6 +208,170 @@ usage: return 1; } +/**Function******************************************************************** + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +******************************************************************************/ +int Abc_CommandGraft( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + extern void Wln_LibGraftOne( Rtl_Lib_t * p, char * pModule1, char * pModule2, int fVerbose ); + Rtl_Lib_t * pLib = Wln_AbcGetRtl(pAbc); + char ** pArgvNew; int nArgcNew; + int c, 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 ( pLib == NULL ) + { + printf( "The design is not entered.\n" ); + return 1; + } + pArgvNew = argv + globalUtilOptind; + nArgcNew = argc - globalUtilOptind; + if ( nArgcNew != 2 ) + { + Abc_Print( -1, "Abc_CommandGraft(): This command expects one AIG file name on the command line.\n" ); + return 1; + } + Wln_LibGraftOne( pLib, pArgvNew[0], pArgvNew[1], fVerbose ); + return 0; +usage: + Abc_Print( -2, "usage: %%graft [-vh] \n" ); + Abc_Print( -2, "\t replace instances of module1 by those of module2\n" ); + Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); + Abc_Print( -2, "\t-h : print the command usage\n"); + return 1; +} + +/**Function******************************************************************** + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +******************************************************************************/ +int Abc_CommandHierarchy( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + extern void Wln_LibMarkHierarchy( Rtl_Lib_t * p, char ** ppModule, int nModules, int fVerbose ); + Rtl_Lib_t * pLib = Wln_AbcGetRtl(pAbc); + char ** pArgvNew; int nArgcNew; + int c, 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 ( pLib == NULL ) + { + printf( "The design is not entered.\n" ); + return 1; + } + pArgvNew = argv + globalUtilOptind; + nArgcNew = argc - globalUtilOptind; + if ( nArgcNew < 1 ) + { + Abc_Print( -1, "Abc_CommandHierarchy(): This command expects one AIG file name on the command line.\n" ); + return 1; + } + Wln_LibMarkHierarchy( pLib, pArgvNew, nArgcNew, fVerbose ); + return 0; +usage: + Abc_Print( -2, "usage: %%hierarchy [-vh] \n" ); + Abc_Print( -2, "\t marks the module whose instances may later be treated as black boxes\n" ); + Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); + Abc_Print( -2, "\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 ) +{ + extern Gia_Man_t * Rtl_LibCollapse( Rtl_Lib_t * p, char * pTopModule, int fVerbose ); + Gia_Man_t * pNew = NULL; + Rtl_Lib_t * pLib = Wln_AbcGetRtl(pAbc); + char * pTopModule = NULL; + int c, fVerbose = 0; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "Tvh" ) ) != EOF ) + { + switch ( c ) + { + case 'T': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-T\" should be followed by a file name.\n" ); + goto usage; + } + pTopModule = argv[globalUtilOptind]; + globalUtilOptind++; + break; + case 'v': + fVerbose ^= 1; + break; + case 'h': + goto usage; + default: + goto usage; + } + } + if ( pLib == NULL ) + { + printf( "The design is not entered.\n" ); + return 1; + } + pNew = Rtl_LibCollapse( pLib, pTopModule, fVerbose ); + Abc_FrameUpdateGia( pAbc, pNew ); + return 0; +usage: + Abc_Print( -2, "usage: %%collapse [-T ] [-vh] \n" ); + Abc_Print( -2, "\t collapse hierarchical design into an AIG\n" ); + Abc_Print( -2, "\t-T : specify the top module of the design [default = none]\n" ); + Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); + Abc_Print( -2, "\t-h : print the command usage\n"); + return 1; +} + /**Function******************************************************************** Synopsis [] -- cgit v1.2.3