ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
ioReadPla.c File Reference
#include "ioAbc.h"
#include "misc/util/utilTruth.h"
Include dependency graph for ioReadPla.c:

Go to the source code of this file.

Functions

void Io_ReadPlaMarkIdentical (word **pCs, int nCubes, int nWords, Vec_Bit_t *vMarks)
 
void Io_ReadPlaMarkContained (word **pCs, int nCubes, int nWords, Vec_Bit_t *vMarks)
 
int Io_ReadPlaRemoveMarked (word **pCs, int nCubes, int nWords, Vec_Bit_t *vMarks)
 
int Io_ReadPlaMergeDistance1 (word **pCs, int nCubes, int nWords, Vec_Bit_t *vMarks)
 
int Io_ReadPlaSelfSubsumption (word **pCs, int nCubes, int nWords, Vec_Bit_t *vMarks)
 
word ** Io_ReadPlaCubeSetup (Vec_Str_t *vSop)
 
void Io_ReadPlaCubeSetdown (Vec_Str_t *vSop, word **pCs, int nCubes, int nVars)
 
void Io_ReadPlaCubePreprocess (Vec_Str_t *vSop, int iCover, int fVerbose)
 
Abc_Ntk_tIo_ReadPla (char *pFileName, int fZeros, int fBoth, int fOnDc, int fSkipPrepro, int fCheck)
 

Function Documentation

◆ Io_ReadPla()

Abc_Ntk_t * Io_ReadPla ( char * pFileName,
int fZeros,
int fBoth,
int fOnDc,
int fSkipPrepro,
int fCheck )

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

Synopsis [Reads the network from a PLA file.]

Description []

SideEffects []

SeeAlso []

Definition at line 329 of file ioReadPla.c.

330{
332 Abc_Ntk_t * pNtk;
333
334 // start the file
335 p = Extra_FileReaderAlloc( pFileName, "#", "\n\r", " \t|" );
336// p = Extra_FileReaderAlloc( pFileName, "", "\n\r", " \t|" );
337 if ( p == NULL )
338 return NULL;
339
340 // read the network
341 pNtk = Io_ReadPlaNetwork( p, fZeros, fBoth, fOnDc, fSkipPrepro );
343 if ( pNtk == NULL )
344 return NULL;
345
346 // make sure that everything is okay with the network structure
347 if ( fCheck && !Abc_NtkCheckRead( pNtk ) )
348 {
349 printf( "Io_ReadPla: The network check has failed.\n" );
350 Abc_NtkDelete( pNtk );
351 return NULL;
352 }
353 return pNtk;
354}
ABC_DLL int Abc_NtkCheckRead(Abc_Ntk_t *pNtk)
Definition abcCheck.c:80
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition abcNtk.c:1421
Cube * p
Definition exorList.c:222
Extra_FileReader_t * Extra_FileReaderAlloc(char *pFileName, char *pCharsComment, char *pCharsStop, char *pCharsClean)
FUNCTION DEFINITIONS ///.
struct Extra_FileReader_t_ Extra_FileReader_t
Definition extra.h:135
void Extra_FileReaderFree(Extra_FileReader_t *p)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Io_ReadPlaCubePreprocess()

void Io_ReadPlaCubePreprocess ( Vec_Str_t * vSop,
int iCover,
int fVerbose )

Definition at line 275 of file ioReadPla.c.

