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

Go to the source code of this file.

Classes

struct  Map_CutTableStrutct_t
 

Macros

#define MAP_CUTS_MAX_COMPUTE   1000
 DECLARATIONS ///.
 
#define MAP_CUTS_MAX_USE   250
 
#define Map_ListForEachCut(pList, pCut)
 
#define Map_ListForEachCutSafe(pList, pCut, pCut2)
 

Typedefs

typedef struct Map_CutTableStrutct_t Map_CutTable_t
 

Functions

int Map_MappingCountAllCuts (Map_Man_t *pMan)
 FUNCTION DEFINITIONS ///.
 
void Map_MappingCutsInput (Map_Man_t *p, Map_Node_t *pNode)
 
void Map_MappingCuts (Map_Man_t *p)
 GLOBAL VARIABLES ///.
 
Map_Cut_tMap_CutMergeLists2 (Map_Man_t *p, Map_CutTable_t *pTable, Map_Cut_t *pList1, Map_Cut_t *pList2, int fComp1, int fComp2)
 
int Map_CutSortCutsCompare (Map_Cut_t **pC1, Map_Cut_t **pC2)
 

Macro Definition Documentation

◆ MAP_CUTS_MAX_COMPUTE

#define MAP_CUTS_MAX_COMPUTE   1000

DECLARATIONS ///.

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

FileName [mapperCut.c]

PackageName [MVSIS 1.3: Multi-valued logic synthesis system.]

Synopsis [Generic technology mapping engine.]

Author [MVSIS Group]

Affiliation [UC Berkeley]

Date [Ver. 2.0. Started - June 1, 2004.]

Revision [

Id
mapperCut.c,v 1.12 2005/02/28 05:34:27 alanmi Exp

]

Definition at line 29 of file mapperCut.c.

◆ MAP_CUTS_MAX_USE

#define MAP_CUTS_MAX_USE   250

Definition at line 31 of file mapperCut.c.

◆ Map_ListForEachCut

#define Map_ListForEachCut ( pList,
pCut )
Value:
for ( pCut = pList; \
pCut; \
pCut = pCut->pNext )

Definition at line 74 of file mapperCut.c.

74#define Map_ListForEachCut( pList, pCut ) \
75 for ( pCut = pList; \
76 pCut; \
77 pCut = pCut->pNext )

◆ Map_ListForEachCutSafe

#define Map_ListForEachCutSafe ( pList,
pCut,
pCut2 )
Value:
for ( pCut = pList, \
pCut2 = pCut? pCut->pNext: NULL; \
pCut; \
pCut = pCut2, \
pCut2 = pCut? pCut->pNext: NULL )

Definition at line 78 of file mapperCut.c.

78#define Map_ListForEachCutSafe( pList, pCut, pCut2 ) \
79 for ( pCut = pList, \
80 pCut2 = pCut? pCut->pNext: NULL; \
81 pCut; \
82 pCut = pCut2, \
83 pCut2 = pCut? pCut->pNext: NULL )

Typedef Documentation

◆ Map_CutTable_t

Definition at line 34 of file mapperCut.c.

Function Documentation

◆ Map_CutMergeLists2()

Map_Cut_t * Map_CutMergeLists2 ( Map_Man_t * p,
Map_CutTable_t * pTable,
Map_Cut_t * pList1,
Map_Cut_t * pList2,
int fComp1,
int fComp2 )

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

Synopsis [Merges two lists of cuts.]

Description []

SideEffects []

SeeAlso []

Definition at line 522 of file mapperCut.c.

