From 85c751fbb89658ea7688015fbbd55dac2317dc5c Mon Sep 17 00:00:00 2001 From: Mathias Soeken Date: Tue, 16 Aug 2016 18:46:45 +0200 Subject: Functions to compute T-count. --- src/base/exor/exor.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/base/exor/exor.c b/src/base/exor/exor.c index 9aec90d7..7ae190ce 100644 --- a/src/base/exor/exor.c +++ b/src/base/exor/exor.c @@ -116,6 +116,43 @@ int ComputeQCostBits( Cube * p ) nLits += nLitsN; return QCost[Abc_MinInt(nLits, 7)][Abc_MinInt(nLitsN, 7)]; } +int ToffoliGateCount( int controls, int lines ) +{ + switch ( controls ) + { + case 0u: + case 1u: + return 0; + break; + case 2u: + return 1; + break; + case 3u: + return 4; + break; + case 4u: + return ( ( ( lines + 1 ) / 2 ) >= controls ) ? 8 : 10; + break; + default: + return ( ( ( lines + 1 ) / 2 ) >= controls ) ? 4 * ( controls - 2 ) : 8 * ( controls - 3 ); + } +} +int ComputeQCostTcount( Vec_Int_t * vCube ) +{ + return 7 * ToffoliGateCount( Vec_IntSize( vCube ), g_CoverInfo.nVarsIn + 1 ); +} +int ComputeQCostTcountBits( Cube * p ) +{ + extern varvalue GetVar( Cube* pC, int Var ); + int v, nLits = 0; + for ( v = 0; v < g_CoverInfo.nVarsIn; v++ ) + if ( GetVar( p, v ) != VAR_ABS ) + nLits++; + return 7 * ToffoliGateCount( nLits, g_CoverInfo.nVarsIn + 1 ); + + /* maybe just: 7 * ToffoliGateCount( p->a, g_CoverInfo.nVarsIn + 1 ); */ +} + /**Function************************************************************* -- cgit v1.2.3