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

Go to the source code of this file.

Classes

struct  Ivy_Eva_t_
 

Macros

#define IVY_EVAL_LIMIT   128
 DECLARATIONS ///.
 

Typedefs

typedef struct Ivy_Eva_t_ Ivy_Eva_t
 

Functions

int Ivy_MultiPlus (Ivy_Man_t *p, Vec_Ptr_t *vLeaves, Vec_Ptr_t *vCone, Ivy_Type_t Type, int nLimit, Vec_Ptr_t *vSols)
 FUNCTION DEFINITIONS ///.
 

Macro Definition Documentation

◆ IVY_EVAL_LIMIT

#define IVY_EVAL_LIMIT   128

DECLARATIONS ///.

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

FileName [ivyMulti.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [And-Inverter Graph package.]

Synopsis [Constructing multi-input AND/EXOR gates.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - May 11, 2006.]

Revision [

Id
ivyMulti.c,v 1.00 2006/05/11 00:00:00 alanmi Exp

]

Definition at line 30 of file ivyMulti.c.

Typedef Documentation

◆ Ivy_Eva_t

typedef struct Ivy_Eva_t_ Ivy_Eva_t

Definition at line 32 of file ivyMulti.c.

Function Documentation

◆ Ivy_MultiPlus()

int Ivy_MultiPlus ( Ivy_Man_t * p,
Vec_Ptr_t * vLeaves,
Vec_Ptr_t * vCone,
Ivy_Type_t Type,
int nLimit,
Vec_Ptr_t * vSols )

FUNCTION DEFINITIONS ///.

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

Synopsis [Constructs a balanced tree while taking sharing into account.]

Description [Returns 1 if the implementation exists.]

SideEffects []

SeeAlso []

Definition at line 58 of file ivyMulti.c.

59{
60 static Ivy_Eva_t pEvals[IVY_EVAL_LIMIT];
61 Ivy_Eva_t * pEval, * pFan0, * pFan1;
62 Ivy_Obj_t * pObj = NULL; // Suppress "might be used uninitialized"
63 Ivy_Obj_t * pTemp;
64 int nEvals, nEvalsOld, i, k, x, nLeaves;
65 unsigned uMaskAll;
66
67 // consider special cases
68 nLeaves = Vec_PtrSize(vLeaves);
69 assert( nLeaves > 2 );
70 if ( nLeaves > 32 || nLeaves + Vec_PtrSize(vCone) > IVY_EVAL_LIMIT )
71 return 0;
72// if ( nLeaves == 1 )
73// return Vec_PtrEntry( vLeaves, 0 );
74// if ( nLeaves == 2 )
75// return Ivy_Oper( Vec_PtrEntry(vLeaves, 0), Vec_PtrEntry(vLeaves, 1), Type );
76
77 // set the leaf entries
78 uMaskAll = ((1 << nLeaves) - 1);
79 nEvals = 0;
80 Vec_PtrForEachEntry( Ivy_Obj_t *, vLeaves, pObj, i )
81 {
82 pEval = pEvals + nEvals;
83 pEval->pArg = pObj;
84 pEval->Mask = (1 << nEvals);
85 pEval->Weight = 1;
86 // mark the leaf
87 Ivy_Regular(pObj)->TravId = nEvals;
88 nEvals++;
89 }
90
91 // propagate masks through the cone
92 Vec_PtrForEachEntry( Ivy_Obj_t *, vCone, pObj, i )
93 {
94 pObj->TravId = nEvals + i;
95 if ( Ivy_ObjIsBuf(pObj) )
96 pEvals[pObj->TravId].Mask = pEvals[Ivy_ObjFanin0(pObj)->TravId].Mask;
97 else
98 pEvals[pObj->TravId].Mask = pEvals[Ivy_ObjFanin0(pObj)->TravId].Mask | pEvals[Ivy_ObjFanin1(pObj)->TravId].Mask;
99 }
100
101 // set the internal entries
102 Vec_PtrForEachEntry( Ivy_Obj_t *, vCone, pObj, i )
103 {
104 if ( i == Vec_PtrSize(vCone) - 1 )
105 break;
106 // skip buffers
107 if ( Ivy_ObjIsBuf(pObj) )
108 continue;
109 // skip nodes without external fanout
110 if ( Ivy_ObjRefs(pObj) == 0 )
111 continue;
112 assert( !Ivy_IsComplement(pObj) );
113 pEval = pEvals + nEvals;
114 pEval->pArg = pObj;
115 pEval->Mask = pEvals[pObj->TravId].Mask;
116 pEval->Weight = Extra_WordCountOnes(pEval->Mask);
117 // mark the node
118 pObj->TravId = nEvals;
119 nEvals++;
120 }
121
122 // find the available nodes
123 nEvalsOld = nEvals;
124 for ( i = 1; i < nEvals; i++ )
125 for ( k = 0; k < i; k++ )
126 {
127 pFan0 = pEvals + i;
128 pFan1 = pEvals + k;
129 pTemp = Ivy_TableLookup(p, Ivy_ObjCreateGhost(p, pFan0->pArg, pFan1->pArg, Type, IVY_INIT_NONE));
130 // skip nodes in the cone
131 if ( pTemp == NULL || pTemp->fMarkB )
132 continue;
133 // skip the leaves
134 for ( x = 0; x < nLeaves; x++ )
135 if ( pTemp == Ivy_Regular((Ivy_Obj_t *)vLeaves->pArray[x]) )
136 break;
137 if ( x < nLeaves )
138 continue;
139 pEval = pEvals + nEvals;
140 pEval->pArg = pTemp;
141 pEval->Mask = pFan0->Mask | pFan1->Mask;
142 pEval->Weight = (pFan0->Mask & pFan1->Mask) ? Extra_WordCountOnes(pEval->Mask) : pFan0->Weight + pFan1->Weight;
143 // save the argument
144 pObj->TravId = nEvals;
145 nEvals++;
146 // quit if the number of entries exceeded the limit
147 if ( nEvals == IVY_EVAL_LIMIT )
148 goto Outside;
149 // quit if we found an acceptable implementation
150 if ( pEval->Mask == uMaskAll )
151 goto Outside;
152 }
153Outside:
154
155// Ivy_MultiPrint( pEvals, nLeaves, nEvals );
156 if ( !Ivy_MultiCover( p, pEvals, nLeaves, nEvals, nLimit, vSols ) )
157 return 0;
158 assert( Vec_PtrSize( vSols ) > 0 );
159 return 1;
160}
Cube * p
Definition exorList.c:222
struct Ivy_Eva_t_ Ivy_Eva_t
Definition ivyMulti.c:32
#define IVY_EVAL_LIMIT
DECLARATIONS ///.
Definition ivyMulti.c:30
@ IVY_INIT_NONE
Definition ivy.h:66
Ivy_Obj_t * Ivy_TableLookup(Ivy_Man_t *p, Ivy_Obj_t *pObj)
FUNCTION DEFINITIONS ///.
Definition ivyTable.c:71
struct Ivy_Obj_t_ Ivy_Obj_t
Definition ivy.h:47
unsigned Mask
Definition ivyMulti.c:36
int Weight
Definition ivyMulti.c:37
Ivy_Obj_t * pArg
Definition ivyMulti.c:35
unsigned fMarkB
Definition ivy.h:79
int TravId
Definition ivy.h:76
#define assert(ex)
Definition util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the call graph for this function: