2005-07-29 17:01:00 +02:00
|
|
|
/**CFile****************************************************************
|
|
|
|
|
|
|
|
|
|
FileName [mapperLib.c]
|
|
|
|
|
|
|
|
|
|
PackageName [MVSIS 1.3: Multi-valued logic synthesis system.]
|
|
|
|
|
|
|
|
|
|
Synopsis [Generic technology mapping engine.]
|
|
|
|
|
|
|
|
|
|
Author [MVSIS Group]
|
|
|
|
|
|
|
|
|
|
Affiliation [UC Berkeley]
|
|
|
|
|
|
|
|
|
|
Date [Ver. 2.0. Started - June 1, 2004.]
|
|
|
|
|
|
|
|
|
|
Revision [$Id: mapperLib.c,v 1.6 2005/01/23 06:59:44 alanmi Exp $]
|
|
|
|
|
|
|
|
|
|
***********************************************************************/
|
2008-07-02 17:01:00 +02:00
|
|
|
#define _BSD_SOURCE
|
|
|
|
|
|
|
|
|
|
#ifndef WIN32
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#endif
|
2005-07-29 17:01:00 +02:00
|
|
|
|
|
|
|
|
#include "mapperInt.h"
|
|
|
|
|
|
2010-11-01 09:35:04 +01:00
|
|
|
ABC_NAMESPACE_IMPL_START
|
|
|
|
|
|
|
|
|
|
|
2005-07-29 17:01:00 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
/// DECLARATIONS ///
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
2008-01-31 05:01:00 +01:00
|
|
|
/// FUNCTION DEFINITIONS ///
|
2005-07-29 17:01:00 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
/**Function*************************************************************
|
|
|
|
|
|
|
|
|
|
Synopsis [Reads in the supergate library and prepares it for use.]
|
|
|
|
|
|
|
|
|
|
Description [The supergates library comes in a .super file. This file
|
|
|
|
|
contains descriptions of supergates along with some relevant information.
|
|
|
|
|
This procedure reads the supergate file, canonicizes the supergates,
|
|
|
|
|
and constructs an additional lookup table, which can be used to map
|
|
|
|
|
truth tables of the cuts into the pair (phase, supergate). The phase
|
|
|
|
|
indicates how the current truth table should be phase assigned to
|
|
|
|
|
match the canonical form of the supergate. The resulting phase is the
|
|
|
|
|
bitwise EXOR of the phase needed to canonicize the supergate and the
|
|
|
|
|
phase needed to transform the truth table into its canonical form.]
|
|
|
|
|
|
|
|
|
|
SideEffects []
|
|
|
|
|
|
|
|
|
|
SeeAlso []
|
|
|
|
|
|
|
|
|
|
***********************************************************************/
|
2010-11-01 09:35:04 +01:00
|
|
|
Map_SuperLib_t * Map_SuperLibCreate( char * pFileName, char * pExcludeFile, int fAlgorithm, int fVerbose )
|
2005-07-29 17:01:00 +02:00
|
|
|
{
|
|
|
|
|
Map_SuperLib_t * p;
|
2012-07-08 02:46:54 +02:00
|
|
|
clock_t clk;
|
2005-07-29 17:01:00 +02:00
|
|
|
|
|
|
|
|
// start the supergate library
|
2009-02-15 17:01:00 +01:00
|
|
|
p = ABC_ALLOC( Map_SuperLib_t, 1 );
|
2005-07-29 17:01:00 +02:00
|
|
|
memset( p, 0, sizeof(Map_SuperLib_t) );
|
|
|
|
|
p->pName = pFileName;
|
|
|
|
|
p->fVerbose = fVerbose;
|
|
|
|
|
p->mmSupers = Extra_MmFixedStart( sizeof(Map_Super_t) );
|
|
|
|
|
p->mmEntries = Extra_MmFixedStart( sizeof(Map_HashEntry_t) );
|
|
|
|
|
p->mmForms = Extra_MmFlexStart();
|
|
|
|
|
Map_MappingSetupTruthTables( p->uTruths );
|
|
|
|
|
|
|
|
|
|
// start the hash table
|
|
|
|
|
p->tTableC = Map_SuperTableCreate( p );
|
|
|
|
|
p->tTable = Map_SuperTableCreate( p );
|
|
|
|
|
|
|
|
|
|
// read the supergate library from file
|
|
|
|
|
clk = clock();
|
|
|
|
|
if ( fAlgorithm )
|
|
|
|
|
{
|
|
|
|
|
if ( !Map_LibraryReadTree( p, pFileName, pExcludeFile ) )
|
|
|
|
|
{
|
|
|
|
|
Map_SuperLibFree( p );
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ( pExcludeFile != 0 )
|
|
|
|
|
{
|
2011-03-27 23:17:12 +02:00
|
|
|
Map_SuperLibFree( p );
|
2005-07-29 17:01:00 +02:00
|
|
|
printf ("Error: Exclude file support not present for old format. Stop.\n");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
if ( !Map_LibraryRead( p, pFileName ) )
|
|
|
|
|
{
|
|
|
|
|
Map_SuperLibFree( p );
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
assert( p->nVarsMax > 0 );
|
|
|
|
|
|
|
|
|
|
// report the stats
|
2012-09-25 10:34:26 +02:00
|
|
|
if ( fVerbose )
|
|
|
|
|
{
|
|
|
|
|
printf( "Loaded %d unique %d-input supergates from \"%s\". ",
|
|
|
|
|
p->nSupersReal, p->nVarsMax, pFileName );
|
|
|
|
|
ABC_PRT( "Time", clock() - clk );
|
|
|
|
|
}
|
2005-07-29 17:01:00 +02:00
|
|
|
|
|
|
|
|
// assign the interver parameters
|
|
|
|
|
p->pGateInv = Mio_LibraryReadInv( p->pGenlib );
|
|
|
|
|
p->tDelayInv.Rise = Mio_LibraryReadDelayInvRise( p->pGenlib );
|
|
|
|
|
p->tDelayInv.Fall = Mio_LibraryReadDelayInvFall( p->pGenlib );
|
|
|
|
|
p->tDelayInv.Worst = MAP_MAX( p->tDelayInv.Rise, p->tDelayInv.Fall );
|
|
|
|
|
p->AreaInv = Mio_LibraryReadAreaInv( p->pGenlib );
|
2005-09-04 17:01:00 +02:00
|
|
|
p->AreaBuf = Mio_LibraryReadAreaBuf( p->pGenlib );
|
2005-07-29 17:01:00 +02:00
|
|
|
|
|
|
|
|
// assign the interver supergate
|
|
|
|
|
p->pSuperInv = (Map_Super_t *)Extra_MmFixedEntryFetch( p->mmSupers );
|
|
|
|
|
memset( p->pSuperInv, 0, sizeof(Map_Super_t) );
|
|
|
|
|
p->pSuperInv->Num = -1;
|
|
|
|
|
p->pSuperInv->nGates = 1;
|
|
|
|
|
p->pSuperInv->nFanins = 1;
|
|
|
|
|
p->pSuperInv->nFanLimit = 10;
|
|
|
|
|
p->pSuperInv->pFanins[0] = p->ppSupers[0];
|
|
|
|
|
p->pSuperInv->pRoot = p->pGateInv;
|
|
|
|
|
p->pSuperInv->Area = p->AreaInv;
|
|
|
|
|
p->pSuperInv->tDelayMax = p->tDelayInv;
|
|
|
|
|
p->pSuperInv->tDelaysR[0].Rise = MAP_NO_VAR;
|
|
|
|
|
p->pSuperInv->tDelaysR[0].Fall = p->tDelayInv.Rise;
|
|
|
|
|
p->pSuperInv->tDelaysF[0].Rise = p->tDelayInv.Fall;
|
|
|
|
|
p->pSuperInv->tDelaysF[0].Fall = MAP_NO_VAR;
|
|
|
|
|
return p;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**Function*************************************************************
|
|
|
|
|
|
|
|
|
|
Synopsis [Deallocates the supergate library.]
|
|
|
|
|
|
|
|
|
|
Description []
|
|
|
|
|
|
|
|
|
|
SideEffects []
|
|
|
|
|
|
|
|
|
|
SeeAlso []
|
|
|
|
|
|
|
|
|
|
***********************************************************************/
|
|
|
|
|
void Map_SuperLibFree( Map_SuperLib_t * p )
|
|
|
|
|
{
|
|
|
|
|
if ( p == NULL ) return;
|
|
|
|
|
if ( p->pGenlib )
|
|
|
|
|
{
|
2005-09-05 17:01:00 +02:00
|
|
|
assert( p->pGenlib == Abc_FrameReadLibGen() );
|
2012-09-25 10:34:26 +02:00
|
|
|
// Mio_LibraryDelete( p->pGenlib );
|
|
|
|
|
// Abc_FrameSetLibGen( NULL );
|
|
|
|
|
p->pGenlib = NULL;
|
2005-07-29 17:01:00 +02:00
|
|
|
}
|
|
|
|
|
if ( p->tTableC )
|
|
|
|
|
Map_SuperTableFree( p->tTableC );
|
|
|
|
|
if ( p->tTable )
|
|
|
|
|
Map_SuperTableFree( p->tTable );
|
2008-01-31 05:01:00 +01:00
|
|
|
Extra_MmFixedStop( p->mmSupers );
|
|
|
|
|
Extra_MmFixedStop( p->mmEntries );
|
|
|
|
|
Extra_MmFlexStop( p->mmForms );
|
2009-02-15 17:01:00 +01:00
|
|
|
ABC_FREE( p->ppSupers );
|
|
|
|
|
ABC_FREE( p );
|
2005-07-29 17:01:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**Function*************************************************************
|
|
|
|
|
|
|
|
|
|
Synopsis [Derives the library from the genlib library.]
|
|
|
|
|
|
|
|
|
|
Description []
|
|
|
|
|
|
|
|
|
|
SideEffects []
|
|
|
|
|
|
|
|
|
|
SeeAlso []
|
|
|
|
|
|
|
|
|
|
***********************************************************************/
|
2012-09-25 10:34:26 +02:00
|
|
|
int Map_SuperLibDeriveFromGenlib( Mio_Library_t * pLib, int fVerbose )
|
2005-07-29 17:01:00 +02:00
|
|
|
{
|
2012-09-25 10:34:26 +02:00
|
|
|
extern void Super_Precompute( Mio_Library_t * pLibGen, int nInputs, int nLevels, int nGatesMax, float tDelayMax, float tAreaMax, int TimeLimit, int fSkipInv, int fWriteOldFormat, int fVerbose );
|
2005-07-29 17:01:00 +02:00
|
|
|
Abc_Frame_t * pAbc = Abc_FrameGetGlobalFrame();
|
2012-09-25 10:34:26 +02:00
|
|
|
char * pFileName;
|
2005-07-29 17:01:00 +02:00
|
|
|
if ( pLib == NULL )
|
|
|
|
|
return 0;
|
2012-09-25 10:34:26 +02:00
|
|
|
// compute supergates
|
|
|
|
|
Super_Precompute( pLib, 5, 1, 100000000, 10000000, 10000000, 100, 1, 0, 0 );
|
|
|
|
|
// assuming that it terminated successfully
|
|
|
|
|
pFileName = Extra_FileNameGenericAppend(Mio_LibraryReadName(pLib), ".super");
|
|
|
|
|
if ( Cmd_CommandExecute( pAbc, pFileName ) )
|
2005-07-29 17:01:00 +02:00
|
|
|
{
|
2012-09-25 10:34:26 +02:00
|
|
|
fprintf( stdout, "Cannot execute command \"read_super %s\".\n", pFileName );
|
2005-07-29 17:01:00 +02:00
|
|
|
return 0;
|
|
|
|
|
}
|
2011-05-07 04:27:00 +02:00
|
|
|
return 1;
|
2005-07-29 17:01:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
/// END OF FILE ///
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
2010-11-01 09:35:04 +01:00
|
|
|
ABC_NAMESPACE_IMPL_END
|
|
|
|
|
|