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

Go to the source code of this file.

Functions

static
ABC_NAMESPACE_IMPL_START void 
Abc_NodeEspresso (Abc_Obj_t *pNode)
 DECLARATIONS ///. More...
 
static pset_family Abc_SopToEspresso (char *pSop)
 
static char * Abc_SopFromEspresso (Extra_MmFlex_t *pMan, pset_family Cover)
 
static pset_family Abc_EspressoMinimize (pset_family pOnset, pset_family pDcset)
 
void Abc_NtkEspresso (Abc_Ntk_t *pNtk, int fVerbose)
 FUNCTION DEFINITIONS ///. More...
 

Function Documentation

pset_family Abc_EspressoMinimize ( pset_family  pOnset,
pset_family  pDcset 
)
static

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

Synopsis [Minimizes the cover using Espresso.]

Description []

SideEffects []

SeeAlso []

Definition at line 210 of file abcEspresso.c.

211 {
212  pset_family pOffset;
213  int fNewDcset, i;
214  int fSimple = 0;
215  int fSparse = 0;
216 
217  if ( fSimple )
218  {
219  for ( i = 0; i < cube.num_vars; i++ )
220  pOnset = d1merge( pOnset, i );
221  pOnset = sf_contain( pOnset );
222  return pOnset;
223  }
224 
225  // create the dcset
226  fNewDcset = (pDcset == NULL);
227  if ( pDcset == NULL )
228  pDcset = sf_new( 1, cube.size );
229  pDcset->wsize = pOnset->wsize;
230  pDcset->sf_size = pOnset->sf_size;
231 
232  // derive the offset
233  if ( pDcset->sf_size == 0 || pDcset->count == 0 )
234  pOffset = complement(cube1list(pOnset));
235  else
236  pOffset = complement(cube2list(pOnset, pDcset));
237 
238  // perform minimization
239  skip_make_sparse = !fSparse;
240  pOnset = espresso( pOnset, pDcset, pOffset );
241 
242  // free covers
243  sf_free( pOffset );
244  if ( fNewDcset )
245  sf_free( pDcset );
246  return pOnset;
247 }
pset_family sf_new()
ABC_NAMESPACE_IMPL_START pcover espresso(pcover F, pcover D1, pcover R)
Definition: espresso.c:53
pset_family d1merge(INOUT pset_family A, IN int var)
Definition: contain.c:161
int count
Definition: espresso.h:80
void sf_free()
pcover complement(pcube *T)
Definition: compl.c:49
ABC_NAMESPACE_IMPL_START pset_family sf_contain(INOUT pset_family A)
Definition: contain.c:37
int sf_size
Definition: espresso.h:78
pcube * cube2list(pcover A, pcover B)
Definition: cofactor.c:306
bool skip_make_sparse
Definition: globals.c:28
int wsize
Definition: espresso.h:77
pcube * cube1list(pcover A)
Definition: cofactor.c:289
void Abc_NodeEspresso ( Abc_Obj_t pNode)
static

DECLARATIONS ///.

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

FileName [abcEspresso.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Procedures to minimize SOPs using Espresso.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

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

Synopsis [Minimizes SOP representation of one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 83 of file abcEspresso.c.

84 {
85  extern void define_cube_size( int n );
86  pset_family Cover;
87  int fCompl;
88 
89  assert( Abc_ObjIsNode(pNode) );
90  // define the cube for this node
92  // create the Espresso cover
93  fCompl = Abc_SopIsComplement( pNode->pData );
94  Cover = Abc_SopToEspresso( pNode->pData );
95  // perform minimization
96  Cover = Abc_EspressoMinimize( Cover, NULL ); // deletes also cover
97  // convert back onto the node's SOP representation
98  pNode->pData = Abc_SopFromEspresso( pNode->pNtk->pManFunc, Cover );
99  if ( fCompl ) Abc_SopComplement( pNode->pData );
100  sf_free(Cover);
101 }
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
void sf_free()
void * pManFunc
Definition: abc.h:191
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
static pset_family Abc_EspressoMinimize(pset_family pOnset, pset_family pDcset)
Definition: abcEspresso.c:210
static char * Abc_SopFromEspresso(Extra_MmFlex_t *pMan, pset_family Cover)
Definition: abcEspresso.c:170
void define_cube_size(int n)
Definition: cubehack.c:51
Abc_Ntk_t * pNtk
Definition: abc.h:130
ABC_DLL void Abc_SopComplement(char *pSop)
Definition: abcSop.c:600
#define assert(ex)
Definition: util_old.h:213
static pset_family Abc_SopToEspresso(char *pSop)
Definition: abcEspresso.c:114
void * pData
Definition: abc.h:145
ABC_DLL int Abc_SopIsComplement(char *pSop)
Definition: abcSop.c:655
void Abc_NtkEspresso ( Abc_Ntk_t pNtk,
int  fVerbose 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Minimizes SOP representations using Espresso.]

Description []

SideEffects []

SeeAlso []

Definition at line 51 of file abcEspresso.c.

52 {
53  Abc_Obj_t * pNode;
54  int i;
55  assert( Abc_NtkIsLogic(pNtk) );
56  // convert the network to have SOPs
57  if ( Abc_NtkHasMapping(pNtk) )
58  Abc_NtkMapToSop(pNtk);
59  else if ( Abc_NtkHasBdd(pNtk) )
60  {
61  if ( !Abc_NtkBddToSop(pNtk, 0) )
62  {
63  printf( "Abc_NtkEspresso(): Converting to SOPs has failed.\n" );
64  return;
65  }
66  }
67  // minimize SOPs of all nodes
68  Abc_NtkForEachNode( pNtk, pNode, i )
69  if ( i ) Abc_NodeEspresso( pNode );
70 }
static int Abc_NtkIsLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:250
static int Abc_NtkHasBdd(Abc_Ntk_t *pNtk)
Definition: abc.h:254
static int Abc_NtkHasMapping(Abc_Ntk_t *pNtk)
Definition: abc.h:256
ABC_DLL int Abc_NtkMapToSop(Abc_Ntk_t *pNtk)
Definition: abcFunc.c:1073
static ABC_NAMESPACE_IMPL_START void Abc_NodeEspresso(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcEspresso.c:83
if(last==0)
Definition: sparse_int.h:34
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
ABC_DLL int Abc_NtkBddToSop(Abc_Ntk_t *pNtk, int fDirect)
Definition: abcFunc.c:359
#define assert(ex)
Definition: util_old.h:213
char * Abc_SopFromEspresso ( Extra_MmFlex_t pMan,
pset_family  Cover 
)
static

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

Synopsis [Converts SOP representation in Espresso into SOP in ABC.]

Description []

SideEffects []

SeeAlso []

Definition at line 170 of file abcEspresso.c.

171 {
172  pset set;
173  char * pSop, * pCube;
174  int Lit, nVars, nCubes, i, k;
175 
176  nVars = Cover->sf_size/2;
177  nCubes = Cover->count;
178 
179  pSop = Abc_SopStart( pMan, nCubes, nVars );
180 
181  // go through the cubes
182  i = 0;
183  Abc_SopForEachCube( pSop, nVars, pCube )
184  {
185  set = GETSET(Cover, i++);
186  for ( k = 0; k < nVars; k++ )
187  {
188  Lit = GETINPUT(set, k);
189  if ( Lit == ZERO )
190  pCube[k] = '0';
191  else if ( Lit == ONE )
192  pCube[k] = '1';
193  }
194  }
195  return pSop;
196 }
ABC_DLL char * Abc_SopStart(Mem_Flex_t *pMan, int nCubes, int nVars)
Definition: abcSop.c:76
#define Abc_SopForEachCube(pSop, nFanins, pCube)
Definition: abc.h:531
int count
Definition: espresso.h:80
#define ONE
Definition: espresso.h:414
#define ZERO
Definition: espresso.h:415
#define GETINPUT(c, pos)
Definition: espresso.h:400
int sf_size
Definition: espresso.h:78
unsigned int * pset
Definition: espresso.h:73
#define GETSET(family, index)
Definition: espresso.h:161
pset_family Abc_SopToEspresso ( char *  pSop)
static

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

Synopsis [Converts SOP in ABC into SOP representation in Espresso.]

Description []

SideEffects []

SeeAlso []

Definition at line 114 of file abcEspresso.c.

115 {
116  char * pCube;
117  pset_family Cover;
118  pset set;
119  int nCubes, nVars, Value, v;
120 
121  if ( pSop == NULL )
122  return NULL;
123 
124  nVars = Abc_SopGetVarNum(pSop);
125  nCubes = Abc_SopGetCubeNum(pSop);
126  assert( cube.size == 2 * nVars );
127 
128  if ( Abc_SopIsConst0(pSop) )
129  {
130  Cover = sf_new(0, cube.size);
131  return Cover;
132  }
133  if ( Abc_SopIsConst1(pSop) )
134  {
135  Cover = sf_new(1, cube.size);
136  set = GETSET(Cover, Cover->count++);
137  set_copy( set, cube.fullset );
138  return Cover;
139  }
140 
141  // create the cover
142  Cover = sf_new(nCubes, cube.size);
143  // fill in the cubes
144  Abc_SopForEachCube( pSop, nVars, pCube )
145  {
146  set = GETSET(Cover, Cover->count++);
147  set_copy( set, cube.fullset );
148  Abc_CubeForEachVar( pCube, Value, v )
149  {
150  if ( Value == '0' )
151  set_remove(set, 2*v+1);
152  else if ( Value == '1' )
153  set_remove(set, 2*v);
154  }
155  }
156  return Cover;
157 }
pset_family sf_new()
pset set_copy()
#define Abc_SopForEachCube(pSop, nFanins, pCube)
Definition: abc.h:531
ABC_DLL int Abc_SopGetCubeNum(char *pSop)
Definition: abcSop.c:489
int count
Definition: espresso.h:80
#define Abc_CubeForEachVar(pCube, Value, i)
Definition: abc.h:529
unsigned int * pset
Definition: espresso.h:73
ABC_DLL int Abc_SopIsConst0(char *pSop)
Definition: abcSop.c:676
ABC_DLL int Abc_SopIsConst1(char *pSop)
Definition: abcSop.c:692
#define set_remove(set, e)
Definition: espresso.h:171
#define GETSET(family, index)
Definition: espresso.h:161
ABC_DLL int Abc_SopGetVarNum(char *pSop)
Definition: abcSop.c:536
#define assert(ex)
Definition: util_old.h:213