abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
nwkMerge.h File Reference

Go to the source code of this file.

Data Structures

struct  Nwk_LMPars_t_
 
struct  Nwk_Edg_t_
 
struct  Nwk_Vrt_t_
 
struct  Nwk_Grf_t_
 

Macros

#define NWK_MAX_LIST   16
 INCLUDES ///. More...
 
#define Nwk_GraphForEachEdge(p, pEdge, k)
 MACRO DEFINITIONS ///. More...
 
#define Nwk_ListForEachVertex(p, List, pVrt)
 
#define Nwk_VertexForEachAdjacent(p, pVrt, pNext, k)   for ( k = 0; (k < pVrt->nEdges) && (((pNext) = p->pVerts[pVrt->pEdges[k]]), 1); k++ )
 

Typedefs

typedef struct Nwk_LMPars_t_ Nwk_LMPars_t
 BASIC TYPES ///. More...
 
typedef struct Nwk_Edg_t_ Nwk_Edg_t
 
typedef struct Nwk_Vrt_t_ Nwk_Vrt_t
 
typedef struct Nwk_Grf_t_ Nwk_Grf_t
 

Functions

ABC_DLL Nwk_Grf_tNwk_ManGraphAlloc (int nVertsMax)
 INLINED FUNCTIONS ///. More...
 
ABC_DLL void Nwk_ManGraphFree (Nwk_Grf_t *p)
 
ABC_DLL void Nwk_ManGraphReportMemoryUsage (Nwk_Grf_t *p)
 
ABC_DLL void Nwk_ManGraphHashEdge (Nwk_Grf_t *p, int iLut1, int iLut2)
 
ABC_DLL void Nwk_ManGraphSolve (Nwk_Grf_t *p)
 
ABC_DLL int Nwk_ManLutMergeGraphTest (char *pFileName)
 

Macro Definition Documentation

#define Nwk_GraphForEachEdge (   p,
  pEdge,
 
)
Value:
for ( k = 0; k < p->nEdgeHash; k++ ) \
for ( pEdge = p->pEdgeHash[k]; pEdge; pEdge = pEdge->pNext )
static Llb_Mgr_t * p
Definition: llb3Image.c:950

MACRO DEFINITIONS ///.

Definition at line 111 of file nwkMerge.h.

#define Nwk_ListForEachVertex (   p,
  List,
  pVrt 
)
Value:
for ( pVrt = List? p->pVerts[List] : NULL; pVrt; \
pVrt = pVrt->iNext? p->pVerts[pVrt->iNext] : NULL )
static Llb_Mgr_t * p
Definition: llb3Image.c:950

Definition at line 115 of file nwkMerge.h.

#define NWK_MAX_LIST   16

INCLUDES ///.

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

FileName [nwkMerge.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Logic network representation.]

Synopsis [External declarations.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

Id:
nwkMerge.h,v 1.1 2008/05/14 22:13:09 wudenni Exp

]PARAMETERS ///

Definition at line 38 of file nwkMerge.h.

#define Nwk_VertexForEachAdjacent (   p,
  pVrt,
  pNext,
 
)    for ( k = 0; (k < pVrt->nEdges) && (((pNext) = p->pVerts[pVrt->pEdges[k]]), 1); k++ )

Definition at line 119 of file nwkMerge.h.

Typedef Documentation

typedef struct Nwk_Edg_t_ Nwk_Edg_t

Definition at line 60 of file nwkMerge.h.

typedef struct Nwk_Grf_t_ Nwk_Grf_t

Definition at line 80 of file nwkMerge.h.

typedef struct Nwk_LMPars_t_ Nwk_LMPars_t

BASIC TYPES ///.

Definition at line 45 of file nwkMerge.h.

typedef struct Nwk_Vrt_t_ Nwk_Vrt_t

Definition at line 69 of file nwkMerge.h.

Function Documentation

ABC_DLL Nwk_Grf_t* Nwk_ManGraphAlloc ( int  nVertsMax)

INLINED FUNCTIONS ///.

