abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
rwrDec.c File Reference
#include "rwr.h"
#include "bool/dec/dec.h"

Go to the source code of this file.

Functions

static
ABC_NAMESPACE_IMPL_START
Dec_Graph_t
Rwr_NodePreprocess (Rwr_Man_t *p, Rwr_Node_t *pNode)
 DECLARATIONS ///. More...
 
static Dec_Edge_t Rwr_TravCollect_rec (Rwr_Man_t *p, Rwr_Node_t *pNode, Dec_Graph_t *pGraph)
 
void Rwr_ManPreprocess (Rwr_Man_t *p)
 FUNCTION DEFINITIONS ///. More...
 

Function Documentation

void Rwr_ManPreprocess ( Rwr_Man_t p)

FUNCTION DEFINITIONS ///.

MACRO DEFINITIONS ///.

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

Synopsis [Preprocesses computed library of subgraphs.]

Description []

SideEffects []

SeeAlso []

Definition at line 49 of file rwrDec.c.

50 {
51  Dec_Graph_t * pGraph;
52  Rwr_Node_t * pNode;
53  int i, k;
54  // put the nodes into the structure
55  p->pMapInv = ABC_ALLOC( unsigned short, 222 );
56  memset( p->pMapInv, 0, sizeof(unsigned short) * 222 );
57  p->vClasses = Vec_VecStart( 222 );
58  for ( i = 0; i < p->nFuncs; i++ )
59  {
60  if ( p->pTable[i] == NULL )
61  continue;
62  // consider all implementations of this function
63  for ( pNode = p->pTable[i]; pNode; pNode = pNode->pNext )
64  {
65  assert( pNode->uTruth == p->pTable[i]->uTruth );
66  assert( p->pMap[pNode->uTruth] < 222 ); // Guaranteed to be >=0 b/c unsigned
67  Vec_VecPush( p->vClasses, p->pMap[pNode->uTruth], pNode );
68  p->pMapInv[ p->pMap[pNode->uTruth] ] = p->puCanons[pNode->uTruth];
69  }
70  }
71  // compute decomposition forms for each node and verify them
72  Vec_VecForEachEntry( Rwr_Node_t *, p->vClasses, pNode, i, k )
73  {
74  pGraph = Rwr_NodePreprocess( p, pNode );
75  pNode->pNext = (Rwr_Node_t *)pGraph;
76  assert( pNode->uTruth == (Dec_GraphDeriveTruth(pGraph) & 0xFFFF) );
77  }
78 }
char * memset()
static void Vec_VecPush(Vec_Vec_t *p, int Level, void *Entry)
Definition: vecVec.h:456
unsigned char * pMap
Definition: rwr.h:57
#define Vec_VecForEachEntry(Type, vGlob, pEntry, i, k)
Definition: vecVec.h:87
unsigned short * puCanons
Definition: rwr.h:54
unsigned uTruth
Definition: rwr.h:105
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Vec_Vec_t * vClasses
Definition: rwr.h:64
unsigned Dec_GraphDeriveTruth(Dec_Graph_t *pGraph)
Definition: decUtil.c:95
static Vec_Vec_t * Vec_VecStart(int nSize)
Definition: vecVec.h:168
unsigned short * pMapInv
Definition: rwr.h:58
static ABC_NAMESPACE_IMPL_START Dec_Graph_t * Rwr_NodePreprocess(Rwr_Man_t *p, Rwr_Node_t *pNode)
DECLARATIONS ///.
Definition: rwrDec.c:91
Rwr_Node_t ** pTable
Definition: rwr.h:63
#define assert(ex)
Definition: util_old.h:213
Rwr_Node_t * pNext
Definition: rwr.h:112
int nFuncs
Definition: rwr.h:53
Dec_Graph_t * Rwr_NodePreprocess ( Rwr_Man_t p,
Rwr_Node_t pNode 
)
static

DECLARATIONS ///.

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

FileName [rwrDec.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [DAG-aware AIG rewriting package.]

Synopsis [Evaluation and decomposition procedures.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id:
rwrDec.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]

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

Synopsis [Preprocesses subgraphs rooted at this node.]

Description []

SideEffects []

SeeAlso []

Definition at line 91 of file rwrDec.c.

92 {
93  Dec_Graph_t * pGraph;
94  Dec_Edge_t eRoot;
95  assert( !Rwr_IsComplement(pNode) );
96  // consider constant
97  if ( pNode->uTruth == 0 )
98  return Dec_GraphCreateConst0();
99  // consider the case of elementary var
100  if ( pNode->uTruth == 0x00FF )
101  return Dec_GraphCreateLeaf( 3, 4, 1 );
102  // start the subgraphs
103  pGraph = Dec_GraphCreate( 4 );
104  // collect the nodes
105  Rwr_ManIncTravId( p );
106  eRoot = Rwr_TravCollect_rec( p, pNode, pGraph );
107  Dec_GraphSetRoot( pGraph, eRoot );
108  return pGraph;
109 }
static Dec_Edge_t Rwr_TravCollect_rec(Rwr_Man_t *p, Rwr_Node_t *pNode, Dec_Graph_t *pGraph)
Definition: rwrDec.c:122
unsigned uTruth
Definition: rwr.h:105
static int Rwr_IsComplement(Rwr_Node_t *p)
Definition: rwr.h:116
typedefABC_NAMESPACE_HEADER_START struct Dec_Edge_t_ Dec_Edge_t
INCLUDES ///.
Definition: dec.h:42
void Rwr_ManIncTravId(Rwr_Man_t *p)
Definition: rwrLib.c:350
static Dec_Graph_t * Dec_GraphCreateConst0()
Definition: dec.h:245
static void Dec_GraphSetRoot(Dec_Graph_t *pGraph, Dec_Edge_t eRoot)
Definition: dec.h:551
static Dec_Graph_t * Dec_GraphCreateLeaf(int iLeaf, int nLeaves, int fCompl)
Definition: dec.h:286
static Dec_Graph_t * Dec_GraphCreate(int nLeaves)
Definition: dec.h:221
#define assert(ex)
Definition: util_old.h:213
Dec_Edge_t Rwr_TravCollect_rec ( Rwr_Man_t p,
Rwr_Node_t pNode,
Dec_Graph_t pGraph 
)
static

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

Synopsis [Adds one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 122 of file rwrDec.c.

123 {
124  Dec_Edge_t eNode0, eNode1, eNode;
125  // elementary variable
126  if ( pNode->fUsed )
127  return Dec_EdgeCreate( pNode->Id - 1, 0 );
128  // previously visited node
129  if ( pNode->TravId == p->nTravIds )
130  return Dec_IntToEdge( pNode->Volume );
131  pNode->TravId = p->nTravIds;
132  // solve for children
133  eNode0 = Rwr_TravCollect_rec( p, Rwr_Regular(pNode->p0), pGraph );
134  if ( Rwr_IsComplement(pNode->p0) )
135  eNode0.fCompl = !eNode0.fCompl;
136  eNode1 = Rwr_TravCollect_rec( p, Rwr_Regular(pNode->p1), pGraph );
137  if ( Rwr_IsComplement(pNode->p1) )
138  eNode1.fCompl = !eNode1.fCompl;
139  // create the decomposition node(s)
140  if ( pNode->fExor )
141  eNode = Dec_GraphAddNodeXor( pGraph, eNode0, eNode1, 0 );
142  else
143  eNode = Dec_GraphAddNodeAnd( pGraph, eNode0, eNode1 );
144  // save the result
145  pNode->Volume = Dec_EdgeToInt( eNode );
146  return eNode;
147 }
unsigned fUsed
Definition: rwr.h:108
static unsigned Dec_EdgeToInt(Dec_Edge_t eEdge)
Definition: dec.h:151
static Dec_Edge_t Rwr_TravCollect_rec(Rwr_Man_t *p, Rwr_Node_t *pNode, Dec_Graph_t *pGraph)
Definition: rwrDec.c:122
int Id
Definition: rwr.h:100
static Dec_Edge_t Dec_EdgeCreate(int Node, int fCompl)
FUNCTION DEFINITIONS ///.
Definition: dec.h:134
static int Rwr_IsComplement(Rwr_Node_t *p)
Definition: rwr.h:116
Rwr_Node_t * p0
Definition: rwr.h:110
typedefABC_NAMESPACE_HEADER_START struct Dec_Edge_t_ Dec_Edge_t
INCLUDES ///.
Definition: dec.h:42
static Dec_Edge_t Dec_IntToEdge(unsigned Edge)
Definition: dec.h:167
int nTravIds
Definition: rwr.h:67
static Dec_Edge_t Dec_GraphAddNodeAnd(Dec_Graph_t *pGraph, Dec_Edge_t eEdge0, Dec_Edge_t eEdge1)
Definition: dec.h:591
int TravId
Definition: rwr.h:101
unsigned fExor
Definition: rwr.h:109
static Dec_Edge_t Dec_GraphAddNodeXor(Dec_Graph_t *pGraph, Dec_Edge_t eEdge0, Dec_Edge_t eEdge1, int Type)
Definition: dec.h:643
Rwr_Node_t * p1
Definition: rwr.h:111
unsigned Volume
Definition: rwr.h:106
static Rwr_Node_t * Rwr_Regular(Rwr_Node_t *p)
Definition: rwr.h:117