abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
abcOrder.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [abcOrder.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Network and node package.]
8 
9  Synopsis [Exploring static BDD variable orders.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - June 20, 2005.]
16 
17  Revision [$Id: abcOrder.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "base/abc/abc.h"
22 
24 
25 
26 ////////////////////////////////////////////////////////////////////////
27 /// DECLARATIONS ///
28 ////////////////////////////////////////////////////////////////////////
29 
30 static void Abc_NtkChangeCiOrder( Abc_Ntk_t * pNtk, Vec_Ptr_t * vSupp, int fReverse );
31 
32 ////////////////////////////////////////////////////////////////////////
33 /// FUNCTION DEFINITIONS ///
34 ////////////////////////////////////////////////////////////////////////
35 
36 /**Function*************************************************************
37 
38  Synopsis [Changes the order of primary inputs.]
39 
40  Description []
41 
42  SideEffects []
43 
44  SeeAlso []
45 
46 ***********************************************************************/
47 void Abc_NtkFindCiOrder( Abc_Ntk_t * pNtk, int fReverse, int fVerbose )
48 {
49  Vec_Ptr_t * vSupp;
50  vSupp = Abc_NtkSupport( pNtk );
51  Abc_NtkChangeCiOrder( pNtk, vSupp, fReverse );
52  Vec_PtrFree( vSupp );
53 }
54 
55 /**Function*************************************************************
56 
57  Synopsis [Implements the given variable order.]
58 
59  Description []
60 
61  SideEffects []
62 
63  SeeAlso []
64 
65 ***********************************************************************/
66 void Abc_NtkImplementCiOrder( Abc_Ntk_t * pNtk, char * pFileName, int fReverse, int fVerbose )
67 {
68  char Buffer[1000];
69  FILE * pFile;
70  Vec_Ptr_t * vSupp;
71  Abc_Obj_t * pObj;
72  pFile = fopen( pFileName, "r" );
73  vSupp = Vec_PtrAlloc( Abc_NtkCiNum(pNtk) );
74  while ( fscanf( pFile, "%s", Buffer ) == 1 )
75  {
76  pObj = Abc_NtkFindCi( pNtk, Buffer );
77  if ( pObj == NULL || !Abc_ObjIsCi(pObj) )
78  {
79  printf( "Name \"%s\" is not a PI name. Cannot use this order.\n", Buffer );
80  Vec_PtrFree( vSupp );
81  fclose( pFile );
82  return;
83  }
84  Vec_PtrPush( vSupp, pObj );
85  }
86  fclose( pFile );
87  if ( Vec_PtrSize(vSupp) != Abc_NtkCiNum(pNtk) )
88  {
89  printf( "The number of names in the order (%d) is not the same as the number of PIs (%d).\n", Vec_PtrSize(vSupp), Abc_NtkCiNum(pNtk) );
90  Vec_PtrFree( vSupp );
91  return;
92  }
93  Abc_NtkChangeCiOrder( pNtk, vSupp, fReverse );
94  Vec_PtrFree( vSupp );
95 }
96 
97 /**Function*************************************************************
98 
99  Synopsis [Changes the order of primary inputs.]
100 
101  Description []
102 
103  SideEffects []
104 
105  SeeAlso []
106 
107 ***********************************************************************/
108 void Abc_NtkChangeCiOrder( Abc_Ntk_t * pNtk, Vec_Ptr_t * vSupp, int fReverse )
109 {
110  Abc_Obj_t * pObj;
111  int i;
112  assert( Vec_PtrSize(vSupp) == Abc_NtkCiNum(pNtk) );
113  // order CIs using the array
114  if ( fReverse )
115  Vec_PtrForEachEntry( Abc_Obj_t *, vSupp, pObj, i )
116  Vec_PtrWriteEntry( pNtk->vCis, Vec_PtrSize(vSupp)-1-i, pObj );
117  else
118  Vec_PtrForEachEntry( Abc_Obj_t *, vSupp, pObj, i )
119  Vec_PtrWriteEntry( pNtk->vCis, i, pObj );
120  // order PIs accordingly
121  Vec_PtrClear( pNtk->vPis );
122  Abc_NtkForEachCi( pNtk, pObj, i )
123  if ( Abc_ObjIsPi(pObj) )
124  Vec_PtrPush( pNtk->vPis, pObj );
125 // Abc_NtkForEachCi( pNtk, pObj, i )
126 // printf( "%s ", Abc_ObjName(pObj) );
127 // printf( "\n" );
128 }
129 
130 ////////////////////////////////////////////////////////////////////////
131 /// END OF FILE ///
132 ////////////////////////////////////////////////////////////////////////
133 
134 
136 
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
void Abc_NtkImplementCiOrder(Abc_Ntk_t *pNtk, char *pFileName, int fReverse, int fVerbose)
Definition: abcOrder.c:66
static int Abc_ObjIsPi(Abc_Obj_t *pObj)
Definition: abc.h:347
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:287
Vec_Ptr_t * vPis
Definition: abc.h:163
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
ABC_DLL Abc_Obj_t * Abc_NtkFindCi(Abc_Ntk_t *pNtk, char *pName)
Definition: abcObj.c:530
Vec_Ptr_t * vCis
Definition: abc.h:165
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
static ABC_NAMESPACE_IMPL_START void Abc_NtkChangeCiOrder(Abc_Ntk_t *pNtk, Vec_Ptr_t *vSupp, int fReverse)
DECLARATIONS ///.
Definition: abcOrder.c:108
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
ABC_DLL Vec_Ptr_t * Abc_NtkSupport(Abc_Ntk_t *pNtk)
Definition: abcDfs.c:828
#define assert(ex)
Definition: util_old.h:213
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
void Abc_NtkFindCiOrder(Abc_Ntk_t *pNtk, int fReverse, int fVerbose)
FUNCTION DEFINITIONS ///.
Definition: abcOrder.c:47
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223