ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
wlcAbc.c File Reference
#include "wlc.h"
#include "base/abc/abc.h"
Include dependency graph for wlcAbc.c:

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START void Wlc_NtkPrintInputInfo (Wlc_Ntk_t *pNtk)
 DECLARATIONS ///.
 
void Wlc_NtkPrintInvStats (Wlc_Ntk_t *pNtk, Vec_Int_t *vCounts, int fVerbose)
 
Abc_Ntk_tWlc_NtkGetInv (Wlc_Ntk_t *pNtk, Vec_Int_t *vInv, Vec_Ptr_t *vNamesIn)
 
Vec_Int_tWlc_NtkGetPut (Abc_Ntk_t *pNtk, Gia_Man_t *pGia)
 

Function Documentation

◆ Wlc_NtkGetInv()

Abc_Ntk_t * Wlc_NtkGetInv ( Wlc_Ntk_t * pNtk,
Vec_Int_t * vInv,
Vec_Ptr_t * vNamesIn )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 143 of file wlcAbc.c.

144{
145 extern Vec_Int_t * Pdr_InvCounts( Vec_Int_t * vInv );
146 extern Vec_Str_t * Pdr_InvPrintStr( Vec_Int_t * vInv, Vec_Int_t * vCounts );
147
148 Vec_Int_t * vCounts = Pdr_InvCounts( vInv );
149 Vec_Str_t * vSop = Pdr_InvPrintStr( vInv, vCounts );
150
151 Wlc_Obj_t * pObj;
152 int i, k, nNum, nRange, nBits = 0;
153 Abc_Ntk_t * pMainNtk = NULL;
154 Abc_Obj_t * pMainObj, * pMainTemp;
155 char Buffer[5000];
156 // start the network
157 pMainNtk = Abc_NtkAlloc( ABC_NTK_LOGIC, ABC_FUNC_SOP, 1 );
158 // duplicate the name and the spec
159 pMainNtk->pName = Extra_UtilStrsav(pNtk ? pNtk->pName : "inv");
160 // create primary inputs
161 if ( pNtk == NULL )
162 {
163 int Entry, nInputs = Abc_SopGetVarNum( Vec_StrArray(vSop) );
164 Vec_IntForEachEntry( vCounts, Entry, i )
165 {
166 if ( Entry == 0 )
167 continue;
168 pMainObj = Abc_NtkCreatePi( pMainNtk );
169 // If vNamesIn is given, take names from there for as many entries as possible
170 // otherwise generate names from counter
171 if (vNamesIn != NULL && i < Vec_PtrSize(vNamesIn)) {
172 Abc_ObjAssignName( pMainObj, (char *)Vec_PtrEntry(vNamesIn, i), NULL );
173 }
174 else
175 {
176 sprintf( Buffer, "pi%d", i );
177 Abc_ObjAssignName( pMainObj, Buffer, NULL );
178 }
179 }
180 if ( Abc_NtkPiNum(pMainNtk) != nInputs )
181 {
182 printf( "Mismatch between number of inputs and the number of literals in the invariant.\n" );
183 Abc_NtkDelete( pMainNtk );
184 return NULL;
185 }
186 }
187 else
188 {
189 Wlc_NtkForEachCi( pNtk, pObj, i )
190 {
191 if ( pObj->Type != WLC_OBJ_FO )
192 continue;
193 nRange = Wlc_ObjRange(pObj);
194 for ( k = 0; k < nRange; k++ )
195 {
196 nNum = Vec_IntEntry(vCounts, nBits + k);
197 if ( nNum )
198 break;
199 }
200 if ( k == nRange )
201 {
202 nBits += nRange;
203 continue;
204 }
205 //printf( "%s[%d:%d] : ", Wlc_ObjName(pNtk, Wlc_ObjId(pNtk, pObj)), pObj->End, pObj->Beg );
206 for ( k = 0; k < nRange; k++ )
207 {
208 nNum = Vec_IntEntry( vCounts, nBits + k );
209 if ( nNum == 0 )
210 continue;
211 //printf( " [%d] -> %d", k, nNum );
212 pMainObj = Abc_NtkCreatePi( pMainNtk );
213 sprintf( Buffer, "%s[%d]", Wlc_ObjName(pNtk, Wlc_ObjId(pNtk, pObj)), k );
214 Abc_ObjAssignName( pMainObj, Buffer, NULL );
215
216 }
217 //printf( "\n");
218 nBits += nRange;
219 }
220 }
221 //printf( "%d %d\n", Vec_IntSize(vCounts), nBits );
222 assert( pNtk == NULL || Vec_IntSize(vCounts) == nBits );
223 // create node
224 pMainObj = Abc_NtkCreateNode( pMainNtk );
225 Abc_NtkForEachPi( pMainNtk, pMainTemp, i )
226 Abc_ObjAddFanin( pMainObj, pMainTemp );
227 pMainObj->pData = Abc_SopRegister( (Mem_Flex_t *)pMainNtk->pManFunc, Vec_StrArray(vSop) );
228 Vec_IntFree( vCounts );
229 Vec_StrFree( vSop );
230 // create PO
231 pMainTemp = Abc_NtkCreatePo( pMainNtk );
232 Abc_ObjAddFanin( pMainTemp, pMainObj );
233 Abc_ObjAssignName( pMainTemp, "inv", NULL );
234 return pMainNtk;
235}
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
ABC_DLL Abc_Ntk_t * Abc_NtkAlloc(Abc_NtkType_t Type, Abc_NtkFunc_t Func, int fUseMemMan)
DECLARATIONS ///.
Definition abcNtk.c:53
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition abcFanio.c:84
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
ABC_DLL char * Abc_ObjAssignName(Abc_Obj_t *pObj, char *pName, char *pSuffix)
Definition abcNames.c:69
@ ABC_NTK_LOGIC
Definition abc.h:57
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition abc.h:516
ABC_DLL int Abc_SopGetVarNum(char *pSop)
Definition abcSop.c:584
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition abcNtk.c:1421
@ ABC_FUNC_SOP
Definition abc.h:65
ABC_DLL char * Abc_SopRegister(Mem_Flex_t *pMan, const char *pName)
DECLARATIONS ///.
Definition abcSop.c:62
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
struct Vec_Str_t_ Vec_Str_t
Definition bblif.c:46
char * Extra_UtilStrsav(const char *s)
struct Mem_Flex_t_ Mem_Flex_t
Definition mem.h:34
Vec_Str_t * Pdr_InvPrintStr(Vec_Int_t *vInv, Vec_Int_t *vCounts)
Definition pdrInv.c:667
Vec_Int_t * Pdr_InvCounts(Vec_Int_t *vInv)
Definition pdrInv.c:650
char * pName
Definition abc.h:158
void * pManFunc
Definition abc.h:191
void * pData
Definition abc.h:145
char * pName
Definition wlc.h:138
unsigned Type
Definition wlc.h:121
#define assert(ex)
Definition util_old.h:213
char * sprintf()
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
#define Wlc_NtkForEachCi(p, pCi, i)
Definition wlc.h:366
char * Wlc_ObjName(Wlc_Ntk_t *p, int iObj)
Definition wlcNtk.c:225
@ WLC_OBJ_FO
Definition wlc.h:48
struct Wlc_Obj_t_ Wlc_Obj_t
BASIC TYPES ///.
Definition wlc.h:118
Here is the call graph for this function:

