abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
abcBlifMv.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [abcBlifMv.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Network and node package.]
8 
9  Synopsis [Procedures to process BLIF-MV networks and AIGs.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - June 20, 2005.]
16 
17  Revision [$Id: abcBlifMv.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "abc.h"
22 #include "misc/extra/extraBdd.h"
23 
25 
26 
27 ////////////////////////////////////////////////////////////////////////
28 /// DECLARATIONS ///
29 ////////////////////////////////////////////////////////////////////////
30 
31 ////////////////////////////////////////////////////////////////////////
32 /// FUNCTION DEFINITIONS ///
33 ////////////////////////////////////////////////////////////////////////
34 
35 /**Function*************************************************************
36 
37  Synopsis [Starts the Mv-Var manager.]
38 
39  Description []
40 
41  SideEffects []
42 
43  SeeAlso []
44 
45 ***********************************************************************/
47 {
48  Vec_Att_t * pAttMan;
49  assert( Abc_NtkMvVar(pNtk) == NULL );
50  pAttMan = Vec_AttAlloc( Abc_NtkObjNumMax(pNtk) + 1, Mem_FlexStart(), (void(*)(void*))Mem_FlexStop, NULL, NULL );
51  Vec_PtrWriteEntry( pNtk->vAttrs, VEC_ATTR_MVVAR, pAttMan );
52 //printf( "allocing attr\n" );
53 }
54 
55 /**Function*************************************************************
56 
57  Synopsis [Stops the Mv-Var manager.]
58 
59  Description []
60 
61  SideEffects []
62 
63  SeeAlso []
64 
65 ***********************************************************************/
67 {
68  Mem_Flex_t * pUserMan;
69  pUserMan = (Mem_Flex_t *)Abc_NtkAttrFree( pNtk, VEC_ATTR_GLOBAL_BDD, 0 );
70  Mem_FlexStop( pUserMan, 0 );
71 }
72 
73 /**Function*************************************************************
74 
75  Synopsis [Duplicate the MV variable.]
76 
77  Description []
78 
79  SideEffects []
80 
81  SeeAlso []
82 
83 ***********************************************************************/
84 void Abc_NtkSetMvVarValues( Abc_Obj_t * pObj, int nValues )
85 {
86  Mem_Flex_t * pFlex;
87  struct temp
88  {
89  int nValues;
90  char ** pNames;
91  } * pVarStruct;
92  assert( nValues > 1 );
93  // skip binary signals
94  if ( nValues == 2 )
95  return;
96  // skip already assigned signals
97  if ( Abc_ObjMvVar(pObj) != NULL )
98  return;
99  // create the structure
100  pFlex = (Mem_Flex_t *)Abc_NtkMvVarMan( pObj->pNtk );
101  pVarStruct = (struct temp *)Mem_FlexEntryFetch( pFlex, sizeof(struct temp) );
102  pVarStruct->nValues = nValues;
103  pVarStruct->pNames = NULL;
104  Abc_ObjSetMvVar( pObj, pVarStruct );
105 }
106 
107 /**Function*************************************************************
108 
109  Synopsis [Strashes the BLIF-MV netlist.]
110 
111  Description []
112 
113  SideEffects []
114 
115  SeeAlso []
116 
117 ***********************************************************************/
118 static inline int Abc_StringGetNumber( char ** ppStr )
119 {
120  char * pStr = *ppStr;
121  int Number = 0;
122  assert( *pStr >= '0' && *pStr <= '9' );
123  for ( ; *pStr >= '0' && *pStr <= '9'; pStr++ )
124  Number = 10 * Number + *pStr - '0';
125  *ppStr = pStr;
126  return Number;
127 }
128 
129 /**Function*************************************************************
130 
131  Synopsis [Strashes one node in the BLIF-MV netlist.]
132 
133  Description []
134 
135  SideEffects []
136 
137  SeeAlso []
138 
139 ***********************************************************************/
140 int Abc_NodeStrashBlifMv( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pObj )
141 {
142  int fAddFreeVars = 1;
143  char * pSop;
144  Abc_Obj_t ** pValues, ** pValuesF, ** pValuesF2;
145  Abc_Obj_t * pTemp, * pTemp2, * pFanin, * pFanin2, * pNet;
146  int k, v, Def, DefIndex, Index, nValues, nValuesF, nValuesF2;
147 
148  // start the output values
149  assert( Abc_ObjIsNode(pObj) );
150  pNet = Abc_ObjFanout0(pObj);
151  nValues = Abc_ObjMvVarNum(pNet);
152  pValues = ABC_ALLOC( Abc_Obj_t *, nValues );
153  for ( k = 0; k < nValues; k++ )
154  pValues[k] = Abc_ObjNot( Abc_AigConst1(pNtkNew) );
155 
156  // get the BLIF-MV formula
157  pSop = (char *)pObj->pData;
158  // skip the value line
159 // while ( *pSop++ != '\n' );
160 
161  // handle the constant
162  if ( Abc_ObjFaninNum(pObj) == 0 )
163  {
164  // skip the default if present
165  if ( *pSop == 'd' )
166  while ( *pSop++ != '\n' );
167  // skip space if present
168  if ( *pSop == ' ' )
169  pSop++;
170  // assume don't-care constant to be zero
171  if ( *pSop == '-' )
172  Index = 0;
173  else
174  Index = Abc_StringGetNumber( &pSop );
175  assert( Index < nValues );
176  ////////////////////////////////////////////
177  // adding free variables for binary ND-constants
178  if ( fAddFreeVars && nValues == 2 && *pSop == '-' )
179  {
180  pValues[1] = Abc_NtkCreatePi(pNtkNew);
181  pValues[0] = Abc_ObjNot( pValues[1] );
182  Abc_ObjAssignName( pValues[1], "free_var_", Abc_ObjName(pValues[1]) );
183  }
184  else
185  pValues[Index] = Abc_AigConst1(pNtkNew);
186  ////////////////////////////////////////////
187  // save the values in the fanout net
188  pNet->pCopy = (Abc_Obj_t *)pValues;
189  return 1;
190  }
191 
192  // parse the default line
193  Def = DefIndex = -1;
194  if ( *pSop == 'd' )
195  {
196  pSop++;
197  if ( *pSop == '=' )
198  {
199  pSop++;
200  DefIndex = Abc_StringGetNumber( &pSop );
201  assert( DefIndex < Abc_ObjFaninNum(pObj) );
202  }
203  else if ( *pSop == '-' )
204  {
205  pSop++;
206  Def = 0;
207  }
208  else
209  {
210  Def = Abc_StringGetNumber( &pSop );
211  assert( Def < nValues );
212  }
213  assert( *pSop == '\n' );
214  pSop++;
215  }
216 
217  // convert the values
218  while ( *pSop )
219  {
220  // extract the values for each cube
221  pTemp = Abc_AigConst1(pNtkNew);
222  Abc_ObjForEachFanin( pObj, pFanin, k )
223  {
224  if ( *pSop == '-' )
225  {
226  pSop += 2;
227  continue;
228  }
229  if ( *pSop == '!' )
230  {
231  ABC_FREE( pValues );
232  printf( "Abc_NodeStrashBlifMv(): Cannot handle complement in the MV function of node %s.\n", Abc_ObjName(Abc_ObjFanout0(pObj)) );
233  return 0;
234  }
235  if ( *pSop == '{' )
236  {
237  ABC_FREE( pValues );
238  printf( "Abc_NodeStrashBlifMv(): Cannot handle braces in the MV function of node %s.\n", Abc_ObjName(Abc_ObjFanout0(pObj)) );
239  return 0;
240  }
241  // get the value set
242  nValuesF = Abc_ObjMvVarNum(pFanin);
243  pValuesF = (Abc_Obj_t **)pFanin->pCopy;
244  if ( *pSop == '(' )
245  {
246  pSop++;
247  pTemp2 = Abc_ObjNot( Abc_AigConst1(pNtkNew) );
248  while ( *pSop != ')' )
249  {
250  Index = Abc_StringGetNumber( &pSop );
251  assert( Index < nValuesF );
252  pTemp2 = Abc_AigOr( (Abc_Aig_t *)pNtkNew->pManFunc, pTemp2, pValuesF[Index] );
253  assert( *pSop == ')' || *pSop == ',' );
254  if ( *pSop == ',' )
255  pSop++;
256  }
257  assert( *pSop == ')' );
258  pSop++;
259  }
260  else if ( *pSop == '=' )
261  {
262  pSop++;
263  // get the fanin index
264  Index = Abc_StringGetNumber( &pSop );
265  assert( Index < Abc_ObjFaninNum(pObj) );
266  assert( Index != k );
267  // get the fanin
268  pFanin2 = Abc_ObjFanin( pObj, Index );
269  nValuesF2 = Abc_ObjMvVarNum(pFanin2);
270  pValuesF2 = (Abc_Obj_t **)pFanin2->pCopy;
271  // create the sum of products of values
272  assert( nValuesF == nValuesF2 );
273  pTemp2 = Abc_ObjNot( Abc_AigConst1(pNtkNew) );
274  for ( v = 0; v < nValues; v++ )
275  pTemp2 = Abc_AigOr( (Abc_Aig_t *)pNtkNew->pManFunc, pTemp2, Abc_AigAnd((Abc_Aig_t *)pNtkNew->pManFunc, pValuesF[v], pValuesF2[v]) );
276  }
277  else
278  {
279  Index = Abc_StringGetNumber( &pSop );
280  assert( Index < nValuesF );
281  pTemp2 = pValuesF[Index];
282  }
283  // compute the compute
284  pTemp = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, pTemp, pTemp2 );
285  // advance the reading point
286  assert( *pSop == ' ' );
287  pSop++;
288  }
289  // check if the output value is an equal construct
290  if ( *pSop == '=' )
291  {
292  pSop++;
293  // get the output value
294  Index = Abc_StringGetNumber( &pSop );
295  assert( Index < Abc_ObjFaninNum(pObj) );
296  // add values of the given fanin with the given cube
297  pFanin = Abc_ObjFanin( pObj, Index );
298  nValuesF = Abc_ObjMvVarNum(pFanin);
299  pValuesF = (Abc_Obj_t **)pFanin->pCopy;
300  assert( nValuesF == nValues ); // should be guaranteed by the parser
301  for ( k = 0; k < nValuesF; k++ )
302  pValues[k] = Abc_AigOr( (Abc_Aig_t *)pNtkNew->pManFunc, pValues[k], Abc_AigAnd((Abc_Aig_t *)pNtkNew->pManFunc, pTemp, pValuesF[k]) );
303  }
304  else
305  {
306  // get the output value
307  Index = Abc_StringGetNumber( &pSop );
308  assert( Index < nValues );
309  pValues[Index] = Abc_AigOr( (Abc_Aig_t *)pNtkNew->pManFunc, pValues[Index], pTemp );
310  }
311  // advance the reading point
312  assert( *pSop == '\n' );
313  pSop++;
314  }
315 
316  // compute the default value
317  if ( Def >= 0 || DefIndex >= 0 )
318  {
319  pTemp = Abc_AigConst1(pNtkNew);
320  for ( k = 0; k < nValues; k++ )
321  {
322  if ( k == Def )
323  continue;
324  pTemp = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, pTemp, Abc_ObjNot(pValues[k]) );
325  }
326 
327  // assign the default value
328  if ( Def >= 0 )
329  pValues[Def] = pTemp;
330  else
331  {
332  assert( DefIndex >= 0 );
333  // add values of the given fanin with the given cube
334  pFanin = Abc_ObjFanin( pObj, DefIndex );
335  nValuesF = Abc_ObjMvVarNum(pFanin);
336  pValuesF = (Abc_Obj_t **)pFanin->pCopy;
337  assert( nValuesF == nValues ); // should be guaranteed by the parser
338  for ( k = 0; k < nValuesF; k++ )
339  pValues[k] = Abc_AigOr( (Abc_Aig_t *)pNtkNew->pManFunc, pValues[k], Abc_AigAnd((Abc_Aig_t *)pNtkNew->pManFunc, pTemp, pValuesF[k]) );
340  }
341 
342  }
343 
344  // save the values in the fanout net
345  pNet->pCopy = (Abc_Obj_t *)pValues;
346  return 1;
347 }
348 
349 /**Function*************************************************************
350 
351  Synopsis [Assigns name with index.]
352 
353  Description []
354 
355  SideEffects []
356 
357  SeeAlso []
358 
359 ***********************************************************************/
360 static inline void Abc_NtkConvertAssignName( Abc_Obj_t * pObj, Abc_Obj_t * pNet, int Index )
361 {
362  char Suffix[16];
363  assert( Abc_ObjIsTerm(pObj) );
364  assert( Abc_ObjIsNet(pNet) );
365  sprintf( Suffix, "[%d]", Index );
366  Abc_ObjAssignName( pObj, Abc_ObjName(pNet), Suffix );
367 }
368 
369 /**Function*************************************************************
370 
371  Synopsis [Strashes the BLIF-MV netlist.]
372 
373  Description []
374 
375  SideEffects []
376 
377  SeeAlso []
378 
379 ***********************************************************************/
381 {
382  int fUsePositional = 0;
383  Vec_Ptr_t * vNodes;
384  Abc_Obj_t ** pBits;
385  Abc_Obj_t ** pValues;
386  Abc_Ntk_t * pNtkNew;
387  Abc_Obj_t * pObj, * pTemp, * pBit, * pNet;
388  int i, k, v, nValues, nValuesMax, nBits;
389  int nCount1, nCount2;
390 
391  assert( Abc_NtkIsNetlist(pNtk) );
392  assert( Abc_NtkHasBlifMv(pNtk) );
393  assert( Abc_NtkWhiteboxNum(pNtk) == 0 );
394  assert( Abc_NtkBlackboxNum(pNtk) == 0 );
395 
396  // get the largest number of values
397  nValuesMax = 2;
398  Abc_NtkForEachNet( pNtk, pObj, i )
399  {
400  nValues = Abc_ObjMvVarNum(pObj);
401  if ( nValuesMax < nValues )
402  nValuesMax = nValues;
403  }
404  nBits = Abc_Base2Log( nValuesMax );
405  pBits = ABC_ALLOC( Abc_Obj_t *, nBits );
406 
407  // clean the node copy fields
408  Abc_NtkCleanCopy( pNtk );
409  // collect the nodes
410  vNodes = Abc_NtkDfs( pNtk, 0 );
411 
412  // start the network
413  pNtkNew = Abc_NtkAlloc( ABC_NTK_STRASH, ABC_FUNC_AIG, 1 );
414  // duplicate the name and the spec
415  pNtkNew->pName = Extra_UtilStrsav( pNtk->pName );
416 // pNtkNew->pSpec = Extra_UtilStrsav( pNtk->pName );
417 
418  nCount1 = nCount2 = 0;
419  // encode the CI nets
420  Abc_NtkIncrementTravId( pNtk );
421  if ( fUsePositional )
422  {
423  Abc_NtkForEachCi( pNtk, pObj, i )
424  {
425  if ( !Abc_ObjIsPi(pObj) )
426  continue;
427  pNet = Abc_ObjFanout0(pObj);
428  nValues = Abc_ObjMvVarNum(pNet);
429  pValues = ABC_ALLOC( Abc_Obj_t *, nValues );
430  // create PIs for the values
431  for ( v = 0; v < nValues; v++ )
432  {
433  pValues[v] = Abc_NtkCreatePi( pNtkNew );
434  if ( nValuesMax == 2 )
435  Abc_ObjAssignName( pValues[v], Abc_ObjName(pNet), NULL );
436  else
437  Abc_NtkConvertAssignName( pValues[v], pNet, v );
438  }
439  // save the values in the fanout net
440  pNet->pCopy = (Abc_Obj_t *)pValues;
441  // mark the net
442  Abc_NodeSetTravIdCurrent( pNet );
443  }
444  Abc_NtkForEachCi( pNtk, pObj, i )
445  {
446  if ( Abc_ObjIsPi(pObj) )
447  continue;
448  pNet = Abc_ObjFanout0(pObj);
449  nValues = Abc_ObjMvVarNum(pNet);
450  pValues = ABC_ALLOC( Abc_Obj_t *, nValues );
451  // create PIs for the values
452  for ( v = 0; v < nValues; v++ )
453  {
454  pValues[v] = Abc_NtkCreateBo( pNtkNew );
455  if ( nValuesMax == 2 )
456  Abc_ObjAssignName( pValues[v], Abc_ObjName(pNet), NULL );
457  else
458  Abc_NtkConvertAssignName( pValues[v], pNet, v );
459  nCount1++;
460  }
461  // save the values in the fanout net
462  pNet->pCopy = (Abc_Obj_t *)pValues;
463  // mark the net
464  Abc_NodeSetTravIdCurrent( pNet );
465  }
466  }
467  else
468  {
469  Abc_NtkForEachCi( pNtk, pObj, i )
470  {
471  if ( !Abc_ObjIsPi(pObj) )
472  continue;
473  pNet = Abc_ObjFanout0(pObj);
474  nValues = Abc_ObjMvVarNum(pNet);
475  pValues = ABC_ALLOC( Abc_Obj_t *, nValues );
476  // create PIs for the encoding bits
477  nBits = Abc_Base2Log( nValues );
478  for ( k = 0; k < nBits; k++ )
479  {
480  pBits[k] = Abc_NtkCreatePi( pNtkNew );
481  if ( nValuesMax == 2 )
482  Abc_ObjAssignName( pBits[k], Abc_ObjName(pNet), NULL );
483  else
484  Abc_NtkConvertAssignName( pBits[k], pNet, k );
485  }
486  // encode the values
487  for ( v = 0; v < nValues; v++ )
488  {
489  pValues[v] = Abc_AigConst1(pNtkNew);
490  for ( k = 0; k < nBits; k++ )
491  {
492  pBit = Abc_ObjNotCond( pBits[k], (v&(1<<k)) == 0 );
493  pValues[v] = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, pValues[v], pBit );
494  }
495  }
496  // save the values in the fanout net
497  pNet->pCopy = (Abc_Obj_t *)pValues;
498  // mark the net
499  Abc_NodeSetTravIdCurrent( pNet );
500  }
501  Abc_NtkForEachCi( pNtk, pObj, i )
502  {
503  if ( Abc_ObjIsPi(pObj) )
504  continue;
505  pNet = Abc_ObjFanout0(pObj);
506  nValues = Abc_ObjMvVarNum(pNet);
507  pValues = ABC_ALLOC( Abc_Obj_t *, nValues );
508  // create PIs for the encoding bits
509  nBits = Abc_Base2Log( nValues );
510  for ( k = 0; k < nBits; k++ )
511  {
512  pBits[k] = Abc_NtkCreateBo( pNtkNew );
513  if ( nValuesMax == 2 )
514  Abc_ObjAssignName( pBits[k], Abc_ObjName(pNet), NULL );
515  else
516  Abc_NtkConvertAssignName( pBits[k], pNet, k );
517  nCount1++;
518  }
519  // encode the values
520  for ( v = 0; v < nValues; v++ )
521  {
522  pValues[v] = Abc_AigConst1(pNtkNew);
523  for ( k = 0; k < nBits; k++ )
524  {
525  pBit = Abc_ObjNotCond( pBits[k], (v&(1<<k)) == 0 );
526  pValues[v] = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, pValues[v], pBit );
527  }
528  }
529  // save the values in the fanout net
530  pNet->pCopy = (Abc_Obj_t *)pValues;
531  // mark the net
532  Abc_NodeSetTravIdCurrent( pNet );
533  }
534  }
535 
536  // process nodes in the topological order
537  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
538  if ( !Abc_NodeStrashBlifMv( pNtkNew, pObj ) )
539  {
540  Abc_NtkDelete( pNtkNew );
541  return NULL;
542  }
543  Vec_PtrFree( vNodes );
544 
545  // encode the CO nets
546  if ( fUsePositional )
547  {
548  Abc_NtkForEachCo( pNtk, pObj, i )
549  {
550  if ( !Abc_ObjIsPo(pObj) )
551  continue;
552  pNet = Abc_ObjFanin0(pObj);
553  // skip marked nets
554 // if ( Abc_NodeIsTravIdCurrent(pNet) )
555 // continue;
556 // Abc_NodeSetTravIdCurrent( pNet );
557  nValues = Abc_ObjMvVarNum(pNet);
558  pValues = (Abc_Obj_t **)pNet->pCopy;
559  for ( v = 0; v < nValues; v++ )
560  {
561  pTemp = Abc_NtkCreatePo( pNtkNew );
562  Abc_ObjAddFanin( pTemp, pValues[v] );
563  if ( nValuesMax == 2 )
564  Abc_ObjAssignName( pTemp, Abc_ObjName(pNet), NULL );
565  else
566  Abc_NtkConvertAssignName( pTemp, pNet, v );
567  }
568  }
569  Abc_NtkForEachCo( pNtk, pObj, i )
570  {
571  if ( Abc_ObjIsPo(pObj) )
572  continue;
573  pNet = Abc_ObjFanin0(pObj);
574  // skip marked nets
575 // if ( Abc_NodeIsTravIdCurrent(pNet) )
576 // continue;
577 // Abc_NodeSetTravIdCurrent( pNet );
578  nValues = Abc_ObjMvVarNum(pNet);
579  pValues = (Abc_Obj_t **)pNet->pCopy;
580  for ( v = 0; v < nValues; v++ )
581  {
582  pTemp = Abc_NtkCreateBi( pNtkNew );
583  Abc_ObjAddFanin( pTemp, pValues[v] );
584  if ( nValuesMax == 2 )
585  Abc_ObjAssignName( pTemp, Abc_ObjName(pNet), NULL );
586  else
587  Abc_NtkConvertAssignName( pTemp, pNet, v );
588  nCount2++;
589  }
590  }
591  }
592  else // if ( fPositional == 0 )
593  {
594  Abc_NtkForEachCo( pNtk, pObj, i )
595  {
596  if ( !Abc_ObjIsPo(pObj) )
597  continue;
598  pNet = Abc_ObjFanin0(pObj);
599  // skip marked nets
600 // if ( Abc_NodeIsTravIdCurrent(pNet) )
601 // continue;
602 // Abc_NodeSetTravIdCurrent( pNet );
603  nValues = Abc_ObjMvVarNum(pNet);
604  pValues = (Abc_Obj_t **)pNet->pCopy;
605  nBits = Abc_Base2Log( nValues );
606  for ( k = 0; k < nBits; k++ )
607  {
608  pBit = Abc_ObjNot( Abc_AigConst1(pNtkNew) );
609  for ( v = 0; v < nValues; v++ )
610  if ( v & (1<<k) )
611  pBit = Abc_AigOr( (Abc_Aig_t *)pNtkNew->pManFunc, pBit, pValues[v] );
612  pTemp = Abc_NtkCreatePo( pNtkNew );
613  Abc_ObjAddFanin( pTemp, pBit );
614  if ( nValuesMax == 2 )
615  Abc_ObjAssignName( pTemp, Abc_ObjName(pNet), NULL );
616  else
617  Abc_NtkConvertAssignName( pTemp, pNet, k );
618  }
619  }
620  Abc_NtkForEachCo( pNtk, pObj, i )
621  {
622  if ( Abc_ObjIsPo(pObj) )
623  continue;
624  pNet = Abc_ObjFanin0(pObj);
625  // skip marked nets
626 // if ( Abc_NodeIsTravIdCurrent(pNet) )
627 // continue;
628 // Abc_NodeSetTravIdCurrent( pNet );
629  nValues = Abc_ObjMvVarNum(pNet);
630  pValues = (Abc_Obj_t **)pNet->pCopy;
631  nBits = Abc_Base2Log( nValues );
632  for ( k = 0; k < nBits; k++ )
633  {
634  pBit = Abc_ObjNot( Abc_AigConst1(pNtkNew) );
635  for ( v = 0; v < nValues; v++ )
636  if ( v & (1<<k) )
637  pBit = Abc_AigOr( (Abc_Aig_t *)pNtkNew->pManFunc, pBit, pValues[v] );
638  pTemp = Abc_NtkCreateBi( pNtkNew );
639  Abc_ObjAddFanin( pTemp, pBit );
640  if ( nValuesMax == 2 )
641  Abc_ObjAssignName( pTemp, Abc_ObjName(pNet), NULL );
642  else
643  Abc_NtkConvertAssignName( pTemp, pNet, k );
644  nCount2++;
645  }
646  }
647  }
648 
649  if ( Abc_NtkLatchNum(pNtk) )
650  {
651  Vec_Ptr_t * vTemp;
652  Abc_Obj_t * pLatch, * pObjLi, * pObjLo;
653  int i;
654  // move free vars to the front among the PIs
655  vTemp = Vec_PtrAlloc( Vec_PtrSize(pNtkNew->vPis) );
656  Abc_NtkForEachPi( pNtkNew, pObj, i )
657  if ( strncmp( Abc_ObjName(pObj), "free_var_", 9 ) == 0 )
658  Vec_PtrPush( vTemp, pObj );
659  Abc_NtkForEachPi( pNtkNew, pObj, i )
660  if ( strncmp( Abc_ObjName(pObj), "free_var_", 9 ) != 0 )
661  Vec_PtrPush( vTemp, pObj );
662  assert( Vec_PtrSize(vTemp) == Vec_PtrSize(pNtkNew->vPis) );
663  Vec_PtrFree( pNtkNew->vPis );
664  pNtkNew->vPis = vTemp;
665  // move free vars to the front among the CIs
666  vTemp = Vec_PtrAlloc( Vec_PtrSize(pNtkNew->vCis) );
667  Abc_NtkForEachCi( pNtkNew, pObj, i )
668  if ( strncmp( Abc_ObjName(pObj), "free_var_", 9 ) == 0 )
669  Vec_PtrPush( vTemp, pObj );
670  Abc_NtkForEachCi( pNtkNew, pObj, i )
671  if ( strncmp( Abc_ObjName(pObj), "free_var_", 9 ) != 0 )
672  Vec_PtrPush( vTemp, pObj );
673  assert( Vec_PtrSize(vTemp) == Vec_PtrSize(pNtkNew->vCis) );
674  Vec_PtrFree( pNtkNew->vCis );
675  pNtkNew->vCis = vTemp;
676  // create registers
677  assert( nCount1 == nCount2 );
678  for ( i = 0; i < nCount1; i++ )
679  {
680  // create latch
681  pLatch = Abc_NtkCreateLatch( pNtkNew );
682  Abc_LatchSetInit0( pLatch );
683  Abc_ObjAssignName( pLatch, Abc_ObjName(pLatch), NULL );
684  // connect
685  pObjLi = Abc_NtkCo( pNtkNew, Abc_NtkCoNum(pNtkNew)-nCount1+i );
686  pObjLo = Abc_NtkCi( pNtkNew, Abc_NtkCiNum(pNtkNew)-nCount1+i );
687  Abc_ObjAddFanin( pLatch, pObjLi );
688  Abc_ObjAddFanin( pObjLo, pLatch );
689  }
690  }
691 
692  // cleanup
693  ABC_FREE( pBits );
694  Abc_NtkForEachObj( pNtk, pObj, i )
695  if ( pObj->pCopy )
696  ABC_FREE( pObj->pCopy );
697 
698  // remove dangling nodes
699  i = Abc_AigCleanup((Abc_Aig_t *)pNtkNew->pManFunc);
700 // printf( "Cleanup removed %d nodes.\n", i );
701 // Abc_NtkReassignIds( pNtkNew );
702 
703  // check integrity
704  if ( !Abc_NtkCheck( pNtkNew ) )
705  {
706  fprintf( stdout, "Abc_NtkStrashBlifMv(): Network check has failed.\n" );
707  Abc_NtkDelete( pNtkNew );
708  return NULL;
709  }
710  return pNtkNew;
711 }
712 
713 /**Function*************************************************************
714 
715  Synopsis [Extract the MV-skeleton of the BLIF-MV network.]
716 
717  Description []
718 
719  SideEffects []
720 
721  SeeAlso []
722 
723 ***********************************************************************/
725 {
726  int fUsePositional = 0;
727  Abc_Ntk_t * pNtkNew;
728  Abc_Obj_t * pObj, * pNet, * pNetNew, * pNodeNew, * pTermNew, * pBoxNew;
729  int i, k, v, nValues, nBits;
730 
731  assert( Abc_NtkIsNetlist(pNtk) );
732  assert( Abc_NtkHasBlifMv(pNtk) );
733  assert( Abc_NtkWhiteboxNum(pNtk) == 0 );
734  assert( Abc_NtkBlackboxNum(pNtk) == 0 );
735 
736  // clean the node copy fields
737  Abc_NtkCleanCopy( pNtk );
738 
739  // start the network
740  pNtkNew = Abc_NtkAlloc( pNtk->ntkType, pNtk->ntkFunc, 1 );
741  // duplicate the name and the spec
742  pNtkNew->pName = Extra_UtilStrsav( pNtk->pName );
743  pNtkNew->pSpec = Extra_UtilStrsav( pNtk->pName );
744  // create the internal box (it is important to put it first!)
745  pBoxNew = Abc_NtkCreateWhitebox( pNtkNew );
746  // create PIs and their nets
747  Abc_NtkForEachPi( pNtk, pObj, i )
748  {
749  Abc_NtkDupObj( pNtkNew, pObj, 0 );
750  pNet = Abc_ObjFanout0(pObj);
751  Abc_NtkDupObj( pNtkNew, pNet, 1 );
752  Abc_ObjAddFanin( pNet->pCopy, pObj->pCopy );
753  }
754  // create POs and their nets
755  Abc_NtkForEachPo( pNtk, pObj, i )
756  {
757  Abc_NtkDupObj( pNtkNew, pObj, 0 );
758  pNet = Abc_ObjFanin0(pObj);
759  if ( pNet->pCopy == NULL )
760  Abc_NtkDupObj( pNtkNew, pNet, 1 );
761  Abc_ObjAddFanin( pObj->pCopy, pNet->pCopy );
762  }
763  // create latches
764  Abc_NtkForEachLatch( pNtk, pObj, i )
765  {
766  Abc_NtkDupBox( pNtkNew, pObj, 0 );
767  // latch outputs
768  pNet = Abc_ObjFanout0(Abc_ObjFanout0(pObj));
769  assert( pNet->pCopy == NULL );
770  Abc_NtkDupObj( pNtkNew, pNet, 1 );
771  Abc_ObjAddFanin( pNet->pCopy, Abc_ObjFanout0(pObj)->pCopy );
772  // latch inputs
773  pNet = Abc_ObjFanin0(Abc_ObjFanin0(pObj));
774  if ( pNet->pCopy == NULL )
775  Abc_NtkDupObj( pNtkNew, pNet, 1 );
776  Abc_ObjAddFanin( Abc_ObjFanin0(pObj)->pCopy, pNet->pCopy );
777  }
778 
779  // encode the CI nets
780  Abc_NtkIncrementTravId( pNtk );
781  if ( fUsePositional )
782  {
783  Abc_NtkForEachCi( pNtk, pObj, i )
784  {
785  pNet = Abc_ObjFanout0(pObj);
786  nValues = Abc_ObjMvVarNum(pNet);
787  for ( v = 0; v < nValues; v++ )
788  {
789  pNodeNew = Abc_NtkCreateNode( pNtkNew );
790  pNodeNew->pData = Abc_SopEncoderPos( (Mem_Flex_t *)pNtkNew->pManFunc, v, nValues );
791  pNetNew = Abc_NtkCreateNet( pNtkNew );
792  pTermNew = Abc_NtkCreateBi( pNtkNew );
793  Abc_ObjAddFanin( pNodeNew, pNet->pCopy );
794  Abc_ObjAddFanin( pNetNew, pNodeNew );
795  Abc_ObjAddFanin( pTermNew, pNetNew );
796  Abc_ObjAddFanin( pBoxNew, pTermNew );
797  }
798  // mark the net
799  Abc_NodeSetTravIdCurrent( pNet );
800  }
801  }
802  else
803  {
804  Abc_NtkForEachCi( pNtk, pObj, i )
805  {
806  pNet = Abc_ObjFanout0(pObj);
807  nValues = Abc_ObjMvVarNum(pNet);
808  nBits = Abc_Base2Log( nValues );
809  for ( k = 0; k < nBits; k++ )
810  {
811  pNodeNew = Abc_NtkCreateNode( pNtkNew );
812  pNodeNew->pData = Abc_SopEncoderLog( (Mem_Flex_t *)pNtkNew->pManFunc, k, nValues );
813  pNetNew = Abc_NtkCreateNet( pNtkNew );
814  pTermNew = Abc_NtkCreateBi( pNtkNew );
815  Abc_ObjAddFanin( pNodeNew, pNet->pCopy );
816  Abc_ObjAddFanin( pNetNew, pNodeNew );
817  Abc_ObjAddFanin( pTermNew, pNetNew );
818  Abc_ObjAddFanin( pBoxNew, pTermNew );
819  }
820  // mark the net
821  Abc_NodeSetTravIdCurrent( pNet );
822  }
823  }
824 
825  // encode the CO nets
826  if ( fUsePositional )
827  {
828  Abc_NtkForEachCo( pNtk, pObj, i )
829  {
830  pNet = Abc_ObjFanin0(pObj);
831  // skip marked nets
832  if ( Abc_NodeIsTravIdCurrent(pNet) )
833  continue;
834  Abc_NodeSetTravIdCurrent( pNet );
835  nValues = Abc_ObjMvVarNum(pNet);
836  pNodeNew = Abc_NtkCreateNode( pNtkNew );
837  pNodeNew->pData = Abc_SopDecoderPos( (Mem_Flex_t *)pNtkNew->pManFunc, nValues );
838  for ( v = 0; v < nValues; v++ )
839  {
840  pTermNew = Abc_NtkCreateBo( pNtkNew );
841  pNetNew = Abc_NtkCreateNet( pNtkNew );
842  Abc_ObjAddFanin( pTermNew, pBoxNew );
843  Abc_ObjAddFanin( pNetNew, pTermNew );
844  Abc_ObjAddFanin( pNodeNew, pNetNew );
845  }
846  Abc_ObjAddFanin( pNet->pCopy, pNodeNew );
847  }
848  }
849  else
850  {
851  Abc_NtkForEachCo( pNtk, pObj, i )
852  {
853  pNet = Abc_ObjFanin0(pObj);
854  // skip marked nets
855  if ( Abc_NodeIsTravIdCurrent(pNet) )
856  continue;
857  Abc_NodeSetTravIdCurrent( pNet );
858  nValues = Abc_ObjMvVarNum(pNet);
859  nBits = Abc_Base2Log( nValues );
860  pNodeNew = Abc_NtkCreateNode( pNtkNew );
861  pNodeNew->pData = Abc_SopDecoderLog( (Mem_Flex_t *)pNtkNew->pManFunc, nValues );
862  for ( k = 0; k < nBits; k++ )
863  {
864  pTermNew = Abc_NtkCreateBo( pNtkNew );
865  pNetNew = Abc_NtkCreateNet( pNtkNew );
866  Abc_ObjAddFanin( pTermNew, pBoxNew );
867  Abc_ObjAddFanin( pNetNew, pTermNew );
868  Abc_ObjAddFanin( pNodeNew, pNetNew );
869  }
870  Abc_ObjAddFanin( pNet->pCopy, pNodeNew );
871  }
872  }
873 
874  // if it is a BLIF-MV netlist transfer the values of all nets
875  if ( Abc_NtkHasBlifMv(pNtk) && Abc_NtkMvVar(pNtk) )
876  {
877  if ( Abc_NtkMvVar( pNtkNew ) == NULL )
878  Abc_NtkStartMvVars( pNtkNew );
879  Abc_NtkForEachNet( pNtk, pObj, i )
880  if ( pObj->pCopy )
882  }
883 
884  // check integrity
885  if ( !Abc_NtkCheck( pNtkNew ) )
886  {
887  fprintf( stdout, "Abc_NtkSkeletonBlifMv(): Network check has failed.\n" );
888  Abc_NtkDelete( pNtkNew );
889  return NULL;
890  }
891  return pNtkNew;
892 }
893 
894 /**Function*************************************************************
895 
896  Synopsis [Inserts processed network into original base MV network.]
897 
898  Description [The original network remembers the interface of combinational
899  logic (PIs/POs/latches names and values). The processed network may
900  be binary or multi-valued (currently, multi-value is not supported).
901  The resulting network has the same interface as the original network
902  while the internal logic is the same as that of the processed network.]
903 
904  SideEffects []
905 
906  SeeAlso []
907 
908 ***********************************************************************/
909 Abc_Ntk_t * Abc_NtkInsertBlifMv( Abc_Ntk_t * pNtkBase, Abc_Ntk_t * pNtkLogic )
910 {
911  Abc_Ntk_t * pNtkSkel, * pNtkNew;
912  Abc_Obj_t * pBox;
913 
914  assert( Abc_NtkIsNetlist(pNtkBase) );
915  assert( Abc_NtkHasBlifMv(pNtkBase) );
916  assert( Abc_NtkWhiteboxNum(pNtkBase) == 0 );
917  assert( Abc_NtkBlackboxNum(pNtkBase) == 0 );
918 
919  assert( Abc_NtkIsNetlist(pNtkLogic) );
920  assert( Abc_NtkHasBlifMv(pNtkLogic) );
921  assert( Abc_NtkWhiteboxNum(pNtkLogic) == 0 );
922  assert( Abc_NtkBlackboxNum(pNtkLogic) == 0 );
923 
924  // extract the skeleton of the old network
925  pNtkSkel = Abc_NtkSkeletonBlifMv( pNtkBase );
926 
927  // set the implementation of the box to be the same as the processed network
928  assert( Abc_NtkWhiteboxNum(pNtkSkel) == 1 );
929  pBox = Abc_NtkBox( pNtkSkel, 0 );
930  assert( Abc_ObjIsWhitebox(pBox) );
931  assert( pBox->pData == NULL );
932  assert( Abc_ObjFaninNum(pBox) == Abc_NtkPiNum(pNtkLogic) );
933  assert( Abc_ObjFanoutNum(pBox) == Abc_NtkPoNum(pNtkLogic) );
934  pBox->pData = pNtkLogic;
935 
936  // flatten the hierarchy to insert the processed network
937  pNtkNew = Abc_NtkFlattenLogicHierarchy( pNtkSkel );
938  pBox->pData = NULL;
939  Abc_NtkDelete( pNtkSkel );
940  return pNtkNew;
941 }
942 
943 /**Function*************************************************************
944 
945  Synopsis [Converts SOP netlist into BLIF-MV netlist.]
946 
947  Description []
948 
949  SideEffects []
950 
951  SeeAlso []
952 
953 ***********************************************************************/
955 {
956  Mem_Flex_t * pMmFlex;
957  Abc_Obj_t * pNode;
958  Vec_Str_t * vCube;
959  char * pSop0, * pSop1, * pBlifMv, * pCube, * pCur;
960  int Value, nCubes, nSize, i, k;
961 
962  assert( Abc_NtkIsNetlist(pNtk) );
963  if ( !Abc_NtkToBdd(pNtk) )
964  {
965  printf( "Converting logic functions to BDDs has failed.\n" );
966  return 0;
967  }
968 
969  pMmFlex = Mem_FlexStart();
970  vCube = Vec_StrAlloc( 100 );
971  Abc_NtkForEachNode( pNtk, pNode, i )
972  {
973  // convert BDD into cubes for on-set and off-set
974  Abc_NodeBddToCnf( pNode, pMmFlex, vCube, 0, &pSop0, &pSop1 );
975  // allocate room for the MV-SOP
976  nCubes = Abc_SopGetCubeNum(pSop0) + Abc_SopGetCubeNum(pSop1);
977  nSize = nCubes*(2*Abc_ObjFaninNum(pNode) + 2)+1;
978  pBlifMv = Mem_FlexEntryFetch( pMmFlex, nSize );
979  // add the cubes
980  pCur = pBlifMv;
981  Abc_SopForEachCube( pSop0, Abc_ObjFaninNum(pNode), pCube )
982  {
983  Abc_CubeForEachVar( pCube, Value, k )
984  {
985  *pCur++ = Value;
986  *pCur++ = ' ';
987  }
988  *pCur++ = '0';
989  *pCur++ = '\n';
990  }
991  Abc_SopForEachCube( pSop1, Abc_ObjFaninNum(pNode), pCube )
992  {
993  Abc_CubeForEachVar( pCube, Value, k )
994  {
995  *pCur++ = Value;
996  *pCur++ = ' ';
997  }
998  *pCur++ = '1';
999  *pCur++ = '\n';
1000  }
1001  *pCur++ = 0;
1002  assert( pCur - pBlifMv == nSize );
1003  // update the node representation
1004  Cudd_RecursiveDeref( (DdManager *)pNtk->pManFunc, (DdNode *)pNode->pData );
1005  pNode->pData = pBlifMv;
1006  }
1007 
1008  // update the functionality type
1009  pNtk->ntkFunc = ABC_FUNC_BLIFMV;
1010  Cudd_Quit( (DdManager *)pNtk->pManFunc );
1011  pNtk->pManFunc = pMmFlex;
1012 
1013  Vec_StrFree( vCube );
1014  return 1;
1015 }
1016 
1017 /**Function*************************************************************
1018 
1019  Synopsis [Converts SOP into MV-SOP.]
1020 
1021  Description []
1022 
1023  SideEffects []
1024 
1025  SeeAlso []
1026 
1027 ***********************************************************************/
1028 char * Abc_NodeConvertSopToMvSop( int nVars, Vec_Int_t * vSop0, Vec_Int_t * vSop1 )
1029 {
1030  char * pMvSop, * pCur;
1031  unsigned uCube;
1032  int nCubes, nSize, Value, i, k;
1033  // consider the case of the constant node
1034  if ( Vec_IntSize(vSop0) == 0 || Vec_IntSize(vSop1) == 0 )
1035  {
1036  // (temporary) create a tautology cube
1037  pMvSop = ABC_ALLOC( char, nVars + 3 );
1038  for ( k = 0; k < nVars; k++ )
1039  pMvSop[k] = '-';
1040  pMvSop[nVars] = '0' + (int)(Vec_IntSize(vSop1) > 0);
1041  pMvSop[nVars+1] = '\n';
1042  pMvSop[nVars+2] = 0;
1043  return pMvSop;
1044  }
1045  // find the total number of cubes
1046  nCubes = Vec_IntSize(vSop0) + Vec_IntSize(vSop1);
1047  // find the size of the MVSOP represented as a C-string
1048  // (each cube has nVars variables + one output literal + end-of-line,
1049  // and the string is zero-terminated)
1050  nSize = nCubes * (nVars + 2) + 1;
1051  // allocate memory
1052  pMvSop = pCur = ABC_ALLOC( char, nSize );
1053  // fill in the negative polarity cubes
1054  Vec_IntForEachEntry( vSop0, uCube, i )
1055  {
1056  for ( k = 0; k < nVars; k++ )
1057  {
1058  Value = (uCube >> (2*k)) & 3;
1059  if ( Value == 1 )
1060  *pCur++ = '0';
1061  else if ( Value == 2 )
1062  *pCur++ = '1';
1063  else if ( Value == 0 )
1064  *pCur++ = '-';
1065  else
1066  assert( 0 );
1067  }
1068  *pCur++ = '0';
1069  *pCur++ = '\n';
1070  }
1071  // fill in the positive polarity cubes
1072  Vec_IntForEachEntry( vSop1, uCube, i )
1073  {
1074  for ( k = 0; k < nVars; k++ )
1075  {
1076  Value = (uCube >> (2*k)) & 3;
1077  if ( Value == 1 )
1078  *pCur++ = '0';
1079  else if ( Value == 2 )
1080  *pCur++ = '1';
1081  else if ( Value == 0 )
1082  *pCur++ = '-';
1083  else
1084  assert( 0 );
1085  }
1086  *pCur++ = '1';
1087  *pCur++ = '\n';
1088  }
1089  *pCur++ = 0;
1090  assert( pCur - pMvSop == nSize );
1091  return pMvSop;
1092 }
1093 
1094 
1095 /**Function*************************************************************
1096 
1097  Synopsis [A prototype of internal cost evaluation procedure.]
1098 
1099  Description [This procedure takes the number of variables (nVars),
1100  the array of values of the inputs and the output (pVarValues)
1101  (note that this array has nVars+1 entries), and an MV-SOP represented
1102  as a C-string with one charater for each literal, including inputs
1103  and output. Each cube is terminated with the new-line character ('\n').
1104  The string is zero-terminated.]
1105 
1106  SideEffects []
1107 
1108  SeeAlso []
1109 
1110 ***********************************************************************/
1111 int Abc_NodeEvalMvCostInternal( int nVars, int * pVarValues, char * pMvSop )
1112 {
1113  // for now, return the number of cubes in the MV-SOP
1114  int Counter = 0;
1115  while ( *pMvSop ) Counter += (*pMvSop++ == '\n');
1116  return Counter;
1117 }
1118 
1119 
1120 /**Function*************************************************************
1121 
1122  Synopsis [Evaluates the cost of the cut.]
1123 
1124  Description [The Boolean function of the cut is specified by two SOPs,
1125  which represent the negative/positive polarities of the cut function.
1126  Converts these two SOPs into a mutually-agreed-upon representation
1127  to be passed to the internal cost-evaluation procedure (see the above
1128  prototype Abc_NodeEvalMvCostInternal).]
1129 
1130  SideEffects []
1131 
1132  SeeAlso []
1133 
1134 ***********************************************************************/
1135 int Abc_NodeEvalMvCost( int nVars, Vec_Int_t * vSop0, Vec_Int_t * vSop1 )
1136 {
1137  char * pMvSop;
1138  int * pVarValues;
1139  int i, RetValue;
1140  // collect the input and output values (currently, they are binary)
1141  pVarValues = ABC_ALLOC( int, nVars + 1 );
1142  for ( i = 0; i <= nVars; i++ )
1143  pVarValues[i] = 2;
1144  // prepare MV-SOP for evaluation
1145  pMvSop = Abc_NodeConvertSopToMvSop( nVars, vSop0, vSop1 );
1146  // have a look at the MV-SOP:
1147 // printf( "%s\n", pMvSop );
1148  // get the result of internal cost evaluation
1149  RetValue = Abc_NodeEvalMvCostInternal( nVars, pVarValues, pMvSop );
1150  // cleanup
1151  ABC_FREE( pVarValues );
1152  ABC_FREE( pMvSop );
1153  return RetValue;
1154 }
1155 
1156 ////////////////////////////////////////////////////////////////////////
1157 /// END OF FILE ///
1158 ////////////////////////////////////////////////////////////////////////
1159 
1160 
1162 
Vec_Ptr_t * vAttrs
Definition: abc.h:214
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
ABC_DLL Abc_Obj_t * Abc_AigOr(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
Definition: abcAig.c:719
int Abc_NtkConvertToBlifMv(Abc_Ntk_t *pNtk)
Definition: abcBlifMv.c:954
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
static Abc_Obj_t * Abc_NtkCreateWhitebox(Abc_Ntk_t *pNtk)
Definition: abc.h:310
Definition: cudd.h:278
Abc_Ntk_t * Abc_NtkSkeletonBlifMv(Abc_Ntk_t *pNtk)
Definition: abcBlifMv.c:724
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
Definition: abc.h:284
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition: abcAig.c:683
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Abc_NtkIsNetlist(Abc_Ntk_t *pNtk)
Definition: abc.h:249
#define Abc_SopForEachCube(pSop, nFanins, pCube)
Definition: abc.h:531
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
ABC_DLL int Abc_SopGetCubeNum(char *pSop)
Definition: abcSop.c:489
Abc_Ntk_t * Abc_NtkStrashBlifMv(Abc_Ntk_t *pNtk)
Definition: abcBlifMv.c:380
static void * Abc_NtkMvVar(Abc_Ntk_t *pNtk)
Definition: abc.h:435
int Abc_NodeStrashBlifMv(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj)
Definition: abcBlifMv.c:140
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
static void Abc_ObjSetMvVar(Abc_Obj_t *pObj, void *pV)
Definition: abc.h:439
ABC_DLL Abc_Obj_t * Abc_NtkDupObj(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, int fCopyName)
Definition: abcObj.c:337
static int Abc_NtkLatchNum(Abc_Ntk_t *pNtk)
Definition: abc.h:294
char * Abc_NodeConvertSopToMvSop(int nVars, Vec_Int_t *vSop0, Vec_Int_t *vSop1)
Definition: abcBlifMv.c:1028
static int Abc_ObjIsPi(Abc_Obj_t *pObj)
Definition: abc.h:347
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:287
ABC_DLL Abc_Ntk_t * Abc_NtkFlattenLogicHierarchy(Abc_Ntk_t *pNtk)
Definition: abcHie.c:514
void Abc_NtkFreeMvVars(Abc_Ntk_t *pNtk)
Definition: abcBlifMv.c:66
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static int Abc_ObjIsWhitebox(Abc_Obj_t *pObj)
Definition: abc.h:358
ABC_DLL char * Abc_SopDecoderPos(Mem_Flex_t *pMan, int nValues)
Definition: abcSop.c:1093
static void * Abc_NtkMvVarMan(Abc_Ntk_t *pNtk)
Definition: abc.h:436
void Abc_NtkSetMvVarValues(Abc_Obj_t *pObj, int nValues)
Definition: abcBlifMv.c:84
static Abc_Obj_t * Abc_NtkCi(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:317
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: abcCheck.c:61
ABC_DLL char * Abc_ObjAssignName(Abc_Obj_t *pObj, char *pName, char *pSuffix)
Definition: abcNames.c:68
static Vec_Str_t * Vec_StrAlloc(int nCap)
Definition: bblif.c:495
#define Abc_CubeForEachVar(pCube, Value, i)
Definition: abc.h:529
ABC_DLL Vec_Ptr_t * Abc_NtkDfs(Abc_Ntk_t *pNtk, int fCollectAll)
Definition: abcDfs.c:81
Vec_Ptr_t * vPis
Definition: abc.h:163
static int Abc_NtkHasBlifMv(Abc_Ntk_t *pNtk)
Definition: abc.h:257
static int Abc_NtkWhiteboxNum(Abc_Ntk_t *pNtk)
Definition: abc.h:295
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
for(p=first;p->value< newval;p=p->next)
static int Abc_NtkCoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:288
DECLARATIONS ///.
Definition: abcAig.c:52
char * Mem_FlexEntryFetch(Mem_Flex_t *p, int nBytes)
Definition: mem.c:372
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
char * Extra_UtilStrsav(const char *s)
static Abc_Obj_t * Abc_NtkCo(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:318
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
ABC_DLL Abc_Ntk_t * Abc_NtkAlloc(Abc_NtkType_t Type, Abc_NtkFunc_t Func, int fUseMemMan)
DECLARATIONS ///.
Definition: abcNtk.c:50
Vec_Ptr_t * vCis
Definition: abc.h:165
ABC_NAMESPACE_IMPL_START void Abc_NtkStartMvVars(Abc_Ntk_t *pNtk)
DECLARATIONS ///.
Definition: abcBlifMv.c:46
static Abc_Obj_t * Abc_NtkCreateBo(Abc_Ntk_t *pNtk)
Definition: abc.h:306
void * pManFunc
Definition: abc.h:191
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
Mem_Flex_t * Mem_FlexStart()
Definition: mem.c:311
ABC_DLL Abc_Obj_t * Abc_AigAnd(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
Definition: abcAig.c:700
ABC_DLL char * Abc_SopDecoderLog(Mem_Flex_t *pMan, int nValues)
Definition: abcSop.c:1129
ABC_DLL char * Abc_SopEncoderLog(Mem_Flex_t *pMan, int iBit, int nValues)
Definition: abcSop.c:1049
Abc_Obj_t * pCopy
Definition: abc.h:148
static int Abc_StringGetNumber(char **ppStr)
Definition: abcBlifMv.c:118
ABC_DLL Abc_Obj_t * Abc_NtkDupBox(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pBox, int fCopyName)
Definition: abcObj.c:407
ABC_DLL int Abc_AigCleanup(Abc_Aig_t *pMan)
Definition: abcAig.c:194
static void Vec_StrFree(Vec_Str_t *p)
Definition: bblif.c:616
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
if(last==0)
Definition: sparse_int.h:34
static Abc_Obj_t * Abc_NtkCreateLatch(Abc_Ntk_t *pNtk)
Definition: abc.h:309
#define Abc_NtkForEachNet(pNtk, pNet, i)
Definition: abc.h:458
ABC_DLL int Abc_NtkToBdd(Abc_Ntk_t *pNtk)
Definition: abcFunc.c:1160
char * sprintf()
static int Counter
static void * Abc_ObjMvVar(Abc_Obj_t *pObj)
Definition: abc.h:437
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition: abc.h:497
static Abc_Obj_t * Abc_NtkCreatePi(Abc_Ntk_t *pNtk)
Definition: abc.h:303
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
static Abc_Obj_t * Abc_NtkBox(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:319
void Mem_FlexStop(Mem_Flex_t *p, int fVerbose)
Definition: mem.c:343
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
char * pSpec
Definition: abc.h:159
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
Abc_Ntk_t * pNtk
Definition: abc.h:130
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static void Abc_NtkConvertAssignName(Abc_Obj_t *pObj, Abc_Obj_t *pNet, int Index)
Definition: abcBlifMv.c:360
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
static int Abc_NtkPoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:286
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
Abc_NtkFunc_t ntkFunc
Definition: abc.h:157
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
static Vec_Att_t * Vec_AttAlloc(int nSize, void *pMan, void(*pFuncFreeMan)(void *), void *(*pFuncStartObj)(void *), void(*pFuncFreeObj)(void *, void *))
MACRO DEFINITIONS ///.
Definition: vecAtt.h:96
#define ABC_FREE(obj)
Definition: abc_global.h:232
static int Abc_NtkPiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:285
Abc_Ntk_t * Abc_NtkInsertBlifMv(Abc_Ntk_t *pNtkBase, Abc_Ntk_t *pNtkLogic)
Definition: abcBlifMv.c:909
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
static int Abc_Base2Log(unsigned n)
Definition: abc_global.h:251
static void Abc_NtkIncrementTravId(Abc_Ntk_t *p)
Definition: abc.h:406
static Abc_Obj_t * Abc_NtkCreateNode(Abc_Ntk_t *pNtk)
Definition: abc.h:308
static int Abc_ObjIsNet(Abc_Obj_t *pObj)
Definition: abc.h:354
int strncmp()
static int Abc_ObjMvVarNum(Abc_Obj_t *pObj)
Definition: abc.h:438
static int Abc_ObjIsPo(Abc_Obj_t *pObj)
Definition: abc.h:348
ABC_DLL void Abc_NtkCleanCopy(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:507
static Abc_Obj_t * Abc_ObjNotCond(Abc_Obj_t *p, int c)
Definition: abc.h:325
ABC_DLL void Abc_NodeBddToCnf(Abc_Obj_t *pNode, Mem_Flex_t *pMmMan, Vec_Str_t *vCube, int fAllPrimes, char **ppSop0, char **ppSop1)
Definition: abcFunc.c:490
#define assert(ex)
Definition: util_old.h:213
static Abc_Obj_t * Abc_ObjNot(Abc_Obj_t *p)
Definition: abc.h:324
void Cudd_Quit(DdManager *unique)
Definition: cuddInit.c:225
void * pData
Definition: abc.h:145
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition: abc.h:517
static int Abc_NtkBlackboxNum(Abc_Ntk_t *pNtk)
Definition: abc.h:296
static Abc_Obj_t * Abc_NtkCreateBi(Abc_Ntk_t *pNtk)
Definition: abc.h:305
static Abc_Obj_t * Abc_ObjFanin(Abc_Obj_t *pObj, int i)
Definition: abc.h:372
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
int Abc_NodeEvalMvCostInternal(int nVars, int *pVarValues, char *pMvSop)
Definition: abcBlifMv.c:1111
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
static int Abc_ObjIsTerm(Abc_Obj_t *pObj)
Definition: abc.h:353
ABC_DLL char * Abc_SopEncoderPos(Mem_Flex_t *pMan, int iValue, int nValues)
Definition: abcSop.c:1030
static void Abc_LatchSetInit0(Abc_Obj_t *pLatch)
Definition: abc.h:418
static Abc_Obj_t * Abc_NtkCreatePo(Abc_Ntk_t *pNtk)
Definition: abc.h:304
ABC_DLL void * Abc_NtkAttrFree(Abc_Ntk_t *pNtk, int Attr, int fFreeMan)
DECLARATIONS ///.
Definition: abcUtil.c:50
char * pName
Definition: abc.h:158
int Abc_NodeEvalMvCost(int nVars, Vec_Int_t *vSop0, Vec_Int_t *vSop1)
Definition: abcBlifMv.c:1135
Abc_NtkType_t ntkType
Definition: abc.h:156
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition: abc.h:513
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
static Abc_Obj_t * Abc_NtkCreateNet(Abc_Ntk_t *pNtk)
Definition: abc.h:307
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223