From f3ba29b30266ecd4955881c0c4d3cbefeffa632f Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Wed, 9 Jan 2019 11:42:50 -0800 Subject: Procedures to generate constant-argument multipliers. --- src/misc/extra/extraUtilCfs.c | 46 ++++++++++++++++++++++++++++++++++++++++++ src/misc/extra/extraUtilMacc.c | 41 ++++++++++++++++++------------------- 2 files changed, 66 insertions(+), 21 deletions(-) create mode 100644 src/misc/extra/extraUtilCfs.c (limited to 'src/misc/extra') diff --git a/src/misc/extra/extraUtilCfs.c b/src/misc/extra/extraUtilCfs.c new file mode 100644 index 00000000..408f9de6 --- /dev/null +++ b/src/misc/extra/extraUtilCfs.c @@ -0,0 +1,46 @@ +/**CFile**************************************************************** + + FileName [extraUtilCfs.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: extraUtilCfs.c,v 1.0 2003/02/01 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include +#include +#include +#include + +#include "aig/gia/gia.h" +#include "misc/extra/extra.h" +#include "misc/util/utilTruth.h" + +ABC_NAMESPACE_IMPL_START + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + +ABC_NAMESPACE_IMPL_END + diff --git a/src/misc/extra/extraUtilMacc.c b/src/misc/extra/extraUtilMacc.c index 1d058f3b..5a7a8164 100644 --- a/src/misc/extra/extraUtilMacc.c +++ b/src/misc/extra/extraUtilMacc.c @@ -49,11 +49,10 @@ ABC_NAMESPACE_IMPL_START SeeAlso [] ***********************************************************************/ -void Wlc_ConstMultSpecOne( FILE * pFile, int n, int nBits, int nWidth ) +void Macc_ConstMultSpecOne( FILE * pFile, int n, int nBits, int nWidth ) { int nTotal = nWidth+nBits; int Bound = 1 << (nBits-1); - char Sign = n < 0 ? '_' : ' '; assert( -Bound <= n && n < Bound ); fprintf( pFile, "// %d-bit multiplier by %d-bit constant %d generated by ABC\n", nWidth, nBits, n ); fprintf( pFile, "module mul%03d%s (\n", Abc_AbsInt(n), n < 0 ? "_neg" : "_pos" ); @@ -61,13 +60,13 @@ void Wlc_ConstMultSpecOne( FILE * pFile, int n, int nBits, int nWidth ) fprintf( pFile, " output [%d:0] o\n", nWidth-1 ); fprintf( pFile, ");\n" ); fprintf( pFile, " wire [%d:0] c = %d\'h%x;\n", nBits-1, nBits, Abc_AbsInt(n) ); - fprintf( pFile, " wire [%d:0] I = {{%d{i[%d]}}, i};\n", nTotal-1, nBits, nWidth-1 ); + fprintf( pFile, " wire [%d:0] I = {{%d{i[%d]}}, i};\n", nTotal-1, nBits, nWidth-1 ); fprintf( pFile, " wire [%d:0] m = I * c;\n", nTotal-1 ); fprintf( pFile, " wire [%d:0] t = %cm;\n", nTotal-1, n < 0 ? '-' : ' ' ); fprintf( pFile, " assign o = t[%d:%d];\n", nTotal-1, nBits ); fprintf( pFile, "endmodule\n\n" ); } -void Wlc_ConstMultSpecTest() +void Macc_ConstMultSpecTest() { int nBits = 8; int nWidth = 16; @@ -79,7 +78,7 @@ void Wlc_ConstMultSpecTest() { sprintf( Buffer, "const_mul//spec%03d.v", 0xFF & i ); pFile = fopen( Buffer, "wb" ); - Wlc_ConstMultSpecOne( pFile, i, nBits, nWidth ); + Macc_ConstMultSpecOne( pFile, i, nBits, nWidth ); fclose( pFile ); } } @@ -95,7 +94,7 @@ void Wlc_ConstMultSpecTest() SeeAlso [] ***********************************************************************/ -unsigned * Wlc_ConstMultGenerate( int nBits ) +unsigned * Macc_ConstMultGenerate( int nBits ) { unsigned Mask = Abc_InfoMask( nBits ); Vec_Wec_t * vDivs = Vec_WecStart( 2*nBits ); @@ -186,14 +185,14 @@ unsigned * Wlc_ConstMultGenerate( int nBits ) //ABC_FREE( pPlace ); return pPlace; } -void Wlc_ConstMultGenTest0() +void Macc_ConstMultGenTest0() { int nBits = 8; - unsigned * p = Wlc_ConstMultGenerate( nBits ); + unsigned * p = Macc_ConstMultGenerate( nBits ); ABC_FREE( p ); } -void Wlc_ConstMultGenOne_rec( FILE * pFile, unsigned * p, int n, int nBits, int nWidth ) +void Macc_ConstMultGenOne_rec( FILE * pFile, unsigned * p, int n, int nBits, int nWidth ) { unsigned Mask = Abc_InfoMask( nBits ); unsigned New = Mask & (unsigned)n; @@ -213,23 +212,23 @@ void Wlc_ConstMultGenOne_rec( FILE * pFile, unsigned * p, int n, int nBits, int if ( nn == -1 ) fprintf( pFile, " wire [%d:0] N1 = -n1;\n", nTotal-1 ); if ( Abc_AbsInt(nn) != 1 ) - Wlc_ConstMultGenOne_rec( pFile, p, nn, nBits, nWidth ); + Macc_ConstMultGenOne_rec( pFile, p, nn, nBits, nWidth ); if ( nZeros > 0 ) fprintf( pFile, " wire [%d:0] %c%d = %c%d << %d;\n", nTotal-1, Sign, Abc_AbsInt(n), Sign, Abc_AbsInt(nn), nZeros ); } else if ( One && Two ) // add/sub { - Wlc_ConstMultGenOne_rec( pFile, p, One, nBits, nWidth ); - Wlc_ConstMultGenOne_rec( pFile, p, Two, nBits, nWidth ); + Macc_ConstMultGenOne_rec( pFile, p, One, nBits, nWidth ); + Macc_ConstMultGenOne_rec( pFile, p, Two, nBits, nWidth ); fprintf( pFile, " wire [%d:0] %c%d = n%d %c n%d;\n", nTotal-1, Sign, Abc_AbsInt(n), One, Oper, Two ); } else if ( Two == 0 ) // minus { - Wlc_ConstMultGenOne_rec( pFile, p, One, nBits, nWidth ); + Macc_ConstMultGenOne_rec( pFile, p, One, nBits, nWidth ); fprintf( pFile, " wire [%d:0] N%d = -n%d;\n", nTotal-1, One, One ); } } -void Wlc_ConstMultGenMult( FILE * pFile, unsigned * p, int n, int nBits, int nWidth ) +void Macc_ConstMultGenMult( FILE * pFile, unsigned * p, int n, int nBits, int nWidth ) { int nTotal = nWidth+nBits; int Bound = 1 << (nBits-1); @@ -245,12 +244,12 @@ void Wlc_ConstMultGenMult( FILE * pFile, unsigned * p, int n, int nBits, int nWi else { fprintf( pFile, " wire [%d:0] n1 = {{%d{i[%d]}}, i};\n", nTotal-1, nBits, nWidth-1 ); - Wlc_ConstMultGenOne_rec( pFile, p, n, nBits, nWidth ); + Macc_ConstMultGenOne_rec( pFile, p, n, nBits, nWidth ); fprintf( pFile, " assign o = %c%d[%d:%d];\n", Sign, Abc_AbsInt(n), nTotal-1, nBits ); } fprintf( pFile, "endmodule\n\n" ); } -void Wlc_ConstMultGenMacc( FILE * pFile, unsigned * p, int n, int nBits, int nWidth ) +void Macc_ConstMultGenMacc( FILE * pFile, unsigned * p, int n, int nBits, int nWidth ) { int nTotal = nWidth+nBits; int Bound = 1 << (nBits-1); @@ -263,22 +262,22 @@ void Wlc_ConstMultGenMacc( FILE * pFile, unsigned * p, int n, int nBits, int nWi fprintf( pFile, " output [%d:0] o\n", nWidth-1 ); fprintf( pFile, ");\n" ); if ( n == 0 ) - fprintf( pFile, " assign o = %d\'h0;\n", nWidth ); + fprintf( pFile, " assign o = c;\n" ); else { fprintf( pFile, " wire [%d:0] n1 = {{%d{i[%d]}}, i};\n", nTotal-1, nBits, nWidth-1 ); - Wlc_ConstMultGenOne_rec( pFile, p, n, nBits, nWidth ); + Macc_ConstMultGenOne_rec( pFile, p, n, nBits, nWidth ); fprintf( pFile, " wire [%d:0] s = %c%d[%d:%d];\n", nWidth-1, Sign, Abc_AbsInt(n), nTotal-1, nBits ); fprintf( pFile, " assign o = s + c;\n" ); } fprintf( pFile, "endmodule\n\n" ); } -void Wlc_ConstMultGenTest() +void Macc_ConstMultGenTest() { int nBits = 8; int nWidth = 16; int Bound = 1 << (nBits-1); - unsigned * p = Wlc_ConstMultGenerate( nBits ); + unsigned * p = Macc_ConstMultGenerate( nBits ); int i; char Buffer[100]; FILE * pFile; @@ -286,7 +285,7 @@ void Wlc_ConstMultGenTest() { sprintf( Buffer, "const_mul//macc%03d.v", 0xFF & i ); pFile = fopen( Buffer, "wb" ); - Wlc_ConstMultGenMacc( pFile, p, i, nBits, nWidth ); + Macc_ConstMultGenMacc( pFile, p, i, nBits, nWidth ); fclose( pFile ); } ABC_FREE( p ); -- cgit v1.2.3