ITERATORS ///FUNCTION DECLARATIONS ///

INLINED FUNCTIONS ///.

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

FileName [nwkMerge.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Netlist representation.]

Synopsis [LUT merging algorithm.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Allocates the graph.]

Description []

SideEffects []

SeeAlso []

Definition at line 46 of file nwkMerge.c.

47 {
48  Nwk_Grf_t * p;
49  p = ABC_ALLOC( Nwk_Grf_t, 1 );
50  memset( p, 0, sizeof(Nwk_Grf_t) );
51  p->nVertsMax = nVertsMax;
52  p->nEdgeHash = Abc_PrimeCudd( 3 * nVertsMax );
54  p->pMemEdges = Aig_MmFixedStart( sizeof(Nwk_Edg_t), p->nEdgeHash );
55  p->vPairs = Vec_IntAlloc( 1000 );
56  return p;
57 }
char * memset()
static int Abc_PrimeCudd(unsigned int p)
Definition: abc_global.h:383
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int nEdgeHash
Definition: nwkMerge.h:86
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int nVertsMax
Definition: nwkMerge.h:85
Aig_MmFixed_t * Aig_MmFixedStart(int nEntrySize, int nEntriesMax)
FUNCTION DEFINITIONS ///.
Definition: aigMem.c:96
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
Nwk_Edg_t ** pEdgeHash
Definition: nwkMerge.h:87
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
Vec_Int_t * vPairs
Definition: nwkMerge.h:98
Aig_MmFixed_t * pMemEdges
Definition: nwkMerge.h:88
ABC_DLL void Nwk_ManGraphFree ( Nwk_Grf_t p)

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

Synopsis [Deallocates the graph.]

Description []

SideEffects []

SeeAlso []

Definition at line 70 of file nwkMerge.c.

71 {
72  if ( p->vPairs ) Vec_IntFree( p->vPairs );
73  if ( p->pMemEdges ) Aig_MmFixedStop( p->pMemEdges, 0 );
74  if ( p->pMemVerts ) Aig_MmFlexStop( p->pMemVerts, 0 );
75  ABC_FREE( p->pVerts );
76  ABC_FREE( p->pEdgeHash );
77  ABC_FREE( p->pMapLut2Id );
78  ABC_FREE( p->pMapId2Lut );
79  ABC_FREE( p );
80 }
void Aig_MmFixedStop(Aig_MmFixed_t *p, int fVerbose)
Definition: aigMem.c:132
Nwk_Vrt_t ** pVerts
Definition: nwkMerge.h:92
Aig_MmFlex_t * pMemVerts
Definition: nwkMerge.h:93
Nwk_Edg_t ** pEdgeHash
Definition: nwkMerge.h:87
int * pMapLut2Id
Definition: nwkMerge.h:100
int * pMapId2Lut
Definition: nwkMerge.h:101
#define ABC_FREE(obj)
Definition: abc_global.h:232
void Aig_MmFlexStop(Aig_MmFlex_t *p, int fVerbose)
Definition: aigMem.c:337
Vec_Int_t * vPairs
Definition: nwkMerge.h:98
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
Aig_MmFixed_t * pMemEdges
Definition: nwkMerge.h:88
ABC_DLL void Nwk_ManGraphHashEdge ( Nwk_Grf_t p,
int  iLut1,
int  iLut2 
)

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

Synopsis [Finds or adds the edge to the graph.]

Description []

SideEffects []

SeeAlso []

Definition at line 119 of file nwkMerge.c.

120 {
121  Nwk_Edg_t * pEntry;
122  unsigned Key;
123  if ( iLut1 == iLut2 )
124  return;
125  if ( iLut1 > iLut2 )
126  {
127  Key = iLut1;
128  iLut1 = iLut2;
129  iLut2 = Key;
130  }
131  assert( iLut1 < iLut2 );
132  if ( p->nObjs < iLut2 )
133  p->nObjs = iLut2;
134  Key = (unsigned)(741457 * iLut1 + 4256249 * iLut2) % p->nEdgeHash;
135  for ( pEntry = p->pEdgeHash[Key]; pEntry; pEntry = pEntry->pNext )
136  if ( pEntry->iNode1 == iLut1 && pEntry->iNode2 == iLut2 )
137  return;
138  pEntry = (Nwk_Edg_t *)Aig_MmFixedEntryFetch( p->pMemEdges );
139  pEntry->iNode1 = iLut1;
140  pEntry->iNode2 = iLut2;
141  pEntry->pNext = p->pEdgeHash[Key];
142  p->pEdgeHash[Key] = pEntry;
143  p->nEdges++;
144 }
int iNode1
Definition: nwkMerge.h:63
int nEdgeHash
Definition: nwkMerge.h:86
int nEdges
Definition: nwkMerge.h:90
int nObjs
Definition: nwkMerge.h:84
char * Aig_MmFixedEntryFetch(Aig_MmFixed_t *p)
Definition: aigMem.c:161
Nwk_Edg_t ** pEdgeHash
Definition: nwkMerge.h:87
int iNode2
Definition: nwkMerge.h:64
Nwk_Edg_t * pNext
Definition: nwkMerge.h:65
#define assert(ex)
Definition: util_old.h:213
Aig_MmFixed_t * pMemEdges
Definition: nwkMerge.h:88
ABC_DLL void Nwk_ManGraphReportMemoryUsage ( Nwk_Grf_t p)

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

Synopsis [Prepares the graph for solving the problem.]

Description []

SideEffects []

SeeAlso []

Definition at line 93 of file nwkMerge.c.

94 {
95  p->nMemBytes1 =
96  sizeof(Nwk_Grf_t) +
97  sizeof(void *) * p->nEdgeHash +
98  sizeof(int) * (p->nObjs + p->nVertsMax) +
99  sizeof(Nwk_Edg_t) * p->nEdges;
100  p->nMemBytes2 =
101  sizeof(Nwk_Vrt_t) * p->nVerts +
102  sizeof(int) * 2 * p->nEdges;
103  printf( "Memory usage stats: Preprocessing = %.2f MB. Solving = %.2f MB.\n",
104  1.0 * p->nMemBytes1 / (1<<20), 1.0 * p->nMemBytes2 / (1<<20) );
105 }
int nMemBytes1
Definition: nwkMerge.h:103
int nEdgeHash
Definition: nwkMerge.h:86
int nEdges
Definition: nwkMerge.h:90
int nVertsMax
Definition: nwkMerge.h:85
int nVerts
Definition: nwkMerge.h:91
struct Nwk_Edg_t_ Nwk_Edg_t
Definition: nwkMerge.h:60
int nMemBytes2
Definition: nwkMerge.h:104
int nObjs
Definition: nwkMerge.h:84
struct Nwk_Grf_t_ Nwk_Grf_t
Definition: nwkMerge.h:80
ABC_DLL void Nwk_ManGraphSolve ( Nwk_Grf_t p)

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

Synopsis [Solves the problem by extracting one edge at a time.]

Description []

SideEffects []

SeeAlso []

Definition at line 621 of file nwkMerge.c.

