ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
rwrUtil.c File Reference
#include "rwr.h"
Include dependency graph for rwrUtil.c:

Go to the source code of this file.

Functions

void Rwr_ManWriteToArray (Rwr_Man_t *p)
 FUNCTION DEFINITIONS ///.
 
void Rwr_ManLoadFromArray (Rwr_Man_t *p, int fVerbose)
 
void Rwr_ManWriteToFile (Rwr_Man_t *p, char *pFileName)
 
void Rwr_ManLoadFromFile (Rwr_Man_t *p, char *pFileName)
 
void Rwr_ListAddToTail (Rwr_Node_t **ppList, Rwr_Node_t *pNode)
 
char * Rwr_ManGetPractical (Rwr_Man_t *p)
 

Function Documentation

◆ Rwr_ListAddToTail()

void Rwr_ListAddToTail ( Rwr_Node_t ** ppList,
Rwr_Node_t * pNode )

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

Synopsis [Adds the node to the end of the list.]

Description []

SideEffects []

SeeAlso []

Definition at line 619 of file rwrUtil.c.

620{
621 Rwr_Node_t * pTemp;
622 // find the last one
623 for ( pTemp = *ppList; pTemp; pTemp = pTemp->pNext )
624 ppList = &pTemp->pNext;
625 // attach at the end
626 *ppList = pNode;
627}
struct Rwr_Node_t_ Rwr_Node_t
Definition rwr.h:48
Rwr_Node_t * pNext
Definition rwr.h:112
Here is the caller graph for this function:

◆ Rwr_ManGetPractical()

char * Rwr_ManGetPractical ( Rwr_Man_t * p)

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

Synopsis [Create practical classes.]

Description []

SideEffects []

SeeAlso []

Definition at line 640 of file rwrUtil.c.

641{
642 char * pPractical;
643 int i;
644 pPractical = ABC_ALLOC( char, p->nFuncs );
645 memset( pPractical, 0, sizeof(char) * p->nFuncs );
646 pPractical[0] = 1;
647 for ( i = 1; ; i++ )
648 {
649 if ( s_RwrPracticalClasses[i] == 0 )
650 break;
651 pPractical[ s_RwrPracticalClasses[i] ] = 1;
652 }
653 return pPractical;
654}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
Cube * p
Definition exorList.c:222
char * memset()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Rwr_ManLoadFromArray()

void Rwr_ManLoadFromArray ( Rwr_Man_t * p,
int fVerbose )

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

Synopsis [Loads data.]

Description []

SideEffects []

SeeAlso []

Definition at line 472 of file rwrUtil.c.

473{
474 unsigned short * pArray = s_RwtAigSubgraphs;
475 Rwr_Node_t * p0, * p1;
476 unsigned Entry0, Entry1;
477 int Level, Volume, nEntries, fExor;
478 int i;
479 abctime clk = Abc_Clock();
480
481 // reconstruct the forest
482 for ( i = 0; ; i++ )
483 {
484 Entry0 = pArray[2*i + 0];
485 Entry1 = pArray[2*i + 1];
486 if ( Entry0 == 0 && Entry1 == 0 )
487 break;
488 // get EXOR flag
489 fExor = (Entry0 & 1);
490 Entry0 >>= 1;
491 // get the nodes
492 p0 = (Rwr_Node_t *)p->vForest->pArray[Entry0 >> 1];
493 p1 = (Rwr_Node_t *)p->vForest->pArray[Entry1 >> 1];
494 // compute the level and volume of the new nodes
495 Level = 1 + Abc_MaxInt( p0->Level, p1->Level );
496 Volume = 1 + Rwr_ManNodeVolume( p, p0, p1 );
497 // set the complemented attributes
498 p0 = Rwr_NotCond( p0, (Entry0 & 1) );
499 p1 = Rwr_NotCond( p1, (Entry1 & 1) );
500 // add the node
501// Rwr_ManTryNode( p, p0, p1, Level, Volume );
502 Rwr_ManAddNode( p, p0, p1, fExor, Level, Volume + fExor );
503 }
504 nEntries = i - 1;
505 if ( fVerbose )
506 {
507 printf( "The number of classes = %d. Canonical nodes = %d.\n", p->nClasses, p->nAdded );
508 printf( "The number of nodes loaded = %d. ", nEntries ); ABC_PRT( "Loading", Abc_Clock() - clk );
509 }
510}
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_PRT(a, t)
Definition abc_global.h:255
Rwr_Node_t * Rwr_ManAddNode(Rwr_Man_t *p, Rwr_Node_t *p0, Rwr_Node_t *p1, int fExor, int Level, int Volume)
Definition rwrLib.c:206
int Rwr_ManNodeVolume(Rwr_Man_t *p, Rwr_Node_t *p0, Rwr_Node_t *p1)
Definition rwrLib.c:330
unsigned Level
Definition rwr.h:107
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Rwr_ManLoadFromFile()

void Rwr_ManLoadFromFile ( Rwr_Man_t * p,
char * pFileName )

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

Synopsis [Loads data.]

Description []

SideEffects []

SeeAlso []

Definition at line 562 of file rwrUtil.c.

563{
564 FILE * pFile;
565 Rwr_Node_t * p0, * p1;
566 unsigned * pBuffer;
567 int Level, Volume, nEntries, fExor;
568 int i;
569 abctime clk = Abc_Clock();
570 int RetValue;
571
572 // load the data
573 pFile = fopen( pFileName, "rb" );
574 if ( pFile == NULL )
575 {
576 printf( "Rwr_ManLoadFromFile: Cannot open file \"%s\".\n", pFileName );
577 return;
578 }
579 RetValue = fread( &nEntries, sizeof(int), 1, pFile );
580 pBuffer = ABC_ALLOC( unsigned, nEntries * 2 );
581 RetValue = fread( pBuffer, sizeof(unsigned), nEntries * 2, pFile );
582 fclose( pFile );
583 // reconstruct the forest
584 for ( i = 0; i < nEntries; i++ )
585 {
586 // get EXOR flag
587 fExor = (pBuffer[2*i + 0] & 1);
588 pBuffer[2*i + 0] = (pBuffer[2*i + 0] >> 1);
589 // get the nodes
590 p0 = (Rwr_Node_t *)p->vForest->pArray[pBuffer[2*i + 0] >> 1];
591 p1 = (Rwr_Node_t *)p->vForest->pArray[pBuffer[2*i + 1] >> 1];
592 // compute the level and volume of the new nodes
593 Level = 1 + Abc_MaxInt( p0->Level, p1->Level );
594 Volume = 1 + Rwr_ManNodeVolume( p, p0, p1 );
595 // set the complemented attributes
596 p0 = Rwr_NotCond( p0, (pBuffer[2*i + 0] & 1) );
597 p1 = Rwr_NotCond( p1, (pBuffer[2*i + 1] & 1) );
598 // add the node
599// Rwr_ManTryNode( p, p0, p1, Level, Volume );
600 Rwr_ManAddNode( p, p0, p1, fExor, Level, Volume + fExor );
601 }
602 ABC_FREE( pBuffer );
603 printf( "The number of classes = %d. Canonical nodes = %d.\n", p->nClasses, p->nAdded );
604 printf( "The number of nodes loaded = %d. ", nEntries ); ABC_PRT( "Loading", Abc_Clock() - clk );
605}
#define ABC_FREE(obj)
Definition abc_global.h:267
Here is the call graph for this function:

◆ Rwr_ManWriteToArray()

void Rwr_ManWriteToArray ( Rwr_Man_t * p)

FUNCTION DEFINITIONS ///.

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

Synopsis [Writes data.]

Description []

SideEffects []

SeeAlso []

Definition at line 426 of file rwrUtil.c.

427{
428 FILE * pFile;
429 Rwr_Node_t * pNode;
430 unsigned Entry0, Entry1;
431 int i, nEntries;
432 abctime clk = Abc_Clock();
433 // prepare the buffer
434 nEntries = p->vForest->nSize - 5;
435 pFile = fopen( "npn4_aig_array.txt", "w" );
436 fprintf( pFile, "static unsigned short s_RwtAigSubgraphs[] = \n{" );
437 for ( i = 0; i < nEntries; i++ )
438 {
439 if ( i % 5 == 0 )
440 fprintf( pFile, "\n " );
441 pNode = (Rwr_Node_t *)p->vForest->pArray[i+5];
442 Entry0 = (Rwr_Regular(pNode->p0)->Id << 1) | Rwr_IsComplement(pNode->p0);
443 Entry1 = (Rwr_Regular(pNode->p1)->Id << 1) | Rwr_IsComplement(pNode->p1);
444 Entry0 = (Entry0 << 1) | pNode->fExor;
445 Extra_PrintHex( pFile, &Entry0, 4 );
446 fprintf( pFile, "," );
447 Extra_PrintHex( pFile, &Entry1, 4 );
448 fprintf( pFile, ", " );
449 }
450 if ( i % 5 == 0 )
451 fprintf( pFile, "\n " );
452 Entry0 = 0;
453 Extra_PrintHex( pFile, &Entry0, 4 );
454 fprintf( pFile, "," );
455 Extra_PrintHex( pFile, &Entry0, 4 );
456 fprintf( pFile, " \n};\n" );
457 fclose( pFile );
458 printf( "The number of nodes saved = %d. ", nEntries ); ABC_PRT( "Saving", Abc_Clock() - clk );
459}
void Extra_PrintHex(FILE *pFile, unsigned *pTruth, int nVars)
Rwr_Node_t * p1
Definition rwr.h:111
Rwr_Node_t * p0
Definition rwr.h:110
unsigned fExor
Definition rwr.h:109
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Rwr_ManWriteToFile()

void Rwr_ManWriteToFile ( Rwr_Man_t * p,
char * pFileName )

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

Synopsis [Writes.]

Description []

SideEffects []

SeeAlso []

Definition at line 524 of file rwrUtil.c.

525{
526 FILE * pFile;
527 Rwr_Node_t * pNode;
528 unsigned * pBuffer;
529 int i, nEntries;
530 abctime clk = Abc_Clock();
531 // prepare the buffer
532 nEntries = p->vForest->nSize - 5;
533 pBuffer = ABC_ALLOC( unsigned, nEntries * 2 );
534 for ( i = 0; i < nEntries; i++ )
535 {
536 pNode = (Rwr_Node_t *)p->vForest->pArray[i+5];
537 pBuffer[2*i + 0] = (Rwr_Regular(pNode->p0)->Id << 1) | Rwr_IsComplement(pNode->p0);
538 pBuffer[2*i + 1] = (Rwr_Regular(pNode->p1)->Id << 1) | Rwr_IsComplement(pNode->p1);
539 // save EXOR flag
540 pBuffer[2*i + 0] = (pBuffer[2*i + 0] << 1) | pNode->fExor;
541
542 }
543 pFile = fopen( pFileName, "wb" );
544 fwrite( &nEntries, sizeof(int), 1, pFile );
545 fwrite( pBuffer, sizeof(unsigned), nEntries * 2, pFile );
546 ABC_FREE( pBuffer );
547 fclose( pFile );
548 printf( "The number of nodes saved = %d. ", nEntries ); ABC_PRT( "Saving", Abc_Clock() - clk );
549}