diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2019-01-15 15:37:39 -0800 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2019-01-15 15:37:39 -0800 |
commit | 1779f545e3637c85b02bf4b66bf839ca27eb5355 (patch) | |
tree | 24458de9d5ff1cadb091f9e4716d5bc111190d59 | |
parent | 32a687baa80e58e3340f0c82be54d2371a2f225e (diff) | |
download | abc-1779f545e3637c85b02bf4b66bf839ca27eb5355.tar.gz abc-1779f545e3637c85b02bf4b66bf839ca27eb5355.tar.bz2 abc-1779f545e3637c85b02bf4b66bf839ca27eb5355.zip |
Procedures to generate constant-argument multipliers.
-rw-r--r-- | abclib.dsp | 4 | ||||
-rw-r--r-- | src/base/abci/abc.c | 193 | ||||
-rw-r--r-- | src/misc/extra/extraUtilCfs.c | 15 | ||||
-rw-r--r-- | src/misc/extra/extraUtilGen.c | 64 | ||||
-rw-r--r-- | src/misc/extra/extraUtilMacc.c | 44 | ||||
-rw-r--r-- | src/misc/extra/module.make | 1 |
6 files changed, 318 insertions, 3 deletions
@@ -3711,6 +3711,10 @@ SOURCE=.\src\misc\extra\extraUtilFile.c # End Source File # Begin Source File +SOURCE=.\src\misc\extra\extraUtilGen.c +# End Source File +# Begin Source File + SOURCE=.\src\misc\extra\extraUtilMacc.c # End Source File # Begin Source File diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 742c0802..84c39e01 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -535,6 +535,9 @@ static int Abc_CommandAbc9Gla2Vta ( Abc_Frame_t * pAbc, int argc, cha static int Abc_CommandAbc9Fla2Gla ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Gla2Fla ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandAbc9Gen ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandAbc9Cfs ( Abc_Frame_t * pAbc, int argc, char ** argv ); + static int Abc_CommandAbc9Test ( Abc_Frame_t * pAbc, int argc, char ** argv ); extern int Abc_CommandAbcLivenessToSafety ( Abc_Frame_t * pAbc, int argc, char ** argv ); @@ -1234,6 +1237,9 @@ void Abc_Init( Abc_Frame_t * pAbc ) Cmd_CommandAdd( pAbc, "Liveness", "kcs", Abc_CommandCS_kLiveness, 0 ); Cmd_CommandAdd( pAbc, "Liveness", "nck", Abc_CommandNChooseK, 0 ); + Cmd_CommandAdd( pAbc, "ABC9", "gen", Abc_CommandAbc9Gen, 0 ); + Cmd_CommandAdd( pAbc, "ABC9", "cfs", Abc_CommandAbc9Cfs, 0 ); + Cmd_CommandAdd( pAbc, "ABC9", "&test", Abc_CommandAbc9Test, 0 ); { // extern Mf_ManTruthCount(); @@ -45431,6 +45437,193 @@ usage: SeeAlso [] ***********************************************************************/ +int Abc_CommandAbc9Gen( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + extern Gia_Man_t * Extra_CommandGen( int Algo, int LutSize, int nLuts, int nLevels, int fVerbose ); + Gia_Man_t * pTemp = NULL; + int Algo = 0; + int LutSize = 6; + int nLuts = 256; + int nLevels = 8; + int c, fVerbose = 0; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "AKNLvh" ) ) != EOF ) + { + switch ( c ) + { + case 'A': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-A\" should be followed by an integer.\n" ); + goto usage; + } + Algo = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( Algo < 0 ) + goto usage; + break; + case 'K': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" ); + goto usage; + } + LutSize = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( LutSize < 0 ) + goto usage; + break; + case 'N': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" ); + goto usage; + } + nLuts = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( nLuts < 0 ) + goto usage; + break; + case 'L': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" ); + goto usage; + } + nLevels = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( nLevels < 0 ) + goto usage; + break; + case 'v': + fVerbose ^= 1; + break; + case 'h': + goto usage; + default: + goto usage; + } + } + pTemp = Extra_CommandGen( Algo, LutSize, nLuts, nLevels, fVerbose ); + Abc_FrameUpdateGia( pAbc, pTemp ); + return 0; + +usage: + Abc_Print( -2, "usage: &gen [-AKNLvh]\n" ); + Abc_Print( -2, "\t generates network\n" ); + Abc_Print( -2, "\t-A num : the generation algorithm [default = %d]\n", Algo ); + Abc_Print( -2, "\t-K num : the number of LUT inputs [default = %d]\n", LutSize ); + Abc_Print( -2, "\t-N num : the number of LUTs on one level [default = %d]\n", nLuts ); + Abc_Print( -2, "\t-L num : the number of LUT levels [default = %d]\n", nLevels ); + 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_CommandAbc9Cfs( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + extern void Extra_CommandCfs( int Limit, int Reps, int UnseenUse, int RareUse, int fVerbose ); + int Limit = 0; + int Reps = 1; + int UnseenUse = 2; + int RareUse = 2; + int c, fVerbose = 0; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "LNURvh" ) ) != EOF ) + { + switch ( c ) + { + case 'L': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" ); + goto usage; + } + Limit = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( Limit < 0 ) + goto usage; + break; + case 'N': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" ); + goto usage; + } + Reps = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( Reps < 0 ) + goto usage; + break; + case 'U': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-U\" should be followed by an integer.\n" ); + goto usage; + } + UnseenUse = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( UnseenUse < 0 ) + goto usage; + break; + case 'R': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" ); + goto usage; + } + RareUse = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( RareUse < 0 ) + goto usage; + break; + case 'v': + fVerbose ^= 1; + break; + case 'h': + goto usage; + default: + goto usage; + } + } + Extra_CommandCfs( Limit, Reps, UnseenUse, RareUse, fVerbose ); + return 0; + +usage: + Abc_Print( -2, "usage: &cfs [-LNURvh]\n" ); + Abc_Print( -2, "\t performs simulation\n" ); + Abc_Print( -2, "\t-L num : the limit on the number of occurrences [default = %d]\n", Limit ); + Abc_Print( -2, "\t-N num : the number of repetions of each pattern [default = %d]\n", Reps ); + Abc_Print( -2, "\t-U num : what to do with unseen patterns [default = %d]\n", UnseenUse ); + Abc_Print( -2, "\t-R num : what to do with rare patterns [default = %d]\n", RareUse ); + 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_CommandAbc9Test( Abc_Frame_t * pAbc, int argc, char ** argv ) { // Gia_Man_t * pTemp = NULL; diff --git a/src/misc/extra/extraUtilCfs.c b/src/misc/extra/extraUtilCfs.c index 408f9de6..3d3dbd17 100644 --- a/src/misc/extra/extraUtilCfs.c +++ b/src/misc/extra/extraUtilCfs.c @@ -37,6 +37,21 @@ ABC_NAMESPACE_IMPL_START /// FUNCTION DEFINITIONS /// //////////////////////////////////////////////////////////////////////// +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Extra_CommandCfs( int Limit, int Reps, int UnseenUse, int RareUse, int fVerbose ) +{ +} + //////////////////////////////////////////////////////////////////////// /// END OF FILE /// //////////////////////////////////////////////////////////////////////// diff --git a/src/misc/extra/extraUtilGen.c b/src/misc/extra/extraUtilGen.c new file mode 100644 index 00000000..840b9a74 --- /dev/null +++ b/src/misc/extra/extraUtilGen.c @@ -0,0 +1,64 @@ +/**CFile**************************************************************** + + FileName [extraUtilGen.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [extra] + + Synopsis [CF simulation.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - June 20, 2005.] + + Revision [$Id: extraUtilGen.c,v 1.0 2003/02/01 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <assert.h> + +#include "aig/gia/gia.h" +#include "misc/vec/vecMem.h" +#include "misc/extra/extra.h" +#include "misc/util/utilTruth.h" + +ABC_NAMESPACE_IMPL_START + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gia_Man_t * Extra_CommandGen( int Algo, int LutSize, int nLuts, int nLevels, int fVerbose ) +{ + return NULL; +} + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + +ABC_NAMESPACE_IMPL_END + diff --git a/src/misc/extra/extraUtilMacc.c b/src/misc/extra/extraUtilMacc.c index 5a7a8164..67515aa7 100644 --- a/src/misc/extra/extraUtilMacc.c +++ b/src/misc/extra/extraUtilMacc.c @@ -49,6 +49,22 @@ ABC_NAMESPACE_IMPL_START SeeAlso [] ***********************************************************************/ +void Macc_ConstMultSpecOne2( FILE * pFile, int n, int nBits, int nWidth ) +{ + int nTotal = nWidth+nBits; + int Bound = 1 << (nBits-1); + assert( -Bound <= n && n < Bound ); + fprintf( pFile, "// %d-bit multiplier-accumulator with constant %d generated by ABC on %s\n", nTotal, n, Extra_TimeStamp() ); + fprintf( pFile, "module mulacc%03d%s (\n", Abc_AbsInt(n), n < 0 ? "_neg" : "_pos" ); + fprintf( pFile, " input [%d:0] i,\n", nTotal-1 ); + fprintf( pFile, " input [%d:0] s,\n", nTotal-1 ); + fprintf( pFile, " output [%d:0] o\n", nTotal-1 ); + fprintf( pFile, ");\n" ); + fprintf( pFile, " wire [%d:0] c = %d\'h%x;\n", nTotal-1, nTotal, Abc_AbsInt(n) ); + fprintf( pFile, " wire [%d:0] m = i * c;\n", nTotal-1 ); + fprintf( pFile, " assign o = s %c m;\n", n < 0 ? '-' : '+' ); + fprintf( pFile, "endmodule\n\n" ); +} void Macc_ConstMultSpecOne( FILE * pFile, int n, int nBits, int nWidth ) { int nTotal = nWidth+nBits; @@ -76,9 +92,9 @@ void Macc_ConstMultSpecTest() FILE * pFile; for ( i = -Bound; i < Bound; i++ ) { - sprintf( Buffer, "const_mul//spec%03d.v", 0xFF & i ); + sprintf( Buffer, "const_mul//macc_spec_%03d.v", 0xFF & i ); pFile = fopen( Buffer, "wb" ); - Macc_ConstMultSpecOne( pFile, i, nBits, nWidth ); + Macc_ConstMultSpecOne2( pFile, i, nBits, nWidth ); fclose( pFile ); } } @@ -272,6 +288,28 @@ void Macc_ConstMultGenMacc( FILE * pFile, unsigned * p, int n, int nBits, int nW } fprintf( pFile, "endmodule\n\n" ); } +void Macc_ConstMultGenMacc2( FILE * pFile, unsigned * p, int n, int nBits, int nWidth ) +{ + int nTotal = nWidth+nBits; + int Bound = 1 << (nBits-1); + char Sign = n < 0 ? 'N' : 'n'; + assert( -Bound <= n && n < Bound ); + fprintf( pFile, "// %d-bit multiplier-accumulator by constant %d generated by ABC on %s\n", nTotal, n, Extra_TimeStamp() ); + fprintf( pFile, "module macc%03d%s (\n", Abc_AbsInt(n), n < 0 ? "_neg" : "_pos" ); + fprintf( pFile, " input [%d:0] i,\n", nTotal-1 ); + fprintf( pFile, " input [%d:0] s,\n", nTotal-1 ); + fprintf( pFile, " output [%d:0] o\n", nTotal-1 ); + fprintf( pFile, ");\n" ); + if ( n == 0 ) + fprintf( pFile, " assign o = s;\n" ); + else + { + fprintf( pFile, " wire [%d:0] n1 = i;\n", nTotal-1 ); + Macc_ConstMultGenOne_rec( pFile, p, n, nBits, nWidth ); + fprintf( pFile, " assign o = s + %c%d;\n", Sign, Abc_AbsInt(n) ); + } + fprintf( pFile, "endmodule\n\n" ); +} void Macc_ConstMultGenTest() { int nBits = 8; @@ -285,7 +323,7 @@ void Macc_ConstMultGenTest() { sprintf( Buffer, "const_mul//macc%03d.v", 0xFF & i ); pFile = fopen( Buffer, "wb" ); - Macc_ConstMultGenMacc( pFile, p, i, nBits, nWidth ); + Macc_ConstMultGenMacc2( pFile, p, i, nBits, nWidth ); fclose( pFile ); } ABC_FREE( p ); diff --git a/src/misc/extra/module.make b/src/misc/extra/module.make index 4ab13038..05bc5e08 100644 --- a/src/misc/extra/module.make +++ b/src/misc/extra/module.make @@ -5,6 +5,7 @@ SRC += src/misc/extra/extraUtilBitMatrix.c \ src/misc/extra/extraUtilDsd.c \ src/misc/extra/extraUtilEnum.c \ src/misc/extra/extraUtilFile.c \ + src/misc/extra/extraUtilGen.c \ src/misc/extra/extraUtilMacc.c \ src/misc/extra/extraUtilMaj.c \ src/misc/extra/extraUtilMemory.c \ |