524{
525 Map_Node_t * ppNodes[6];
526 Map_Cut_t * pListNew, ** ppListNew, * pLists[7] = { NULL };
527 Map_Cut_t * pCut, * pPrev, * pTemp1, * pTemp2;
528 int nNodes, Counter, i;
529
530 // prepare the manager for the cut computation
531 Map_CutTableRestart( pTable );
532 // go through the cut pairs
533 Counter = 0;
534 for ( pTemp1 = pList1; pTemp1; pTemp1 = pTemp1->pNext )
535 for ( pTemp2 = pList2; pTemp2; pTemp2 = pTemp2->pNext )
536 {
537 // check if k-feasible cut exists
538 nNodes = Map_CutMergeTwo( pTemp1, pTemp2, ppNodes, p->nVarsMax );
539 if ( nNodes == 0 )
540 continue;
541 // consider the cut for possible addition to the set of new cuts
542 pCut = Map_CutTableConsider( p, pTable, ppNodes, nNodes );
543 if ( pCut == NULL )
544 continue;
545 // add data to the cut
546 pCut->pOne = Map_CutNotCond( pTemp1, fComp1 );
547 pCut->pTwo = Map_CutNotCond( pTemp2, fComp2 );
548 // add it to the corresponding list
549 pCut->pNext = pLists[(int)pCut->nLeaves];
550 pLists[(int)pCut->nLeaves] = pCut;
551 // count this cut and quit if limit is reached
552 Counter++;
553 if ( Counter == MAP_CUTS_MAX_COMPUTE )
554 goto QUITS;
555 }
556QUITS :
557 // combine all the lists into one
558 pListNew = NULL;
559 ppListNew = &pListNew;
560 for ( i = 1; i <= p->nVarsMax; i++ )
561 {
562 if ( pLists[i] == NULL )
563 continue;
564 // find the last entry
565 for ( pPrev = pLists[i], pCut = pPrev->pNext; pCut;
566 pPrev = pCut, pCut = pCut->pNext );
567 // connect these lists
568 *ppListNew = pLists[i];
569 ppListNew = &pPrev->pNext;
570 }
571 *ppListNew = NULL;
572 // soft the cuts by arrival times and use only the first MAP_CUTS_MAX_USE
573 pListNew = Map_CutSortCuts( p, pTable, pListNew );
574 return pListNew;
575}
Cube * p
Definition exorList.c:222
#define MAP_CUTS_MAX_COMPUTE
DECLARATIONS ///.
Definition mapperCut.c:29
#define Map_CutNotCond(p, c)
Definition mapperInt.h:71
struct Map_CutStruct_t_ Map_Cut_t
Definition mapper.h:43
struct Map_NodeStruct_t_ Map_Node_t
Definition mapper.h:41
Map_Cut_t * pTwo
Definition mapperInt.h:268
Map_Cut_t * pOne
Definition mapperInt.h:267
Map_Cut_t * pNext
Definition mapperInt.h:266

◆ Map_CutSortCutsCompare()

int Map_CutSortCutsCompare ( Map_Cut_t ** pC1,
Map_Cut_t ** pC2 )

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

Synopsis [Compares the cuts by the number of leaves and then by delay.]

Description []

SideEffects []

SeeAlso []

Definition at line 980 of file mapperCut.c.

981{
982 if ( (*pC1)->nLeaves < (*pC2)->nLeaves )
983 return -1;
984 if ( (*pC1)->nLeaves > (*pC2)->nLeaves )
985 return 1;
986 return 0;
987}

◆ Map_MappingCountAllCuts()

int Map_MappingCountAllCuts ( Map_Man_t * pMan)

FUNCTION DEFINITIONS ///.

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

Synopsis [Counts all the cuts.]

Description []

SideEffects []

SeeAlso []

Definition at line 100 of file mapperCut.c.

101{
102 Map_Node_t * pNode;
103 Map_Cut_t * pCut;
104 int i, nCuts;
105// int nCuts55 = 0, nCuts5x = 0, nCuts4x = 0, nCuts3x = 0;
106// int pCounts[7] = {0};
107 nCuts = 0;
108 for ( i = 0; i < pMan->nBins; i++ )
109 for ( pNode = pMan->pBins[i]; pNode; pNode = pNode->pNext )
110 for ( pCut = pNode->pCuts; pCut; pCut = pCut->pNext )
111 if ( pCut->nLeaves > 1 ) // skip the elementary cuts
112 {
113 nCuts++;
114/*
115 if ( Map_CutRegular(pCut->pOne)->nLeaves == 5 && Map_CutRegular(pCut->pTwo)->nLeaves == 5 )
116 nCuts55++;
117 if ( Map_CutRegular(pCut->pOne)->nLeaves == 5 || Map_CutRegular(pCut->pTwo)->nLeaves == 5 )
118 nCuts5x++;
119 else if ( Map_CutRegular(pCut->pOne)->nLeaves == 4 || Map_CutRegular(pCut->pTwo)->nLeaves == 4 )
120 nCuts4x++;
121 else if ( Map_CutRegular(pCut->pOne)->nLeaves == 3 || Map_CutRegular(pCut->pTwo)->nLeaves == 3 )
122 nCuts3x++;
123*/
124// pCounts[ Map_CutRegular(pCut->pOne)->nLeaves ]++;
125// pCounts[ Map_CutRegular(pCut->pTwo)->nLeaves ]++;
126 }
127// printf( "Total cuts = %6d. 55 = %6d. 5x = %6d. 4x = %6d. 3x = %6d.\n", nCuts, nCuts55, nCuts5x, nCuts4x, nCuts3x );
128
129// printf( "Total cuts = %6d. 6= %6d. 5= %6d. 4= %6d. 3= %6d. 2= %6d. 1= %6d.\n",
130// nCuts, pCounts[6], pCounts[5], pCounts[4], pCounts[3], pCounts[2], pCounts[1] );
131 return nCuts;
132}
Map_Node_t * pNext
Definition mapperInt.h:209
Map_Cut_t * pCuts
Definition mapperInt.h:244
Here is the caller graph for this function:

◆ Map_MappingCuts()

void Map_MappingCuts ( Map_Man_t * p)