◆ Wlc_NtkGetPut()

Vec_Int_t * Wlc_NtkGetPut ( Abc_Ntk_t * pNtk,
Gia_Man_t * pGia )

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

Synopsis [Translate current network into an invariant.]

Description []

SideEffects []

SeeAlso []

Definition at line 248 of file wlcAbc.c.

249{
250 int nRegs = Gia_ManRegNum(pGia);
251 Vec_Int_t * vRes = NULL;
252 if ( Abc_NtkPoNum(pNtk) != 1 )
253 printf( "The number of outputs is other than 1.\n" );
254 else if ( Abc_NtkNodeNum(pNtk) != 1 )
255 printf( "The number of internal nodes is other than 1.\n" );
256 else
257 {
258 Abc_Nam_t * pNames = NULL;
259 Abc_Obj_t * pFanin, * pNode = Abc_ObjFanin0( Abc_NtkCo(pNtk, 0) );
260 char * pName, * pCube, * pSop = (char *)pNode->pData;
261 Vec_Int_t * vFanins = Vec_IntAlloc( Abc_ObjFaninNum(pNode) );
262 int i, k, Value, nLits, Counter = 0;
263 if ( pGia->vNamesIn )
264 {
265 // hash the names
266 pNames = Abc_NamStart( 100, 16 );
267 Vec_PtrForEachEntry( char *, pGia->vNamesIn, pName, i )
268 {
269 Value = Abc_NamStrFindOrAdd( pNames, pName, NULL );
270 assert( Value == i+1 );
271 //printf( "%s(%d) ", pName, i );
272 }
273 //printf( "\n" );
274 }
275 Abc_ObjForEachFanin( pNode, pFanin, i )
276 {
277 assert( Abc_ObjIsCi(pFanin) );
278 pName = Abc_ObjName(pFanin);
279 if ( pNames )
280 {
281 Value = Abc_NamStrFind(pNames, pName) - 1 - Gia_ManPiNum(pGia);
282 if ( Value < 0 )
283 {
284 if ( Counter++ == 0 )
285 printf( "Cannot read input name \"%s\" of fanin %d.\n", pName, i );
286 Value = i;
287 }
288 }
289 else
290 {
291 for ( k = (int)strlen(pName)-1; k >= 0; k-- )
292 if ( pName[k] < '0' || pName[k] > '9' )
293 break;
294 if ( k == (int)strlen(pName)-1 )
295 {
296 if ( Counter++ == 0 )
297 printf( "Cannot read input name \"%s\" of fanin %d.\n", pName, i );
298 Value = i;
299 }
300 else
301 Value = atoi(pName + k + 1);
302 }
303 Vec_IntPush( vFanins, Value );
304 }
305 if ( Counter )
306 printf( "Cannot read names for %d inputs of the invariant.\n", Counter );
307 if ( pNames )
308 Abc_NamStop( pNames );
309 assert( Vec_IntSize(vFanins) == Abc_ObjFaninNum(pNode) );
310 vRes = Vec_IntAlloc( 1000 );
311 Vec_IntPush( vRes, Abc_SopGetCubeNum(pSop) );
312 Abc_SopForEachCube( pSop, Abc_ObjFaninNum(pNode), pCube )
313 {
314 nLits = 0;
315 Abc_CubeForEachVar( pCube, Value, k )
316 if ( Value != '-' )
317 nLits++;
318 Vec_IntPush( vRes, nLits );
319 Abc_CubeForEachVar( pCube, Value, k )
320 if ( Value != '-' )
321 Vec_IntPush( vRes, Abc_Var2Lit(Vec_IntEntry(vFanins, k), (int)Value == '0') );
322 }
323 Vec_IntPush( vRes, nRegs );
324 Vec_IntFree( vFanins );
325 }
326 return vRes;
327}
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition abc.h:527
#define Abc_CubeForEachVar(pCube, Value, i)
Definition abc.h:536
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition abcNames.c:49
#define Abc_SopForEachCube(pSop, nFanins, pCube)
Definition abc.h:538
ABC_DLL int Abc_SopGetCubeNum(char *pSop)
Definition abcSop.c:537
Vec_Ptr_t * vNamesIn
Definition gia.h:181
int Abc_NamStrFind(Abc_Nam_t *p, char *pStr)
Definition utilNam.c:433
void Abc_NamStop(Abc_Nam_t *p)
Definition utilNam.c:112
int Abc_NamStrFindOrAdd(Abc_Nam_t *p, char *pStr, int *pfFound)
Definition utilNam.c:453
Abc_Nam_t * Abc_NamStart(int nObjs, int nAveSize)
FUNCTION DEFINITIONS ///.
Definition utilNam.c:80
typedefABC_NAMESPACE_HEADER_START struct Abc_Nam_t_ Abc_Nam_t
INCLUDES ///.
Definition utilNam.h:39
int strlen()
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the call graph for this function:

◆ Wlc_NtkPrintInputInfo()

ABC_NAMESPACE_IMPL_START void Wlc_NtkPrintInputInfo ( Wlc_Ntk_t * pNtk)

DECLARATIONS ///.

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

FileName [wlcAbc.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Verilog parser.]

Synopsis [Parses several flavors of word-level Verilog.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - August 22, 2014.]

Revision [

Id
wlcAbc.c,v 1.00 2014/09/12 00:00:00 alanmi Exp

] FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file wlcAbc.c.

46{
47 Wlc_Obj_t * pObj;
48 int i, k, nRange, nBeg, nEnd, nBits = 0;
49 FILE * output;
50
51 output = fopen("abc_blast_input.info","w");
52
53 Wlc_NtkForEachCi( pNtk, pObj, i )
54 {
55 nRange = Wlc_ObjRange(pObj);
56 nBeg = pObj->Beg;
57 nEnd = pObj->End;
58
59 for ( k = 0; k < nRange; k++ )
60 {
61 int index = nEnd > nBeg ? nBeg + k : nEnd + k;
62 char c = pObj->Type != WLC_OBJ_FO ? 'i' : pNtk->pInits[nBits + k];
63 fprintf(output,"%s[%d] : %c \n", Wlc_ObjName(pNtk, Wlc_ObjId(pNtk, pObj)), index , c );
64 }
65 if (pObj->Type == WLC_OBJ_FO)
66 nBits += nRange;
67 }
68
69 Wlc_NtkForEachPo( pNtk, pObj, i )
70 {
71 nRange = Wlc_ObjRange(pObj);
72 nBeg = pObj->Beg;
73 nEnd = pObj->End;
74
75 for ( k = 0; k < nRange; k++ )
76 {
77 int index = nEnd > nBeg ? nBeg + k : nEnd + k;
78 fprintf(output,"%s[%d] : o \n", Wlc_ObjName(pNtk, Wlc_ObjId(pNtk, pObj)), index);
79 }
80 }
81
82 fclose(output);
83 return;
84}
char * pInits
Definition wlc.h:148
int End
Definition wlc.h:129
int Beg
Definition wlc.h:130
#define Wlc_NtkForEachPo(p, pPo, i)
Definition wlc.h:364
Here is the call graph for this function:

◆ Wlc_NtkPrintInvStats()

void Wlc_NtkPrintInvStats ( Wlc_Ntk_t * pNtk,
Vec_Int_t * vCounts,
int fVerbose )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 97 of file wlcAbc.c.

98{
99 Wlc_Obj_t * pObj;
100 int i, k, nNum, nRange, nBits = 0;
101 Wlc_NtkForEachCi( pNtk, pObj, i )
102 {
103 if ( pObj->Type != WLC_OBJ_FO )
104 continue;
105 nRange = Wlc_ObjRange(pObj);
106 for ( k = 0; k < nRange; k++ )
107 {
108 nNum = Vec_IntEntry(vCounts, nBits + k);
109 if ( nNum )
110 break;
111 }
112 if ( k == nRange )
113 {
114 nBits += nRange;
115 continue;
116 }
117 printf( "%s[%d:%d] : ", Wlc_ObjName(pNtk, Wlc_ObjId(pNtk, pObj)), pObj->End, pObj->Beg );
118 for ( k = 0; k < nRange; k++ )
119 {
120 nNum = Vec_IntEntry( vCounts, nBits + k );
121 if ( nNum == 0 )
122 continue;
123 printf( " [%d] -> %d", k, nNum );
124 }
125 printf( "\n");
126 nBits += nRange;
127 }
128 //printf( "%d %d\n", Vec_IntSize(vCounts), nBits );
129 assert( Vec_IntSize(vCounts) == nBits );
130}
Here is the call graph for this function: