abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
cutSeq.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [cutSeq.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [K-feasible cut computation package.]
8 
9  Synopsis [Sequential cut computation.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - June 20, 2005.]
16 
17  Revision [$Id: cutSeq.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "cutInt.h"
22 
24 
25 
26 ////////////////////////////////////////////////////////////////////////
27 /// DECLARATIONS ///
28 ////////////////////////////////////////////////////////////////////////
29 
30 ////////////////////////////////////////////////////////////////////////
31 /// FUNCTION DEFINITIONS ///
32 ////////////////////////////////////////////////////////////////////////
33 
34 /**Function*************************************************************
35 
36  Synopsis [Shifts all cut leaves of the node by the given number of latches.]
37 
38  Description []
39 
40  SideEffects []
41 
42  SeeAlso []
43 
44 ***********************************************************************/
45 static inline void Cut_NodeShiftCutLeaves( Cut_Cut_t * pList, int nLat )
46 {
47  Cut_Cut_t * pTemp;
48  int i;
49  // shift the cuts by as many latches
50  Cut_ListForEachCut( pList, pTemp )
51  {
52  pTemp->uSign = 0;
53  for ( i = 0; i < (int)pTemp->nLeaves; i++ )
54  {
55  pTemp->pLeaves[i] += nLat;
56  pTemp->uSign |= Cut_NodeSign( pTemp->pLeaves[i] );
57  }
58  }
59 }
60 
61 /**Function*************************************************************
62 
63  Synopsis [Computes sequential cuts for the node from its fanins.]
64 
65  Description []
66 
67  SideEffects []
68 
69  SeeAlso []
70 
71 ***********************************************************************/
72 void Cut_NodeComputeCutsSeq( Cut_Man_t * p, int Node, int Node0, int Node1, int fCompl0, int fCompl1, int nLat0, int nLat1, int fTriv, int CutSetNum )
73 {
74  Cut_List_t Super, * pSuper = &Super;
75  Cut_Cut_t * pListNew;
76  abctime clk;
77 
78  // get the number of cuts at the node
80  if ( p->nNodeCuts >= p->pParams->nKeepMax )
81  return;
82 
83  // count only the first visit
84  if ( p->nNodeCuts == 0 )
85  p->nNodes++;
86 
87  // store the fanin lists
88  p->pStore0[0] = Cut_NodeReadCutsOld( p, Node0 );
89  p->pStore0[1] = Cut_NodeReadCutsNew( p, Node0 );
90  p->pStore1[0] = Cut_NodeReadCutsOld( p, Node1 );
91  p->pStore1[1] = Cut_NodeReadCutsNew( p, Node1 );
92 
93  // duplicate the cut lists if fanin nodes are non-standard
94  if ( Node == Node0 || Node == Node1 || Node0 == Node1 )
95  {
96  p->pStore0[0] = Cut_CutDupList( p, p->pStore0[0] );
97  p->pStore0[1] = Cut_CutDupList( p, p->pStore0[1] );
98  p->pStore1[0] = Cut_CutDupList( p, p->pStore1[0] );
99  p->pStore1[1] = Cut_CutDupList( p, p->pStore1[1] );
100  }
101 
102  // shift the cuts by as many latches and recompute signatures
103  if ( nLat0 ) Cut_NodeShiftCutLeaves( p->pStore0[0], nLat0 );
104  if ( nLat0 ) Cut_NodeShiftCutLeaves( p->pStore0[1], nLat0 );
105  if ( nLat1 ) Cut_NodeShiftCutLeaves( p->pStore1[0], nLat1 );
106  if ( nLat1 ) Cut_NodeShiftCutLeaves( p->pStore1[1], nLat1 );
107 
108  // store the original lists for comparison
109  p->pCompareOld = Cut_NodeReadCutsOld( p, Node );
110  p->pCompareNew = Cut_NodeReadCutsNew( p, Node );
111 
112  // merge the old and the new
113 clk = Abc_Clock();
114  Cut_ListStart( pSuper );
115  Cut_NodeDoComputeCuts( p, pSuper, Node, fCompl0, fCompl1, p->pStore0[0], p->pStore1[1], 0, 0 );
116  Cut_NodeDoComputeCuts( p, pSuper, Node, fCompl0, fCompl1, p->pStore0[1], p->pStore1[0], 0, 0 );
117  Cut_NodeDoComputeCuts( p, pSuper, Node, fCompl0, fCompl1, p->pStore0[1], p->pStore1[1], fTriv, 0 );
118  pListNew = Cut_ListFinish( pSuper );
119 p->timeMerge += Abc_Clock() - clk;
120 
121  // shift the cuts by as many latches and recompute signatures
122  if ( Node == Node0 || Node == Node1 || Node0 == Node1 )
123  {
124  Cut_CutRecycleList( p, p->pStore0[0] );
125  Cut_CutRecycleList( p, p->pStore0[1] );
126  Cut_CutRecycleList( p, p->pStore1[0] );
127  Cut_CutRecycleList( p, p->pStore1[1] );
128  }
129  else
130  {
131  if ( nLat0 ) Cut_NodeShiftCutLeaves( p->pStore0[0], -nLat0 );
132  if ( nLat0 ) Cut_NodeShiftCutLeaves( p->pStore0[1], -nLat0 );
133  if ( nLat1 ) Cut_NodeShiftCutLeaves( p->pStore1[0], -nLat1 );
134  if ( nLat1 ) Cut_NodeShiftCutLeaves( p->pStore1[1], -nLat1 );
135  }
136 
137  // set the lists at the node
138  if ( CutSetNum >= 0 )
139  {
140  assert( Cut_NodeReadCutsTemp(p, CutSetNum) == NULL );
141  Cut_NodeWriteCutsTemp( p, CutSetNum, pListNew );
142  }
143  else
144  {
145  assert( Cut_NodeReadCutsNew(p, Node) == NULL );
146  Cut_NodeWriteCutsNew( p, Node, pListNew );
147  }
148 
149  // mark the node if we exceeded the number of cuts
150  if ( p->nNodeCuts >= p->pParams->nKeepMax )
151  p->nCutsLimit++;
152 }
153 
154 /**Function*************************************************************
155 
156  Synopsis [Merges the new cuts with the old cuts.]
157 
158  Description []
159 
160  SideEffects []
161 
162  SeeAlso []
163 
164 ***********************************************************************/
166 {
167  Cut_Cut_t * pListOld, * pListNew, * pList;
168  // get the new cuts
169  pListNew = Cut_NodeReadCutsNew( p, Node );
170  if ( pListNew == NULL )
171  return;
172  Cut_NodeWriteCutsNew( p, Node, NULL );
173  // get the old cuts
174  pListOld = Cut_NodeReadCutsOld( p, Node );
175  if ( pListOld == NULL )
176  {
177  Cut_NodeWriteCutsOld( p, Node, pListNew );
178  return;
179  }
180  // merge the lists
181  pList = Cut_CutMergeLists( pListOld, pListNew );
182  Cut_NodeWriteCutsOld( p, Node, pList );
183 }
184 
185 
186 /**Function*************************************************************
187 
188  Synopsis [Transfers the temporary cuts to be the new cuts.]
189 
190  Description [Returns 1 if something was transferred.]
191 
192  SideEffects []
193 
194  SeeAlso []
195 
196 ***********************************************************************/
197 int Cut_NodeTempTransferToNew( Cut_Man_t * p, int Node, int CutSetNum )
198 {
199  Cut_Cut_t * pList;
200  pList = Cut_NodeReadCutsTemp( p, CutSetNum );
201  Cut_NodeWriteCutsTemp( p, CutSetNum, NULL );
202  Cut_NodeWriteCutsNew( p, Node, pList );
203  return pList != NULL;
204 }
205 
206 /**Function*************************************************************
207 
208  Synopsis [Transfers the old cuts to be the new cuts.]
209 
210  Description []
211 
212  SideEffects []
213 
214  SeeAlso []
215 
216 ***********************************************************************/
218 {
219  Cut_Cut_t * pList;
220  pList = Cut_NodeReadCutsOld( p, Node );
221  Cut_NodeWriteCutsOld( p, Node, NULL );
222  Cut_NodeWriteCutsNew( p, Node, pList );
223 // Cut_CutListVerify( pList );
224 }
225 
226 ////////////////////////////////////////////////////////////////////////
227 /// END OF FILE ///
228 ////////////////////////////////////////////////////////////////////////
229 
230 
232 
void Cut_CutRecycleList(Cut_Man_t *p, Cut_Cut_t *pList)
Definition: cutCut.c:148
static Cut_Cut_t * Cut_ListFinish(Cut_List_t *p)
Definition: cutList.h:191
Cut_Cut_t * Cut_NodeReadCutsTemp(Cut_Man_t *p, int Node)
Definition: cutApi.c:80
Cut_Cut_t * Cut_NodeReadCutsOld(Cut_Man_t *p, int Node)
Definition: cutApi.c:63
typedefABC_NAMESPACE_HEADER_START struct Cut_ListStruct_t_ Cut_List_t
INCLUDES ///.
Definition: cutList.h:40
Cut_Cut_t * Cut_CutDupList(Cut_Man_t *p, Cut_Cut_t *pList)
Definition: cutCut.c:120
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Cut_CutCountList(Cut_Cut_t *pList)
Definition: cutCut.c:166
static unsigned Cut_NodeSign(int Node)
MACRO DEFINITIONS ///.
Definition: cutInt.h:124
static abctime Abc_Clock()
Definition: abc_global.h:279
void Cut_NodeWriteCutsTemp(Cut_Man_t *p, int Node, Cut_Cut_t *pList)
Definition: cutApi.c:129
void Cut_NodeWriteCutsOld(Cut_Man_t *p, int Node, Cut_Cut_t *pList)
Definition: cutApi.c:113
Cut_Cut_t * Cut_CutMergeLists(Cut_Cut_t *pList1, Cut_Cut_t *pList2)
Definition: cutCut.c:185
int pLeaves[0]
Definition: cut.h:89
unsigned nLeaves
Definition: cut.h:84
abctime timeMerge
Definition: cutInt.h:95
unsigned uSign
Definition: cut.h:85
Cut_Cut_t * pStore1[2]
Definition: cutInt.h:70
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
void Cut_NodeOldTransferToNew(Cut_Man_t *p, int Node)
Definition: cutSeq.c:217
Cut_Cut_t * pCompareNew
Definition: cutInt.h:72
Cut_Cut_t * pStore0[2]
Definition: cutInt.h:69
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
Cut_Cut_t * pCompareOld
Definition: cutInt.h:71
static void Cut_ListStart(Cut_List_t *p)
MACRO DEFINITIONS ///.
Definition: cutList.h:66
static ABC_NAMESPACE_IMPL_START void Cut_NodeShiftCutLeaves(Cut_Cut_t *pList, int nLat)
DECLARATIONS ///.
Definition: cutSeq.c:45
int Cut_NodeTempTransferToNew(Cut_Man_t *p, int Node, int CutSetNum)
Definition: cutSeq.c:197
Cut_Params_t * pParams
Definition: cutInt.h:51
#define assert(ex)
Definition: util_old.h:213
#define Cut_ListForEachCut(pList, pCut)
Definition: cutInt.h:104
void Cut_NodeDoComputeCuts(Cut_Man_t *p, Cut_List_t *pSuper, int Node, int fCompl0, int fCompl1, Cut_Cut_t *pList0, Cut_Cut_t *pList1, int fTriv, int TreeCode)
Definition: cutNode.c:572
void Cut_NodeComputeCutsSeq(Cut_Man_t *p, int Node, int Node0, int Node1, int fCompl0, int fCompl1, int nLat0, int nLat1, int fTriv, int CutSetNum)
Definition: cutSeq.c:72
void Cut_NodeNewMergeWithOld(Cut_Man_t *p, int Node)
Definition: cutSeq.c:165
ABC_INT64_T abctime
Definition: abc_global.h:278
void Cut_NodeWriteCutsNew(Cut_Man_t *p, int Node, Cut_Cut_t *pList)
Definition: cutApi.c:97
Cut_Cut_t * Cut_NodeReadCutsNew(Cut_Man_t *p, int Node)
MACRO DEFINITIONS ///.
Definition: cutApi.c:45
int nCutsLimit
Definition: cutInt.h:90