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

Go to the source code of this file.

Functions

void Mpm_CutPrint (Mpm_Cut_t *pCut)
 
int Mpm_ObjAddCutToStore (Mpm_Man_t *p, Mpm_Cut_t *pCut, int ArrTime)
 
void Mpm_ObjAddChoiceCutsToStore (Mpm_Man_t *p, Mig_Obj_t *pRoot, Mig_Obj_t *pObj, int ReqTime)
 
void Mpm_ObjTranslateCutsFromStore (Mpm_Man_t *p, Mig_Obj_t *pObj)
 
int Mpm_ManDeriveCuts (Mpm_Man_t *p, Mig_Obj_t *pObj)
 
int Mpm_CutCompareDelay (Mpm_Uni_t *pOld, Mpm_Uni_t *pNew)
 
int Mpm_CutCompareDelay2 (Mpm_Uni_t *pOld, Mpm_Uni_t *pNew)
 
int Mpm_CutCompareArea (Mpm_Uni_t *pOld, Mpm_Uni_t *pNew)
 
int Mpm_CutCompareArea2 (Mpm_Uni_t *pOld, Mpm_Uni_t *pNew)
 
void Mpm_ManPrepare (Mpm_Man_t *p)
 
void Mpm_ManPerformRound (Mpm_Man_t *p)
 
void Mpm_ManPerform (Mpm_Man_t *p)
 

Function Documentation

◆ Mpm_CutCompareArea()

int Mpm_CutCompareArea ( Mpm_Uni_t * pOld,
Mpm_Uni_t * pNew )

Definition at line 764 of file mpmMap.c.

765{
766 if ( pOld->mArea != pNew->mArea ) return pOld->mArea - pNew->mArea;
767 if ( pOld->pCut.nLeaves != pNew->pCut.nLeaves ) return pOld->pCut.nLeaves - pNew->pCut.nLeaves;
768 if ( pOld->mEdge != pNew->mEdge ) return pOld->mEdge - pNew->mEdge;
769 if ( pOld->mAveRefs != pNew->mAveRefs ) return pOld->mAveRefs - pNew->mAveRefs;
770 if ( pOld->mTime != pNew->mTime ) return pOld->mTime - pNew->mTime;
771 return 0;
772}
unsigned nLeaves
Definition mpmInt.h:68
Mpm_Cut_t pCut
Definition mpmInt.h:80
int mTime
Definition mpmInt.h:74
int mEdge
Definition mpmInt.h:76
int mArea
Definition mpmInt.h:75
int mAveRefs
Definition mpmInt.h:77
Here is the caller graph for this function:

◆ Mpm_CutCompareArea2()

int Mpm_CutCompareArea2 ( Mpm_Uni_t * pOld,
Mpm_Uni_t * pNew )

Definition at line 773 of file mpmMap.c.

774{
775 if ( pOld->mArea != pNew->mArea ) return pOld->mArea - pNew->mArea;
776 if ( pOld->mEdge != pNew->mEdge ) return pOld->mEdge - pNew->mEdge;
777 if ( pOld->mAveRefs != pNew->mAveRefs ) return pOld->mAveRefs - pNew->mAveRefs;
778 if ( pOld->pCut.nLeaves != pNew->pCut.nLeaves ) return pOld->pCut.nLeaves - pNew->pCut.nLeaves;
779 if ( pOld->mTime != pNew->mTime ) return pOld->mTime - pNew->mTime;
780 return 0;
781}
Here is the caller graph for this function:

◆ Mpm_CutCompareDelay()

int Mpm_CutCompareDelay ( Mpm_Uni_t * pOld,
Mpm_Uni_t * pNew )

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

Synopsis [Cut comparison.]

Description [Returns positive number if new one is better than old one.]

SideEffects []

SeeAlso []

Definition at line 748 of file mpmMap.c.

749{
750 if ( pOld->mTime != pNew->mTime ) return pOld->mTime - pNew->mTime;
751 if ( pOld->pCut.nLeaves != pNew->pCut.nLeaves ) return pOld->pCut.nLeaves - pNew->pCut.nLeaves;
752 if ( pOld->mArea != pNew->mArea ) return pOld->mArea - pNew->mArea;
753 if ( pOld->mEdge != pNew->mEdge ) return pOld->mEdge - pNew->mEdge;
754 return 0;
755}
Here is the caller graph for this function:

◆ Mpm_CutCompareDelay2()

int Mpm_CutCompareDelay2 ( Mpm_Uni_t * pOld,
Mpm_Uni_t * pNew )

