summaryrefslogtreecommitdiffstats
path: root/src/map/mio/mioUtils.c
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2015-12-14 00:44:33 -0800
committerAlan Mishchenko <alanmi@berkeley.edu>2015-12-14 00:44:33 -0800
commit19586f105cd15279084541a5edf033724a32be49 (patch)
tree1a468a5de4856992b461532b3cc78911e363ff03 /src/map/mio/mioUtils.c
parent64afe6e9f861f8c570ba68c3a2d47ec92ebad96f (diff)
downloadabc-19586f105cd15279084541a5edf033724a32be49.tar.gz
abc-19586f105cd15279084541a5edf033724a32be49.tar.bz2
abc-19586f105cd15279084541a5edf033724a32be49.zip
Adding code to support gate profiles.
Diffstat (limited to 'src/map/mio/mioUtils.c')
-rw-r--r--src/map/mio/mioUtils.c42
1 files changed, 39 insertions, 3 deletions
diff --git a/src/map/mio/mioUtils.c b/src/map/mio/mioUtils.c
index 14b8b45d..c7c6c6dc 100644
--- a/src/map/mio/mioUtils.c
+++ b/src/map/mio/mioUtils.c
@@ -1403,19 +1403,55 @@ int Mio_LibraryHasProfile( Mio_Library_t * pLib )
return 0;
}
+
void Mio_LibraryTransferProfile( Mio_Library_t * pLibDst, Mio_Library_t * pLibSrc )
{
Mio_Gate_t * pGateSrc, * pGateDst;
+ Mio_LibraryForEachGate( pLibDst, pGateDst )
+ Mio_GateSetProfile( pGateDst, 0 );
Mio_LibraryForEachGate( pLibSrc, pGateSrc )
if ( Mio_GateReadProfile(pGateSrc) > 0 )
{
+ // find gate by name
pGateDst = Mio_LibraryReadGateByName( pLibDst, Mio_GateReadName(pGateSrc), NULL );
if ( pGateDst == NULL )
{
- printf( "Cannot find gate \"%s\" in library \"%s\".\n", Mio_GateReadName(pGateSrc), Mio_LibraryReadName(pLibDst) );
- continue;
+ // find gate by function
+ Mio_LibraryForEachGate( pLibDst, pGateDst )
+ if ( pGateDst->uTruth == pGateSrc->uTruth )
+ break;
+ if ( pGateDst == NULL )
+ {
+ printf( "Cannot find gate \"%s\" in library \"%s\".\n", Mio_GateReadName(pGateSrc), Mio_LibraryReadName(pLibDst) );
+ continue;
+ }
+ }
+ Mio_GateAddToProfile( pGateDst, Mio_GateReadProfile(pGateSrc) );
+ }
+}
+void Mio_LibraryTransferProfile2( Mio_Library_t * pLibDst, Mio_Library_t * pLibSrc )
+{
+ Mio_Gate_t * pGateSrc, * pGateDst;
+ Mio_LibraryForEachGate( pLibDst, pGateDst )
+ Mio_GateSetProfile2( pGateDst, 0 );
+ Mio_LibraryForEachGate( pLibSrc, pGateSrc )
+ if ( Mio_GateReadProfile2(pGateSrc) > 0 )
+ {
+ // find gate by name
+ pGateDst = Mio_LibraryReadGateByName( pLibDst, Mio_GateReadName(pGateSrc), NULL );
+ if ( pGateDst == NULL )
+ {
+ // find gate by function
+ Mio_LibraryForEachGate( pLibDst, pGateDst )
+ if ( pGateDst->uTruth == pGateSrc->uTruth )
+ break;
+ if ( pGateDst == NULL )
+ {
+ printf( "Cannot find gate \"%s\" in library \"%s\".\n", Mio_GateReadName(pGateSrc), Mio_LibraryReadName(pLibDst) );
+ continue;
+ }
}
- Mio_GateSetProfile( pGateDst, Mio_GateReadProfile(pGateSrc) );
+ Mio_GateAddToProfile2( pGateDst, Mio_GateReadProfile2(pGateSrc) );
}
}