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

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START Amap_Cut_tAmap_ManDupCut (Amap_Man_t *p, Amap_Cut_t *pCut)
 DECLARATIONS ///.
 
void Amap_ManCleanRefs (Amap_Man_t *p)
 
float Amap_ManMaxDelay (Amap_Man_t *p)
 
void Amap_ManCleanData (Amap_Man_t *p)
 
float Amap_ManComputeMapping_rec (Amap_Man_t *p, Amap_Obj_t *pObj, int fCompl)
 
float Amap_ManComputeMapping (Amap_Man_t *p)
 
int Amap_ManCountInverters (Amap_Man_t *p)
 
void Amap_ManMatchNode (Amap_Man_t *p, Amap_Obj_t *pNode, int fFlow, int fRefs)
 
void Amap_ManMatch (Amap_Man_t *p, int fFlow, int fRefs)
 
void Amap_ManMap (Amap_Man_t *p)
 

Function Documentation

◆ Amap_ManCleanData()

void Amap_ManCleanData ( Amap_Man_t * p)

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

Synopsis [Cleans reference counters.]

Description []

SideEffects []

SeeAlso []

Definition at line 123 of file amapMatch.c.

124{
125 Amap_Obj_t * pObj;
126 int i;
127// Amap_ManForEachNode( p, pObj, i )
128// ABC_FREE( pObj->pData );
129 Amap_ManForEachObj( p, pObj, i )
130 pObj->pData = NULL;
131}
struct Amap_Obj_t_ Amap_Obj_t
Definition amapInt.h:71
#define Amap_ManForEachObj(p, pObj, i)
Definition amapInt.h:287
Cube * p
Definition exorList.c:222
void * pData
Definition amapInt.h:213
Here is the caller graph for this function:

◆ Amap_ManCleanRefs()

void Amap_ManCleanRefs ( Amap_Man_t * p)

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

Synopsis [Cleans reference counters.]

Description []

SideEffects []

SeeAlso []

Definition at line 83 of file amapMatch.c.

84{
85 Amap_Obj_t * pObj;
86 int i;
87 Amap_ManForEachObj( p, pObj, i )
88 pObj->nFouts[0] = pObj->nFouts[1] = 0;
89}
int nFouts[2]
Definition amapInt.h:218
Here is the caller graph for this function:

◆ Amap_ManComputeMapping()

float Amap_ManComputeMapping ( Amap_Man_t * p)

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

Synopsis [Compute nodes used in the mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 179 of file amapMatch.c.

180{
181 Amap_Obj_t * pObj;
182 float Area = 0.0;
183 int i;
185 Amap_ManForEachPo( p, pObj, i )
186 Area += Amap_ManComputeMapping_rec( p, Amap_ObjFanin0(p, pObj), Amap_ObjFaninC0(pObj) );
187 return Area;
188}
#define Amap_ManForEachPo(p, pObj, i)
Definition amapInt.h:284
float Amap_ManComputeMapping_rec(Amap_Man_t *p, Amap_Obj_t *pObj, int fCompl)
Definition amapMatch.c:144
void Amap_ManCleanRefs(Amap_Man_t *p)
Definition amapMatch.c:83
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Amap_ManComputeMapping_rec()

float Amap_ManComputeMapping_rec ( Amap_Man_t * p,
Amap_Obj_t * pObj,
int fCompl )

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

Synopsis [Compute nodes used in the mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 144 of file amapMatch.c.

145{
146 Amap_Mat_t * pM = &pObj->Best;
147 Amap_Obj_t * pFanin;
148 Amap_Gat_t * pGate;
149 int i, iFanin, fComplFanin;
150 float Area;
151 if ( pObj->nFouts[fCompl]++ + pObj->nFouts[!fCompl] > 0 )
152 return 0.0;
153 if ( Amap_ObjIsPi(pObj) || Amap_ObjIsConst1(pObj) )
154 return 0.0;
155 pGate = Amap_LibGate( p->pLib, pM->pSet->iGate );
156 assert( pGate->nPins == pM->pCut->nFans );
157 Area = pGate->dArea;
158 for ( i = 0; i < (int)pGate->nPins; i++ )
159 {
160 iFanin = Abc_Lit2Var( pM->pSet->Ins[i] );
161 pFanin = Amap_ManObj( p, Abc_Lit2Var(pM->pCut->Fans[iFanin]) );
162 fComplFanin = Abc_LitIsCompl( pM->pSet->Ins[i] ) ^ Abc_LitIsCompl( pM->pCut->Fans[iFanin] );
163 Area += Amap_ManComputeMapping_rec( p, pFanin, fComplFanin );
164 }
165 return Area;
166}
struct Amap_Gat_t_ Amap_Gat_t
Definition amapInt.h:66
struct Amap_Mat_t_ Amap_Mat_t
Definition amapInt.h:73
unsigned nFans
Definition amapInt.h:188
int Fans[0]
Definition amapInt.h:189
double dArea
Definition amapInt.h:157
unsigned nPins
Definition amapInt.h:162
Amap_Set_t * pSet
Definition amapInt.h:194
Amap_Cut_t * pCut
Definition amapInt.h:193
Amap_Mat_t Best
Definition amapInt.h:219
unsigned iGate
Definition amapInt.h:168
char Ins[AMAP_MAXINS]
Definition amapInt.h:171
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Amap_ManCountInverters()

int Amap_ManCountInverters ( Amap_Man_t * p)

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

Synopsis [Counts the number of inverters to be added.]

Description [Should be called after mapping has been set.]

SideEffects []

SeeAlso []

Definition at line 201 of file amapMatch.c.

202{
203 Amap_Obj_t * pObj;
204 int i, Counter = 0;
205 Amap_ManForEachObj( p, pObj, i )
206 Counter += (int)(pObj->nFouts[!pObj->fPolar] > 0);
207 return Counter;
208}
unsigned fPolar
Definition amapInt.h:206
Here is the caller graph for this function:

◆ Amap_ManDupCut()

ABC_NAMESPACE_IMPL_START Amap_Cut_t * Amap_ManDupCut ( Amap_Man_t * p,
Amap_Cut_t * pCut )

DECLARATIONS ///.

CFile****************************************************************

FileName [amapMatch.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Technology mapper for standard cells.]

Synopsis []

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id
amapMatch.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

] FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis [Duplicates the cut using new memory manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file amapMatch.c.

46{
47 Amap_Cut_t * pNew;
48 int nBytes = sizeof(Amap_Cut_t) + sizeof(int) * pCut->nFans;
49 pNew = (Amap_Cut_t *)Aig_MmFlexEntryFetch( p->pMemCutBest, nBytes );
50 memcpy( pNew, pCut, (size_t)nBytes );
51 return pNew;
52}
char * Aig_MmFlexEntryFetch(Aig_MmFlex_t *p, int nBytes)
Definition aigMem.c:366
struct Amap_Cut_t_ Amap_Cut_t
Definition amapInt.h:72
char * memcpy()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Amap_ManMap()

void Amap_ManMap ( Amap_Man_t * p)

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

Synopsis [Performs mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 657 of file amapMatch.c.

658{
659 int i;
660 Amap_ManMerge( p );
661 for ( i = 0; i < p->pPars->nIterFlow; i++ )
662 Amap_ManMatch( p, 1, i>0 );
663 for ( i = 0; i < p->pPars->nIterArea; i++ )
664 Amap_ManMatch( p, 0, p->pPars->nIterFlow>0||i>0 );
665/*
666 for ( i = 0; i < p->pPars->nIterFlow; i++ )
667 Amap_ManMatch( p, 1, 1 );
668 for ( i = 0; i < p->pPars->nIterArea; i++ )
669 Amap_ManMatch( p, 0, 1 );
670*/
672}
void Amap_ManMerge(Amap_Man_t *p)
Definition amapMerge.c:514
void Amap_ManMatch(Amap_Man_t *p, int fFlow, int fRefs)
Definition amapMatch.c:618
void Amap_ManCleanData(Amap_Man_t *p)
Definition amapMatch.c:123
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Amap_ManMatch()

void Amap_ManMatch ( Amap_Man_t * p,
int fFlow,
int fRefs )

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

Synopsis [Performs one round of mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 618 of file amapMatch.c.

619{
620 Aig_MmFlex_t * pMemOld;
621 Amap_Obj_t * pObj;
622 float Area;
623 int i, nInvs;
624 abctime clk = Abc_Clock();
625 pMemOld = p->pMemCutBest;
626 p->pMemCutBest = Aig_MmFlexStart();
627 Amap_ManForEachNode( p, pObj, i )
628 if ( pObj->pData )
629 Amap_ManMatchNode( p, pObj, fFlow, fRefs );
630 Aig_MmFlexStop( pMemOld, 0 );
631 Area = Amap_ManComputeMapping( p );
632 nInvs = Amap_ManCountInverters( p );
633if ( p->pPars->fVerbose )
634{
635 printf( "Area =%9.2f. Gate =%9.2f. Inv =%9.2f. (%6d.) Delay =%6.2f. ",
636 Area + nInvs * p->fAreaInv,
637 Area, nInvs * p->fAreaInv, nInvs,
639ABC_PRT( "Time ", Abc_Clock() - clk );
640}
641 // test procedures
642// Amap_ManForEachNode( p, pObj, i )
643// Amap_CutAreaTest( p, pObj );
644}
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_PRT(a, t)
Definition abc_global.h:255
void Aig_MmFlexStop(Aig_MmFlex_t *p, int fVerbose)
Definition aigMem.c:337
struct Aig_MmFlex_t_ Aig_MmFlex_t
Definition aig.h:53
Aig_MmFlex_t * Aig_MmFlexStart()
Definition aigMem.c:305
#define Amap_ManForEachNode(p, pObj, i)
Definition amapInt.h:290
void Amap_ManMatchNode(Amap_Man_t *p, Amap_Obj_t *pNode, int fFlow, int fRefs)
Definition amapMatch.c:519
float Amap_ManMaxDelay(Amap_Man_t *p)
Definition amapMatch.c:102
float Amap_ManComputeMapping(Amap_Man_t *p)
Definition amapMatch.c:179
int Amap_ManCountInverters(Amap_Man_t *p)
Definition amapMatch.c:201
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Amap_ManMatchNode()

void Amap_ManMatchNode ( Amap_Man_t * p,
Amap_Obj_t * pNode,
int fFlow,
int fRefs )

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

Synopsis [Computes the best match at each node.]

Description []

SideEffects []

SeeAlso []

Definition at line 519 of file amapMatch.c.

520{
521 int fVerbose = 0; //(pNode->Level == 2 || pNode->Level == 4);
522 int fVeryVerbose = fVerbose;
523
524 Amap_Mat_t MA = {0}, MD = {0}, M = {0};
525 Amap_Mat_t * pMBestA = &MA, * pMBestD = &MD, * pMThis = &M, * pMBest;
526 Amap_Cut_t * pCut;
527 Amap_Set_t * pSet;
528 Amap_Nod_t * pNod;
529 int i;
530
531 if ( fRefs )
532 pNode->EstRefs = (float)((2.0 * pNode->EstRefs + Amap_ObjRefsTotal(pNode)) / 3.0);
533 else
534 pNode->EstRefs = (float)pNode->nRefs;
535 if ( fRefs && Amap_ObjRefsTotal(pNode) > 0 )
536 Amap_CutAreaDeref( p, &pNode->Best );
537
538 if ( fVerbose )
539 printf( "\nNode %d (%d)\n", pNode->Id, pNode->Level );
540
541 pMBestA->pCut = pMBestD->pCut = NULL;
542 Amap_NodeForEachCut( pNode, pCut, i )
543 {
544 if ( pCut->iMat == 0 )
545 continue;
546 pNod = Amap_LibNod( p->pLib, pCut->iMat );
547 Amap_LibNodeForEachSet( pNod, pSet )
548 {
549 Amap_ManMatchStart( pMThis, pCut, pSet );
550 if ( fFlow )
551 Amap_ManMatchGetFlows( p, pMThis );
552 else
553 Amap_ManMatchGetExacts( p, pNode, pMThis );
554 if ( pMBestD->pCut == NULL || Amap_CutCompareDelay(p, pMBestD, pMThis) == 1 )
555 *pMBestD = *pMThis;
556 if ( pMBestA->pCut == NULL || Amap_CutCompareArea(p, pMBestA, pMThis) == 1 )
557 *pMBestA = *pMThis;
558
559 if ( fVeryVerbose )
560 {
561 printf( "Cut %2d (%d) : ", i, pCut->nFans );
562 printf( "Gate %10s ", Amap_LibGate(p->pLib, pMThis->pSet->iGate)->pName );
563 printf( "%s ", pMThis->pSet->fInv ? "inv" : " " );
564 printf( "Delay %5.2f ", pMThis->Delay );
565 printf( "Area %5.2f ", pMThis->Area );
566 printf( "\n" );
567 }
568 }
569 }
570
571 if ( Abc_AbsFloat(pMBestA->Area - pMBestD->Area) / pMBestD->Area >= p->pPars->fADratio * Abc_AbsFloat(pMBestA->Delay - pMBestD->Delay) / pMBestA->Delay )
572 pMBest = pMBestA;
573 else
574 pMBest = pMBestD;
575
576 if ( fVerbose )
577 {
578 printf( "BEST MATCHA: " );
579 printf( "Gate %10s ", Amap_LibGate(p->pLib, pMBestA->pSet->iGate)->pName );
580 printf( "%s ", pMBestA->pSet->fInv ? "inv" : " " );
581 printf( "Delay %5.2f ", pMBestA->Delay );
582 printf( "Area %5.2f ", pMBestA->Area );
583 printf( "\n" );
584
585 printf( "BEST MATCHD: " );
586 printf( "Gate %10s ", Amap_LibGate(p->pLib, pMBestD->pSet->iGate)->pName );
587 printf( "%s ", pMBestD->pSet->fInv ? "inv" : " " );
588 printf( "Delay %5.2f ", pMBestD->Delay );
589 printf( "Area %5.2f ", pMBestD->Area );
590 printf( "\n" );
591
592 printf( "BEST MATCH : " );
593 printf( "Gate %10s ", Amap_LibGate(p->pLib, pMBest->pSet->iGate)->pName );
594 printf( "%s ", pMBest->pSet->fInv ? "inv" : " " );
595 printf( "Delay %5.2f ", pMBest->Delay );
596 printf( "Area %5.2f ", pMBest->Area );
597 printf( "\n" );
598 }
599
600 pNode->fPolar = pMBest->pCut->fInv ^ pMBest->pSet->fInv;
601 pNode->Best = *pMBest;
602 pNode->Best.pCut = Amap_ManDupCut( p, pNode->Best.pCut );
603 if ( fRefs && Amap_ObjRefsTotal(pNode) > 0 )
604 Amap_CutAreaRef( p, &pNode->Best );
605}
#define Amap_NodeForEachCut(pNode, pCut, i)
Definition amapInt.h:301
struct Amap_Set_t_ Amap_Set_t
Definition amapInt.h:68
#define Amap_LibNodeForEachSet(pNod, pSet)
Definition amapInt.h:306
struct Amap_Nod_t_ Amap_Nod_t
Definition amapInt.h:67
ABC_NAMESPACE_IMPL_START Amap_Cut_t * Amap_ManDupCut(Amap_Man_t *p, Amap_Cut_t *pCut)
DECLARATIONS ///.
Definition amapMatch.c:45
word M(word f1, word f2, int n)
Definition kitPerm.c:240
unsigned iMat
Definition amapInt.h:186
float Delay
Definition amapInt.h:197
float Area
Definition amapInt.h:195
float EstRefs
Definition amapInt.h:217
unsigned Id
Definition amapInt.h:202
unsigned Level
Definition amapInt.h:207
unsigned fInv
Definition amapInt.h:169
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Amap_ManMaxDelay()

float Amap_ManMaxDelay ( Amap_Man_t * p)

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

Synopsis [Computes delay.]

Description []

SideEffects []

SeeAlso []

Definition at line 102 of file amapMatch.c.

103{
104 Amap_Obj_t * pObj;
105 float Delay = 0.0;
106 int i;
107 Amap_ManForEachPo( p, pObj, i )
108 Delay = Abc_MaxInt( Delay, Amap_ObjFanin0(p,pObj)->Best.Delay );
109 return Delay;
110}
Here is the caller graph for this function: