summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathias Soeken <mathias.soeken@epfl.ch>2016-08-16 18:46:45 +0200
committerMathias Soeken <mathias.soeken@epfl.ch>2016-08-16 18:46:45 +0200
commit85c751fbb89658ea7688015fbbd55dac2317dc5c (patch)
tree4731bd3e3d3d8fe360d594d01b4ba9d9db480a79
parent2f149364eb80e162c85d79d461885482d17dd1ba (diff)
downloadabc-85c751fbb89658ea7688015fbbd55dac2317dc5c.tar.gz
abc-85c751fbb89658ea7688015fbbd55dac2317dc5c.tar.bz2
abc-85c751fbb89658ea7688015fbbd55dac2317dc5c.zip
Functions to compute T-count.
-rw-r--r--src/base/exor/exor.c37
1 files changed, 37 insertions, 0 deletions
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*************************************************************