summaryrefslogtreecommitdiffstats
path: root/src/misc
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2019-01-15 15:37:39 -0800
committerAlan Mishchenko <alanmi@berkeley.edu>2019-01-15 15:37:39 -0800
commit1779f545e3637c85b02bf4b66bf839ca27eb5355 (patch)
tree24458de9d5ff1cadb091f9e4716d5bc111190d59 /src/misc
parent32a687baa80e58e3340f0c82be54d2371a2f225e (diff)
downloadabc-1779f545e3637c85b02bf4b66bf839ca27eb5355.tar.gz
abc-1779f545e3637c85b02bf4b66bf839ca27eb5355.tar.bz2
abc-1779f545e3637c85b02bf4b66bf839ca27eb5355.zip
Procedures to generate constant-argument multipliers.
Diffstat (limited to 'src/misc')
-rw-r--r--src/misc/extra/extraUtilCfs.c15
-rw-r--r--src/misc/extra/extraUtilGen.c64
-rw-r--r--src/misc/extra/extraUtilMacc.c44
-rw-r--r--src/misc/extra/module.make1
4 files changed, 121 insertions, 3 deletions
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 \