ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
retArea.c File Reference
#include "retInt.h"
Include dependency graph for retArea.c:

Go to the source code of this file.

Functions

Abc_Ntk_tAbc_NtkAttachBottom (Abc_Ntk_t *pNtkTop, Abc_Ntk_t *pNtkBottom)
 
int Abc_NtkRetimeMinArea (Abc_Ntk_t *pNtk, int fForwardOnly, int fBackwardOnly, int fUseOldNames, int fVerbose)
 FUNCTION DEFINITIONS ///.
 
void Abc_NtkMarkCone_rec (Abc_Obj_t *pObj, int fForward)
 
void Abc_NtkUnmarkCone_rec (Abc_Obj_t *pObj, int fForward)
 
int Abc_NtkRetimeMinAreaInitValues_rec (Abc_Obj_t *pObj)
 
Abc_Obj_tAbc_NtkRetimeMinAreaConstructNtk_rec (Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj)
 

Function Documentation

◆ Abc_NtkAttachBottom()

Abc_Ntk_t * Abc_NtkAttachBottom ( Abc_Ntk_t * pNtkTop,
Abc_Ntk_t * pNtkBottom )
extern

Function*************************************************************

Synopsis [Attaches the second network at the bottom of the first.]

Description [Returns the first network. Deletes the second network.]

SideEffects []

SeeAlso []

Definition at line 866 of file abcNtk.c.

867{
868 Abc_Obj_t * pObj, * pFanin, * pBuffer;
869 Vec_Ptr_t * vNodes;
870 int i, k;
871 assert( pNtkBottom != NULL );
872 if ( pNtkTop == NULL )
873 return pNtkBottom;
874 // make sure the networks are combinational
875 assert( Abc_NtkPiNum(pNtkTop) == Abc_NtkCiNum(pNtkTop) );
876 assert( Abc_NtkPiNum(pNtkBottom) == Abc_NtkCiNum(pNtkBottom) );
877 // make sure the POs of the bottom correspond to the PIs of the top
878 assert( Abc_NtkPoNum(pNtkBottom) == Abc_NtkPiNum(pNtkTop) );
879 assert( Abc_NtkPiNum(pNtkBottom) < Abc_NtkPiNum(pNtkTop) );
880 // add buffers for the PIs of the top - save results in the POs of the bottom
881 Abc_NtkForEachPi( pNtkTop, pObj, i )
882 {
883 pBuffer = Abc_NtkCreateNodeBuf( pNtkTop, NULL );
884 Abc_ObjTransferFanout( pObj, pBuffer );
885 Abc_NtkPo(pNtkBottom, i)->pCopy = pBuffer;
886 }
887 // remove useless PIs of the top
888 for ( i = Abc_NtkPiNum(pNtkTop) - 1; i >= Abc_NtkPiNum(pNtkBottom); i-- )
889 Abc_NtkDeleteObj( Abc_NtkPi(pNtkTop, i) );
890 assert( Abc_NtkPiNum(pNtkBottom) == Abc_NtkPiNum(pNtkTop) );
891 // copy the bottom network
892 Abc_NtkForEachPi( pNtkBottom, pObj, i )
893 Abc_NtkPi(pNtkBottom, i)->pCopy = Abc_NtkPi(pNtkTop, i);
894 // construct all nodes
895 vNodes = Abc_NtkDfs( pNtkBottom, 0 );
896 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
897 {
898 Abc_NtkDupObj(pNtkTop, pObj, 0);
899 Abc_ObjForEachFanin( pObj, pFanin, k )
900 Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy );
901 }
902 Vec_PtrFree( vNodes );
903 // connect the POs
904 Abc_NtkForEachPo( pNtkBottom, pObj, i )
905 Abc_ObjAddFanin( pObj->pCopy, Abc_ObjFanin0(pObj)->pCopy );
906 // delete old network
907 Abc_NtkDelete( pNtkBottom );
908 // return the network
909 if ( !Abc_NtkCheck( pNtkTop ) )
910 fprintf( stdout, "Abc_NtkAttachBottom(): Network check has failed.\n" );
911 return pNtkTop;
912}
void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition abcNtk.c:1421
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition abcFanio.c:84
ABC_DLL void Abc_NtkDeleteObj(Abc_Obj_t *pObj)
Definition abcObj.c:170
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition abc.h:520
ABC_DLL Abc_Obj_t * Abc_NtkDupObj(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, int fCopyName)
Definition abcObj.c:342
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeBuf(Abc_Ntk_t *pNtk, Abc_Obj_t *pFanin)
Definition abcObj.c:706
ABC_DLL Vec_Ptr_t * Abc_NtkDfs(Abc_Ntk_t *pNtk, int fCollectAll)
Definition abcDfs.c:82
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition abcCheck.c:64
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition abc.h:527
ABC_DLL void Abc_ObjTransferFanout(Abc_Obj_t *pObjOld, Abc_Obj_t *pObjNew)
Definition abcFanio.c:292
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition abc.h:516
Abc_Obj_t * pCopy
Definition abc.h:148
#define assert(ex)
Definition util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NtkMarkCone_rec()