622 {
623  Nwk_Vrt_t * pVertex, * pNext;
624  int i, j;
625  Nwk_ManGraphPrepare( p );
626  while ( 1 )
627  {
628  // find the next vertex to extract
629  assert( p->pLists1[0] == 0 );
630  for ( i = 1; i <= NWK_MAX_LIST; i++ )
631  if ( p->pLists1[i] )
632  {
633 // printf( "%d ", i );
634 // printf( "ListA = %2d. Length = %5d.\n", i, Nwk_ManGraphListLength(p,p->pLists1[i]) );
635  pVertex = p->pVerts[ p->pLists1[i] ];
636  assert( pVertex->nEdges == 1 );
637  pNext = p->pVerts[ pVertex->pEdges[0] ];
638  Nwk_ManGraphUpdate( p, pVertex, pNext );
639  break;
640  }
641  if ( i < NWK_MAX_LIST + 1 )
642  continue;
643  // find the next vertex to extract
644  assert( p->pLists2[0] == 0 );
645  assert( p->pLists2[1] == 0 );
646  for ( j = 2; j <= NWK_MAX_LIST; j++ )
647  if ( p->pLists2[j] )
648  {
649 // printf( "***%d ", j );
650 // printf( "ListB = %2d. Length = %5d.\n", j, Nwk_ManGraphListLength(p,p->pLists2[j]) );
651  pVertex = Nwk_ManGraphListFindMin( p, p->pLists2[j] );
652  assert( pVertex->nEdges == j || j == NWK_MAX_LIST );
653  pNext = Nwk_ManGraphListFindMinEdge( p, pVertex );
654  Nwk_ManGraphUpdate( p, pVertex, pNext );
655  break;
656  }
657  if ( j == NWK_MAX_LIST + 1 )
658  break;
659  }
661 }
Nwk_Vrt_t ** pVerts
Definition: nwkMerge.h:92
int pEdges[0]
Definition: nwkMerge.h:76
int pLists2[NWK_MAX_LIST+1]
Definition: nwkMerge.h:96
int nEdges
Definition: nwkMerge.h:75
int pLists1[NWK_MAX_LIST+1]
Definition: nwkMerge.h:95
Nwk_Vrt_t * Nwk_ManGraphListFindMinEdge(Nwk_Grf_t *p, Nwk_Vrt_t *pVert)
Definition: nwkMerge.c:567
void Nwk_ManGraphUpdate(Nwk_Grf_t *p, Nwk_Vrt_t *pVertex, Nwk_Vrt_t *pNext)
Definition: nwkMerge.c:460
void Nwk_ManGraphSortPairs(Nwk_Grf_t *p)
Definition: nwkMerge.c:363
#define NWK_MAX_LIST
INCLUDES ///.
Definition: nwkMerge.h:38
void Nwk_ManGraphPrepare(Nwk_Grf_t *p)
Definition: nwkMerge.c:276
#define assert(ex)
Definition: util_old.h:213
Nwk_Vrt_t * Nwk_ManGraphListFindMin(Nwk_Grf_t *p, int List)
Definition: nwkMerge.c:590
ABC_DLL int Nwk_ManLutMergeGraphTest ( char *  pFileName)

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

Synopsis [Solves the graph coming from file.]

Description []

SideEffects []

SeeAlso []

Definition at line 703 of file nwkMerge.c.

704 {
705  int nPairs;
706  Nwk_Grf_t * p;
707  abctime clk = Abc_Clock();
708  p = Nwk_ManLutMergeReadGraph( pFileName );
709  ABC_PRT( "Reading", Abc_Clock() - clk );
710  clk = Abc_Clock();
711  Nwk_ManGraphSolve( p );
712  printf( "GRAPH: Nodes = %6d. Edges = %6d. Pairs = %6d. ",
713  p->nVerts, p->nEdges, Vec_IntSize(p->vPairs)/2 );
714  ABC_PRT( "Solving", Abc_Clock() - clk );
715  nPairs = Vec_IntSize(p->vPairs)/2;
717  Nwk_ManGraphFree( p );
718  return nPairs;
719 }
void Nwk_ManGraphReportMemoryUsage(Nwk_Grf_t *p)
Definition: nwkMerge.c:93
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Nwk_ManGraphFree(Nwk_Grf_t *p)
Definition: nwkMerge.c:70
int nEdges
Definition: nwkMerge.h:90
void Nwk_ManGraphSolve(Nwk_Grf_t *p)
Definition: nwkMerge.c:621
static abctime Abc_Clock()
Definition: abc_global.h:279
int nVerts
Definition: nwkMerge.h:91
Nwk_Grf_t * Nwk_ManLutMergeReadGraph(char *pFileName)
Definition: nwkMerge.c:674
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define ABC_PRT(a, t)
Definition: abc_global.h:220
Vec_Int_t * vPairs
Definition: nwkMerge.h:98
ABC_INT64_T abctime
Definition: abc_global.h:278