GLOBAL VARIABLES ///.

FUNCTION DEFINITIONS ///

Definition at line 172 of file mapperCut.c.

173{
174 ProgressBar * pProgress;
175 Map_CutTable_t * pTable;
176 Map_Node_t * pNode;
177 int nCuts, nNodes, i;
178 abctime clk = Abc_Clock();
179 // set the elementary cuts for the PI variables
180 assert( p->nVarsMax > 1 && p->nVarsMax < 7 );
181 for ( i = 0; i < p->nInputs; i++ )
182 Map_MappingCutsInput( p, p->pInputs[i] );
183
184 // compute the cuts for the internal nodes
185 nNodes = p->vMapObjs->nSize;
186 pProgress = Extra_ProgressBarStart( stdout, nNodes );
187 pTable = Map_CutTableStart( p );
188 for ( i = 0; i < nNodes; i++ )
189 {
190 pNode = p->vMapObjs->pArray[i];
191 if ( Map_NodeIsBuf(pNode) )
192 Map_MappingCutsInput( p, pNode );
193 else if ( Map_NodeIsAnd(pNode) )
194 Map_CutCompute( p, pTable, pNode );
195 else continue;
196 Extra_ProgressBarUpdate( pProgress, i, "Cuts ..." );
197 }
198 Extra_ProgressBarStop( pProgress );
199 Map_CutTableStop( pTable );
200
201 // report the stats
202 if ( p->fVerbose )
203 {
204 nCuts = Map_MappingCountAllCuts(p);
205 printf( "Nodes = %6d. Total %d-feasible cuts = %10d. Per node = %.1f. ",
206 p->nNodes, p->nVarsMax, nCuts, ((float)nCuts)/p->nNodes );
207 ABC_PRT( "Time", Abc_Clock() - clk );
208 }
209
210 // print the cuts for the first primary output
211// Map_CutListPrint( p, Map_Regular(p->pOutputs[0]) );
212}
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_PRT(a, t)
Definition abc_global.h:255
ABC_NAMESPACE_IMPL_START typedef char ProgressBar
Definition bbrNtbdd.c:27
void Extra_ProgressBarStop(ProgressBar *p)
ProgressBar * Extra_ProgressBarStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
int Map_MappingCountAllCuts(Map_Man_t *pMan)
FUNCTION DEFINITIONS ///.
Definition mapperCut.c:100
void Map_MappingCutsInput(Map_Man_t *p, Map_Node_t *pNode)
Definition mapperCut.c:158
struct Map_CutTableStrutct_t Map_CutTable_t
Definition mapperCut.c:34
int Map_NodeIsBuf(Map_Node_t *p)
int Map_NodeIsAnd(Map_Node_t *p)
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Map_MappingCutsInput()

void Map_MappingCutsInput ( Map_Man_t * p,
Map_Node_t * pNode )

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

Synopsis [Computes the cuts for each node in the object graph.]

Description [The cuts are computed in one sweep over the mapping graph. First, the elementary cuts, which include the node itself, are assigned to the PI nodes. The internal nodes are considered in the DFS order. Each node is two-input AND-gate. So to compute the cuts at a node, we need to merge the sets of cuts of its two predecessors. The merged set contains only unique cuts with the number of inputs equal to k or less. Finally, the elementary cut, composed of the node itself, is added to the set of cuts for the node.

This procedure is pretty fast for 5-feasible cuts, but it dramatically slows down on some "dense" networks when computing 6-feasible cuts. The problem is that there are too many cuts in this case. We should think how to heuristically trim the number of cuts in such cases, to have reasonable runtime.]

SideEffects []

SeeAlso []

Definition at line 158 of file mapperCut.c.

159{
160 Map_Cut_t * pCut;
161 assert( Map_NodeIsVar(pNode) || Map_NodeIsBuf(pNode) );
162 pCut = Map_CutAlloc( p );
163 pCut->nLeaves = 1;
164 pCut->ppLeaves[0] = pNode;
165 pNode->pCuts = pCut;
166 pNode->pCutBest[0] = NULL; // negative polarity is not mapped
167 pNode->pCutBest[1] = pCut; // positive polarity is a trivial cut
168 pCut->uTruth = 0xAAAAAAAA; // the first variable "1010"
169 pCut->M[0].AreaFlow = 0.0;
170 pCut->M[1].AreaFlow = 0.0;
171}
Map_Cut_t * Map_CutAlloc(Map_Man_t *p)
DECLARATIONS ///.
int Map_NodeIsVar(Map_Node_t *p)
Map_Match_t M[2]
Definition mapperInt.h:275
Map_Node_t * ppLeaves[6]
Definition mapperInt.h:269
unsigned uTruth
Definition mapperInt.h:270
Map_Cut_t * pCutBest[2]
Definition mapperInt.h:243
Here is the call graph for this function:
Here is the caller graph for this function: