00001
00021 #include "aig.h"
00022
00026
00027 typedef struct Aig_TBox_t_ Aig_TBox_t;
00028 typedef struct Aig_TObj_t_ Aig_TObj_t;
00029
00030
00031 struct Aig_TMan_t_
00032 {
00033 Vec_Ptr_t * vBoxes;
00034 Aig_MmFlex_t * pMemObj;
00035 int nTravIds;
00036 int nPis;
00037 int nPos;
00038 Aig_TObj_t * pPis;
00039 Aig_TObj_t * pPos;
00040 };
00041
00042
00043 struct Aig_TBox_t_
00044 {
00045 int iBox;
00046 int TravId;
00047 int nInputs;
00048 int nOutputs;
00049 int Inouts[0];
00050 };
00051
00052
00053 struct Aig_TObj_t_
00054 {
00055 int iObj2Box;
00056 float timeOffset;
00057 float timeActual;
00058 };
00059
00063
00075 Aig_TMan_t * Aig_TManStart( int nPis, int nPos )
00076 {
00077 Aig_TMan_t * p;
00078 int i;
00079 p = ALLOC( Aig_TMan_t, 1 );
00080 memset( p, 0, sizeof(Aig_TMan_t) );
00081 p->pMemObj = Aig_MmFlexStart();
00082 p->vBoxes = Vec_PtrAlloc( 100 );
00083 Vec_PtrPush( p->vBoxes, NULL );
00084 p->nPis = nPis;
00085 p->nPos = nPos;
00086 p->pPis = ALLOC( Aig_TObj_t, nPis );
00087 memset( p->pPis, 0, sizeof(Aig_TObj_t) * nPis );
00088 p->pPos = ALLOC( Aig_TObj_t, nPos );
00089 memset( p->pPos, 0, sizeof(Aig_TObj_t) * nPos );
00090 for ( i = 0; i < nPis; i++ )
00091 p->pPis[i].iObj2Box = -1;
00092 for ( i = 0; i < nPos; i++ )
00093 p->pPos[i].iObj2Box = -1;
00094 return p;
00095 }
00096
00108 void Aig_TManStop( Aig_TMan_t * p )
00109 {
00110 Vec_PtrFree( p->vBoxes );
00111 Aig_MmFlexStop( p->pMemObj, 0 );
00112 free( p->pPis );
00113 free( p->pPos );
00114 free( p );
00115 }
00116
00128 void Aig_TManCreateBox( Aig_TMan_t * p, int * pPis, int nPis, int * pPos, int nPos, float * pPiTimes, float * pPoTimes )
00129 {
00130 Aig_TBox_t * pBox;
00131 int i;
00132 pBox = (Aig_TBox_t *)Aig_MmFlexEntryFetch( p->pMemObj, sizeof(Aig_TBox_t) + sizeof(int) * (nPis+nPos) );
00133 memset( pBox, 0, sizeof(Aig_TBox_t) );
00134 pBox->iBox = Vec_PtrSize( p->vBoxes );
00135 Vec_PtrPush( p->vBoxes, pBox );
00136 pBox->nInputs = nPis;
00137 pBox->nOutputs = nPos;
00138 for ( i = 0; i < nPis; i++ )
00139 {
00140 assert( pPis[i] < p->nPis );
00141 pBox->Inouts[i] = pPis[i];
00142 Aig_TManSetPiArrival( p, pPis[i], pPiTimes[i] );
00143 p->pPis[pPis[i]].iObj2Box = pBox->iBox;
00144 }
00145 for ( i = 0; i < nPos; i++ )
00146 {
00147 assert( pPos[i] < p->nPos );
00148 pBox->Inouts[nPis+i] = pPos[i];
00149 Aig_TManSetPoRequired( p, pPos[i], pPoTimes[i] );
00150 p->pPos[pPos[i]].iObj2Box = pBox->iBox;
00151 }
00152 }
00153
00165 void Aig_TManSetPiDelay( Aig_TMan_t * p, int iPi, float Delay )
00166 {
00167 assert( iPi < p->nPis );
00168 p->pPis[iPi].timeActual = Delay;
00169 }
00170
00182 void Aig_TManSetPoDelay( Aig_TMan_t * p, int iPo, float Delay )
00183 {
00184 assert( iPo < p->nPos );
00185 p->pPos[iPo].timeActual = Delay;
00186 }
00187
00199 void Aig_TManSetPiArrival( Aig_TMan_t * p, int iPi, float Delay )
00200 {
00201 assert( iPi < p->nPis );
00202 p->pPis[iPi].timeOffset = Delay;
00203 }
00204
00216 void Aig_TManSetPoRequired( Aig_TMan_t * p, int iPo, float Delay )
00217 {
00218 assert( iPo < p->nPos );
00219 p->pPos[iPo].timeOffset = Delay;
00220 }
00221
00233 void Aig_TManIncrementTravId( Aig_TMan_t * p )
00234 {
00235 p->nTravIds++;
00236 }
00237
00249 float Aig_TManGetPiArrival( Aig_TMan_t * p, int iPi )
00250 {
00251 Aig_TBox_t * pBox;
00252 Aig_TObj_t * pObj;
00253 float DelayMax;
00254 int i;
00255 assert( iPi < p->nPis );
00256 if ( p->pPis[iPi].iObj2Box < 0 )
00257 return p->pPis[iPi].timeOffset;
00258 pBox = Vec_PtrEntry( p->vBoxes, p->pPis[iPi].iObj2Box );
00259
00260 if ( pBox->TravId == p->nTravIds )
00261 return p->pPis[iPi].timeOffset;
00262 pBox->TravId = p->nTravIds;
00263
00264 DelayMax = -1.0e+20F;
00265 for ( i = 0; i < pBox->nOutputs; i++ )
00266 {
00267 pObj = p->pPos + pBox->Inouts[pBox->nInputs+i];
00268 DelayMax = AIG_MAX( DelayMax, pObj->timeActual + pObj->timeOffset );
00269 }
00270 for ( i = 0; i < pBox->nInputs; i++ )
00271 {
00272 pObj = p->pPis + pBox->Inouts[i];
00273 pObj->timeActual = DelayMax + pObj->timeOffset;
00274 }
00275 return p->pPis[iPi].timeActual;
00276 }
00277
00289 float Aig_TManGetPoRequired( Aig_TMan_t * p, int iPo )
00290 {
00291 return 0.0;
00292 }
00293
00294
00298
00299