diff options
Diffstat (limited to 'src/misc/tim/timDump.c')
-rw-r--r-- | src/misc/tim/timDump.c | 181 |
1 files changed, 181 insertions, 0 deletions
diff --git a/src/misc/tim/timDump.c b/src/misc/tim/timDump.c new file mode 100644 index 00000000..031ef5fc --- /dev/null +++ b/src/misc/tim/timDump.c @@ -0,0 +1,181 @@ +/**CFile**************************************************************** + + FileName [timDump.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [Hierarchy/timing manager.] + + Synopsis [Saving and loading the hierarchy timing manager.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - April 28, 2007.] + + Revision [$Id: timDump.c,v 1.00 2007/04/28 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "timInt.h" + +ABC_NAMESPACE_IMPL_START + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +#define TIM_DUMP_VER_NUM 1 + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [Transform the timing manager into the char stream.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Vec_Str_t * Tim_ManSave( Tim_Man_t * p ) +{ + Tim_Box_t * pBox; + Tim_Obj_t * pObj; + Vec_Str_t * vStr; + float * pDelayTable; + int i, k, TableSize; + // create output stream + vStr = Vec_StrAlloc( 10000 ); + // dump version number + Vec_StrPutI_ne( vStr, TIM_DUMP_VER_NUM ); + // save CI/CO counts + Vec_StrPutI_ne( vStr, Tim_ManCiNum(p) ); + Vec_StrPutI_ne( vStr, Tim_ManCoNum(p) ); + // save PI/PO counts + Vec_StrPutI_ne( vStr, Tim_ManPiNum(p) ); + Vec_StrPutI_ne( vStr, Tim_ManPoNum(p) ); + // save number of boxes + Vec_StrPutI_ne( vStr, Tim_ManBoxNum(p) ); + // for each box, save num_inputs, num_outputs, and delay table ID + Tim_ManForEachBox( p, pBox, i ) + { + Vec_StrPutI_ne( vStr, Tim_ManBoxInputNum(p, pBox->iBox) ); + Vec_StrPutI_ne( vStr, Tim_ManBoxOutputNum(p, pBox->iBox) ); + Vec_StrPutI_ne( vStr, pBox->iDelayTable ); // can be -1 if delay table is not given + } + // save the number of delay tables + Vec_StrPutI_ne( vStr, Tim_ManDelayTableNum(p) ); + // save the delay tables + Vec_PtrForEachEntry( float *, p->vDelayTables, pDelayTable, i ) + { + assert( (int)pDelayTable[0] == i ); + // save table ID and dimensions (inputs x outputs) + Vec_StrPutI_ne( vStr, (int)pDelayTable[0] ); + Vec_StrPutI_ne( vStr, (int)pDelayTable[1] ); + Vec_StrPutI_ne( vStr, (int)pDelayTable[2] ); + // save table contents + TableSize = (int)pDelayTable[1] * (int)pDelayTable[2]; + for ( k = 0; k < TableSize; k++ ) + Vec_StrPutF( vStr, pDelayTable[k+3] ); + } + // save PI arrival times + Tim_ManForEachPi( p, pObj, i ) + Vec_StrPutF( vStr, Tim_ManGetCiArrival(p, pObj->Id) ); + // save PO required times + Tim_ManForEachPo( p, pObj, i ) + Vec_StrPutF( vStr, Tim_ManGetCoRequired(p, pObj->Id) ); + return vStr; +} + +/**Function************************************************************* + + Synopsis [Restores the timing manager from the char stream.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Tim_Man_t * Tim_ManLoad( Vec_Str_t * p ) +{ + Tim_Man_t * pMan; + int VerNum, nCis, nCos, nPis, nPos; + int nBoxes, nBoxIns, nBoxOuts; + int TableId, nTables, TableSize, TableX, TableY; + int i, k, curPi, curPo, iStr = 0; + float * pDelayTable; + // get version number + VerNum = Vec_StrGetI_ne( p, &iStr ); + assert( VerNum == TIM_DUMP_VER_NUM ); + // get the number of CIs/COs + nCis = Vec_StrGetI_ne( p, &iStr ); + nCos = Vec_StrGetI_ne( p, &iStr ); + // get the number of PIs/POs + nPis = Vec_StrGetI_ne( p, &iStr ); + nPos = Vec_StrGetI_ne( p, &iStr ); + // start the timing manager + pMan = Tim_ManStart( nCis, nCos ); + // start boxes + nBoxes = Vec_StrGetI_ne( p, &iStr ); + assert( pMan->vBoxes == NULL ); + pMan->vBoxes = Vec_PtrAlloc( nBoxes ); + // create boxes + curPi = nPis; + curPo = 0; + for ( i = 0; i < nBoxes; i++ ) + { + nBoxIns = Vec_StrGetI_ne( p, &iStr ); + nBoxOuts = Vec_StrGetI_ne( p, &iStr ); + TableId = Vec_StrGetI_ne( p, &iStr ); + Tim_ManCreateBox( pMan, curPo, nBoxIns, curPi, nBoxOuts, TableId ); + curPi += nBoxOuts; + curPo += nBoxIns; + } + curPo += nPos; + assert( curPi == nCis ); + assert( curPo == nCos ); + // create delay tables + nTables = Vec_StrGetI_ne( p, &iStr ); + assert( pMan->vDelayTables == NULL ); + pMan->vDelayTables = Vec_PtrAlloc( nTables ); + // read delay tables + assert( Vec_PtrSize(pMan->vDelayTables) == 0 ); + for ( i = 0; i < nTables; i++ ) + { + // read table ID and dimensions + TableId = Vec_StrGetI_ne( p, &iStr ); + TableX = Vec_StrGetI_ne( p, &iStr ); + TableY = Vec_StrGetI_ne( p, &iStr ); + assert( TableId == i ); + // create new table + TableSize = TableX * TableY; + pDelayTable = ABC_ALLOC( float, TableSize + 3 ); + pDelayTable[0] = TableId; + pDelayTable[1] = TableX; + pDelayTable[2] = TableY; + // read table contents + for ( k = 0; k < TableSize; k++ ) + pDelayTable[k+3] = Vec_StrGetF( p, &iStr ); + assert( Vec_PtrSize(pMan->vDelayTables) == TableId ); + Vec_PtrPush( pMan->vDelayTables, pDelayTable ); + } + assert( Vec_PtrSize(pMan->vDelayTables) == nTables ); +// Tim_ManPrint( pMan ); + return pMan; +} + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + +ABC_NAMESPACE_IMPL_END + |