From 79c282de9cf17b28686071e06e19fa2847f4c38a Mon Sep 17 00:00:00 2001 From: vijay_ganesh Date: Sun, 6 Sep 2009 21:02:01 +0000 Subject: [PATCH] added vc_ExtractBit_One git-svn-id: https://stp-fast-prover.svn.sourceforge.net/svnroot/stp-fast-prover/trunk/stp@193 e59a4935-1847-0410-ae03-e826735625c1 --- src/c_interface/c_interface.cpp | 32 ++++++++++++++++++++++++++++++++ src/c_interface/c_interface.h | 11 ++++++++--- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/src/c_interface/c_interface.cpp b/src/c_interface/c_interface.cpp index 2a063f5..21cd30f 100644 --- a/src/c_interface/c_interface.cpp +++ b/src/c_interface/c_interface.cpp @@ -1268,6 +1268,38 @@ Expr vc_bvBoolExtract(VC vc, Expr ccc, int bit_num) { return output; } +Expr vc_bvBoolExtract_Zero(VC vc, Expr ccc, int bit_num) { + bmstar b = (bmstar)vc; + nodestar a = (nodestar)ccc; + b->BVTypeCheck(*a); + + node bit = b->CreateBVConst(32,bit_num); + //node o = b->CreateNode(BEEV::BVGETBIT,*a,bit); + node zero = b->CreateBVConst(1,0); + node oo = b->CreateTerm(BEEV::BVEXTRACT,1,*a,bit,bit); + node o = b->CreateNode(BEEV::EQ,oo,zero); + b->BVTypeCheck(o); + nodestar output = new node(o); + //if(cinterface_exprdelete_on) created_exprs.push_back(output); + return output; +} + +Expr vc_bvBoolExtract_One(VC vc, Expr ccc, int bit_num) { + bmstar b = (bmstar)vc; + nodestar a = (nodestar)ccc; + b->BVTypeCheck(*a); + + node bit = b->CreateBVConst(32,bit_num); + //node o = b->CreateNode(BEEV::BVGETBIT,*a,bit); + node one = b->CreateBVConst(1,1); + node oo = b->CreateTerm(BEEV::BVEXTRACT,1,*a,bit,bit); + node o = b->CreateNode(BEEV::EQ,oo,one); + b->BVTypeCheck(o); + nodestar output = new node(o); + //if(cinterface_exprdelete_on) created_exprs.push_back(output); + return output; +} + Expr vc_bvSignExtend(VC vc, Expr ccc, int nbits) { bmstar b = (bmstar)vc; nodestar a = (nodestar)ccc; diff --git a/src/c_interface/c_interface.h b/src/c_interface/c_interface.h index 0f4d1d5..89ede24 100644 --- a/src/c_interface/c_interface.h +++ b/src/c_interface/c_interface.h @@ -260,9 +260,14 @@ extern "C" { //accepts a bitvector and position, and returns a boolean //corresponding to that position. More precisely, it return the - //equation (x[bit_no:bit_no] = 0) - //FIXME = 1 ? - Expr vc_bvBoolExtract(VC vc, Expr x, int bit_no); + //equation (x[bit_no:bit_no] == 0) + Expr vc_bvBoolExtract(VC vc, Expr x, int bit_no); + Expr vc_bvBoolExtract_Zero(VC vc, Expr x, int bit_no); + + //accepts a bitvector and position, and returns a boolean + //corresponding to that position. More precisely, it return the + //equation (x[bit_no:bit_no] == 1) + Expr vc_bvBoolExtract_One(VC vc, Expr x, int bit_no); Expr vc_bvSignExtend(VC vc, Expr child, int nbits); /*C pointer support: C interface to support C memory arrays in CVCL */ -- 2.47.3