276{
277 word ** pCs = Io_ReadPlaCubeSetup( vSop );
278 int nCubes = Abc_SopGetCubeNum( Vec_StrArray(vSop) );
279 int nVars = Abc_SopGetVarNum( Vec_StrArray(vSop) );
280 int nWords = Abc_Bit6WordNum( 2*nVars );
281 int nCubesNew, Count, Iter = 0;
282 Vec_Bit_t * vMarks = Vec_BitStart( nCubes );
283 if ( fVerbose )
284 printf( "Cover %5d : V =%5d C%d =%5d", iCover, nVars, Iter, nCubes );
285
286 do
287 {
288 Iter++;
289 do
290 {
291 // remove contained
292 Io_ReadPlaMarkContained( pCs, nCubes, nWords, vMarks );
293 nCubesNew = Io_ReadPlaRemoveMarked( pCs, nCubes, nWords, vMarks );
294 //if ( fVerbose )
295 // printf( " C =%5d", nCubes - nCubesNew );
296 nCubes = nCubesNew;
297 // merge distance-1
298 Count = Io_ReadPlaMergeDistance1( pCs, nCubes, nWords, vMarks );
299 } while ( Count );
300 if ( fVerbose )
301 printf( " C%d =%5d", Iter, nCubes );
302 // try consensus
303 //Count = Io_ReadPlaSelfSubsumption( pCs, nCubes, nWords, vMarks );
304 if ( fVerbose )
305 printf( "%4d", Count );
306 } while ( Count );
307
308 // translate
309 Io_ReadPlaCubeSetdown( vSop, pCs, nCubes, nVars );
310 // finalize
311 if ( fVerbose )
312 printf( "\n" );
313 Vec_BitFree( vMarks );
314 ABC_FREE( pCs[0] );
315 ABC_FREE( pCs );
316}
int nWords
Definition abcNpn.c:127
ABC_DLL int Abc_SopGetVarNum(char *pSop)
Definition abcSop.c:584
ABC_DLL int Abc_SopGetCubeNum(char *pSop)
Definition abcSop.c:537
#define ABC_FREE(obj)
Definition abc_global.h:267
word ** Io_ReadPlaCubeSetup(Vec_Str_t *vSop)
Definition ioReadPla.c:240
int Io_ReadPlaRemoveMarked(word **pCs, int nCubes, int nWords, Vec_Bit_t *vMarks)
Definition ioReadPla.c:145
void Io_ReadPlaCubeSetdown(Vec_Str_t *vSop, word **pCs, int nCubes, int nVars)
Definition ioReadPla.c:263
void Io_ReadPlaMarkContained(word **pCs, int nCubes, int nWords, Vec_Bit_t *vMarks)
Definition ioReadPla.c:127
int Io_ReadPlaMergeDistance1(word **pCs, int nCubes, int nWords, Vec_Bit_t *vMarks)
Definition ioReadPla.c:158
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
typedefABC_NAMESPACE_HEADER_START struct Vec_Bit_t_ Vec_Bit_t
INCLUDES ///.
Definition vecBit.h:42
Here is the call graph for this function:

◆ Io_ReadPlaCubeSetdown()

void Io_ReadPlaCubeSetdown ( Vec_Str_t * vSop,
word ** pCs,
int nCubes,
int nVars )

Definition at line 263 of file ioReadPla.c.

264{
265 char Symbs[3] = {'-', '0', '1'}; int c, v;
266 Vec_StrClear( vSop );
267 for ( c = 0; c < nCubes; c++ )
268 {
269 for ( v = 0; v < nVars; v++ )
270 Vec_StrPush( vSop, Symbs[Abc_TtGetQua(pCs[c], v)] );
271 Vec_StrPrintStr( vSop, " 1\n" );
272 }
273 Vec_StrPush( vSop, 0 );
274}
Here is the caller graph for this function:

◆ Io_ReadPlaCubeSetup()

word ** Io_ReadPlaCubeSetup ( Vec_Str_t * vSop)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 240 of file ioReadPla.c.

241{
242 char * pSop = Vec_StrArray( vSop ), * pCube, Lit;
243 int nCubes = Abc_SopGetCubeNum( pSop );
244 int nVars = Abc_SopGetVarNum( pSop );
245 int nWords = Abc_Bit6WordNum( 2*nVars ), c, v;
246 word ** pCs = ABC_ALLOC( word *, nCubes );
247 pCs[0] = ABC_CALLOC( word, nCubes * nWords );
248 for ( c = 1; c < nCubes; c++ )
249 pCs[c] = pCs[c-1] + nWords;
250 c = 0;
251 Abc_SopForEachCube( pSop, nVars, pCube )
252 {
253 Abc_CubeForEachVar( pCube, Lit, v )
254 if ( Lit == '0' )
255 Abc_TtSetBit( pCs[c], Abc_Var2Lit(v,0) );
256 else if ( Lit == '1' )
257 Abc_TtSetBit( pCs[c], Abc_Var2Lit(v,1) );
258 c++;
259 }
260 assert( c == nCubes );
261 return pCs;
262}
#define Abc_CubeForEachVar(pCube, Value, i)
Definition abc.h:536
#define Abc_SopForEachCube(pSop, nFanins, pCube)
Definition abc.h:538
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Io_ReadPlaMarkContained()

void Io_ReadPlaMarkContained ( word ** pCs,
int nCubes,
int nWords,
Vec_Bit_t * vMarks )

Definition at line 127 of file ioReadPla.c.

128{
129 int c1, c2;
130 Vec_BitFill( vMarks, nCubes, 0 );
131 for ( c1 = 0; c1 < nCubes; c1++ )
132 if ( !Vec_BitEntry(vMarks, c1) )
133 for ( c2 = c1 + 1; c2 < nCubes; c2++ )
134 if ( !Vec_BitEntry(vMarks, c2) )
135 {
136 if ( Abc_TtImply(pCs[c1], pCs[c2], nWords) )
137 Vec_BitWriteEntry( vMarks, c2, 1 );
138 else if ( Abc_TtImply(pCs[c2], pCs[c1], nWords) )
139 {
140 Vec_BitWriteEntry( vMarks, c1, 1 );
141 break;
142 }
143 }
144}
Here is the caller graph for this function:

◆ Io_ReadPlaMarkIdentical()