void Abc_NtkMarkCone_rec ( Abc_Obj_t * pObj,
int fForward )

Function*************************************************************

Synopsis [Marks the cone with MarkA.]

Description []

SideEffects []

SeeAlso []

Definition at line 147 of file retArea.c.

148{
149 Abc_Obj_t * pNext;
150 int i;
151 if ( pObj->fMarkA )
152 return;
153 pObj->fMarkA = 1;
154 if ( fForward )
155 {
156 Abc_ObjForEachFanout( pObj, pNext, i )
157 Abc_NtkMarkCone_rec( pNext, fForward );
158 }
159 else
160 {
161 Abc_ObjForEachFanin( pObj, pNext, i )
162 Abc_NtkMarkCone_rec( pNext, fForward );
163 }
164}
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition abc.h:529
void Abc_NtkMarkCone_rec(Abc_Obj_t *pObj, int fForward)
Definition retArea.c:147
unsigned fMarkA
Definition abc.h:134
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NtkRetimeMinArea()

int Abc_NtkRetimeMinArea ( Abc_Ntk_t * pNtk,
int fForwardOnly,
int fBackwardOnly,
int fUseOldNames,
int fVerbose )

FUNCTION DEFINITIONS ///.

INCLUDES ///.

Function*************************************************************

Synopsis [Performs min-area retiming.]

Description [Returns the number of latches reduced.]

SideEffects []

SeeAlso []

Definition at line 53 of file retArea.c.

54{
55 Abc_Ntk_t * pNtkTotal = NULL, * pNtkBottom;
56 Vec_Int_t * vValuesNew = NULL, * vValues;
57 int nLatches = Abc_NtkLatchNum(pNtk);
58 int fOneFrame = 0;
59 assert( !fForwardOnly || !fBackwardOnly );
60 // there should not be black boxes
61 assert( Abc_NtkIsSopLogic(pNtk) );
62 assert( Abc_NtkLatchNum(pNtk) == Vec_PtrSize(pNtk->vBoxes) );
63 // reorder CI/CO/latch inputs
64 Abc_NtkOrderCisCos( pNtk );
65 // perform forward retiming
66 if ( !fBackwardOnly )
67 {
68 if ( fOneFrame )
69 Abc_NtkRetimeMinAreaOne( pNtk, 1, fUseOldNames, fVerbose );
70 else
71 while ( Abc_NtkRetimeMinAreaOne( pNtk, 1, fUseOldNames, fVerbose ) );
72 }
73 // remember initial values
74 vValues = Abc_NtkCollectLatchValues( pNtk );
75 // perform backward retiming
76 if ( !fForwardOnly )
77 {
78 if ( fOneFrame )
79 pNtkTotal = Abc_NtkRetimeMinAreaOne( pNtk, 0, fUseOldNames, fVerbose );
80 else
81 while ( (pNtkBottom = Abc_NtkRetimeMinAreaOne( pNtk, 0, fUseOldNames, fVerbose )) )
82 pNtkTotal = Abc_NtkAttachBottom( pNtkTotal, pNtkBottom );
83 }
84 // compute initial values
85 vValuesNew = Abc_NtkRetimeInitialValues( pNtkTotal, vValues, fVerbose );
86 if ( pNtkTotal ) Abc_NtkDelete( pNtkTotal );
87 // insert new initial values
88 Abc_NtkInsertLatchValues( pNtk, vValuesNew );
89 if ( vValuesNew ) Vec_IntFree( vValuesNew );
90 if ( vValues ) Vec_IntFree( vValues );
91 // fix the COs (this changes the circuit structure)
92// Abc_NtkLogicMakeSimpleCos( pNtk, 0 );
93 // check for correctness
94 if ( !Abc_NtkCheck( pNtk ) )
95 fprintf( stdout, "Abc_NtkRetimeMinArea(): Network check has failed.\n" );
96 // return the number of latches saved
97 return nLatches - Abc_NtkLatchNum(pNtk);
98}
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
ABC_DLL void Abc_NtkInsertLatchValues(Abc_Ntk_t *pNtk, Vec_Int_t *vValues)
Definition abcLatch.c:235
ABC_DLL Vec_Int_t * Abc_NtkCollectLatchValues(Abc_Ntk_t *pNtk)
Definition abcLatch.c:181
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition abcNtk.c:1421
ABC_DLL void Abc_NtkOrderCisCos(Abc_Ntk_t *pNtk)
Definition abcUtil.c:76
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
Abc_Ntk_t * Abc_NtkAttachBottom(Abc_Ntk_t *pNtkTop, Abc_Ntk_t *pNtkBottom)
Definition abcNtk.c:866
Vec_Int_t * Abc_NtkRetimeInitialValues(Abc_Ntk_t *pNtkCone, Vec_Int_t *vValues, int fVerbose)
FUNCTION DEFINITIONS ///.
Definition retInit.c:47
Vec_Ptr_t * vBoxes
Definition abc.h:168
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NtkRetimeMinAreaConstructNtk_rec()

