summaryrefslogtreecommitdiffstats
path: root/src/base/cba
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2015-09-23 16:04:06 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2015-09-23 16:04:06 -0700
commita84c8174e73882f0cdd6433ca27b8222e87dbaa2 (patch)
tree60f0ecc552d84366b3971379051b4fbc1d5b1db4 /src/base/cba
parent19a4bb930edcfc7910388bb08fd86482b9dd35e7 (diff)
downloadabc-a84c8174e73882f0cdd6433ca27b8222e87dbaa2.tar.gz
abc-a84c8174e73882f0cdd6433ca27b8222e87dbaa2.tar.bz2
abc-a84c8174e73882f0cdd6433ca27b8222e87dbaa2.zip
Improving bit-blasting of full-adder.
Diffstat (limited to 'src/base/cba')
-rw-r--r--src/base/cba/cbaBlast.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/base/cba/cbaBlast.c b/src/base/cba/cbaBlast.c
index b14b0bcd..322d4372 100644
--- a/src/base/cba/cbaBlast.c
+++ b/src/base/cba/cbaBlast.c
@@ -295,11 +295,25 @@ int Cba_BlastLessSigned( Gia_Man_t * pNew, int * pArg0, int * pArg1, int nBits )
}
void Cba_BlastFullAdder( Gia_Man_t * pNew, int a, int b, int c, int * pc, int * ps )
{
- int Xor = Gia_ManHashXor(pNew, a, b);
- int And1 = Gia_ManHashAnd(pNew, a, b);
- int And2 = Gia_ManHashAnd(pNew, c, Xor);
- *ps = Gia_ManHashXor(pNew, c, Xor);
- *pc = Gia_ManHashOr (pNew, And1, And2);
+ int fUseXor = 0;
+ if ( fUseXor )
+ {
+ int Xor = Gia_ManHashXor(pNew, a, b);
+ int And1 = Gia_ManHashAnd(pNew, a, b);
+ int And2 = Gia_ManHashAnd(pNew, c, Xor);
+ *ps = Gia_ManHashXor(pNew, c, Xor);
+ *pc = Gia_ManHashOr (pNew, And1, And2);
+ }
+ else
+ {
+ int And1 = Gia_ManHashAnd(pNew, a, b);
+ int And1_= Gia_ManHashAnd(pNew, Abc_LitNot(a), Abc_LitNot(b));
+ int Xor = Abc_LitNot(Gia_ManHashOr(pNew, And1, And1_));
+ int And2 = Gia_ManHashAnd(pNew, c, Xor);
+ int And2_= Gia_ManHashAnd(pNew, Abc_LitNot(c), Abc_LitNot(Xor));
+ *ps = Abc_LitNot(Gia_ManHashOr(pNew, And2, And2_));
+ *pc = Gia_ManHashOr (pNew, And1, And2);
+ }
}
int Cba_BlastAdder( Gia_Man_t * pNew, int Carry, int * pAdd0, int * pAdd1, int nBits ) // result is in pAdd0
{