mirror of https://github.com/YosysHQ/abc.git
Procedures to generate constant-argument multipliers.
This commit is contained in:
parent
c2c87aa66c
commit
f3ba29b302
|
|
@ -3691,6 +3691,10 @@ SOURCE=.\src\misc\extra\extraUtilCanon.c
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\misc\extra\extraUtilCfs.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\misc\extra\extraUtilCube.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
@ -3707,6 +3711,10 @@ SOURCE=.\src\misc\extra\extraUtilFile.c
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\misc\extra\extraUtilMacc.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\misc\extra\extraUtilMaj.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
|
|||
|
|
@ -13367,7 +13367,7 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
}
|
||||
// Abc_NtkComputePaths( Abc_FrameReadNtk(pAbc) );
|
||||
//Dau_NetworkEnumTest();
|
||||
//Ext_TruthDiagnoseTest();
|
||||
//Extra_DigitsDumpGiaTest();
|
||||
return 0;
|
||||
usage:
|
||||
Abc_Print( -2, "usage: test [-CKDNM] [-aovwh] <file_name>\n" );
|
||||
|
|
|
|||
|
|
@ -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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#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
|
||||
|
||||
|
|
@ -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 );
|
||||
|
|
|
|||
Loading…
Reference in New Issue