Definition at line 756 of file mpmMap.c.

757{
758 if ( pOld->mTime != pNew->mTime ) return pOld->mTime - pNew->mTime;
759 if ( pOld->mArea != pNew->mArea ) return pOld->mArea - pNew->mArea;
760 if ( pOld->mEdge != pNew->mEdge ) return pOld->mEdge - pNew->mEdge;
761 if ( pOld->pCut.nLeaves != pNew->pCut.nLeaves ) return pOld->pCut.nLeaves - pNew->pCut.nLeaves;
762 return 0;
763}
Here is the caller graph for this function:

◆ Mpm_CutPrint()

void Mpm_CutPrint ( Mpm_Cut_t * pCut)

Definition at line 103 of file mpmMap.c.

104{
105 int i;
106 printf( "%d : { ", pCut->nLeaves );
107 for ( i = 0; i < (int)pCut->nLeaves; i++ )
108 printf( "%d ", pCut->pLeaves[i] );
109 printf( "}\n" );
110}
int pLeaves[1]
Definition mpmInt.h:69
Here is the caller graph for this function:

◆ Mpm_ManDeriveCuts()

int Mpm_ManDeriveCuts ( Mpm_Man_t * p,
Mig_Obj_t * pObj )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 580 of file mpmMap.c.

581{
582 Mpm_Cut_t * pCut0, * pCut1, * pCut2;
583 int Required = Mpm_ObjRequired( p, pObj );
584 int hCutBest = Mpm_ObjCutBest( p, pObj );
585 int c0, c1, c2;
586#ifdef MIG_RUNTIME
587abctime clk;
588#endif
589
590 assert( Vec_PtrSize( &p->vFreeUnits ) == p->nNumCuts + 1 );
591 assert( Mpm_ObjCutList(p, pObj) == 0 );
592 p->nCutStore = 0;
593 if ( hCutBest > 0 ) // cut list is assigned
594 {
595 Mpm_Cut_t * pCut = Mpm_ObjCutBestP( p, pObj );
596 int Times = Mpm_CutGetArrTime( p, pCut );
597 assert( pCut->hNext == 0 );
598 if ( Times > Required )
599 printf( "Arrival time (%d) exceeds required time (%d) at object %d.\n", Times, Required, Mig_ObjId(pObj) );
600 if ( p->fMainRun )
601 Mpm_ObjAddCutToStore( p, Mpm_ManMergeCuts(p, pCut, NULL, NULL), Times );
602 else
603 Mpm_ObjSetTime( p, pObj, Times );
604 }
605 // start storage with choice cuts
606 if ( Mig_ManChoiceNum(p->pMig) && Mig_ObjSiblId(pObj) )
607 Mpm_ObjAddChoiceCutsToStore( p, pObj, Mig_ObjSibl(pObj), Required );
608
609#ifdef MIG_RUNTIME
610clk = Abc_Clock();
611#endif
612 Mpm_ObjPrepareFanins( p, pObj );
613 if ( Mig_ObjIsNode2(pObj) )
614 {
615 // go through cut pairs
616 for ( c0 = 0; c0 < p->nCuts[0] && (pCut0 = p->pCuts[0][c0]); c0++ )
617 for ( c1 = 0; c1 < p->nCuts[1] && (pCut1 = p->pCuts[1][c1]); c1++ )
618 if ( Abc_TtCountOnes(p->pSigns[0][c0] | p->pSigns[1][c1]) <= p->nLutSize )
619 if ( !Mpm_ManExploreNewCut( p, pObj, pCut0, pCut1, NULL, Required ) )
620 goto finish;
621 }
622 else if ( Mig_ObjIsNode3(pObj) )
623 {
624 // go through cut triples
625 for ( c0 = 0; c0 < p->nCuts[0] && (pCut0 = p->pCuts[0][c0]); c0++ )
626 for ( c1 = 0; c1 < p->nCuts[1] && (pCut1 = p->pCuts[1][c1]); c1++ )
627 for ( c2 = 0; c2 < p->nCuts[2] && (pCut2 = p->pCuts[2][c2]); c2++ )
628 if ( Abc_TtCountOnes(p->pSigns[0][c0] | p->pSigns[1][c1] | p->pSigns[2][c2]) <= p->nLutSize )
629 if ( !Mpm_ManExploreNewCut( p, pObj, pCut0, pCut1, pCut2, Required ) )
630 goto finish;
631 }
632 else assert( 0 );
633#ifdef MIG_RUNTIME
634p->timeDerive += Abc_Clock() - clk;
635#endif
636
637finish:
638 // save best cut
639 assert( p->nCutStore > 0 );
640 if ( p->pCutStore[0]->mTime <= Required )
641 {
642 Mpm_Cut_t * pCut;
643 if ( hCutBest )
644 Mmr_StepRecycle( p->pManCuts, hCutBest );
645 hCutBest = Mpm_CutCreate( p, &p->pCutStore[0]->pCut, &pCut );
646 Mpm_ObjSetCutBest( p, pObj, hCutBest );
647 Mpm_ObjSetTime( p, pObj, p->pCutStore[0]->mTime );
648 Mpm_ObjSetArea( p, pObj, p->pCutStore[0]->mArea );
649 Mpm_ObjSetEdge( p, pObj, p->pCutStore[0]->mEdge );
650 }
651 else assert( !p->fMainRun );
652 assert( hCutBest > 0 );
653 // transform internal storage into regular cuts
655 // dereference fanin cuts and reference node
656 Mpm_ObjDerefFaninCuts( p, pObj );
657 return 1;
658}
ABC_INT64_T abctime
Definition abc_global.h:332
Cube * p
Definition exorList.c:222
struct Mpm_Cut_t_ Mpm_Cut_t
BASIC TYPES ///.
Definition mpmInt.h:61
void Mpm_ObjAddChoiceCutsToStore(Mpm_Man_t *p, Mig_Obj_t *pRoot, Mig_Obj_t *pObj, int ReqTime)
Definition mpmMap.c:529
int Mpm_ObjAddCutToStore(Mpm_Man_t *p, Mpm_Cut_t *pCut, int ArrTime)
Definition mpmMap.c:225
void Mpm_ObjTranslateCutsFromStore(Mpm_Man_t *p, Mig_Obj_t *pObj)
Definition mpmMap.c:547
int hNext
Definition mpmInt.h:64
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mpm_ManPerform()

