ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
cnfCore.c
Go to the documentation of this file.
1
20
21#include "cnf.h"
22
24
25
29
30static Cnf_Man_t * s_pManCnf = NULL;
31
35
47{
48 if ( s_pManCnf == NULL )
49 {
50// printf( "\n\nCreating CNF manager!!!!!\n\n" );
51 s_pManCnf = Cnf_ManStart();
52 }
53}
55{
56 return s_pManCnf;
57}
59{
60 if ( s_pManCnf == NULL )
61 return;
62 Cnf_ManStop( s_pManCnf );
63 s_pManCnf = NULL;
64}
65
66
79{
80 Vec_Int_t * vResult;
81 Cnf_Man_t * p;
82 Vec_Ptr_t * vMapped;
83 Aig_MmFixed_t * pMemCuts;
84 abctime clk;
85 // allocate the CNF manager
86 p = Cnf_ManStart();
87 p->pManAig = pAig;
88
89 // generate cuts for all nodes, assign cost, and find best cuts
90clk = Abc_Clock();
91 pMemCuts = Dar_ManComputeCuts( pAig, 10, 0, 0 );
92p->timeCuts = Abc_Clock() - clk;
93
94 // find the mapping
95clk = Abc_Clock();
97p->timeMap = Abc_Clock() - clk;
98// Aig_ManScanMapping( p, 1 );
99
100 // convert it into CNF
101clk = Abc_Clock();
103 vMapped = Cnf_ManScanMapping( p, 1, 0 );
104 vResult = Cnf_ManWriteCnfMapping( p, vMapped );
105 Vec_PtrFree( vMapped );
106 Aig_MmFixedStop( pMemCuts, 0 );
107p->timeSave = Abc_Clock() - clk;
108
109 // reset reference counters
110 Aig_ManResetRefs( pAig );
111//ABC_PRT( "Cuts ", p->timeCuts );
112//ABC_PRT( "Map ", p->timeMap );
113//ABC_PRT( "Saving ", p->timeSave );
114 Cnf_ManStop( p );
115 return vResult;
116}
117
129Cnf_Dat_t * Cnf_DeriveWithMan( Cnf_Man_t * p, Aig_Man_t * pAig, int nOutputs )
130{
131 Cnf_Dat_t * pCnf;
132 Vec_Ptr_t * vMapped;
133 Aig_MmFixed_t * pMemCuts;
134 abctime clk;
135 // connect the managers
136 p->pManAig = pAig;
137
138 // generate cuts for all nodes, assign cost, and find best cuts
139clk = Abc_Clock();
140 pMemCuts = Dar_ManComputeCuts( pAig, 10, 0, 0 );
141p->timeCuts = Abc_Clock() - clk;
142
143 // find the mapping
144clk = Abc_Clock();
146p->timeMap = Abc_Clock() - clk;
147// Aig_ManScanMapping( p, 1 );
148
149 // convert it into CNF
150clk = Abc_Clock();
152 vMapped = Cnf_ManScanMapping( p, 1, 1 );
153 pCnf = Cnf_ManWriteCnf( p, vMapped, nOutputs );
154 Vec_PtrFree( vMapped );
155 Aig_MmFixedStop( pMemCuts, 0 );
156p->timeSave = Abc_Clock() - clk;
157
158 // reset reference counters
159 Aig_ManResetRefs( pAig );
160//ABC_PRT( "Cuts ", p->timeCuts );
161//ABC_PRT( "Map ", p->timeMap );
162//ABC_PRT( "Saving ", p->timeSave );
163 return pCnf;
164}
165Cnf_Dat_t * Cnf_Derive( Aig_Man_t * pAig, int nOutputs )
166{
168 return Cnf_DeriveWithMan( s_pManCnf, pAig, nOutputs );
169}
170
183{
184 Cnf_Dat_t * pCnf;
185 Vec_Ptr_t * vMapped;
186 Aig_MmFixed_t * pMemCuts;
187 abctime clk;
188 // connect the managers
189 p->pManAig = pAig;
190
191 // generate cuts for all nodes, assign cost, and find best cuts
192clk = Abc_Clock();
193 pMemCuts = Dar_ManComputeCuts( pAig, 10, fSkipTtMin, 0 );
194p->timeCuts = Abc_Clock() - clk;
195
196 // find the mapping
197clk = Abc_Clock();
199p->timeMap = Abc_Clock() - clk;
200// Aig_ManScanMapping( p, 1 );
201
202 // convert it into CNF
203clk = Abc_Clock();
205 vMapped = Cnf_ManScanMapping( p, 1, 1 );
206 pCnf = Cnf_ManWriteCnfOther( p, vMapped );
207 pCnf->vMapping = Cnf_ManWriteCnfMapping( p, vMapped );
208 Vec_PtrFree( vMapped );
209 Aig_MmFixedStop( pMemCuts, 0 );
210p->timeSave = Abc_Clock() - clk;
211
212 // reset reference counters
213 Aig_ManResetRefs( pAig );
214//ABC_PRT( "Cuts ", p->timeCuts );
215//ABC_PRT( "Map ", p->timeMap );
216//ABC_PRT( "Saving ", p->timeSave );
217 return pCnf;
218}
219Cnf_Dat_t * Cnf_DeriveOther( Aig_Man_t * pAig, int fSkipTtMin )
220{
222 return Cnf_DeriveOtherWithMan( s_pManCnf, pAig, fSkipTtMin );
223}
224
225#if 0
226
238Cnf_Dat_t * Cnf_Derive_old( Aig_Man_t * pAig )
239{
240/*
241 // iteratively improve area flow
242 for ( i = 0; i < nIters; i++ )
243 {
244clk = Abc_Clock();
245 Cnf_ManScanMapping( p, 0 );
246 Cnf_ManMapForCnf( p );
247ABC_PRT( "iter ", Abc_Clock() - clk );
248 }
249*/
250 // write the file
251 vMapped = Aig_ManScanMapping( p, 1 );
252 Vec_PtrFree( vMapped );
253
254clk = Abc_Clock();
256
258 Cnf_ManScanMapping( p, 0 );
259/*
260 Cnf_ManPostprocess( p );
261 Cnf_ManScanMapping( p, 0 );
262 Cnf_ManPostprocess( p );
263 Cnf_ManScanMapping( p, 0 );
264*/
265ABC_PRT( "Ext ", Abc_Clock() - clk );
266
267/*
268 vMapped = Cnf_ManScanMapping( p, 1 );
269 pCnf = Cnf_ManWriteCnf( p, vMapped );
270 Vec_PtrFree( vMapped );
271
272 // clean up
273 Cnf_ManFreeCuts( p );
274 Dar_ManCutsFree( pAig );
275 return pCnf;
276*/
277 Aig_MmFixedStop( pMemCuts, 0 );
278 return NULL;
279}
280
281#endif
282
283
287
288
290
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_PRT(a, t)
Definition abc_global.h:255
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition aig.h:50
void Aig_ManResetRefs(Aig_Man_t *p)
Definition aigUtil.c:122
struct Aig_MmFixed_t_ Aig_MmFixed_t
Definition aig.h:52
void Aig_MmFixedStop(Aig_MmFixed_t *p, int fVerbose)
Definition aigMem.c:132
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
Vec_Int_t * Cnf_DeriveMappingArray(Aig_Man_t *pAig)
FUNCTION DECLARATIONS ///.
Definition cnfCore.c:78
Cnf_Dat_t * Cnf_Derive(Aig_Man_t *pAig, int nOutputs)
Definition cnfCore.c:165
void Cnf_ManPrepare()
FUNCTION DEFINITIONS ///.
Definition cnfCore.c:46
Cnf_Dat_t * Cnf_DeriveOther(Aig_Man_t *pAig, int fSkipTtMin)
Definition cnfCore.c:219
void Cnf_ManFree()
Definition cnfCore.c:58
Cnf_Dat_t * Cnf_DeriveWithMan(Cnf_Man_t *p, Aig_Man_t *pAig, int nOutputs)
Definition cnfCore.c:129
Cnf_Man_t * Cnf_ManRead()
Definition cnfCore.c:54
Cnf_Dat_t * Cnf_DeriveOtherWithMan(Cnf_Man_t *p, Aig_Man_t *pAig, int fSkipTtMin)
Definition cnfCore.c:182
void Cnf_ManTransferCuts(Cnf_Man_t *p)
Definition cnfPost.c:117
Cnf_Dat_t * Cnf_ManWriteCnfOther(Cnf_Man_t *p, Vec_Ptr_t *vMapped)
Definition cnfWrite.c:419
typedefABC_NAMESPACE_HEADER_START struct Cnf_Man_t_ Cnf_Man_t
INCLUDES ///.
Definition cnf.h:51
Cnf_Dat_t * Cnf_ManWriteCnf(Cnf_Man_t *p, Vec_Ptr_t *vMapped, int nOutputs)
Definition cnfWrite.c:199
Cnf_Man_t * Cnf_ManStart()
FUNCTION DEFINITIONS ///.
Definition cnfMan.c:51
void Cnf_ManPostprocess(Cnf_Man_t *p)
Definition cnfPost.c:165
void Cnf_DeriveMapping(Cnf_Man_t *p)
Definition cnfMap.c:100
Vec_Ptr_t * Cnf_ManScanMapping(Cnf_Man_t *p, int fCollect, int fPreorder)
Definition cnfUtil.c:377
struct Cnf_Dat_t_ Cnf_Dat_t
Definition cnf.h:52
void Cnf_ManStop(Cnf_Man_t *p)
Definition cnfMan.c:82
Vec_Int_t * Cnf_ManWriteCnfMapping(Cnf_Man_t *p, Vec_Ptr_t *vMapped)
DECLARATIONS ///.
Definition cnfWrite.c:45
Vec_Ptr_t * Aig_ManScanMapping(Cnf_Man_t *p, int fCollect)
Definition cnfUtil.c:297
Aig_MmFixed_t * Dar_ManComputeCuts(Aig_Man_t *pAig, int nCutsMax, int fSkipTtMin, int fVerbose)
Definition darCore.c:291
Cube * p
Definition exorList.c:222
Vec_Int_t * vMapping
Definition cnf.h:67
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42