#include "aig.h"
Go to the source code of this file.
Data Structures | |
struct | Rtm_Man_t_ |
struct | Rtm_Edg_t_ |
struct | Rtm_Obj_t_ |
Defines | |
#define | Rtm_ManForEachPi(p, pObj, i) Vec_PtrForEachEntry( p->vPis, pObj, i ) |
#define | Rtm_ManForEachPo(p, pObj, i) Vec_PtrForEachEntry( p->vPos, pObj, i ) |
#define | Rtm_ManForEachObj(p, pObj, i) Vec_PtrForEachEntry( p->vObjs, pObj, i ) |
#define | Rtm_ObjForEachFanin(pObj, pFanin, i) for ( i = 0; i < (int)(pObj)->nFanins && ((pFanin = Rtm_ObjFanin(pObj, i)), 1); i++ ) |
#define | Rtm_ObjForEachFanout(pObj, pFanout, i) for ( i = 0; i < (int)(pObj)->nFanouts && ((pFanout = Rtm_ObjFanout(pObj, i)), 1); i++ ) |
#define | Rtm_ObjForEachFaninEdge(pObj, pEdge, i) for ( i = 0; i < (int)(pObj)->nFanins && ((pEdge = Rtm_ObjEdge(pObj, i)), 1); i++ ) |
#define | Rtm_ObjForEachFanoutEdge(pObj, pEdge, i) for ( i = 0; i < (int)(pObj)->nFanouts && ((pEdge = Rtm_ObjFanoutEdge(pObj, i)), 1); i++ ) |
Typedefs | |
typedef struct Rtm_Man_t_ | Rtm_Man_t |
typedef struct Rtm_Edg_t_ | Rtm_Edg_t |
typedef struct Rtm_Obj_t_ | Rtm_Obj_t |
Enumerations | |
enum | Rtm_Init_t { RTM_VAL_NONE, RTM_VAL_ZERO, RTM_VAL_ONE, RTM_VAL_VOID } |
Functions | |
static Rtm_Obj_t * | Rtm_ObjFanin (Rtm_Obj_t *pObj, int i) |
static Rtm_Obj_t * | Rtm_ObjFanout (Rtm_Obj_t *pObj, int i) |
static Rtm_Edg_t * | Rtm_ObjEdge (Rtm_Obj_t *pObj, int i) |
static Rtm_Edg_t * | Rtm_ObjFanoutEdge (Rtm_Obj_t *pObj, int i) |
static Rtm_Init_t | Rtm_InitNot (Rtm_Init_t Val) |
static Rtm_Init_t | Rtm_InitNotCond (Rtm_Init_t Val, int c) |
static Rtm_Init_t | Rtm_InitAnd (Rtm_Init_t ValA, Rtm_Init_t ValB) |
static int | Rtm_InitWordsNum (int nLats) |
static int | Rtm_InitGetTwo (unsigned *p, int i) |
static void | Rtm_InitSetTwo (unsigned *p, int i, int val) |
static void | Rtm_InitXorTwo (unsigned *p, int i, int val) |
static Rtm_Init_t | Rtm_ObjGetFirst1 (Rtm_Edg_t *pEdge) |
static Rtm_Init_t | Rtm_ObjGetLast1 (Rtm_Edg_t *pEdge) |
static Rtm_Init_t | Rtm_ObjGetOne1 (Rtm_Edg_t *pEdge, int i) |
static Rtm_Init_t | Rtm_ObjRemFirst1 (Rtm_Edg_t *pEdge) |
static Rtm_Init_t | Rtm_ObjRemLast1 (Rtm_Edg_t *pEdge) |
static void | Rtm_ObjAddFirst1 (Rtm_Edg_t *pEdge, Rtm_Init_t Val) |
static void | Rtm_ObjAddLast1 (Rtm_Edg_t *pEdge, Rtm_Init_t Val) |
static Rtm_Init_t | Rtm_ObjGetFirst2 (Rtm_Man_t *p, Rtm_Edg_t *pEdge) |
static Rtm_Init_t | Rtm_ObjGetLast2 (Rtm_Man_t *p, Rtm_Edg_t *pEdge) |
static Rtm_Init_t | Rtm_ObjGetOne2 (Rtm_Man_t *p, Rtm_Edg_t *pEdge, int i) |
static Rtm_Init_t | Rtm_ObjRemFirst2 (Rtm_Man_t *p, Rtm_Edg_t *pEdge) |
static Rtm_Init_t | Rtm_ObjRemLast2 (Rtm_Man_t *p, Rtm_Edg_t *pEdge) |
static void | Rtm_ObjAddFirst2 (Rtm_Man_t *p, Rtm_Edg_t *pEdge, Rtm_Init_t Val) |
static void | Rtm_ObjAddLast2 (Rtm_Man_t *p, Rtm_Edg_t *pEdge, Rtm_Init_t Val) |
static void | Rtm_ObjTransferToSmall (Rtm_Man_t *p, Rtm_Edg_t *pEdge) |
static void | Rtm_ObjTransferToBig (Rtm_Man_t *p, Rtm_Edg_t *pEdge) |
static void | Rtm_ObjTransferToBigger (Rtm_Man_t *p, Rtm_Edg_t *pEdge) |
static Rtm_Init_t | Rtm_ObjGetFirst (Rtm_Man_t *p, Rtm_Edg_t *pEdge) |
static Rtm_Init_t | Rtm_ObjGetLast (Rtm_Man_t *p, Rtm_Edg_t *pEdge) |
static Rtm_Init_t | Rtm_ObjGetOne (Rtm_Man_t *p, Rtm_Edg_t *pEdge, int i) |
static Rtm_Init_t | Rtm_ObjRemFirst (Rtm_Man_t *p, Rtm_Edg_t *pEdge) |
static Rtm_Init_t | Rtm_ObjRemLast (Rtm_Man_t *p, Rtm_Edg_t *pEdge) |
static void | Rtm_ObjAddFirst (Rtm_Man_t *p, Rtm_Edg_t *pEdge, Rtm_Init_t Val) |
static void | Rtm_ObjAddLast (Rtm_Man_t *p, Rtm_Edg_t *pEdge, Rtm_Init_t Val) |
void | Rtm_PrintEdge (Rtm_Man_t *p, Rtm_Edg_t *pEdge) |
Rtm_Man_t * | Rtm_ManAlloc (Aig_Man_t *p) |
void | Rtm_ManFree (Rtm_Man_t *p) |
int | Rtm_ManLatchMax (Rtm_Man_t *p) |
Rtm_Obj_t * | Rtm_ObjAlloc (Rtm_Man_t *pRtm, int nFanins, int nFanouts) |
void | Rtm_ObjAddFanin (Rtm_Obj_t *pObj, Rtm_Obj_t *pFanin, int fCompl) |
int | Rtm_ObjCheckRetimeFwd (Rtm_Obj_t *pObj) |
int | Rtm_ObjCheckRetimeBwd (Rtm_Obj_t *pObj) |
int | Rtm_ObjGetDegreeFwd (Rtm_Obj_t *pObj) |
int | Rtm_ObjGetDegreeBwd (Rtm_Obj_t *pObj) |
void | Rtm_ObjRetimeFwd (Rtm_Man_t *pRtm, Rtm_Obj_t *pObj) |
void | Rtm_ObjRetimeBwd (Rtm_Man_t *pRtm, Rtm_Obj_t *pObj) |
void | Rtm_ObjMarkAutoFwd_rec (Rtm_Obj_t *pObj) |
int | Rtm_ManMarkAutoFwd (Rtm_Man_t *pRtm) |
void | Rtm_ObjMarkAutoBwd_rec (Rtm_Obj_t *pObj) |
int | Rtm_ManMarkAutoBwd (Rtm_Man_t *pRtm) |
Rtm_Man_t * | Rtm_ManFromAig (Aig_Man_t *p) |
Aig_Obj_t * | Rtm_ManToAig_rec (Aig_Man_t *pNew, Rtm_Man_t *pRtm, Rtm_Obj_t *pObjRtm, int *pLatches) |
Aig_Man_t * | Rtm_ManToAig (Rtm_Man_t *pRtm) |
Aig_Man_t * | Rtm_ManRetime (Aig_Man_t *p, int fForward, int nStepsMax, int fVerbose) |
#define Rtm_ManForEachObj | ( | p, | |||
pObj, | |||||
i | ) | Vec_PtrForEachEntry( p->vObjs, pObj, i ) |
#define Rtm_ManForEachPi | ( | p, | |||
pObj, | |||||
i | ) | Vec_PtrForEachEntry( p->vPis, pObj, i ) |
#define Rtm_ManForEachPo | ( | p, | |||
pObj, | |||||
i | ) | Vec_PtrForEachEntry( p->vPos, pObj, i ) |
#define Rtm_ObjForEachFanin | ( | pObj, | |||
pFanin, | |||||
i | ) | for ( i = 0; i < (int)(pObj)->nFanins && ((pFanin = Rtm_ObjFanin(pObj, i)), 1); i++ ) |
#define Rtm_ObjForEachFaninEdge | ( | pObj, | |||
pEdge, | |||||
i | ) | for ( i = 0; i < (int)(pObj)->nFanins && ((pEdge = Rtm_ObjEdge(pObj, i)), 1); i++ ) |
#define Rtm_ObjForEachFanout | ( | pObj, | |||
pFanout, | |||||
i | ) | for ( i = 0; i < (int)(pObj)->nFanouts && ((pFanout = Rtm_ObjFanout(pObj, i)), 1); i++ ) |
#define Rtm_ObjForEachFanoutEdge | ( | pObj, | |||
pEdge, | |||||
i | ) | for ( i = 0; i < (int)(pObj)->nFanouts && ((pEdge = Rtm_ObjFanoutEdge(pObj, i)), 1); i++ ) |
typedef struct Rtm_Edg_t_ Rtm_Edg_t |
typedef struct Rtm_Man_t_ Rtm_Man_t |
typedef struct Rtm_Obj_t_ Rtm_Obj_t |
enum Rtm_Init_t |
CFile****************************************************************
FileName [aigRet.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [AIG package.]
Synopsis [Retiming of AIGs.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - April 28, 2007.]
Revision [
] DECLARATIONS ///
Definition at line 28 of file aigRet.c.
00028 { 00029 RTM_VAL_NONE, // 0: non-existent value 00030 RTM_VAL_ZERO, // 1: initial value 0 00031 RTM_VAL_ONE, // 2: initial value 1 00032 RTM_VAL_VOID // 3: unused value 00033 } Rtm_Init_t;
static Rtm_Init_t Rtm_InitAnd | ( | Rtm_Init_t | ValA, | |
Rtm_Init_t | ValB | |||
) | [inline, static] |
Definition at line 81 of file aigRet.c.
00081 { if ( ValA == RTM_VAL_ONE && ValB == RTM_VAL_ONE ) return RTM_VAL_ONE; if ( ValA == RTM_VAL_ZERO || ValB == RTM_VAL_ZERO ) return RTM_VAL_ZERO; assert( 0 ); return -1; }
static int Rtm_InitGetTwo | ( | unsigned * | p, | |
int | i | |||
) | [inline, static] |
static Rtm_Init_t Rtm_InitNot | ( | Rtm_Init_t | Val | ) | [inline, static] |
Definition at line 79 of file aigRet.c.
00079 { if ( Val == RTM_VAL_ZERO ) return RTM_VAL_ONE; if ( Val == RTM_VAL_ONE ) return RTM_VAL_ZERO; assert( 0 ); return -1; }
static Rtm_Init_t Rtm_InitNotCond | ( | Rtm_Init_t | Val, | |
int | c | |||
) | [inline, static] |
Definition at line 80 of file aigRet.c.
00080 { return c ? Rtm_InitNot(Val) : Val; }
static void Rtm_InitSetTwo | ( | unsigned * | p, | |
int | i, | |||
int | val | |||
) | [inline, static] |
static int Rtm_InitWordsNum | ( | int | nLats | ) | [inline, static] |
static void Rtm_InitXorTwo | ( | unsigned * | p, | |
int | i, | |||
int | val | |||
) | [inline, static] |
Function*************************************************************
Synopsis [Allocates the retiming manager.]
Description []
SideEffects []
SeeAlso []
Definition at line 299 of file aigRet.c.
00300 { 00301 Rtm_Man_t * pRtm; 00302 // start the manager 00303 pRtm = ALLOC( Rtm_Man_t, 1 ); 00304 memset( pRtm, 0, sizeof(Rtm_Man_t) ); 00305 // perform initializations 00306 pRtm->vObjs = Vec_PtrAlloc( Aig_ManObjNum(p) ); 00307 pRtm->vPis = Vec_PtrAlloc( Aig_ManPiNum(p) ); 00308 pRtm->vPos = Vec_PtrAlloc( Aig_ManPoNum(p) ); 00309 pRtm->pMem = Aig_MmFlexStart(); 00310 return pRtm; 00311 }
void Rtm_ManFree | ( | Rtm_Man_t * | p | ) |
Function*************************************************************
Synopsis [Allocates the retiming manager.]
Description []
SideEffects []
SeeAlso []
Definition at line 324 of file aigRet.c.
00325 { 00326 Vec_PtrFree( p->vObjs ); 00327 Vec_PtrFree( p->vPis ); 00328 Vec_PtrFree( p->vPos ); 00329 Aig_MmFlexStop( p->pMem, 0 ); 00330 FREE( p->pExtra ); 00331 free( p ); 00332 }
Function*************************************************************
Synopsis [Derive retiming manager from the given AIG manager.]
Description []
SideEffects []
SeeAlso []
Definition at line 672 of file aigRet.c.
00673 { 00674 Rtm_Man_t * pRtm; 00675 Aig_Obj_t * pObj, * pObjLi, * pObjLo; 00676 int i; 00677 assert( Aig_ManRegNum(p) > 0 ); 00678 assert( Aig_ManBufNum(p) == 0 ); 00679 // allocate the manager 00680 pRtm = Rtm_ManAlloc( p ); 00681 // allocate objects 00682 pObj = Aig_ManConst1(p); 00683 pObj->pData = Rtm_ObjAlloc( pRtm, 0, pObj->nRefs ); 00684 Aig_ManForEachPiSeq( p, pObj, i ) 00685 { 00686 pObj->pData = Rtm_ObjAlloc( pRtm, 0, pObj->nRefs ); 00687 Vec_PtrPush( pRtm->vPis, pObj->pData ); 00688 } 00689 Aig_ManForEachPoSeq( p, pObj, i ) 00690 { 00691 pObj->pData = Rtm_ObjAlloc( pRtm, 1, 0 ); 00692 Vec_PtrPush( pRtm->vPos, pObj->pData ); 00693 } 00694 Aig_ManForEachLoSeq( p, pObj, i ) 00695 pObj->pData = Rtm_ObjAlloc( pRtm, 1, pObj->nRefs ); 00696 Aig_ManForEachLiSeq( p, pObj, i ) 00697 pObj->pData = Rtm_ObjAlloc( pRtm, 1, 1 ); 00698 Aig_ManForEachNode( p, pObj, i ) 00699 pObj->pData = Rtm_ObjAlloc( pRtm, 2, pObj->nRefs ); 00700 // connect objects 00701 Aig_ManForEachPoSeq( p, pObj, i ) 00702 Rtm_ObjAddFanin( pObj->pData, Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0(pObj) ); 00703 Aig_ManForEachLiSeq( p, pObj, i ) 00704 Rtm_ObjAddFanin( pObj->pData, Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0(pObj) ); 00705 Aig_ManForEachLiLoSeq( p, pObjLi, pObjLo, i ) 00706 Rtm_ObjAddFanin( pObjLo->pData, pObjLi->pData, 0 ); 00707 Aig_ManForEachNode( p, pObj, i ) 00708 { 00709 Rtm_ObjAddFanin( pObj->pData, Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0(pObj) ); 00710 Rtm_ObjAddFanin( pObj->pData, Aig_ObjFanin1(pObj)->pData, Aig_ObjFaninC1(pObj) ); 00711 } 00712 return pRtm; 00713 }
int Rtm_ManLatchMax | ( | Rtm_Man_t * | p | ) |
Function*************************************************************
Synopsis [Counts the maximum number of latches on an edge.]
Description []
SideEffects []
SeeAlso []
Definition at line 345 of file aigRet.c.
00346 { 00347 Rtm_Obj_t * pObj; 00348 Rtm_Edg_t * pEdge; 00349 int nLatchMax = 0, i, k;//, c, Val; 00350 Rtm_ManForEachObj( p, pObj, i ) 00351 Rtm_ObjForEachFaninEdge( pObj, pEdge, k ) 00352 { 00353 /* 00354 for ( c = 0; c < (int)pEdge->nLats; c++ ) 00355 { 00356 Val = Rtm_ObjGetOne( p, pEdge, c ); 00357 assert( Val == 1 || Val == 2 ); 00358 } 00359 */ 00360 nLatchMax = AIG_MAX( nLatchMax, (int)pEdge->nLats ); 00361 } 00362 return nLatchMax; 00363 }
int Rtm_ManMarkAutoBwd | ( | Rtm_Man_t * | pRtm | ) |
Function*************************************************************
Synopsis [Marks the nodes unreachable from the POs.]
Description []
SideEffects []
SeeAlso []
Definition at line 640 of file aigRet.c.
00641 { 00642 Rtm_Obj_t * pObjRtm; 00643 int i, Counter = 0; 00644 // mark nodes reachable from the PIs 00645 pObjRtm = Vec_PtrEntry( pRtm->vObjs, 0 ); 00646 pObjRtm->fAuto = 1; 00647 Rtm_ManForEachPi( pRtm, pObjRtm, i ) 00648 pObjRtm->fAuto = 1; 00649 Rtm_ManForEachPo( pRtm, pObjRtm, i ) 00650 Rtm_ObjMarkAutoBwd_rec( pObjRtm ); 00651 // count the number of autonomous nodes 00652 Rtm_ManForEachObj( pRtm, pObjRtm, i ) 00653 { 00654 pObjRtm->fAuto = !pObjRtm->fAuto; 00655 Counter += pObjRtm->fAuto; 00656 } 00657 // mark the fanins of the autonomous nodes 00658 return Counter; 00659 }
int Rtm_ManMarkAutoFwd | ( | Rtm_Man_t * | pRtm | ) |
Function*************************************************************
Synopsis [Marks the nodes unreachable from the PIs.]
Description []
SideEffects []
SeeAlso []
Definition at line 588 of file aigRet.c.
00589 { 00590 Rtm_Obj_t * pObjRtm; 00591 int i, Counter = 0; 00592 // mark nodes reachable from the PIs 00593 pObjRtm = Vec_PtrEntry( pRtm->vObjs, 0 ); 00594 Rtm_ObjMarkAutoFwd_rec( pObjRtm ); 00595 Rtm_ManForEachPi( pRtm, pObjRtm, i ) 00596 Rtm_ObjMarkAutoFwd_rec( pObjRtm ); 00597 // count the number of autonomous nodes 00598 Rtm_ManForEachObj( pRtm, pObjRtm, i ) 00599 { 00600 pObjRtm->fAuto = !pObjRtm->fAuto; 00601 Counter += pObjRtm->fAuto; 00602 } 00603 // mark the fanins of the autonomous nodes 00604 return Counter; 00605 }
Function*************************************************************
Synopsis [Performs forward retiming with the given limit on depth.]
Description []
SideEffects []
SeeAlso []
Definition at line 831 of file aigRet.c.
00832 { 00833 Vec_Ptr_t * vQueue; 00834 Aig_Man_t * pNew; 00835 Rtm_Man_t * pRtm; 00836 Rtm_Obj_t * pObj, * pNext; 00837 Aig_Obj_t * pObjAig; 00838 int i, k, nAutos, Degree, DegreeMax = 0; 00839 int clk; 00840 00841 // create the retiming manager 00842 clk = clock(); 00843 pRtm = Rtm_ManFromAig( p ); 00844 // set registers 00845 Aig_ManForEachLoSeq( p, pObjAig, i ) 00846 Rtm_ObjAddFirst( pRtm, Rtm_ObjEdge(pObjAig->pData, 0), fForward? RTM_VAL_ZERO : RTM_VAL_VOID ); 00847 // detect and mark the autonomous components 00848 if ( fForward ) 00849 nAutos = Rtm_ManMarkAutoFwd( pRtm ); 00850 else 00851 nAutos = Rtm_ManMarkAutoBwd( pRtm ); 00852 if ( fVerbose ) 00853 { 00854 printf( "Detected %d autonomous objects. ", nAutos ); 00855 PRT( "Time", clock() - clk ); 00856 } 00857 00858 // set the current retiming number 00859 Rtm_ManForEachObj( pRtm, pObj, i ) 00860 { 00861 assert( pObj->nFanins == pObj->Num ); 00862 assert( pObj->nFanouts == pObj->Temp ); 00863 pObj->Num = 0; 00864 } 00865 00866 clk = clock(); 00867 // put the LOs on the queue 00868 vQueue = Vec_PtrAlloc( 1000 ); 00869 if ( fForward ) 00870 { 00871 Aig_ManForEachLoSeq( p, pObjAig, i ) 00872 { 00873 pObj = pObjAig->pData; 00874 if ( pObj->fAuto ) 00875 continue; 00876 pObj->fMark = 1; 00877 Vec_PtrPush( vQueue, pObj ); 00878 } 00879 } 00880 else 00881 { 00882 Aig_ManForEachLiSeq( p, pObjAig, i ) 00883 { 00884 pObj = pObjAig->pData; 00885 if ( pObj->fAuto ) 00886 continue; 00887 pObj->fMark = 1; 00888 Vec_PtrPush( vQueue, pObj ); 00889 } 00890 } 00891 // perform retiming 00892 DegreeMax = 0; 00893 Vec_PtrForEachEntry( vQueue, pObj, i ) 00894 { 00895 pObj->fMark = 0; 00896 // retime the node 00897 if ( fForward ) 00898 { 00899 Rtm_ObjRetimeFwd( pRtm, pObj ); 00900 // check if its fanouts should be retimed 00901 Rtm_ObjForEachFanout( pObj, pNext, k ) 00902 { 00903 if ( pNext->fMark ) // skip aleady scheduled 00904 continue; 00905 if ( pNext->Type ) // skip POs 00906 continue; 00907 if ( !Rtm_ObjCheckRetimeFwd( pNext ) ) // skip non-retimable 00908 continue; 00909 Degree = Rtm_ObjGetDegreeFwd( pNext ); 00910 DegreeMax = AIG_MAX( DegreeMax, Degree ); 00911 if ( Degree > nStepsMax ) // skip nodes with high degree 00912 continue; 00913 pNext->fMark = 1; 00914 pNext->Num = Degree; 00915 Vec_PtrPush( vQueue, pNext ); 00916 } 00917 } 00918 else 00919 { 00920 Rtm_ObjRetimeBwd( pRtm, pObj ); 00921 // check if its fanouts should be retimed 00922 Rtm_ObjForEachFanin( pObj, pNext, k ) 00923 { 00924 if ( pNext->fMark ) // skip aleady scheduled 00925 continue; 00926 if ( pNext->nFanins == 0 ) // skip PIs 00927 continue; 00928 if ( !Rtm_ObjCheckRetimeBwd( pNext ) ) // skip non-retimable 00929 continue; 00930 Degree = Rtm_ObjGetDegreeBwd( pNext ); 00931 DegreeMax = AIG_MAX( DegreeMax, Degree ); 00932 if ( Degree > nStepsMax ) // skip nodes with high degree 00933 continue; 00934 pNext->fMark = 1; 00935 pNext->Num = Degree; 00936 Vec_PtrPush( vQueue, pNext ); 00937 } 00938 } 00939 } 00940 00941 if ( fVerbose ) 00942 { 00943 printf( "Performed %d %s latch moves of max depth %d and max latch count %d.\n", 00944 Vec_PtrSize(vQueue), fForward? "fwd":"bwd", DegreeMax, Rtm_ManLatchMax(pRtm) ); 00945 printf( "Memory usage = %d. ", pRtm->nExtraCur ); 00946 PRT( "Time", clock() - clk ); 00947 } 00948 Vec_PtrFree( vQueue ); 00949 00950 // get the new manager 00951 pNew = Rtm_ManToAig( pRtm ); 00952 pNew->pName = Aig_UtilStrsav( p->pName ); 00953 Rtm_ManFree( pRtm ); 00954 // group the registers 00955 clk = clock(); 00956 pNew = Aig_ManReduceLaches( pNew, fVerbose ); 00957 if ( fVerbose ) 00958 { 00959 PRT( "Register sharing time", clock() - clk ); 00960 } 00961 return pNew; 00962 }
Function*************************************************************
Synopsis [Derive AIG manager after retiming.]
Description []
SideEffects []
SeeAlso []
Definition at line 762 of file aigRet.c.
00763 { 00764 Aig_Man_t * pNew; 00765 Aig_Obj_t * pObjNew; 00766 Rtm_Obj_t * pObjRtm; 00767 Rtm_Edg_t * pEdge; 00768 int i, k, m, Val, nLatches, * pLatches; 00769 // count latches and mark the first latch on each edge 00770 pLatches = ALLOC( int, 2 * Vec_PtrSize(pRtm->vObjs) ); 00771 nLatches = 0; 00772 Rtm_ManForEachObj( pRtm, pObjRtm, i ) 00773 Rtm_ObjForEachFaninEdge( pObjRtm, pEdge, k ) 00774 { 00775 pLatches[2*pObjRtm->Id + k] = Vec_PtrSize(pRtm->vPis) + nLatches; 00776 nLatches += pEdge->nLats; 00777 } 00778 // create the new manager 00779 pNew = Aig_ManStart( Vec_PtrSize(pRtm->vObjs) + nLatches ); 00780 // create PIs/POs and latches 00781 pObjRtm = Vec_PtrEntry( pRtm->vObjs, 0 ); 00782 pObjRtm->pCopy = Aig_ManConst1(pNew); 00783 Rtm_ManForEachPi( pRtm, pObjRtm, i ) 00784 pObjRtm->pCopy = Aig_ObjCreatePi(pNew); 00785 for ( i = 0; i < nLatches; i++ ) 00786 Aig_ObjCreatePi(pNew); 00787 // create internal nodes 00788 Rtm_ManForEachObj( pRtm, pObjRtm, i ) 00789 Rtm_ManToAig_rec( pNew, pRtm, pObjRtm, pLatches ); 00790 // create POs 00791 Rtm_ManForEachPo( pRtm, pObjRtm, i ) 00792 Aig_ObjCreatePo( pNew, pObjRtm->pCopy ); 00793 // connect latches 00794 Rtm_ManForEachObj( pRtm, pObjRtm, i ) 00795 Rtm_ObjForEachFaninEdge( pObjRtm, pEdge, k ) 00796 { 00797 if ( pEdge->nLats == 0 ) 00798 continue; 00799 pObjNew = Rtm_ObjFanin( pObjRtm, k )->pCopy; 00800 for ( m = 0; m < (int)pEdge->nLats; m++ ) 00801 { 00802 Val = Rtm_ObjGetOne( pRtm, pEdge, pEdge->nLats - 1 - m ); 00803 assert( Val == RTM_VAL_ZERO || Val == RTM_VAL_ONE || Val == RTM_VAL_VOID ); 00804 pObjNew = Aig_NotCond( pObjNew, Val == RTM_VAL_ONE ); 00805 Aig_ObjCreatePo( pNew, pObjNew ); 00806 pObjNew = Aig_ManPi( pNew, pLatches[2*pObjRtm->Id + k] + m ); 00807 pObjNew = Aig_NotCond( pObjNew, Val == RTM_VAL_ONE ); 00808 } 00809 // assert( Aig_Regular(pObjNew)->nRefs > 0 ); 00810 } 00811 free( pLatches ); 00812 pNew->nRegs = nLatches; 00813 // remove useless nodes 00814 Aig_ManCleanup( pNew ); 00815 if ( !Aig_ManCheck( pNew ) ) 00816 printf( "Rtm_ManToAig: The network check has failed.\n" ); 00817 return pNew; 00818 }
Aig_Obj_t* Rtm_ManToAig_rec | ( | Aig_Man_t * | pNew, | |
Rtm_Man_t * | pRtm, | |||
Rtm_Obj_t * | pObjRtm, | |||
int * | pLatches | |||
) |
Function*************************************************************
Synopsis [Derive AIG manager after retiming.]
Description []
SideEffects []
SeeAlso []
Definition at line 726 of file aigRet.c.
00727 { 00728 Rtm_Edg_t * pEdge; 00729 Aig_Obj_t * pRes, * pFanin; 00730 int k, Val; 00731 if ( pObjRtm->pCopy ) 00732 return pObjRtm->pCopy; 00733 // get the inputs 00734 pRes = Aig_ManConst1( pNew ); 00735 Rtm_ObjForEachFaninEdge( pObjRtm, pEdge, k ) 00736 { 00737 if ( pEdge->nLats == 0 ) 00738 pFanin = Rtm_ManToAig_rec( pNew, pRtm, Rtm_ObjFanin(pObjRtm, k), pLatches ); 00739 else 00740 { 00741 Val = Rtm_ObjGetFirst( pRtm, pEdge ); 00742 pFanin = Aig_ManPi( pNew, pLatches[2*pObjRtm->Id + k] + pEdge->nLats - 1 ); 00743 pFanin = Aig_NotCond( pFanin, Val == RTM_VAL_ONE ); 00744 } 00745 pFanin = Aig_NotCond( pFanin, k ? pObjRtm->fCompl1 : pObjRtm->fCompl0 ); 00746 pRes = Aig_And( pNew, pRes, pFanin ); 00747 } 00748 return pObjRtm->pCopy = pRes; 00749 }
Function*************************************************************
Synopsis [Allocates the retiming object.]
Description []
SideEffects []
SeeAlso []
Definition at line 401 of file aigRet.c.
00402 { 00403 pObj->pFanio[ 2*pObj->nFanins ] = pFanin; 00404 pObj->pFanio[ 2*pObj->nFanins + 1 ] = NULL; 00405 pFanin->pFanio[ 2*(pFanin->Num + pFanin->nFanouts) ] = pObj; 00406 pFanin->pFanio[ 2*(pFanin->Num + pFanin->nFanouts) + 1 ] = pObj->pFanio + 2*pObj->nFanins + 1; 00407 if ( pObj->nFanins == 0 ) 00408 pObj->fCompl0 = fCompl; 00409 else if ( pObj->nFanins == 1 ) 00410 pObj->fCompl1 = fCompl; 00411 else 00412 assert( 0 ); 00413 pObj->nFanins++; 00414 pFanin->nFanouts++; 00415 assert( pObj->nFanins <= pObj->Num ); 00416 assert( pFanin->nFanouts <= pFanin->Temp ); 00417 }
static void Rtm_ObjAddFirst | ( | Rtm_Man_t * | p, | |
Rtm_Edg_t * | pEdge, | |||
Rtm_Init_t | Val | |||
) | [static] |
Definition at line 113 of file aigRet.c.
00113 { if ( pEdge->nLats == 10 ) Rtm_ObjTransferToBig(p, pEdge); else if ( (pEdge->nLats & 15) == 15 ) Rtm_ObjTransferToBigger(p, pEdge); if ( pEdge->nLats >= 10 ) Rtm_ObjAddFirst2(p, pEdge, Val); else Rtm_ObjAddFirst1(pEdge, Val); }
static void Rtm_ObjAddFirst1 | ( | Rtm_Edg_t * | pEdge, | |
Rtm_Init_t | Val | |||
) | [inline, static] |
void Rtm_ObjAddFirst2 | ( | Rtm_Man_t * | p, | |
Rtm_Edg_t * | pEdge, | |||
Rtm_Init_t | Val | |||
) | [static] |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 249 of file aigRet.c.
00250 { 00251 unsigned * pB = p->pExtra + pEdge->LData, * pE = pB + Rtm_InitWordsNum( ++pEdge->nLats ); 00252 Rtm_Init_t Temp; 00253 assert( Val != 0 ); 00254 while ( pB < pE ) 00255 { 00256 Temp = *pB >> 30; 00257 *pB = (*pB << 2) | Val; 00258 Val = Temp; 00259 pB++; 00260 } 00261 }
static void Rtm_ObjAddLast | ( | Rtm_Man_t * | p, | |
Rtm_Edg_t * | pEdge, | |||
Rtm_Init_t | Val | |||
) | [static] |
Definition at line 114 of file aigRet.c.
00114 { if ( pEdge->nLats == 10 ) Rtm_ObjTransferToBig(p, pEdge); else if ( (pEdge->nLats & 15) == 15 ) Rtm_ObjTransferToBigger(p, pEdge); if ( pEdge->nLats >= 10 ) Rtm_ObjAddLast2(p, pEdge, Val); else Rtm_ObjAddLast1(pEdge, Val); }
static void Rtm_ObjAddLast1 | ( | Rtm_Edg_t * | pEdge, | |
Rtm_Init_t | Val | |||
) | [inline, static] |
static void Rtm_ObjAddLast2 | ( | Rtm_Man_t * | p, | |
Rtm_Edg_t * | pEdge, | |||
Rtm_Init_t | Val | |||
) | [inline, static] |
Function*************************************************************
Synopsis [Allocates the retiming object.]
Description []
SideEffects []
SeeAlso []
Definition at line 376 of file aigRet.c.
00377 { 00378 Rtm_Obj_t * pObj; 00379 int Size = sizeof(Rtm_Obj_t) + sizeof(Rtm_Obj_t *) * (nFanins + nFanouts) * 2; 00380 pObj = (Rtm_Obj_t *)Aig_MmFlexEntryFetch( pRtm->pMem, Size ); 00381 memset( pObj, 0, sizeof(Rtm_Obj_t) ); 00382 pObj->Type = (int)(nFanins == 1 && nFanouts == 0); // mark PO 00383 pObj->Num = nFanins; // temporary 00384 pObj->Temp = nFanouts; 00385 pObj->Id = Vec_PtrSize(pRtm->vObjs); 00386 Vec_PtrPush( pRtm->vObjs, pObj ); 00387 return pObj; 00388 }
int Rtm_ObjCheckRetimeBwd | ( | Rtm_Obj_t * | pObj | ) |
Function*************************************************************
Synopsis [Check the possibility of forward retiming.]
Description []
SideEffects []
SeeAlso []
Definition at line 451 of file aigRet.c.
00452 { 00453 Rtm_Edg_t * pEdge; 00454 int i; 00455 Rtm_ObjForEachFanoutEdge( pObj, pEdge, i ) 00456 if ( pEdge->nLats == 0 ) 00457 return 0; 00458 return 1; 00459 }
int Rtm_ObjCheckRetimeFwd | ( | Rtm_Obj_t * | pObj | ) |
Function*************************************************************
Synopsis [Check the possibility of forward retiming.]
Description []
SideEffects []
SeeAlso []
Definition at line 430 of file aigRet.c.
00431 { 00432 Rtm_Edg_t * pEdge; 00433 int i; 00434 Rtm_ObjForEachFaninEdge( pObj, pEdge, i ) 00435 if ( pEdge->nLats == 0 ) 00436 return 0; 00437 return 1; 00438 }
int Rtm_ObjGetDegreeBwd | ( | Rtm_Obj_t * | pObj | ) |
Function*************************************************************
Synopsis [Check the possibility of forward retiming.]
Description []
SideEffects []
SeeAlso []
Definition at line 492 of file aigRet.c.
00493 { 00494 Rtm_Obj_t * pFanout; 00495 int i, Degree = 0; 00496 Rtm_ObjForEachFanout( pObj, pFanout, i ) 00497 Degree = AIG_MAX( Degree, (int)pFanout->Num ); 00498 return Degree + 1; 00499 }
int Rtm_ObjGetDegreeFwd | ( | Rtm_Obj_t * | pObj | ) |
Function*************************************************************
Synopsis [Check the possibility of forward retiming.]
Description []
SideEffects []
SeeAlso []
Definition at line 472 of file aigRet.c.
00473 { 00474 Rtm_Obj_t * pFanin; 00475 int i, Degree = 0; 00476 Rtm_ObjForEachFanin( pObj, pFanin, i ) 00477 Degree = AIG_MAX( Degree, (int)pFanin->Num ); 00478 return Degree + 1; 00479 }
static Rtm_Init_t Rtm_ObjGetFirst | ( | Rtm_Man_t * | p, | |
Rtm_Edg_t * | pEdge | |||
) | [inline, static] |
Definition at line 108 of file aigRet.c.
00108 { return pEdge->nLats > 10? Rtm_ObjGetFirst2(p, pEdge) : Rtm_ObjGetFirst1(pEdge); }
static Rtm_Init_t Rtm_ObjGetFirst1 | ( | Rtm_Edg_t * | pEdge | ) | [inline, static] |
static Rtm_Init_t Rtm_ObjGetFirst2 | ( | Rtm_Man_t * | p, | |
Rtm_Edg_t * | pEdge | |||
) | [inline, static] |
Definition at line 96 of file aigRet.c.
00096 { return Rtm_InitGetTwo( p->pExtra + pEdge->LData, 0 ); }
static Rtm_Init_t Rtm_ObjGetLast | ( | Rtm_Man_t * | p, | |
Rtm_Edg_t * | pEdge | |||
) | [inline, static] |
Definition at line 109 of file aigRet.c.
00109 { return pEdge->nLats > 10? Rtm_ObjGetLast2(p, pEdge) : Rtm_ObjGetLast1(pEdge); }
static Rtm_Init_t Rtm_ObjGetLast1 | ( | Rtm_Edg_t * | pEdge | ) | [inline, static] |
static Rtm_Init_t Rtm_ObjGetLast2 | ( | Rtm_Man_t * | p, | |
Rtm_Edg_t * | pEdge | |||
) | [inline, static] |
static Rtm_Init_t Rtm_ObjGetOne | ( | Rtm_Man_t * | p, | |
Rtm_Edg_t * | pEdge, | |||
int | i | |||
) | [inline, static] |
Definition at line 110 of file aigRet.c.
00110 { return pEdge->nLats > 10? Rtm_ObjGetOne2(p, pEdge, i) : Rtm_ObjGetOne1(pEdge, i); }
static Rtm_Init_t Rtm_ObjGetOne1 | ( | Rtm_Edg_t * | pEdge, | |
int | i | |||
) | [inline, static] |
static Rtm_Init_t Rtm_ObjGetOne2 | ( | Rtm_Man_t * | p, | |
Rtm_Edg_t * | pEdge, | |||
int | i | |||
) | [inline, static] |
Definition at line 98 of file aigRet.c.
00098 { return Rtm_InitGetTwo( p->pExtra + pEdge->LData, i ); }
void Rtm_ObjMarkAutoBwd_rec | ( | Rtm_Obj_t * | pObj | ) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 618 of file aigRet.c.
00619 { 00620 Rtm_Obj_t * pFanin; 00621 int i; 00622 if ( pObj->fAuto ) 00623 return; 00624 pObj->fAuto = 1; 00625 Rtm_ObjForEachFanin( pObj, pFanin, i ) 00626 Rtm_ObjMarkAutoBwd_rec( pFanin ); 00627 }
void Rtm_ObjMarkAutoFwd_rec | ( | Rtm_Obj_t * | pObj | ) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 566 of file aigRet.c.
00567 { 00568 Rtm_Obj_t * pFanout; 00569 int i; 00570 if ( pObj->fAuto ) 00571 return; 00572 pObj->fAuto = 1; 00573 Rtm_ObjForEachFanout( pObj, pFanout, i ) 00574 Rtm_ObjMarkAutoFwd_rec( pFanout ); 00575 }
static Rtm_Init_t Rtm_ObjRemFirst | ( | Rtm_Man_t * | p, | |
Rtm_Edg_t * | pEdge | |||
) | [static] |
Definition at line 111 of file aigRet.c.
00111 { Rtm_Init_t Res = pEdge->nLats > 10 ? Rtm_ObjRemFirst2(p, pEdge) : Rtm_ObjRemFirst1(pEdge); if ( pEdge->nLats == 10 ) Rtm_ObjTransferToSmall(p, pEdge); return Res; }
static Rtm_Init_t Rtm_ObjRemFirst1 | ( | Rtm_Edg_t * | pEdge | ) | [inline, static] |
Rtm_Init_t Rtm_ObjRemFirst2 | ( | Rtm_Man_t * | p, | |
Rtm_Edg_t * | pEdge | |||
) | [static] |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 223 of file aigRet.c.
00224 { 00225 Rtm_Init_t Val = 0, Temp; 00226 unsigned * pB = p->pExtra + pEdge->LData, * pE = pB + Rtm_InitWordsNum( pEdge->nLats-- ) - 1; 00227 while ( pE >= pB ) 00228 { 00229 Temp = *pE & 3; 00230 *pE = (*pE >> 2) | (Val << 30); 00231 Val = Temp; 00232 pE--; 00233 } 00234 assert( Val != 0 ); 00235 return Val; 00236 }
static Rtm_Init_t Rtm_ObjRemLast | ( | Rtm_Man_t * | p, | |
Rtm_Edg_t * | pEdge | |||
) | [static] |
Definition at line 112 of file aigRet.c.
00112 { Rtm_Init_t Res = pEdge->nLats > 10 ? Rtm_ObjRemLast2(p, pEdge) : Rtm_ObjRemLast1(pEdge); if ( pEdge->nLats == 10 ) Rtm_ObjTransferToSmall(p, pEdge); return Res; }
static Rtm_Init_t Rtm_ObjRemLast1 | ( | Rtm_Edg_t * | pEdge | ) | [inline, static] |
static Rtm_Init_t Rtm_ObjRemLast2 | ( | Rtm_Man_t * | p, | |
Rtm_Edg_t * | pEdge | |||
) | [inline, static] |
Definition at line 100 of file aigRet.c.
00100 { Rtm_Init_t Val = Rtm_ObjGetLast2( p, pEdge ); Rtm_InitXorTwo( p->pExtra + pEdge->LData, pEdge->nLats - 1, Val ); pEdge->nLats--; return Val; }
Function*************************************************************
Synopsis [Performs forward retiming.]
Description []
SideEffects []
SeeAlso []
Definition at line 542 of file aigRet.c.
00543 { 00544 Rtm_Edg_t * pEdge; 00545 int i; 00546 assert( Rtm_ObjCheckRetimeBwd(pObj) ); 00547 // extract values and compute the result 00548 Rtm_ObjForEachFanoutEdge( pObj, pEdge, i ) 00549 Rtm_ObjRemLast( pRtm, pEdge ); 00550 // insert the result in the fanout values 00551 Rtm_ObjForEachFaninEdge( pObj, pEdge, i ) 00552 Rtm_ObjAddFirst( pRtm, pEdge, RTM_VAL_VOID ); 00553 }
Function*************************************************************
Synopsis [Performs forward retiming.]
Description []
SideEffects []
SeeAlso []
Definition at line 512 of file aigRet.c.
00513 { 00514 Rtm_Init_t ValTotal, ValCur; 00515 Rtm_Edg_t * pEdge; 00516 int i; 00517 assert( Rtm_ObjCheckRetimeFwd(pObj) ); 00518 // extract values and compute the result 00519 ValTotal = RTM_VAL_ONE; 00520 Rtm_ObjForEachFaninEdge( pObj, pEdge, i ) 00521 { 00522 ValCur = Rtm_ObjRemFirst( pRtm, pEdge ); 00523 ValCur = Rtm_InitNotCond( ValCur, i? pObj->fCompl1 : pObj->fCompl0 ); 00524 ValTotal = Rtm_InitAnd( ValTotal, ValCur ); 00525 } 00526 // insert the result in the fanout values 00527 Rtm_ObjForEachFanoutEdge( pObj, pEdge, i ) 00528 Rtm_ObjAddLast( pRtm, pEdge, ValTotal ); 00529 }
Function*************************************************************
Synopsis [Transfers from small to big storage.]
Description []
SideEffects []
SeeAlso []
Definition at line 171 of file aigRet.c.
00172 { 00173 assert( pEdge->nLats == 10 ); 00174 if ( p->nExtraCur + 1 > p->nExtraAlloc ) 00175 { 00176 int nExtraAllocNew = AIG_MAX( 2 * p->nExtraAlloc, 1024 ); 00177 p->pExtra = REALLOC( unsigned, p->pExtra, nExtraAllocNew ); 00178 p->nExtraAlloc = nExtraAllocNew; 00179 } 00180 p->pExtra[p->nExtraCur] = pEdge->LData; 00181 pEdge->LData = p->nExtraCur++; 00182 }
Function*************************************************************
Synopsis [Transfers to bigger storage.]
Description []
SideEffects []
SeeAlso []
Definition at line 195 of file aigRet.c.
00196 { 00197 int nWords; 00198 assert( (pEdge->nLats & 15) == 15 ); 00199 nWords = (pEdge->nLats + 1) >> 4; 00200 if ( p->nExtraCur + nWords + 1 > p->nExtraAlloc ) 00201 { 00202 int nExtraAllocNew = AIG_MAX( 2 * p->nExtraAlloc, 1024 ); 00203 p->pExtra = REALLOC( unsigned, p->pExtra, nExtraAllocNew ); 00204 p->nExtraAlloc = nExtraAllocNew; 00205 } 00206 memcpy( p->pExtra + p->nExtraCur, p->pExtra + pEdge->LData, sizeof(unsigned) * nWords ); 00207 p->pExtra[p->nExtraCur + nWords] = 0; 00208 pEdge->LData = p->nExtraCur; 00209 p->nExtraCur += nWords + 1; 00210 }
FUNCTION DEFINITIONS ///Function*************************************************************
Synopsis [Transfers from big to small storage.]
Description []
SideEffects []
SeeAlso []
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 274 of file aigRet.c.
00275 { 00276 // unsigned LData = pEdge->LData; 00277 printf( "%d : ", pEdge->nLats ); 00278 /* 00279 if ( pEdge->nLats > 10 ) 00280 Extra_PrintBinary( stdout, p->pExtra + pEdge->LData, 2*(pEdge->nLats+1) ); 00281 else 00282 Extra_PrintBinary( stdout, &LData, 2*(pEdge->nLats+1) ); 00283 */ 00284 printf( "\n" ); 00285 }