void Mpm_ManPerform ( Mpm_Man_t * p)

Definition at line 833 of file mpmMap.c.

834{
835 if ( p->pPars->fMap4Cnf )
836 {
837 p->pCutCmp = Mpm_CutCompareArea;
839 }
840 else
841 {
842 p->pCutCmp = Mpm_CutCompareDelay;
844 if ( p->pPars->fOneRound )
845 return;
846
847 p->pCutCmp = Mpm_CutCompareDelay2;
849
850 p->pCutCmp = Mpm_CutCompareArea;
852
853 p->fMainRun = 1;
854
855 p->pCutCmp = Mpm_CutCompareArea;
856 Mpm_ManComputeEstRefs( p );
858
859 p->pCutCmp = Mpm_CutCompareArea2;
860 Mpm_ManComputeEstRefs( p );
862 }
863}
void Mpm_ManPerformRound(Mpm_Man_t *p)
Definition mpmMap.c:807
int Mpm_CutCompareDelay2(Mpm_Uni_t *pOld, Mpm_Uni_t *pNew)
Definition mpmMap.c:756
int Mpm_CutCompareDelay(Mpm_Uni_t *pOld, Mpm_Uni_t *pNew)
Definition mpmMap.c:748
int Mpm_CutCompareArea(Mpm_Uni_t *pOld, Mpm_Uni_t *pNew)
Definition mpmMap.c:764
int Mpm_CutCompareArea2(Mpm_Uni_t *pOld, Mpm_Uni_t *pNew)
Definition mpmMap.c:773
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mpm_ManPerformRound()

void Mpm_ManPerformRound ( Mpm_Man_t * p)

Definition at line 807 of file mpmMap.c.