Abc_Obj_t * Abc_NtkRetimeMinAreaConstructNtk_rec ( Abc_Ntk_t * pNtkNew,
Abc_Obj_t * pObj )

Function*************************************************************

Synopsis [Performs min-area retiming backward.]

Description []

SideEffects []

SeeAlso []

Definition at line 329 of file retArea.c.

330{
331 Abc_Obj_t * pFanin;
332 int i;
333 // skip visited nodes
334 if ( Abc_NodeIsTravIdCurrent(pObj) )
335 return pObj->pCopy;
336 Abc_NodeSetTravIdCurrent(pObj);
337 // consider the case of a latch output
338 if ( Abc_ObjIsBi(pObj) )
339 {
340 pObj->pCopy = Abc_NtkRetimeMinAreaConstructNtk_rec( pNtkNew, Abc_ObjFanin0(pObj) );
341 return pObj->pCopy;
342 }
343 assert( Abc_ObjIsNode(pObj) );
344 // visit the fanins
345 Abc_ObjForEachFanin( pObj, pFanin, i )
346 Abc_NtkRetimeMinAreaConstructNtk_rec( pNtkNew, pFanin );
347 // compute the value of the node
348 Abc_NtkDupObj( pNtkNew, pObj, 0 );
349 Abc_ObjForEachFanin( pObj, pFanin, i )
350 Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy );
351 return pObj->pCopy;
352}
Abc_Obj_t * Abc_NtkRetimeMinAreaConstructNtk_rec(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj)
Definition retArea.c:329
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NtkRetimeMinAreaInitValues_rec()

int Abc_NtkRetimeMinAreaInitValues_rec ( Abc_Obj_t * pObj)

Function*************************************************************

Synopsis [Compute initial values.]

Description []

SideEffects []

SeeAlso []

Definition at line 264 of file retArea.c.

265{
266 Abc_Obj_t * pFanin;
267 int i;
268 // skip visited nodes
269 if ( Abc_NodeIsTravIdCurrent(pObj) )
270 return (int)(ABC_PTRUINT_T)pObj->pCopy;
271 Abc_NodeSetTravIdCurrent(pObj);
272 // consider the case of a latch output
273 if ( Abc_ObjIsBo(pObj) )
274 {
275 assert( Abc_ObjIsLatch(Abc_ObjFanin0(pObj)) );
276 pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)Abc_NtkRetimeMinAreaInitValues_rec( Abc_ObjFanin0(pObj) );
277 return (int)(ABC_PTRUINT_T)pObj->pCopy;
278 }
279 assert( Abc_ObjIsNode(pObj) );
280 // visit the fanins
281 Abc_ObjForEachFanin( pObj, pFanin, i )
283 // compute the value of the node
284 pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)Abc_ObjSopSimulate(pObj);
285 return (int)(ABC_PTRUINT_T)pObj->pCopy;
286}
int Abc_NtkRetimeMinAreaInitValues_rec(Abc_Obj_t *pObj)
Definition retArea.c:264
int Abc_ObjSopSimulate(Abc_Obj_t *pObj)
Definition retInit.c:93
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NtkUnmarkCone_rec()

void Abc_NtkUnmarkCone_rec ( Abc_Obj_t * pObj,
int fForward )

Function*************************************************************

Synopsis [Marks the cone with MarkA.]

Description []

SideEffects []

SeeAlso []

Definition at line 177 of file retArea.c.

178{
179 Abc_Obj_t * pNext;
180 int i;
181 if ( !pObj->fMarkA || Abc_ObjIsLatch(pObj) )
182 return;
183 pObj->fMarkA = 0;
184 if ( fForward )
185 {
186 Abc_ObjForEachFanout( pObj, pNext, i )
187 Abc_NtkUnmarkCone_rec( pNext, fForward );
188 }
189 else
190 {
191 Abc_ObjForEachFanin( pObj, pNext, i )
192 Abc_NtkUnmarkCone_rec( pNext, fForward );
193 }
194}
void Abc_NtkUnmarkCone_rec(Abc_Obj_t *pObj, int fForward)
Definition retArea.c:177
Here is the call graph for this function:
Here is the caller graph for this function: