abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
cutList.h
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [cutList.h]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Implementation of layered listed list of cuts.]
8 
9  Synopsis [External declarations.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - June 20, 2005.]
16 
17  Revision [$Id: cutList.h,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #ifndef ABC__opt__cut__cutList_h
22 #define ABC__opt__cut__cutList_h
23 
24 
26 
27 
28 ////////////////////////////////////////////////////////////////////////
29 /// INCLUDES ///
30 ////////////////////////////////////////////////////////////////////////
31 
32 ////////////////////////////////////////////////////////////////////////
33 /// PARAMETERS ///
34 ////////////////////////////////////////////////////////////////////////
35 
36 ////////////////////////////////////////////////////////////////////////
37 /// BASIC TYPES ///
38 ////////////////////////////////////////////////////////////////////////
39 
42 {
45 };
46 
47 ////////////////////////////////////////////////////////////////////////
48 /// MACRO DEFINITIONS ///
49 ////////////////////////////////////////////////////////////////////////
50 
51 ////////////////////////////////////////////////////////////////////////
52 /// FUNCTION DECLARATIONS ///
53 ////////////////////////////////////////////////////////////////////////
54 
55 /**Function*************************************************************
56 
57  Synopsis [Start the cut list.]
58 
59  Description []
60 
61  SideEffects []
62 
63  SeeAlso []
64 
65 ***********************************************************************/
66 static inline void Cut_ListStart( Cut_List_t * p )
67 {
68  int i;
69  for ( i = 1; i <= CUT_SIZE_MAX; i++ )
70  {
71  p->pHead[i] = 0;
72  p->ppTail[i] = &p->pHead[i];
73  }
74 }
75 
76 /**Function*************************************************************
77 
78  Synopsis [Adds one cut to the cut list.]
79 
80  Description []
81 
82  SideEffects []
83 
84  SeeAlso []
85 
86 ***********************************************************************/
87 static inline void Cut_ListAdd( Cut_List_t * p, Cut_Cut_t * pCut )
88 {
89  assert( pCut->nLeaves > 0 && pCut->nLeaves <= CUT_SIZE_MAX );
90  *p->ppTail[pCut->nLeaves] = pCut;
91  p->ppTail[pCut->nLeaves] = &pCut->pNext;
92 }
93 
94 /**Function*************************************************************
95 
96  Synopsis [Adds one cut to the cut list while preserving order.]
97 
98  Description []
99 
100  SideEffects []
101 
102  SeeAlso []
103 
104 ***********************************************************************/
105 static inline void Cut_ListAdd2( Cut_List_t * p, Cut_Cut_t * pCut )
106 {
107  extern int Cut_CutCompare( Cut_Cut_t * pCut1, Cut_Cut_t * pCut2 );
108  Cut_Cut_t * pTemp, ** ppSpot;
109  assert( pCut->nLeaves > 0 && pCut->nLeaves <= CUT_SIZE_MAX );
110  if ( p->pHead[pCut->nLeaves] != NULL )
111  {
112  ppSpot = &p->pHead[pCut->nLeaves];
113  for ( pTemp = p->pHead[pCut->nLeaves]; pTemp; pTemp = pTemp->pNext )
114  {
115  if ( Cut_CutCompare(pCut, pTemp) < 0 )
116  {
117  *ppSpot = pCut;
118  pCut->pNext = pTemp;
119  return;
120  }
121  else
122  ppSpot = &pTemp->pNext;
123  }
124  }
125  *p->ppTail[pCut->nLeaves] = pCut;
126  p->ppTail[pCut->nLeaves] = &pCut->pNext;
127 }
128 
129 /**Function*************************************************************
130 
131  Synopsis [Derive the super list from the linked list of cuts.]
132 
133  Description []
134 
135  SideEffects []
136 
137  SeeAlso []
138 
139 ***********************************************************************/
140 static inline void Cut_ListDerive( Cut_List_t * p, Cut_Cut_t * pList )
141 {
142  Cut_Cut_t * pPrev;
143  int nLeaves;
144  Cut_ListStart( p );
145  while ( pList != NULL )
146  {
147  nLeaves = pList->nLeaves;
148  p->pHead[nLeaves] = pList;
149  for ( pPrev = pList, pList = pList->pNext; pList; pPrev = pList, pList = pList->pNext )
150  if ( nLeaves < (int)pList->nLeaves )
151  break;
152  p->ppTail[nLeaves] = &pPrev->pNext;
153  pPrev->pNext = NULL;
154  }
155 }
156 
157 /**Function*************************************************************
158 
159  Synopsis [Adds the second list to the first list.]
160 
161  Description []
162 
163  SideEffects []
164 
165  SeeAlso []
166 
167 ***********************************************************************/
168 static inline void Cut_ListAddList( Cut_List_t * pOld, Cut_List_t * pNew )
169 {
170  int i;
171  for ( i = 1; i <= CUT_SIZE_MAX; i++ )
172  {
173  if ( pNew->pHead[i] == NULL )
174  continue;
175  *pOld->ppTail[i] = pNew->pHead[i];
176  pOld->ppTail[i] = pNew->ppTail[i];
177  }
178 }
179 
180 /**Function*************************************************************
181 
182  Synopsis [Returns the cut list linked into one sequence of cuts.]
183 
184  Description []
185 
186  SideEffects []
187 
188  SeeAlso []
189 
190 ***********************************************************************/
191 static inline Cut_Cut_t * Cut_ListFinish( Cut_List_t * p )
192 {
193  Cut_Cut_t * pHead = NULL, ** ppTail = &pHead;
194  int i;
195  for ( i = 1; i <= CUT_SIZE_MAX; i++ )
196  {
197  if ( p->pHead[i] == NULL )
198  continue;
199  *ppTail = p->pHead[i];
200  ppTail = p->ppTail[i];
201  }
202  *ppTail = NULL;
203  return pHead;
204 }
205 
206 
207 
209 
210 #endif
211 
212 ////////////////////////////////////////////////////////////////////////
213 /// END OF FILE ///
214 ////////////////////////////////////////////////////////////////////////
215 
static Cut_Cut_t * Cut_ListFinish(Cut_List_t *p)
Definition: cutList.h:191
static void Cut_ListAdd(Cut_List_t *p, Cut_Cut_t *pCut)
Definition: cutList.h:87
typedefABC_NAMESPACE_HEADER_START struct Cut_ListStruct_t_ Cut_List_t
INCLUDES ///.
Definition: cutList.h:40
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Cut_Cut_t * pNext
Definition: cut.h:88
#define CUT_SIZE_MAX
Definition: cut.h:39
int Cut_CutCompare(Cut_Cut_t *pCut1, Cut_Cut_t *pCut2)
Definition: cutCut.c:92
static void Cut_ListAdd2(Cut_List_t *p, Cut_Cut_t *pCut)
Definition: cutList.h:105
unsigned nLeaves
Definition: cut.h:84
static void Cut_ListDerive(Cut_List_t *p, Cut_Cut_t *pList)
Definition: cutList.h:140
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
Definition: abc_global.h:105
#define ABC_NAMESPACE_HEADER_END
Definition: abc_global.h:106
static void Cut_ListStart(Cut_List_t *p)
MACRO DEFINITIONS ///.
Definition: cutList.h:66
Cut_Cut_t ** ppTail[CUT_SIZE_MAX+1]
Definition: cutList.h:44
static void Cut_ListAddList(Cut_List_t *pOld, Cut_List_t *pNew)
Definition: cutList.h:168
#define assert(ex)
Definition: util_old.h:213
Cut_Cut_t * pHead[CUT_SIZE_MAX+1]
Definition: cutList.h:43