abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
amapUniq.c File Reference
#include "amapInt.h"

Go to the source code of this file.

Functions

static ABC_NAMESPACE_IMPL_START int Vec_IntCheckWithMask (Vec_Int_t *p, int Entry)
 DECLARATIONS ///. More...
 
static void Vec_IntPushOrderWithMask (Vec_Int_t *p, int Entry)
 
int Amap_LibFindNode (Amap_Lib_t *pLib, int iFan0, int iFan1, int fXor)
 
int Amap_LibFindMux (Amap_Lib_t *p, int iFan0, int iFan1, int iFan2)
 
Amap_Nod_tAmap_LibCreateObj (Amap_Lib_t *p)
 
int Amap_LibCreateVar (Amap_Lib_t *p)
 
int Amap_LibCreateNode (Amap_Lib_t *p, int iFan0, int iFan1, int fXor)
 
int Amap_LibCreateMux (Amap_Lib_t *p, int iFan0, int iFan1, int iFan2)
 
int ** Amap_LibLookupTableAlloc (Vec_Ptr_t *vVec, int fVerbose)
 

Function Documentation

int Amap_LibCreateMux ( Amap_Lib_t p,
int  iFan0,
int  iFan1,
int  iFan2 
)

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

Synopsis [Creates a new node.]

Description []

SideEffects []

SeeAlso []

Definition at line 244 of file amapUniq.c.

245 {
246  Amap_Nod_t * pNode;
247  pNode = Amap_LibCreateObj( p );
248  pNode->Type = AMAP_OBJ_MUX;
249  pNode->nSuppSize = p->pNodes[Abc_Lit2Var(iFan0)].nSuppSize + p->pNodes[Abc_Lit2Var(iFan1)].nSuppSize + p->pNodes[Abc_Lit2Var(iFan2)].nSuppSize;
250  pNode->iFan0 = iFan0;
251  pNode->iFan1 = iFan1;
252  pNode->iFan2 = iFan2;
253 if ( p->fVerbose )
254 printf( "Creating node %5d %c : iFan0 = %5d%c iFan1 = %5d%c iFan2 = %5d%c\n",
255 pNode->Id, 'm',
256 Abc_Lit2Var(iFan0), (Abc_LitIsCompl(iFan0)?'-':'+'),
257 Abc_Lit2Var(iFan1), (Abc_LitIsCompl(iFan1)?'-':'+'),
258 Abc_Lit2Var(iFan2), (Abc_LitIsCompl(iFan2)?'-':'+') );
259 
260  Vec_IntPush( p->vRules3, iFan0 );
261  Vec_IntPush( p->vRules3, iFan1 );
262  Vec_IntPush( p->vRules3, iFan2 );
263  Vec_IntPush( p->vRules3, pNode->Id );
264  return pNode->Id;
265 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
short iFan0
Definition: amapInt.h:177
short iFan2
Definition: amapInt.h:179
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
unsigned Type
Definition: amapInt.h:176
unsigned nSuppSize
Definition: amapInt.h:175
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
Amap_Nod_t * Amap_LibCreateObj(Amap_Lib_t *p)
Definition: amapUniq.c:135
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
unsigned Id
Definition: amapInt.h:174
short iFan1
Definition: amapInt.h:178
int Amap_LibCreateNode ( Amap_Lib_t p,
int  iFan0,
int  iFan1,
int  fXor 
)

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

Synopsis [Creates a new node.]

Description []

SideEffects []

SeeAlso []

Definition at line 189 of file amapUniq.c.

190 {
191  Amap_Nod_t * pNode;
192  int iFan;
193  if ( iFan0 < iFan1 )
194  {
195  iFan = iFan0;
196  iFan0 = iFan1;
197  iFan1 = iFan;
198  }
199  pNode = Amap_LibCreateObj( p );
200  pNode->Type = fXor? AMAP_OBJ_XOR : AMAP_OBJ_AND;
201  pNode->nSuppSize = p->pNodes[Abc_Lit2Var(iFan0)].nSuppSize + p->pNodes[Abc_Lit2Var(iFan1)].nSuppSize;
202  pNode->iFan0 = iFan0;
203  pNode->iFan1 = iFan1;
204 if ( p->fVerbose )
205 printf( "Creating node %5d %c : iFan0 = %5d%c iFan1 = %5d%c\n",
206 pNode->Id, (fXor?'x':' '),
207 Abc_Lit2Var(iFan0), (Abc_LitIsCompl(iFan0)?'-':'+'),
208 Abc_Lit2Var(iFan1), (Abc_LitIsCompl(iFan1)?'-':'+') );
209 
210  if ( fXor )
211  {
212  if ( iFan0 == iFan1 )
213  Vec_IntPushOrderWithMask( (Vec_Int_t *)Vec_PtrEntry(p->vRulesX, iFan0), (pNode->Id << 16) | iFan1 );
214  else
215  {
216  Vec_IntPushOrderWithMask( (Vec_Int_t *)Vec_PtrEntry(p->vRulesX, iFan0), (pNode->Id << 16) | iFan1 );
217  Vec_IntPushOrderWithMask( (Vec_Int_t *)Vec_PtrEntry(p->vRulesX, iFan1), (pNode->Id << 16) | iFan0 );
218  }
219  }
220  else
221  {
222  if ( iFan0 == iFan1 )
223  Vec_IntPushOrderWithMask( (Vec_Int_t *)Vec_PtrEntry(p->vRules, iFan0), (pNode->Id << 16) | iFan1 );
224  else
225  {
226  Vec_IntPushOrderWithMask( (Vec_Int_t *)Vec_PtrEntry(p->vRules, iFan0), (pNode->Id << 16) | iFan1 );
227  Vec_IntPushOrderWithMask( (Vec_Int_t *)Vec_PtrEntry(p->vRules, iFan1), (pNode->Id << 16) | iFan0 );
228  }
229  }
230  return pNode->Id;
231 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
short iFan0
Definition: amapInt.h:177
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
unsigned Type
Definition: amapInt.h:176
unsigned nSuppSize
Definition: amapInt.h:175
Amap_Nod_t * Amap_LibCreateObj(Amap_Lib_t *p)
Definition: amapUniq.c:135
static void Vec_IntPushOrderWithMask(Vec_Int_t *p, int Entry)
Definition: amapUniq.c:65
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
unsigned Id
Definition: amapInt.h:174
short iFan1
Definition: amapInt.h:178
Amap_Nod_t* Amap_LibCreateObj ( Amap_Lib_t p)

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

Synopsis [Creates a new node.]

Description []

SideEffects []

SeeAlso []

Definition at line 135 of file amapUniq.c.

136 {
137  Amap_Nod_t * pNode;
138  if ( p->nNodes == p->nNodesAlloc )
139  {
140  p->pNodes = ABC_REALLOC( Amap_Nod_t, p->pNodes, 2*p->nNodesAlloc );
141  p->nNodesAlloc *= 2;
142  }
143  pNode = Amap_LibNod( p, p->nNodes );
144  memset( pNode, 0, sizeof(Amap_Nod_t) );
145  pNode->Id = p->nNodes++;
146  Vec_PtrPush( p->vRules, Vec_IntAlloc(8) );
147  Vec_PtrPush( p->vRules, Vec_IntAlloc(8) );
148  Vec_PtrPush( p->vRulesX, Vec_IntAlloc(8) );
149  Vec_PtrPush( p->vRulesX, Vec_IntAlloc(8) );
150  return pNode;
151 }
char * memset()
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_REALLOC(type, obj, num)
Definition: abc_global.h:233
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
unsigned Id
Definition: amapInt.h:174
static Amap_Nod_t * Amap_LibNod(Amap_Lib_t *p, int i)
Definition: amapInt.h:264
int Amap_LibCreateVar ( Amap_Lib_t p)

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

Synopsis [Creates a new node.]

Description []

SideEffects []

SeeAlso []

Definition at line 164 of file amapUniq.c.

165 {
166  Amap_Nod_t * pNode;
167  // start the manager
168  assert( p->pNodes == NULL );
169  p->nNodesAlloc = 256;
170  p->pNodes = ABC_ALLOC( Amap_Nod_t, p->nNodesAlloc );
171  // create the first node
172  pNode = Amap_LibCreateObj( p );
173  p->pNodes->Type = AMAP_OBJ_PI;
174  p->pNodes->nSuppSize = 1;
175  return 0;
176 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Amap_Nod_t * Amap_LibCreateObj(Amap_Lib_t *p)
Definition: amapUniq.c:135
#define assert(ex)
Definition: util_old.h:213
int Amap_LibFindMux ( Amap_Lib_t p,
int  iFan0,
int  iFan1,
int  iFan2 
)

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

Synopsis [Checks if the three-argument rule exist.]

Description []

SideEffects []

SeeAlso []

Definition at line 109 of file amapUniq.c.

110 {
111  int x;
112  for ( x = 0; x < Vec_IntSize(p->vRules3); x += 4 )
113  {
114  if ( Vec_IntEntry(p->vRules3, x) == iFan0 &&
115  Vec_IntEntry(p->vRules3, x+1) == iFan1 &&
116  Vec_IntEntry(p->vRules3, x+2) == iFan2 )
117  {
118  return Vec_IntEntry(p->vRules3, x+3);
119  }
120  }
121  return -1;
122 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
int Amap_LibFindNode ( Amap_Lib_t pLib,
int  iFan0,
int  iFan1,
int  fXor 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 90 of file amapUniq.c.

91 {
92  if ( fXor )
93  return Vec_IntCheckWithMask( (Vec_Int_t *)Vec_PtrEntry(pLib->vRulesX, iFan0), iFan1 );
94  else
95  return Vec_IntCheckWithMask( (Vec_Int_t *)Vec_PtrEntry(pLib->vRules, iFan0), iFan1 );
96 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static ABC_NAMESPACE_IMPL_START int Vec_IntCheckWithMask(Vec_Int_t *p, int Entry)
DECLARATIONS ///.
Definition: amapUniq.c:45
int** Amap_LibLookupTableAlloc ( Vec_Ptr_t vVec,
int  fVerbose 
)

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

Synopsis [Allocates triangular lookup table.]

Description []

SideEffects []

SeeAlso []

Definition at line 278 of file amapUniq.c.

279 {
280  Vec_Int_t * vOne;
281  int ** pRes, * pBuffer;
282  int i, k, nTotal, nSize, nEntries, Value;
283  // count the total size
284  nEntries = nSize = Vec_PtrSize( vVec );
285  Vec_PtrForEachEntry( Vec_Int_t *, vVec, vOne, i )
286  nEntries += Vec_IntSize(vOne);
287  pBuffer = ABC_ALLOC( int, nSize * sizeof(void *) + nEntries );
288  pRes = (int **)pBuffer;
289  pRes[0] = pBuffer + nSize * sizeof(void *);
290  nTotal = 0;
291  Vec_PtrForEachEntry( Vec_Int_t *, vVec, vOne, i )
292  {
293  pRes[i] = pRes[0] + nTotal;
294  nTotal += Vec_IntSize(vOne) + 1;
295  if ( fVerbose )
296  printf( "%d : ", i );
297  Vec_IntForEachEntry( vOne, Value, k )
298  {
299  pRes[i][k] = Value;
300  if ( fVerbose )
301  printf( "%d(%d) ", Value&0xffff, Value>>16 );
302  }
303  if ( fVerbose )
304  printf( "\n" );
305  pRes[i][k] = 0;
306  }
307  assert( nTotal == nEntries );
308  return pRes;
309 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define assert(ex)
Definition: util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
int nTotal
DECLARATIONS ///.
Definition: cutTruth.c:37
static ABC_NAMESPACE_IMPL_START int Vec_IntCheckWithMask ( Vec_Int_t p,
int  Entry 
)
inlinestatic

DECLARATIONS ///.

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

FileName [amapUniq.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Technology mapper for standard cells.]

Synopsis [Checks if the structural node already exists.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Checks if the entry exists and returns value.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file amapUniq.c.

46 {
47  int i;
48  for ( i = 0; i < p->nSize; i++ )
49  if ( (0xffff & p->pArray[i]) == (0xffff & Entry) )
50  return p->pArray[i] >> 16;
51  return -1;
52 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Vec_IntPushOrderWithMask ( Vec_Int_t p,
int  Entry 
)
inlinestatic

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

Synopsis [Pushes entry in the natural order.]

Description []

SideEffects []

SeeAlso []

Definition at line 65 of file amapUniq.c.

66 {
67  int i;
68  if ( p->nSize == p->nCap )
69  Vec_IntGrow( p, 2 * p->nCap );
70  p->nSize++;
71  for ( i = p->nSize-2; i >= 0; i-- )
72  if ( (0xffff & p->pArray[i]) > (0xffff & Entry) )
73  p->pArray[i+1] = p->pArray[i];
74  else
75  break;
76  p->pArray[i+1] = Entry;
77 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Vec_IntGrow(Vec_Int_t *p, int nCapMin)
Definition: bblif.c:336