808{
809 Mig_Obj_t * pObj;
810 abctime clk = Abc_Clock();
811 int i;
812 // copy references
813 assert( Vec_IntSize(&p->vMigRefs) == Vec_IntSize(&p->pMig->vRefs) );
814 memcpy( Vec_IntArray(&p->vMigRefs), Vec_IntArray(&p->pMig->vRefs), sizeof(int) * Mig_ManObjNum(p->pMig) );
815 Mig_ManForEachCo( p->pMig, pObj, i )
816 Mig_ObjMigRefDec( p, Mig_ObjFanin0(pObj) );
817 // derive cuts
818 p->nCutsMerged = 0;
819 Mig_ManForEachNode( p->pMig, pObj )
820 Mpm_ManDeriveCuts( p, pObj );
821 assert( Mig_ManCandNum(p->pMig) == p->pManCuts->nEntries );
822 Mpm_ManFinalizeRound( p );
823 // report results
824 if ( p->pPars->fVerbose )
825 {
826 printf( "Del =%5d. Ar =%8d. Edge =%8d. Cut =%10d. Max =%8d. Tru =%8d. Small =%6d. ",
827 p->GloRequired, (int)p->GloArea, (int)p->GloEdge,
828 p->nCutsMerged, p->pManCuts->nEntriesMax,
829 p->vTtMem ? p->vTtMem->nEntries : 0, p->nSmallSupp );
830 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
831 }
832}
int Mpm_ManDeriveCuts(Mpm_Man_t *p, Mig_Obj_t *pObj)
Definition mpmMap.c:580
struct Mig_Obj_t_ Mig_Obj_t
Definition mpmMig.h:54
#define Mig_ManForEachNode(p, pObj)
Definition mpmMig.h:322
#define Mig_ManForEachCo(p, pObj, i)
Definition mpmMig.h:329
char * memcpy()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mpm_ManPrepare()

void Mpm_ManPrepare ( Mpm_Man_t * p)

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

Synopsis [Technology mapping experiment.]

Description []

SideEffects []

SeeAlso []

Definition at line 794 of file mpmMap.c.

795{
796 Mig_Obj_t * pObj;
797 int i, hCut;
798 Mig_ManForEachCi( p->pMig, pObj, i )
799 {
800 hCut = Mpm_CutCreateUnit( p, Mig_ObjId(pObj) );
801 Mpm_ObjSetCutBest( p, pObj, hCut );
802 Mpm_ObjSetCutList( p, pObj, hCut );
803 }
804 Mig_ManForEachCand( p->pMig, pObj )
805 Mpm_ObjSetEstRef( p, pObj, MPM_UNIT_REFS * Mig_ObjRefNum(pObj) );
806}
#define MPM_UNIT_REFS
Definition mpmInt.h:55
#define Mig_ManForEachCand(p, pObj)
Definition mpmMig.h:324
#define Mig_ManForEachCi(p, pObj, i)
Definition mpmMig.h:327
Here is the caller graph for this function:

◆ Mpm_ObjAddChoiceCutsToStore()

void Mpm_ObjAddChoiceCutsToStore ( Mpm_Man_t * p,
Mig_Obj_t * pRoot,
Mig_Obj_t * pObj,
int ReqTime )

Definition at line 529 of file mpmMap.c.

530{
531 Mpm_Cut_t * pCut;
532 int hCut, hNext, ArrTime;
533 int fCompl = Mig_ObjPhase(pRoot) ^ Mig_ObjPhase(pObj);
534 Mpm_ObjForEachCutSafe( p, pObj, hCut, pCut, hNext )
535 {
536 if ( Abc_Lit2Var(pCut->pLeaves[0]) == Mig_ObjId(pObj) )
537 continue;
538 ArrTime = Mpm_CutGetArrTime( p, pCut );
539 if ( ArrTime > ReqTime )
540 continue;
541 pCut->fCompl ^= fCompl;
542 pCut = Mpm_ManMergeCuts( p, pCut, NULL, NULL );
543 Mpm_ObjAddCutToStore( p, pCut, ArrTime );
544 }
545}
#define Mpm_ObjForEachCutSafe(p, pObj, hCut, pCut, hNext)
Definition mpmInt.h:214
unsigned fCompl
Definition mpmInt.h:66
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mpm_ObjAddCutToStore()

int Mpm_ObjAddCutToStore ( Mpm_Man_t * p,
Mpm_Cut_t * pCut,
int ArrTime )

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

Synopsis [Compares cut against those present in the store.]

Description []

SideEffects []

SeeAlso []

Definition at line 225 of file mpmMap.c.

