2015-02-01 04:52:32 +01:00
|
|
|
/**CFile****************************************************************
|
|
|
|
|
|
2015-07-22 02:51:28 +02:00
|
|
|
FileName [bacPrsBuild.c]
|
2015-02-01 04:52:32 +01:00
|
|
|
|
|
|
|
|
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.]
|
|
|
|
|
|
2015-07-22 02:51:28 +02:00
|
|
|
Revision [$Id: bacPrsBuild.c,v 1.00 2014/11/29 00:00:00 alanmi Exp $]
|
2015-02-01 04:52:32 +01:00
|
|
|
|
|
|
|
|
***********************************************************************/
|
|
|
|
|
|
2015-07-22 02:51:28 +02:00
|
|
|
#include "bac.h"
|
|
|
|
|
#include "bacPrs.h"
|
2015-02-10 08:27:40 +01:00
|
|
|
#include "map/mio/mio.h"
|
|
|
|
|
#include "base/main/main.h"
|
2015-02-01 04:52:32 +01:00
|
|
|
|
|
|
|
|
ABC_NAMESPACE_IMPL_START
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
/// DECLARATIONS ///
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
/// FUNCTION DEFINITIONS ///
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2015-02-10 08:27:40 +01:00
|
|
|
/**Function*************************************************************
|
|
|
|
|
|
|
|
|
|
Synopsis []
|
|
|
|
|
|
|
|
|
|
Description []
|
|
|
|
|
|
|
|
|
|
SideEffects []
|
|
|
|
|
|
|
|
|
|
SeeAlso []
|
|
|
|
|
|
|
|
|
|
***********************************************************************/
|
2015-07-22 02:51:28 +02:00
|
|
|
int Psr_ManIsMapped( Psr_Ntk_t * pNtk )
|
2015-02-10 08:27:40 +01:00
|
|
|
{
|
|
|
|
|
Vec_Int_t * vSigs; int iBox;
|
2015-04-25 06:33:45 +02:00
|
|
|
Mio_Library_t * pLib = (Mio_Library_t *)Abc_FrameReadLibGen();
|
2015-02-10 08:27:40 +01:00
|
|
|
if ( pLib == NULL )
|
|
|
|
|
return 0;
|
2015-07-22 02:51:28 +02:00
|
|
|
Psr_NtkForEachBox( pNtk, vSigs, iBox )
|
|
|
|
|
if ( !Psr_BoxIsNode(pNtk, iBox) )
|
2015-02-10 08:27:40 +01:00
|
|
|
{
|
2015-07-22 02:51:28 +02:00
|
|
|
int NtkId = Psr_BoxNtk( pNtk, iBox );
|
|
|
|
|
if ( Mio_LibraryReadGateByName(pLib, Psr_NtkStr(pNtk, NtkId), NULL) )
|
2015-02-10 08:27:40 +01:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-01 04:52:32 +01:00
|
|
|
/**Function*************************************************************
|
|
|
|
|
|
|
|
|
|
Synopsis []
|
|
|
|
|
|
|
|
|
|
Description []
|
|
|
|
|
|
|
|
|
|
SideEffects []
|
|
|
|
|
|
|
|
|
|
SeeAlso []
|
|
|
|
|
|
|
|
|
|
***********************************************************************/
|
2015-07-22 02:51:28 +02:00
|
|
|
int Psr_NtkCountObjects( Psr_Ntk_t * pNtk )
|
2015-02-01 04:52:32 +01:00
|
|
|
{
|
|
|
|
|
Vec_Int_t * vFanins;
|
2015-07-22 02:51:28 +02:00
|
|
|
int i, Count = Psr_NtkObjNum(pNtk);
|
|
|
|
|
Psr_NtkForEachBox( pNtk, vFanins, i )
|
|
|
|
|
Count += Psr_BoxIONum(pNtk, i);
|
2015-02-01 04:52:32 +01:00
|
|
|
return Count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**Function*************************************************************
|
|
|
|
|
|
|
|
|
|
Synopsis []
|
|
|
|
|
|
|
|
|
|
Description []
|
|
|
|
|
|
|
|
|
|
SideEffects []
|
|
|
|
|
|
|
|
|
|
SeeAlso []
|
|
|
|
|
|
|
|
|
|
***********************************************************************/
|
|
|
|
|
// replaces NameIds of formal names by their index in the box model
|
2015-07-22 02:51:28 +02:00
|
|
|
void Psr_ManRemapOne( Vec_Int_t * vSigs, Psr_Ntk_t * pNtkBox, Vec_Int_t * vMap )
|
2015-02-01 04:52:32 +01:00
|
|
|
{
|
|
|
|
|
int i, NameId;
|
|
|
|
|
// map formal names into I/O indexes
|
2015-07-22 02:51:28 +02:00
|
|
|
Psr_NtkForEachPi( pNtkBox, NameId, i )
|
2015-02-01 04:52:32 +01:00
|
|
|
{
|
|
|
|
|
assert( Vec_IntEntry(vMap, NameId) == -1 );
|
|
|
|
|
Vec_IntWriteEntry( vMap, NameId, i + 1 ); // +1 to keep 1st form input non-zero
|
|
|
|
|
}
|
2015-07-22 02:51:28 +02:00
|
|
|
Psr_NtkForEachPo( pNtkBox, NameId, i )
|
2015-02-01 04:52:32 +01:00
|
|
|
{
|
|
|
|
|
assert( Vec_IntEntry(vMap, NameId) == -1 );
|
2015-07-22 02:51:28 +02:00
|
|
|
Vec_IntWriteEntry( vMap, NameId, Psr_NtkPiNum(pNtkBox) + i + 1 ); // +1 to keep 1st form input non-zero
|
2015-02-01 04:52:32 +01:00
|
|
|
}
|
|
|
|
|
// remap box
|
|
|
|
|
assert( Vec_IntSize(vSigs) % 2 == 0 );
|
|
|
|
|
Vec_IntForEachEntry( vSigs, NameId, i )
|
|
|
|
|
{
|
|
|
|
|
assert( Vec_IntEntry(vMap, NameId) != -1 );
|
|
|
|
|
Vec_IntWriteEntry( vSigs, i++, Vec_IntEntry(vMap, NameId) );
|
|
|
|
|
}
|
|
|
|
|
// unmap formal inputs
|
2015-07-22 02:51:28 +02:00
|
|
|
Psr_NtkForEachPi( pNtkBox, NameId, i )
|
2015-02-01 04:52:32 +01:00
|
|
|
Vec_IntWriteEntry( vMap, NameId, -1 );
|
2015-07-22 02:51:28 +02:00
|
|
|
Psr_NtkForEachPo( pNtkBox, NameId, i )
|
2015-02-01 04:52:32 +01:00
|
|
|
Vec_IntWriteEntry( vMap, NameId, -1 );
|
|
|
|
|
}
|
2015-07-22 02:51:28 +02:00
|
|
|
void Psr_ManRemapGate( Vec_Int_t * vSigs )
|
2015-02-10 08:27:40 +01:00
|
|
|
{
|
|
|
|
|
int i, FormId;
|
|
|
|
|
Vec_IntForEachEntry( vSigs, FormId, i )
|
|
|
|
|
Vec_IntWriteEntry( vSigs, i, i/2 + 1 ), i++;
|
|
|
|
|
}
|
2015-07-22 02:51:28 +02:00
|
|
|
void Psr_ManRemapBoxes( Bac_Man_t * pNew, Vec_Ptr_t * vDes, Psr_Ntk_t * pNtk, Vec_Int_t * vMap )
|
2015-02-01 04:52:32 +01:00
|
|
|
{
|
|
|
|
|
Vec_Int_t * vSigs; int iBox;
|
2015-07-22 02:51:28 +02:00
|
|
|
Psr_NtkForEachBox( pNtk, vSigs, iBox )
|
|
|
|
|
if ( !Psr_BoxIsNode(pNtk, iBox) )
|
2015-02-01 04:52:32 +01:00
|
|
|
{
|
2015-07-22 02:51:28 +02:00
|
|
|
int NtkId = Psr_BoxNtk( pNtk, iBox );
|
|
|
|
|
int NtkIdNew = Bac_ManNtkFindId( pNew, Psr_NtkStr(pNtk, NtkId) );
|
2015-03-05 01:07:33 +01:00
|
|
|
assert( NtkIdNew > 0 );
|
2015-07-22 02:51:28 +02:00
|
|
|
Psr_BoxSetNtk( pNtk, iBox, NtkIdNew );
|
|
|
|
|
if ( NtkIdNew <= Bac_ManNtkNum(pNew) )
|
|
|
|
|
Psr_ManRemapOne( vSigs, Psr_ManNtk(vDes, NtkIdNew-1), vMap );
|
2015-02-10 17:03:01 +01:00
|
|
|
//else
|
2015-07-22 02:51:28 +02:00
|
|
|
// Psr_ManRemapGate( vSigs );
|
2015-02-01 04:52:32 +01:00
|
|
|
}
|
|
|
|
|
}
|
2015-07-22 02:51:28 +02:00
|
|
|
void Psr_ManCleanMap( Psr_Ntk_t * pNtk, Vec_Int_t * vMap )
|
2015-02-01 04:52:32 +01:00
|
|
|
{
|
|
|
|
|
Vec_Int_t * vSigs;
|
|
|
|
|
int i, k, NameId, Sig;
|
2015-07-22 02:51:28 +02:00
|
|
|
Psr_NtkForEachPi( pNtk, NameId, i )
|
2015-02-01 04:52:32 +01:00
|
|
|
Vec_IntWriteEntry( vMap, NameId, -1 );
|
2015-07-22 02:51:28 +02:00
|
|
|
Psr_NtkForEachBox( pNtk, vSigs, i )
|
2015-02-01 04:52:32 +01:00
|
|
|
Vec_IntForEachEntryDouble( vSigs, NameId, Sig, k )
|
2015-07-22 02:51:28 +02:00
|
|
|
Vec_IntWriteEntry( vMap, Psr_NtkSigName(pNtk, Sig), -1 );
|
|
|
|
|
Psr_NtkForEachPo( pNtk, NameId, i )
|
2015-02-01 04:52:32 +01:00
|
|
|
Vec_IntWriteEntry( vMap, NameId, -1 );
|
|
|
|
|
}
|
|
|
|
|
// create maps of NameId and boxes
|
2015-07-22 02:51:28 +02:00
|
|
|
void Psr_ManBuildNtk( Bac_Ntk_t * pNew, Vec_Ptr_t * vDes, Psr_Ntk_t * pNtk, Vec_Int_t * vMap, Vec_Int_t * vBoxes )
|
2015-02-01 04:52:32 +01:00
|
|
|
{
|
2015-07-22 02:51:28 +02:00
|
|
|
Psr_Ntk_t * pNtkBox; Vec_Int_t * vSigs; int iBox;
|
2015-02-01 04:52:32 +01:00
|
|
|
int i, Index, NameId, iObj, iConst0, iTerm;
|
|
|
|
|
int iNonDriven = -1, nNonDriven = 0;
|
2015-07-22 02:51:28 +02:00
|
|
|
assert( Psr_NtkPioNum(pNtk) == 0 );
|
|
|
|
|
Psr_ManRemapBoxes( pNew->pDesign, vDes, pNtk, vMap );
|
|
|
|
|
Bac_NtkStartNames( pNew );
|
2015-02-01 04:52:32 +01:00
|
|
|
// create primary inputs
|
2015-07-22 02:51:28 +02:00
|
|
|
Psr_NtkForEachPi( pNtk, NameId, i )
|
2015-02-01 04:52:32 +01:00
|
|
|
{
|
|
|
|
|
if ( Vec_IntEntry(vMap, NameId) != -1 )
|
|
|
|
|
printf( "Primary inputs %d and %d have the same name.\n", Vec_IntEntry(vMap, NameId), i );
|
2015-07-22 02:51:28 +02:00
|
|
|
iObj = Bac_ObjAlloc( pNew, BAC_OBJ_PI, -1 );
|
|
|
|
|
Bac_ObjSetName( pNew, iObj, Abc_Var2Lit2(NameId, BAC_NAME_BIN) );
|
2015-02-01 04:52:32 +01:00
|
|
|
Vec_IntWriteEntry( vMap, NameId, iObj );
|
|
|
|
|
}
|
|
|
|
|
// create box outputs
|
|
|
|
|
Vec_IntClear( vBoxes );
|
2015-07-22 02:51:28 +02:00
|
|
|
Psr_NtkForEachBox( pNtk, vSigs, iBox )
|
|
|
|
|
if ( !Psr_BoxIsNode(pNtk, iBox) )
|
2015-02-01 04:52:32 +01:00
|
|
|
{
|
2015-07-22 02:51:28 +02:00
|
|
|
pNtkBox = Psr_ManNtk( vDes, Psr_BoxNtk(pNtk, iBox)-1 );
|
2015-02-10 08:27:40 +01:00
|
|
|
if ( pNtkBox == NULL )
|
2015-02-01 04:52:32 +01:00
|
|
|
{
|
2015-07-22 02:51:28 +02:00
|
|
|
iObj = Bac_BoxAlloc( pNew, BAC_BOX_GATE, Vec_IntSize(vSigs)/2-1, 1, Psr_BoxNtk(pNtk, iBox) );
|
|
|
|
|
Bac_ObjSetName( pNew, iObj, Abc_Var2Lit2(Psr_BoxName(pNtk, iBox), BAC_NAME_BIN) );
|
2015-02-01 04:52:32 +01:00
|
|
|
// consider box output
|
2015-02-10 08:27:40 +01:00
|
|
|
NameId = Vec_IntEntryLast( vSigs );
|
2015-07-22 02:51:28 +02:00
|
|
|
NameId = Psr_NtkSigName( pNtk, NameId );
|
2015-02-01 04:52:32 +01:00
|
|
|
if ( Vec_IntEntry(vMap, NameId) != -1 )
|
|
|
|
|
printf( "Box output name %d is already driven.\n", NameId );
|
2015-07-22 02:51:28 +02:00
|
|
|
iTerm = Bac_BoxBo( pNew, iObj, 0 );
|
|
|
|
|
Bac_ObjSetName( pNew, iTerm, Abc_Var2Lit2(NameId, BAC_NAME_BIN) );
|
2015-02-01 04:52:32 +01:00
|
|
|
Vec_IntWriteEntry( vMap, NameId, iTerm );
|
|
|
|
|
}
|
2015-02-10 08:27:40 +01:00
|
|
|
else
|
|
|
|
|
{
|
2015-07-22 02:51:28 +02:00
|
|
|
iObj = Bac_BoxAlloc( pNew, BAC_OBJ_BOX, Psr_NtkPiNum(pNtkBox), Psr_NtkPoNum(pNtkBox), Psr_BoxNtk(pNtk, iBox) );
|
|
|
|
|
Bac_ObjSetName( pNew, iObj, Abc_Var2Lit2(Psr_BoxName(pNtk, iBox), BAC_NAME_BIN) );
|
|
|
|
|
Bac_NtkSetHost( Bac_ManNtk(pNew->pDesign, Psr_BoxNtk(pNtk, iBox)), Bac_NtkId(pNew), iObj );
|
2015-02-10 08:27:40 +01:00
|
|
|
Vec_IntForEachEntry( vSigs, Index, i )
|
|
|
|
|
{
|
|
|
|
|
i++;
|
2015-07-22 02:51:28 +02:00
|
|
|
if ( --Index < Psr_NtkPiNum(pNtkBox) )
|
2015-02-10 08:27:40 +01:00
|
|
|
continue;
|
2015-07-22 02:51:28 +02:00
|
|
|
assert( Index - Psr_NtkPiNum(pNtkBox) < Psr_NtkPoNum(pNtkBox) );
|
2015-02-10 08:27:40 +01:00
|
|
|
// consider box output
|
|
|
|
|
NameId = Vec_IntEntry( vSigs, i );
|
2015-07-22 02:51:28 +02:00
|
|
|
NameId = Psr_NtkSigName( pNtk, NameId );
|
2015-02-10 08:27:40 +01:00
|
|
|
if ( Vec_IntEntry(vMap, NameId) != -1 )
|
|
|
|
|
printf( "Box output name %d is already driven.\n", NameId );
|
2015-07-22 02:51:28 +02:00
|
|
|
iTerm = Bac_BoxBo( pNew, iObj, Index - Psr_NtkPiNum(pNtkBox) );
|
|
|
|
|
Bac_ObjSetName( pNew, iTerm, Abc_Var2Lit2(NameId, BAC_NAME_BIN) );
|
2015-02-10 08:27:40 +01:00
|
|
|
Vec_IntWriteEntry( vMap, NameId, iTerm );
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-02-01 04:52:32 +01:00
|
|
|
// remember box
|
|
|
|
|
Vec_IntPush( vBoxes, iObj );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2015-07-22 02:51:28 +02:00
|
|
|
iObj = Bac_BoxAlloc( pNew, (Bac_ObjType_t)Psr_BoxNtk(pNtk, iBox), Psr_BoxIONum(pNtk, iBox)-1, 1, -1 );
|
2015-02-01 04:52:32 +01:00
|
|
|
// consider box output
|
|
|
|
|
NameId = Vec_IntEntryLast( vSigs );
|
2015-07-22 02:51:28 +02:00
|
|
|
NameId = Psr_NtkSigName( pNtk, NameId );
|
2015-02-01 04:52:32 +01:00
|
|
|
if ( Vec_IntEntry(vMap, NameId) != -1 )
|
|
|
|
|
printf( "Node output name %d is already driven.\n", NameId );
|
2015-07-22 02:51:28 +02:00
|
|
|
iTerm = Bac_BoxBo( pNew, iObj, 0 );
|
|
|
|
|
Bac_ObjSetName( pNew, iTerm, Abc_Var2Lit2(NameId, BAC_NAME_BIN) );
|
2015-02-01 04:52:32 +01:00
|
|
|
Vec_IntWriteEntry( vMap, NameId, iTerm );
|
|
|
|
|
// remember box
|
|
|
|
|
Vec_IntPush( vBoxes, iObj );
|
|
|
|
|
}
|
|
|
|
|
// add fanins for box inputs
|
2015-07-22 02:51:28 +02:00
|
|
|
Psr_NtkForEachBox( pNtk, vSigs, iBox )
|
|
|
|
|
if ( !Psr_BoxIsNode(pNtk, iBox) )
|
2015-02-01 04:52:32 +01:00
|
|
|
{
|
2015-07-22 02:51:28 +02:00
|
|
|
pNtkBox = Psr_ManNtk( vDes, Psr_BoxNtk(pNtk, iBox)-1 );
|
2015-02-01 04:52:32 +01:00
|
|
|
iObj = Vec_IntEntry( vBoxes, iBox );
|
2015-02-10 08:27:40 +01:00
|
|
|
if ( pNtkBox == NULL )
|
2015-02-01 04:52:32 +01:00
|
|
|
{
|
2015-02-10 08:27:40 +01:00
|
|
|
Vec_IntForEachEntryStop( vSigs, Index, i, Vec_IntSize(vSigs)-2 )
|
2015-02-01 04:52:32 +01:00
|
|
|
{
|
2015-02-10 08:27:40 +01:00
|
|
|
i++;
|
|
|
|
|
NameId = Vec_IntEntry( vSigs, i );
|
2015-07-22 02:51:28 +02:00
|
|
|
NameId = Psr_NtkSigName( pNtk, NameId );
|
|
|
|
|
iTerm = Bac_BoxBi( pNew, iObj, i/2 );
|
2015-02-10 08:27:40 +01:00
|
|
|
if ( Vec_IntEntry(vMap, NameId) == -1 )
|
|
|
|
|
{
|
2015-07-22 02:51:28 +02:00
|
|
|
iConst0 = Bac_BoxAlloc( pNew, BAC_BOX_CF, 0, 1, -1 );
|
2015-02-10 08:27:40 +01:00
|
|
|
Vec_IntWriteEntry( vMap, NameId, iConst0+1 );
|
|
|
|
|
if ( iNonDriven == -1 )
|
|
|
|
|
iNonDriven = NameId;
|
|
|
|
|
nNonDriven++;
|
|
|
|
|
}
|
2015-07-22 02:51:28 +02:00
|
|
|
Bac_ObjSetFanin( pNew, iTerm, Vec_IntEntry(vMap, NameId) );
|
2015-02-10 08:27:40 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Vec_IntForEachEntry( vSigs, Index, i )
|
|
|
|
|
{
|
|
|
|
|
i++;
|
2015-07-22 02:51:28 +02:00
|
|
|
if ( --Index >= Psr_NtkPiNum(pNtkBox) )
|
2015-02-10 08:27:40 +01:00
|
|
|
continue;
|
|
|
|
|
NameId = Vec_IntEntry( vSigs, i );
|
2015-07-22 02:51:28 +02:00
|
|
|
NameId = Psr_NtkSigName( pNtk, NameId );
|
|
|
|
|
iTerm = Bac_BoxBi( pNew, iObj, Index );
|
2015-02-10 08:27:40 +01:00
|
|
|
if ( Vec_IntEntry(vMap, NameId) == -1 )
|
|
|
|
|
{
|
2015-07-22 02:51:28 +02:00
|
|
|
iConst0 = Bac_BoxAlloc( pNew, BAC_BOX_CF, 0, 1, -1 );
|
2015-02-10 08:27:40 +01:00
|
|
|
Vec_IntWriteEntry( vMap, NameId, iConst0+1 );
|
|
|
|
|
if ( iNonDriven == -1 )
|
|
|
|
|
iNonDriven = NameId;
|
|
|
|
|
nNonDriven++;
|
|
|
|
|
}
|
2015-07-22 02:51:28 +02:00
|
|
|
Bac_ObjSetFanin( pNew, iTerm, Vec_IntEntry(vMap, NameId) );
|
2015-02-01 04:52:32 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
iObj = Vec_IntEntry( vBoxes, iBox );
|
|
|
|
|
Vec_IntForEachEntryStop( vSigs, Index, i, Vec_IntSize(vSigs)-2 )
|
|
|
|
|
{
|
|
|
|
|
NameId = Vec_IntEntry( vSigs, ++i );
|
2015-07-22 02:51:28 +02:00
|
|
|
NameId = Psr_NtkSigName( pNtk, NameId );
|
|
|
|
|
iTerm = Bac_BoxBi( pNew, iObj, i/2 );
|
2015-02-01 04:52:32 +01:00
|
|
|
if ( Vec_IntEntry(vMap, NameId) == -1 )
|
|
|
|
|
{
|
2015-07-22 02:51:28 +02:00
|
|
|
iConst0 = Bac_BoxAlloc( pNew, BAC_BOX_CF, 0, 1, -1 );
|
2015-02-01 04:52:32 +01:00
|
|
|
Vec_IntWriteEntry( vMap, NameId, iConst0+1 );
|
|
|
|
|
if ( iNonDriven == -1 )
|
|
|
|
|
iNonDriven = NameId;
|
|
|
|
|
nNonDriven++;
|
|
|
|
|
}
|
2015-07-22 02:51:28 +02:00
|
|
|
Bac_ObjSetFanin( pNew, iTerm, Vec_IntEntry(vMap, NameId) );
|
2015-02-01 04:52:32 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// add fanins for primary outputs
|
2015-07-22 02:51:28 +02:00
|
|
|
Psr_NtkForEachPo( pNtk, NameId, i )
|
2015-02-01 04:52:32 +01:00
|
|
|
if ( Vec_IntEntry(vMap, NameId) == -1 )
|
|
|
|
|
{
|
2015-07-22 02:51:28 +02:00
|
|
|
iConst0 = Bac_BoxAlloc( pNew, BAC_BOX_CF, 0, 1, -1 );
|
2015-02-01 04:52:32 +01:00
|
|
|
Vec_IntWriteEntry( vMap, NameId, iConst0+1 );
|
|
|
|
|
if ( iNonDriven == -1 )
|
|
|
|
|
iNonDriven = NameId;
|
|
|
|
|
nNonDriven++;
|
|
|
|
|
}
|
2015-07-22 02:51:28 +02:00
|
|
|
Psr_NtkForEachPo( pNtk, NameId, i )
|
|
|
|
|
iObj = Bac_ObjAlloc( pNew, BAC_OBJ_PO, Vec_IntEntry(vMap, NameId) );
|
2015-02-01 04:52:32 +01:00
|
|
|
if ( nNonDriven )
|
2015-07-22 02:51:28 +02:00
|
|
|
printf( "Module %s has %d non-driven nets (for example, %s).\n", Psr_NtkName(pNtk), nNonDriven, Psr_NtkStr(pNtk, iNonDriven) );
|
|
|
|
|
Psr_ManCleanMap( pNtk, vMap );
|
2015-02-16 00:37:00 +01:00
|
|
|
// setup info
|
|
|
|
|
Vec_IntForEachEntry( &pNtk->vOrder, NameId, i )
|
2015-07-22 02:51:28 +02:00
|
|
|
Bac_NtkAddInfo( pNew, NameId, -1, -1 );
|
2015-02-01 04:52:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**Function*************************************************************
|
|
|
|
|
|
|
|
|
|
Synopsis []
|
|
|
|
|
|
|
|
|
|
Description []
|
|
|
|
|
|
|
|
|
|
SideEffects []
|
|
|
|
|
|
|
|
|
|
SeeAlso []
|
|
|
|
|
|
|
|
|
|
***********************************************************************/
|
2015-07-22 02:51:28 +02:00
|
|
|
Bac_Man_t * Psr_ManBuildCba( char * pFileName, Vec_Ptr_t * vDes )
|
2015-02-01 04:52:32 +01:00
|
|
|
{
|
2015-07-22 02:51:28 +02:00
|
|
|
Psr_Ntk_t * pNtk = Psr_ManRoot( vDes ); int i;
|
|
|
|
|
Bac_Man_t * pNew = Bac_ManAlloc( pFileName, Vec_PtrSize(vDes) );
|
2015-02-01 04:52:32 +01:00
|
|
|
Vec_Int_t * vMap = Vec_IntStartFull( Abc_NamObjNumMax(pNtk->pStrs) + 1 );
|
2015-07-22 02:51:28 +02:00
|
|
|
Vec_Int_t * vTmp = Vec_IntAlloc( Psr_NtkBoxNum(pNtk) );
|
2015-02-01 04:52:32 +01:00
|
|
|
Abc_NamDeref( pNew->pStrs );
|
|
|
|
|
pNew->pStrs = Abc_NamRef( pNtk->pStrs );
|
2015-07-22 02:51:28 +02:00
|
|
|
Vec_PtrForEachEntry( Psr_Ntk_t *, vDes, pNtk, i )
|
|
|
|
|
Bac_NtkAlloc( Bac_ManNtk(pNew, i+1), Psr_NtkId(pNtk), Psr_NtkPiNum(pNtk), Psr_NtkPoNum(pNtk), Psr_NtkCountObjects(pNtk) );
|
|
|
|
|
if ( (pNtk->fMapped || (pNtk->fSlices && Psr_ManIsMapped(pNtk))) && !Bac_NtkBuildLibrary(pNew) )
|
|
|
|
|
Bac_ManFree(pNew), pNew = NULL;
|
2015-02-10 08:27:40 +01:00
|
|
|
else
|
2015-07-22 02:51:28 +02:00
|
|
|
Vec_PtrForEachEntry( Psr_Ntk_t *, vDes, pNtk, i )
|
|
|
|
|
Psr_ManBuildNtk( Bac_ManNtk(pNew, i+1), vDes, pNtk, vMap, vTmp );
|
2015-02-01 04:52:32 +01:00
|
|
|
assert( Vec_IntCountEntry(vMap, -1) == Vec_IntSize(vMap) );
|
|
|
|
|
Vec_IntFree( vMap );
|
|
|
|
|
Vec_IntFree( vTmp );
|
2015-07-22 02:51:28 +02:00
|
|
|
// Vec_StrPrint( &Bac_ManNtk(pNew, 1)->vType, 1 );
|
2015-02-01 04:52:32 +01:00
|
|
|
return pNew;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
/// END OF FILE ///
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ABC_NAMESPACE_IMPL_END
|
|
|
|
|
|