void Io_ReadPlaMarkIdentical ( word ** pCs,
int nCubes,
int nWords,
Vec_Bit_t * vMarks )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 116 of file ioReadPla.c.

117{
118 int c1, c2;
119 Vec_BitFill( vMarks, nCubes, 0 );
120 for ( c1 = 0; c1 < nCubes; c1++ )
121 if ( !Vec_BitEntry(vMarks, c1) )
122 for ( c2 = c1 + 1; c2 < nCubes; c2++ )
123 if ( !Vec_BitEntry(vMarks, c2) )
124 if ( Abc_TtEqual(pCs[c1], pCs[c2], nWords) )
125 Vec_BitWriteEntry( vMarks, c2, 1 );
126}

◆ Io_ReadPlaMergeDistance1()

int Io_ReadPlaMergeDistance1 ( word ** pCs,
int nCubes,
int nWords,
Vec_Bit_t * vMarks )

Definition at line 158 of file ioReadPla.c.

159{
160 int c1, c2, Res, Counter = 0;
161 Vec_BitFill( vMarks, nCubes, 0 );
162 for ( c1 = 0; c1 < nCubes; c1++ )
163 if ( !Vec_BitEntry(vMarks, c1) )
164 for ( c2 = c1 + 1; c2 < nCubes; c2++ )
165 if ( !Vec_BitEntry(vMarks, c2) )
166 {
167 Res = Io_ReadPlaDistance1( pCs[c1], pCs[c2], nWords );
168 if ( !Res )
169 continue;
170 Abc_TtAnd( pCs[c1], pCs[c1], pCs[c2], nWords, 0 );
171 Vec_BitWriteEntry( vMarks, c2, 1 );
172 Counter++;
173 break;
174 }
175 return Counter;
176}
Here is the caller graph for this function:

◆ Io_ReadPlaRemoveMarked()

int Io_ReadPlaRemoveMarked ( word ** pCs,
int nCubes,
int nWords,
Vec_Bit_t * vMarks )

Definition at line 145 of file ioReadPla.c.

146{
147 int c1, c;
148 for ( c1 = c = 0; c1 < nCubes; c1++ )
149 if ( !Vec_BitEntry(vMarks, c1) )
150 {
151 if ( c == c1 )
152 c++;
153 else
154 Abc_TtCopy( pCs[c++], pCs[c1], nWords, 0 );
155 }
156 return c;
157}
Here is the caller graph for this function:

◆ Io_ReadPlaSelfSubsumption()

int Io_ReadPlaSelfSubsumption ( word ** pCs,
int nCubes,
int nWords,
Vec_Bit_t * vMarks )

Definition at line 177 of file ioReadPla.c.

178{
179 int c1, c2, Res, Counter = 0, iVar = -1, Val0, Val1;
180 Vec_BitFill( vMarks, nCubes, 0 );
181 for ( c1 = 0; c1 < nCubes; c1++ )
182 if ( !Vec_BitEntry(vMarks, c1) )
183 for ( c2 = c1 + 1; c2 < nCubes; c2++ )
184 if ( !Vec_BitEntry(vMarks, c2) )
185 {
186 Res = Io_ReadPlaConsensus( pCs[c1], pCs[c2], nWords, &iVar );
187 if ( !Res )
188 continue;
189 assert( iVar >= 0 && iVar < nWords*32 );
190 Val0 = Abc_TtGetQua( pCs[c1], iVar );
191 Val1 = Abc_TtGetQua( pCs[c2], iVar );
192 // remove values
193 Abc_TtXorQua( pCs[c1], iVar, Val0 );
194 Abc_TtXorQua( pCs[c2], iVar, Val1 );
195 // check containment
196 if ( Abc_TtImply(pCs[c1], pCs[c2], nWords) )
197 {
198 Abc_TtXorQua( pCs[c1], iVar, Val0 );
199 Vec_BitWriteEntry( vMarks, c2, 1 );
200 Counter++;
201 }
202 else if ( Abc_TtImply(pCs[c2], pCs[c1], nWords) )
203 {
204 Abc_TtXorQua( pCs[c2], iVar, Val1 );
205 Vec_BitWriteEntry( vMarks, c1, 1 );
206 Counter++;
207 break;
208 }
209 else
210 {
211 Abc_TtXorQua( pCs[c1], iVar, Val0 );
212 Abc_TtXorQua( pCs[c2], iVar, Val1 );
213 }
214
215/*
216 printf( "Var = %3d ", iVar );
217 printf( "Cube0 = %d ", Abc_TtGetQua(pCs[c1], iVar) );
218 printf( "Cube1 = %d ", Abc_TtGetQua(pCs[c2], iVar) );
219 printf( "\n" );
220 Io_ReadPlaPrintCube( pCs[c1], 32 * nWords );
221 Io_ReadPlaPrintCube( pCs[c2], 32 * nWords );
222 printf( "\n" );
223*/
224 break;
225 }
226 return Counter;
227}