226{
227 int fEnableContainment = 1;
228 Mpm_Uni_t * pUnit, * pUnitNew;
229 int k, iPivot, last;
230 // create new unit
231#ifdef MIG_RUNTIME
232 abctime clk;
233clk = Abc_Clock();
234#endif
235 pUnitNew = Mpm_CutSetupInfo( p, pCut, ArrTime );
236#ifdef MIG_RUNTIME
237p->timeEval += Abc_Clock() - clk;
238#endif
239 // special case when the cut store is empty
240 if ( p->nCutStore == 0 )
241 {
242 p->pCutStore[p->nCutStore++] = pUnitNew;
243 Vec_PtrPop( &p->vFreeUnits );
244 return 1;
245 }
246 // special case when the cut store is full and last cut is better than new cut
247 if ( p->nCutStore == p->nNumCuts-1 && p->pCutCmp(pUnitNew, p->pCutStore[p->nCutStore-1]) > 0 )
248 return 0;
249
250 // find place of the given cut in the store
251 assert( p->nCutStore <= p->nNumCuts );
252 for ( iPivot = p->nCutStore - 1; iPivot >= 0; iPivot-- )
253 if ( p->pCutCmp(pUnitNew, p->pCutStore[iPivot]) > 0 ) // iPivot-th cut is better than new cut
254 break;
255
256 if ( fEnableContainment )
257 {
258#ifdef MIG_RUNTIME
259clk = Abc_Clock();
260#endif
261 // filter this cut using other cuts
262 for ( k = 0; k <= iPivot; k++ )
263 {
264 pUnit = p->pCutStore[k];
265 if ( pUnitNew->pCut.nLeaves >= pUnit->pCut.nLeaves &&
266 (pUnitNew->uSign & pUnit->uSign) == pUnit->uSign &&
267 Mpm_CutIsContained(p, &pUnitNew->pCut, &pUnit->pCut) )
268 {
269#ifdef MIG_RUNTIME
270p->timeCompare += Abc_Clock() - clk;
271#endif
272 return 0;
273 }
274 }
275 }
276
277 // special case when the best cut is useless while the new cut is not
278 if ( p->pCutStore[0]->pCut.fUseless && !pUnitNew->pCut.fUseless )
279 iPivot = -1;
280
281 // add the cut to storage
282 assert( pUnitNew == (Mpm_Uni_t *)Vec_PtrEntryLast(&p->vFreeUnits) );
283 Vec_PtrPop( &p->vFreeUnits );
284
285 // insert this cut at location iPivot
286 iPivot++;
287 for ( k = p->nCutStore++; k > iPivot; k-- )
288 p->pCutStore[k] = p->pCutStore[k-1];
289 p->pCutStore[iPivot] = pUnitNew;
290
291 if ( fEnableContainment )
292 {
293 // filter other cuts using this cut
294 for ( k = last = iPivot+1; k < p->nCutStore; k++ )
295 {
296 pUnit = p->pCutStore[k];
297 if ( pUnitNew->pCut.nLeaves <= pUnit->pCut.nLeaves &&
298 (pUnitNew->uSign & pUnit->uSign) == pUnitNew->uSign &&
299 Mpm_CutIsContained(p, &pUnit->pCut, &pUnitNew->pCut) )
300 {
301 Vec_PtrPush( &p->vFreeUnits, pUnit );
302 continue;
303 }
304 p->pCutStore[last++] = p->pCutStore[k];
305 }
306 p->nCutStore = last;
307#ifdef MIG_RUNTIME
308p->timeCompare += Abc_Clock() - clk;
309#endif
310 }
311
312 // remove the last cut if too many
313 if ( p->nCutStore == p->nNumCuts )
314 Vec_PtrPush( &p->vFreeUnits, p->pCutStore[--p->nCutStore] );
315 assert( p->nCutStore < p->nNumCuts );
316 return 1;
317}
struct Mpm_Uni_t_ Mpm_Uni_t
Definition mpmInt.h:71
unsigned fUseless
Definition mpmInt.h:67
word uSign
Definition mpmInt.h:78
Here is the caller graph for this function:

◆ Mpm_ObjTranslateCutsFromStore()

void Mpm_ObjTranslateCutsFromStore ( Mpm_Man_t * p,
Mig_Obj_t * pObj )

Definition at line 547 of file mpmMap.c.

548{
549 Mpm_Cut_t * pCut = NULL;
550 Mpm_Uni_t * pUnit;
551 int i, *pList = Mpm_ObjCutListP( p, pObj );
552 assert( p->nCutStore > 0 && p->nCutStore <= p->nNumCuts );
553 assert( *pList == 0 );
554 // translate cuts
555 for ( i = 0; i < p->nCutStore; i++ )
556 {
557 pUnit = p->pCutStore[i];
558 *pList = Mpm_CutCreate( p, &pUnit->pCut, &pCut );
559 pList = &pCut->hNext;
560 Vec_PtrPush( &p->vFreeUnits, pUnit );
561 }
562 assert( Vec_PtrSize(&p->vFreeUnits) == p->nNumCuts + 1 );
563 if ( p->nCutStore == 1 && pCut->nLeaves < 2 )
564 *pList = 0;
565 else
566 *pList = Mpm_CutCreateUnit( p, Mig_ObjId(pObj) );
567}
Here is the caller graph for this function: