ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
bacPrsBuild.c File Reference
#include "bac.h"
#include "bacPrs.h"
#include "map/mio/mio.h"
#include "base/main/main.h"
Include dependency graph for bacPrsBuild.c:

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START int Psr_ManIsMapped (Psr_Ntk_t *pNtk)
 DECLARATIONS ///.
 
int Psr_NtkCountObjects (Psr_Ntk_t *pNtk)
 
void Psr_ManRemapOne (Vec_Int_t *vSigs, Psr_Ntk_t *pNtkBox, Vec_Int_t *vMap)
 
void Psr_ManRemapGate (Vec_Int_t *vSigs)
 
void Psr_ManRemapBoxes (Bac_Man_t *pNew, Vec_Ptr_t *vDes, Psr_Ntk_t *pNtk, Vec_Int_t *vMap)
 
void Psr_ManCleanMap (Psr_Ntk_t *pNtk, Vec_Int_t *vMap)
 
void Psr_ManBuildNtk (Bac_Ntk_t *pNew, Vec_Ptr_t *vDes, Psr_Ntk_t *pNtk, Vec_Int_t *vMap, Vec_Int_t *vBoxes)
 
Bac_Man_tPsr_ManBuildCba (char *pFileName, Vec_Ptr_t *vDes)
 

Function Documentation

◆ Psr_ManBuildCba()

Bac_Man_t * Psr_ManBuildCba ( char * pFileName,
Vec_Ptr_t * vDes )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 328 of file bacPrsBuild.c.

329{
330 Psr_Ntk_t * pNtk = Psr_ManRoot( vDes ); int i;
331 Bac_Man_t * pNew = Bac_ManAlloc( pFileName, Vec_PtrSize(vDes) );
332 Vec_Int_t * vMap = Vec_IntStartFull( Abc_NamObjNumMax(pNtk->pStrs) + 1 );
333 Vec_Int_t * vTmp = Vec_IntAlloc( Psr_NtkBoxNum(pNtk) );
334 Abc_NamDeref( pNew->pStrs );
335 pNew->pStrs = Abc_NamRef( pNtk->pStrs );
336 Vec_PtrForEachEntry( Psr_Ntk_t *, vDes, pNtk, i )
337 Bac_NtkAlloc( Bac_ManNtk(pNew, i+1), Psr_NtkId(pNtk), Psr_NtkPiNum(pNtk), Psr_NtkPoNum(pNtk), Psr_NtkCountObjects(pNtk) );
338 if ( (pNtk->fMapped || (pNtk->fSlices && Psr_ManIsMapped(pNtk))) && !Bac_NtkBuildLibrary(pNew) )
339 Bac_ManFree(pNew), pNew = NULL;
340 else
341 Vec_PtrForEachEntry( Psr_Ntk_t *, vDes, pNtk, i )
342 Psr_ManBuildNtk( Bac_ManNtk(pNew, i+1), vDes, pNtk, vMap, vTmp );
343 assert( Vec_IntCountEntry(vMap, -1) == Vec_IntSize(vMap) );
344 Vec_IntFree( vMap );
345 Vec_IntFree( vTmp );
346// Vec_StrPrint( &Bac_ManNtk(pNew, 1)->vType, 1 );
347 return pNew;
348}
ABC_NAMESPACE_IMPL_START int Psr_ManIsMapped(Psr_Ntk_t *pNtk)
DECLARATIONS ///.
Definition bacPrsBuild.c:47
int Psr_NtkCountObjects(Psr_Ntk_t *pNtk)
Definition bacPrsBuild.c:74
void Psr_ManBuildNtk(Bac_Ntk_t *pNew, Vec_Ptr_t *vDes, Psr_Ntk_t *pNtk, Vec_Int_t *vMap, Vec_Int_t *vBoxes)
struct Psr_Ntk_t_ Psr_Ntk_t
BASIC TYPES ///.
Definition bacPrs.h:51
struct Bac_Man_t_ Bac_Man_t
Definition bac.h:142
int Bac_NtkBuildLibrary(Bac_Man_t *p)
Definition bacBlast.c:509
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
Abc_Nam_t * pStrs
Definition bac.h:176
unsigned fMapped
Definition bacPrs.h:56
unsigned fSlices
Definition bacPrs.h:57
Abc_Nam_t * pStrs
Definition bacPrs.h:62
int Abc_NamObjNumMax(Abc_Nam_t *p)
Definition utilNam.c:231
void Abc_NamDeref(Abc_Nam_t *p)
Definition utilNam.c:212
Abc_Nam_t * Abc_NamRef(Abc_Nam_t *p)
Definition utilNam.c:195
#define assert(ex)
Definition util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the call graph for this function:

◆ Psr_ManBuildNtk()

void Psr_ManBuildNtk ( Bac_Ntk_t * pNew,
Vec_Ptr_t * vDes,
Psr_Ntk_t * pNtk,
Vec_Int_t * vMap,
Vec_Int_t * vBoxes )

Definition at line 157 of file bacPrsBuild.c.

158{
159 Psr_Ntk_t * pNtkBox; Vec_Int_t * vSigs; int iBox;
160 int i, Index, NameId, iObj, iConst0, iTerm;
161 int iNonDriven = -1, nNonDriven = 0;
162 assert( Psr_NtkPioNum(pNtk) == 0 );
163 Psr_ManRemapBoxes( pNew->pDesign, vDes, pNtk, vMap );
164 Bac_NtkStartNames( pNew );
165 // create primary inputs
166 Psr_NtkForEachPi( pNtk, NameId, i )
167 {
168 if ( Vec_IntEntry(vMap, NameId) != -1 )
169 printf( "Primary inputs %d and %d have the same name.\n", Vec_IntEntry(vMap, NameId), i );
170 iObj = Bac_ObjAlloc( pNew, BAC_OBJ_PI, -1 );
171 Bac_ObjSetName( pNew, iObj, Abc_Var2Lit2(NameId, BAC_NAME_BIN) );
172 Vec_IntWriteEntry( vMap, NameId, iObj );
173 }
174 // create box outputs
175 Vec_IntClear( vBoxes );
176 Psr_NtkForEachBox( pNtk, vSigs, iBox )
177 if ( !Psr_BoxIsNode(pNtk, iBox) )
178 {
179 pNtkBox = Psr_ManNtk( vDes, Psr_BoxNtk(pNtk, iBox)-1 );
180 if ( pNtkBox == NULL )
181 {
182 iObj = Bac_BoxAlloc( pNew, BAC_BOX_GATE, Vec_IntSize(vSigs)/2-1, 1, Psr_BoxNtk(pNtk, iBox) );
183 Bac_ObjSetName( pNew, iObj, Abc_Var2Lit2(Psr_BoxName(pNtk, iBox), BAC_NAME_BIN) );
184 // consider box output
185 NameId = Vec_IntEntryLast( vSigs );
186 NameId = Psr_NtkSigName( pNtk, NameId );
187 if ( Vec_IntEntry(vMap, NameId) != -1 )
188 printf( "Box output name %d is already driven.\n", NameId );
189 iTerm = Bac_BoxBo( pNew, iObj, 0 );
190 Bac_ObjSetName( pNew, iTerm, Abc_Var2Lit2(NameId, BAC_NAME_BIN) );
191 Vec_IntWriteEntry( vMap, NameId, iTerm );
192 }
193 else
194 {
195 iObj = Bac_BoxAlloc( pNew, BAC_OBJ_BOX, Psr_NtkPiNum(pNtkBox), Psr_NtkPoNum(pNtkBox), Psr_BoxNtk(pNtk, iBox) );
196 Bac_ObjSetName( pNew, iObj, Abc_Var2Lit2(Psr_BoxName(pNtk, iBox), BAC_NAME_BIN) );
197 Bac_NtkSetHost( Bac_ManNtk(pNew->pDesign, Psr_BoxNtk(pNtk, iBox)), Bac_NtkId(pNew), iObj );
198 Vec_IntForEachEntry( vSigs, Index, i )
199 {
200 i++;
201 if ( --Index < Psr_NtkPiNum(pNtkBox) )
202 continue;
203 assert( Index - Psr_NtkPiNum(pNtkBox) < Psr_NtkPoNum(pNtkBox) );
204 // consider box output
205 NameId = Vec_IntEntry( vSigs, i );
206 NameId = Psr_NtkSigName( pNtk, NameId );
207 if ( Vec_IntEntry(vMap, NameId) != -1 )
208 printf( "Box output name %d is already driven.\n", NameId );
209 iTerm = Bac_BoxBo( pNew, iObj, Index - Psr_NtkPiNum(pNtkBox) );
210 Bac_ObjSetName( pNew, iTerm, Abc_Var2Lit2(NameId, BAC_NAME_BIN) );
211 Vec_IntWriteEntry( vMap, NameId, iTerm );
212 }
213 }
214 // remember box
215 Vec_IntPush( vBoxes, iObj );
216 }
217 else
218 {
219 iObj = Bac_BoxAlloc( pNew, (Bac_ObjType_t)Psr_BoxNtk(pNtk, iBox), Psr_BoxIONum(pNtk, iBox)-1, 1, -1 );
220 // consider box output
221 NameId = Vec_IntEntryLast( vSigs );
222 NameId = Psr_NtkSigName( pNtk, NameId );
223 if ( Vec_IntEntry(vMap, NameId) != -1 )
224 printf( "Node output name %d is already driven.\n", NameId );
225 iTerm = Bac_BoxBo( pNew, iObj, 0 );
226 Bac_ObjSetName( pNew, iTerm, Abc_Var2Lit2(NameId, BAC_NAME_BIN) );
227 Vec_IntWriteEntry( vMap, NameId, iTerm );
228 // remember box
229 Vec_IntPush( vBoxes, iObj );
230 }
231 // add fanins for box inputs
232 Psr_NtkForEachBox( pNtk, vSigs, iBox )
233 if ( !Psr_BoxIsNode(pNtk, iBox) )
234 {
235 pNtkBox = Psr_ManNtk( vDes, Psr_BoxNtk(pNtk, iBox)-1 );
236 iObj = Vec_IntEntry( vBoxes, iBox );
237 if ( pNtkBox == NULL )
238 {
239 Vec_IntForEachEntryStop( vSigs, Index, i, Vec_IntSize(vSigs)-2 )
240 {
241 i++;
242 NameId = Vec_IntEntry( vSigs, i );
243 NameId = Psr_NtkSigName( pNtk, NameId );
244 iTerm = Bac_BoxBi( pNew, iObj, i/2 );
245 if ( Vec_IntEntry(vMap, NameId) == -1 )
246 {
247 iConst0 = Bac_BoxAlloc( pNew, BAC_BOX_CF, 0, 1, -1 );
248 Vec_IntWriteEntry( vMap, NameId, iConst0+1 );
249 if ( iNonDriven == -1 )
250 iNonDriven = NameId;
251 nNonDriven++;
252 }
253 Bac_ObjSetFanin( pNew, iTerm, Vec_IntEntry(vMap, NameId) );
254 }
255 }
256 else
257 {
258 Vec_IntForEachEntry( vSigs, Index, i )
259 {
260 i++;
261 if ( --Index >= Psr_NtkPiNum(pNtkBox) )
262 continue;
263 NameId = Vec_IntEntry( vSigs, i );
264 NameId = Psr_NtkSigName( pNtk, NameId );
265 iTerm = Bac_BoxBi( pNew, iObj, Index );
266 if ( Vec_IntEntry(vMap, NameId) == -1 )
267 {
268 iConst0 = Bac_BoxAlloc( pNew, BAC_BOX_CF, 0, 1, -1 );
269 Vec_IntWriteEntry( vMap, NameId, iConst0+1 );
270 if ( iNonDriven == -1 )
271 iNonDriven = NameId;
272 nNonDriven++;
273 }
274 Bac_ObjSetFanin( pNew, iTerm, Vec_IntEntry(vMap, NameId) );
275 }
276 }
277 }
278 else
279 {
280 iObj = Vec_IntEntry( vBoxes, iBox );
281 Vec_IntForEachEntryStop( vSigs, Index, i, Vec_IntSize(vSigs)-2 )
282 {
283 NameId = Vec_IntEntry( vSigs, ++i );
284 NameId = Psr_NtkSigName( pNtk, NameId );
285 iTerm = Bac_BoxBi( pNew, iObj, i/2 );
286 if ( Vec_IntEntry(vMap, NameId) == -1 )
287 {
288 iConst0 = Bac_BoxAlloc( pNew, BAC_BOX_CF, 0, 1, -1 );
289 Vec_IntWriteEntry( vMap, NameId, iConst0+1 );
290 if ( iNonDriven == -1 )
291 iNonDriven = NameId;
292 nNonDriven++;
293 }
294 Bac_ObjSetFanin( pNew, iTerm, Vec_IntEntry(vMap, NameId) );
295 }
296 }
297 // add fanins for primary outputs
298 Psr_NtkForEachPo( pNtk, NameId, i )
299 if ( Vec_IntEntry(vMap, NameId) == -1 )
300 {
301 iConst0 = Bac_BoxAlloc( pNew, BAC_BOX_CF, 0, 1, -1 );
302 Vec_IntWriteEntry( vMap, NameId, iConst0+1 );
303 if ( iNonDriven == -1 )
304 iNonDriven = NameId;
305 nNonDriven++;
306 }
307 Psr_NtkForEachPo( pNtk, NameId, i )
308 iObj = Bac_ObjAlloc( pNew, BAC_OBJ_PO, Vec_IntEntry(vMap, NameId) );
309 if ( nNonDriven )
310 printf( "Module %s has %d non-driven nets (for example, %s).\n", Psr_NtkName(pNtk), nNonDriven, Psr_NtkStr(pNtk, iNonDriven) );
311 Psr_ManCleanMap( pNtk, vMap );
312 // setup info
313 Vec_IntForEachEntry( &pNtk->vOrder, NameId, i )
314 Bac_NtkAddInfo( pNew, NameId, -1, -1 );
315}
void Psr_ManRemapBoxes(Bac_Man_t *pNew, Vec_Ptr_t *vDes, Psr_Ntk_t *pNtk, Vec_Int_t *vMap)
void Psr_ManCleanMap(Psr_Ntk_t *pNtk, Vec_Int_t *vMap)
#define Psr_NtkForEachPo(p, NameId, i)
Definition bacPrs.h:145
#define Psr_NtkForEachPi(p, NameId, i)
Definition bacPrs.h:143
#define Psr_NtkForEachBox(p, vVec, i)
Definition bacPrs.h:147
@ BAC_NAME_BIN
Definition bac.h:134
Bac_ObjType_t
INCLUDES ///.
Definition bac.h:43
@ BAC_OBJ_PO
Definition bac.h:46
@ BAC_BOX_CF
Definition bac.h:51
@ BAC_BOX_GATE
Definition bac.h:112
@ BAC_OBJ_PI
Definition bac.h:45
@ BAC_OBJ_BOX
Definition bac.h:49
Bac_Man_t * pDesign
Definition bac.h:147
Vec_Int_t vOrder
Definition bacPrs.h:64
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
#define Vec_IntForEachEntryStop(vVec, Entry, i, Stop)
Definition vecInt.h:58
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Psr_ManCleanMap()

void Psr_ManCleanMap ( Psr_Ntk_t * pNtk,
Vec_Int_t * vMap )

Definition at line 144 of file bacPrsBuild.c.

145{
146 Vec_Int_t * vSigs;
147 int i, k, NameId, Sig;
148 Psr_NtkForEachPi( pNtk, NameId, i )
149 Vec_IntWriteEntry( vMap, NameId, -1 );
150 Psr_NtkForEachBox( pNtk, vSigs, i )
151 Vec_IntForEachEntryDouble( vSigs, NameId, Sig, k )
152 Vec_IntWriteEntry( vMap, Psr_NtkSigName(pNtk, Sig), -1 );
153 Psr_NtkForEachPo( pNtk, NameId, i )
154 Vec_IntWriteEntry( vMap, NameId, -1 );
155}
#define Vec_IntForEachEntryDouble(vVec, Entry1, Entry2, i)
Definition vecInt.h:72
Here is the caller graph for this function:

◆ Psr_ManIsMapped()

ABC_NAMESPACE_IMPL_START int Psr_ManIsMapped ( Psr_Ntk_t * pNtk)

DECLARATIONS ///.

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

FileName [bacPrsBuild.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Hierarchical word-level netlist.]

Synopsis [Parse tree to netlist transformation.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - November 29, 2014.]

Revision [

Id
bacPrsBuild.c,v 1.00 2014/11/29 00:00:00 alanmi Exp

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 47 of file bacPrsBuild.c.

48{
49 Vec_Int_t * vSigs; int iBox;
51 if ( pLib == NULL )
52 return 0;
53 Psr_NtkForEachBox( pNtk, vSigs, iBox )
54 if ( !Psr_BoxIsNode(pNtk, iBox) )
55 {
56 int NtkId = Psr_BoxNtk( pNtk, iBox );
57 if ( Mio_LibraryReadGateByName(pLib, Psr_NtkStr(pNtk, NtkId), NULL) )
58 return 1;
59 }
60 return 0;
61}
ABC_DLL void * Abc_FrameReadLibGen()
Definition mainFrame.c:59
struct Mio_LibraryStruct_t_ Mio_Library_t
Definition mio.h:42
Mio_Gate_t * Mio_LibraryReadGateByName(Mio_Library_t *pLib, char *pName, char *pOutName)
Definition mioApi.c:105
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Psr_ManRemapBoxes()

void Psr_ManRemapBoxes ( Bac_Man_t * pNew,
Vec_Ptr_t * vDes,
Psr_Ntk_t * pNtk,
Vec_Int_t * vMap )

Definition at line 128 of file bacPrsBuild.c.

129{
130 Vec_Int_t * vSigs; int iBox;
131 Psr_NtkForEachBox( pNtk, vSigs, iBox )
132 if ( !Psr_BoxIsNode(pNtk, iBox) )
133 {
134 int NtkId = Psr_BoxNtk( pNtk, iBox );
135 int NtkIdNew = Bac_ManNtkFindId( pNew, Psr_NtkStr(pNtk, NtkId) );
136 assert( NtkIdNew > 0 );
137 Psr_BoxSetNtk( pNtk, iBox, NtkIdNew );
138 if ( NtkIdNew <= Bac_ManNtkNum(pNew) )
139 Psr_ManRemapOne( vSigs, Psr_ManNtk(vDes, NtkIdNew-1), vMap );
140 //else
141 // Psr_ManRemapGate( vSigs );
142 }
143}
void Psr_ManRemapOne(Vec_Int_t *vSigs, Psr_Ntk_t *pNtkBox, Vec_Int_t *vMap)
Definition bacPrsBuild.c:95
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Psr_ManRemapGate()

void Psr_ManRemapGate ( Vec_Int_t * vSigs)

Definition at line 122 of file bacPrsBuild.c.

123{
124 int i, FormId;
125 Vec_IntForEachEntry( vSigs, FormId, i )
126 Vec_IntWriteEntry( vSigs, i, i/2 + 1 ), i++;
127}

◆ Psr_ManRemapOne()

void Psr_ManRemapOne ( Vec_Int_t * vSigs,
Psr_Ntk_t * pNtkBox,
Vec_Int_t * vMap )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 95 of file bacPrsBuild.c.

96{
97 int i, NameId;
98 // map formal names into I/O indexes
99 Psr_NtkForEachPi( pNtkBox, NameId, i )
100 {
101 assert( Vec_IntEntry(vMap, NameId) == -1 );
102 Vec_IntWriteEntry( vMap, NameId, i + 1 ); // +1 to keep 1st form input non-zero
103 }
104 Psr_NtkForEachPo( pNtkBox, NameId, i )
105 {
106 assert( Vec_IntEntry(vMap, NameId) == -1 );
107 Vec_IntWriteEntry( vMap, NameId, Psr_NtkPiNum(pNtkBox) + i + 1 ); // +1 to keep 1st form input non-zero
108 }
109 // remap box
110 assert( Vec_IntSize(vSigs) % 2 == 0 );
111 Vec_IntForEachEntry( vSigs, NameId, i )
112 {
113 assert( Vec_IntEntry(vMap, NameId) != -1 );
114 Vec_IntWriteEntry( vSigs, i++, Vec_IntEntry(vMap, NameId) );
115 }
116 // unmap formal inputs
117 Psr_NtkForEachPi( pNtkBox, NameId, i )
118 Vec_IntWriteEntry( vMap, NameId, -1 );
119 Psr_NtkForEachPo( pNtkBox, NameId, i )
120 Vec_IntWriteEntry( vMap, NameId, -1 );
121}
Here is the caller graph for this function:

◆ Psr_NtkCountObjects()

int Psr_NtkCountObjects ( Psr_Ntk_t * pNtk)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 74 of file bacPrsBuild.c.

75{
76 Vec_Int_t * vFanins;
77 int i, Count = Psr_NtkObjNum(pNtk);
78 Psr_NtkForEachBox( pNtk, vFanins, i )
79 Count += Psr_BoxIONum(pNtk, i);
80 return Count;
81}
Here is the caller graph for this function: