ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
abcRpo.c File Reference
#include "misc/extra/extra.h"
#include "bool/rpo/rpo.h"
#include "bool/rpo/literal.h"
Include dependency graph for abcRpo.c:

Go to the source code of this file.

Classes

struct  Rpo_TtStore_t_
 

Typedefs

typedef typedefABC_NAMESPACE_IMPL_START struct Rpo_TtStore_t_ Rpo_TtStore_t
 

Functions

int Abc_FileSize (char *pFileName)
 
char * Abc_FileRead (char *pFileName)
 
void Abc_TruthGetParams (char *pFileName, int *pnVars, int *pnTruths)
 
void Abc_TruthRpoPerform (Rpo_TtStore_t *p, int nThreshold, int fVerbose)
 
void Abc_TruthRpoTest (char *pFileName, int nVarNum, int nThreshold, int fVerbose)
 
int Abc_RpoTest (char *pFileName, int nVarNum, int nThreshold, int fVerbose)
 

Typedef Documentation

◆ Rpo_TtStore_t

typedef typedefABC_NAMESPACE_IMPL_START struct Rpo_TtStore_t_ Rpo_TtStore_t

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

FileName [abcRpo.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Rpo package.]

Synopsis [Procedures for executing RPO.]

Author [Mayler G. A. Martins / Vinicius Callegaro]

Affiliation [UFRGS]

Date [Ver. 1.0. Started - May 08, 2013.]

Revision [

Id
abcRpo.c,v 1.00 2013/05/08 00:00:00 mgamartins Exp

]

Definition at line 30 of file abcRpo.c.

Function Documentation

◆ Abc_FileRead()

char * Abc_FileRead ( char * pFileName)
extern

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

Synopsis [Read file contents.]

Description []

SideEffects []

SeeAlso []

Definition at line 223 of file abcDec.c.

224{
225 FILE * pFile;
226 char * pBuffer;
227 int nFileSize, RetValue;
228 pFile = fopen( pFileName, "rb" );
229 if ( pFile == NULL )
230 {
231 printf( "Cannot open file \"%s\" for reading.\n", pFileName );
232 return NULL;
233 }
234 // get the file size, in bytes
235 fseek( pFile, 0, SEEK_END );
236 nFileSize = ftell( pFile );
237 // move the file current reading position to the beginning
238 rewind( pFile );
239 // load the contents of the file into memory
240 pBuffer = (char *)malloc( nFileSize + 3 );
241 RetValue = fread( pBuffer, nFileSize, 1, pFile );
242 // add several empty lines at the end
243 // (these will be used to signal the end of parsing)
244 pBuffer[ nFileSize + 0] = '\n';
245 pBuffer[ nFileSize + 1] = '\n';
246 // terminate the string with '\0'
247 pBuffer[ nFileSize + 2] = '\0';
248 fclose( pFile );
249 return pBuffer;
250}
VOID_HACK rewind()
char * malloc()
#define SEEK_END
Definition zconf.h:392
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_FileSize()

int Abc_FileSize ( char * pFileName)
extern

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

Synopsis [Read file contents.]

Description []

SideEffects []

SeeAlso []

Definition at line 195 of file abcDec.c.

196{
197 FILE * pFile;
198 int nFileSize;
199 pFile = fopen( pFileName, "rb" );
200 if ( pFile == NULL )
201 {
202 printf( "Cannot open file \"%s\" for reading.\n", pFileName );
203 return -1;
204 }
205 // get the file size, in bytes
206 fseek( pFile, 0, SEEK_END );
207 nFileSize = ftell( pFile );
208 fclose( pFile );
209 return nFileSize;
210}
Here is the caller graph for this function:

◆ Abc_RpoTest()

int Abc_RpoTest ( char * pFileName,
int nVarNum,
int nThreshold,
int fVerbose )

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

Synopsis [Testbench for decomposition algorithms.]

Description []

SideEffects []

SeeAlso []

Definition at line 425 of file abcRpo.c.

425 {
426 if (fVerbose) {
427 printf("Using truth tables from file \"%s\"...\n", pFileName);
428 }
429 Abc_TruthRpoTest(pFileName, nVarNum, nThreshold, fVerbose);
430 fflush(stdout);
431 return 0;
432}
void Abc_TruthRpoTest(char *pFileName, int nVarNum, int nThreshold, int fVerbose)
Definition abcRpo.c:394
Here is the call graph for this function:

◆ Abc_TruthGetParams()

void Abc_TruthGetParams ( char * pFileName,
int * pnVars,
int * pnTruths )
extern

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

Synopsis [Determine the number of variables by reading the first line.]

Description [Determine the number of functions by counting the lines.]

SideEffects []

SeeAlso []

Definition at line 263 of file abcDec.c.

264{
265 char * pContents;
266 int i, nVars, nLines;
267 // prepare the output
268 if ( pnVars )
269 *pnVars = 0;
270 if ( pnTruths )
271 *pnTruths = 0;
272 // read data from file
273 pContents = Abc_FileRead( pFileName );
274 if ( pContents == NULL )
275 return;
276 // count the number of symbols before the first space or new-line
277 // (note that on Windows symbols '\r' can be inserted before each '\n')
278 for ( i = 0; pContents[i]; i++ )
279 if ( pContents[i] == ' ' || pContents[i] == '\n' || pContents[i] == '\r' )
280 break;
281 if ( pContents[i] == 0 )
282 printf( "Strange, the input file does not have spaces and new-lines...\n" );
283
284 // acount for the fact that truth tables may have "0x" at the beginning of each line
285 if ( pContents[0] == '0' && pContents[1] == 'x' )
286 i = i - 2;
287
288 // determine the number of variables
289 for ( nVars = 0; nVars < 32; nVars++ )
290 if ( 4 * i == (1 << nVars) ) // the number of bits equal to the size of truth table
291 break;
292 if ( nVars < 2 || nVars > 16 )
293 {
294 printf( "Does not look like the input file contains truth tables...\n" );
295 return;
296 }
297 if ( pnVars )
298 *pnVars = nVars;
299
300 // determine the number of functions by counting the lines
301 nLines = 0;
302 for ( i = 0; pContents[i]; i++ )
303 nLines += (pContents[i] == '\n');
304 if ( pnTruths )
305 *pnTruths = nLines;
306 ABC_FREE( pContents );
307}
char * Abc_FileRead(char *pFileName)
Definition abcDec.c:223
#define ABC_FREE(obj)
Definition abc_global.h:267
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_TruthRpoPerform()

void Abc_TruthRpoPerform ( Rpo_TtStore_t * p,
int nThreshold,
int fVerbose )

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

Synopsis [Apply decomposition to the truth table.]

Description [Returns the number of AIG nodes.]

SideEffects []

SeeAlso []

Definition at line 345 of file abcRpo.c.

345 {
346 clock_t clk = clock();
347 int i;
348 int rpoCount = 0;
349 Literal_t* lit;
350 float percent;
351 for (i = 0; i < p->nFuncs; i++) {
352// if(i>1000) {
353// continue;
354// }
356// if(i!= 2196 ) { //5886
357// continue;
358// }
359 if(fVerbose) {
360 Abc_Print(-2,"%d: ", i+1);
361 }
362
363 lit = Rpo_Factorize((unsigned *) p->pFuncs[i], p->nVars, nThreshold, fVerbose);
364 if (lit != NULL) {
365 if(fVerbose) {
366 Abc_Print(-2, "Solution : %s\n", lit->expression->pArray);
367 Abc_Print(-2, "\n\n");
368 }
369 Lit_Free(lit);
370 rpoCount++;
371 } else {
372 if(fVerbose) {
373 Abc_Print(-2, "null\n");
374 Abc_Print(-2, "\n\n");
375 }
376 }
377 }
378 percent = (rpoCount * 100.0) / p->nFuncs;
379 Abc_Print(-2,"%d of %d (%.2f %%) functions are RPO.\n", rpoCount,p->nFuncs,percent);
380 Abc_PrintTime(1, "Time", clock() - clk);
381}
struct Literal_t_ Literal_t
Definition literal.h:50
Cube * p
Definition exorList.c:222
double percent(double a, double b)
Definition util.hpp:21
Literal_t * Rpo_Factorize(unsigned *target, int nVars, int nThreshold, int verbose)
Definition rpo.c:174
int lit
Definition satVec.h:130
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_TruthRpoTest()

void Abc_TruthRpoTest ( char * pFileName,
int nVarNum,
int nThreshold,
int fVerbose )

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

Synopsis [Apply decomposition to truth tables.]

Description []

SideEffects []

SeeAlso []

Definition at line 394 of file abcRpo.c.

394 {
396
397 // allocate data-structure
398// if (fVerbose) {
399// Abc_Print(-2, "Number of variables = %d\n", nVarNum);
400// }
401 p = Abc_TtStoreLoad(pFileName, nVarNum);
402
403 if (fVerbose) {
404 Abc_Print(-2, "Number of variables = %d\n", p->nVars);
405 }
406 // consider functions from the file
407 Abc_TruthRpoPerform(p, nThreshold, fVerbose);
408
409 // delete data-structure
410 Abc_TtStoreFree(p, nVarNum);
411 // printf( "Finished decomposing truth tables from file \"%s\".\n", pFileName );
412}
void Abc_TtStoreFree(Abc_TtStore_t *p, int nVarNum)
Definition abcDec.c:176
Abc_TtStore_t * Abc_TtStoreLoad(char *pFileName, int nVarNum)
Definition abcDec.c:396
typedefABC_NAMESPACE_IMPL_START struct Rpo_TtStore_t_ Rpo_TtStore_t
Definition abcRpo.c:30
void Abc_TruthRpoPerform(Rpo_TtStore_t *p, int nThreshold, int fVerbose)
Definition abcRpo.c:345
Here is the call graph for this function:
Here is the caller graph for this function: