FatalError("BVTypeCheck:BVSX must have two arguments. The second is the new width\n", n);
break;
- case BVZX:
- //in BVZX(n[0],len), the length of the BVZX term must be
- //greater than the length of n[0]
- if (n[0].GetValueWidth() > n.GetValueWidth())
- {
- FatalError("BVTypeCheck: BVZX(t,bvzx_len) : length of 't' must be <= bvzx_len\n", n);
- }
- if ((v.size() != 2))
- FatalError("BVTypeCheck:BVZX must have two arguments. The second is the new width\n", n);
-
- break;
-
default:
for (ASTVec::const_iterator it = v.begin(), itend = v.end(); it != itend; it++)
if (BITVECTOR_TYPE != it->GetType())
break;
}
- case BVZX:
- {
- output = CONSTANTBV::BitVector_Create(inputwidth, true);
- unsigned t0_width = t[0].GetValueWidth();
- if (inputwidth == t0_width)
- {
- CONSTANTBV::BitVector_Copy(output, tmp0);
- OutputNode = CreateBVConst(output, outputwidth);
- }
- else
- {
- CONSTANTBV::BitVector_Interval_Copy(output, tmp0, 0, 0, t0_width);
- OutputNode = CreateBVConst(output, outputwidth);
- }
- break;
- }
-
case BVLEFTSHIFT:
case BVRIGHTSHIFT:
case BVSRSHIFT:
OutputNode = CreateBVConst(output, outputwidth);
break;
}
- //FIXME Only 2 inputs?
+
case BVCONCAT:
{
+ assert(2==t.Degree());
output = CONSTANTBV::BitVector_Create(inputwidth, true);
unsigned t0_width = t[0].GetValueWidth();
unsigned t1_width = t[1].GetValueWidth();
| BVZX_TOK LBRACKET_TOK NUMERAL_TOK RBRACKET_TOK an_term
{
GlobalBeevMgr->BVTypeCheck(*$5);
+ if (0 != $3)
+ {
unsigned w = $5->GetValueWidth() + $3;
- ASTNode width = GlobalBeevMgr->CreateBVConst(32,w);
- ASTNode *n = new ASTNode(GlobalBeevMgr->CreateTerm(BVZX,w,*$5,width));
+ ASTNode leading_zeroes = GlobalBeevMgr->CreateBVConst($3, 0);
+ ASTNode *n = new ASTNode(GlobalBeevMgr->CreateTerm(BVCONCAT,w,leading_zeroes,*$5));
GlobalBeevMgr->BVTypeCheck(*n);
$$ = n;
delete $5;
}
+ else
+ $$ = $5;
+ }
;
sort_symb:
break;
}
- case BVZX:
- {
- ASTNode a0 = SimplifyTerm(inputterm[0], VarConstMap);
- if (a0.GetKind() == BVCONST)
- output = BVConstEvaluator(CreateTerm(BVZX, inputValueWidth, a0, inputterm[1]));
- else
- output = CreateTerm(BVZX, inputValueWidth, a0, inputterm[1]);
- }
- break;
-
case BVSX:
{
//a0 is the expr which is being sign extended
}
}
- case BVZX:
- {
- // Fill the high-order bits with as many zeroes as needed.
- // Arg 0 is expression to be sign extended.
- const ASTNode& arg = term[0];
- unsigned long result_width = term.GetValueWidth();
- unsigned long arg_width = arg.GetValueWidth();
-
- //FIXME Uses a temporary const ASTNode reference
- const ASTNode& bbarg = BBTerm(arg);
- ASTVec tmp_res(result_width);
-
- //FIXME Should these be gotten from result?
- ASTVec::const_iterator bb_it = bbarg.begin();
- ASTVec::iterator res_it = tmp_res.begin();
- ASTVec::iterator res_ext = res_it + arg_width; // first bit of extended part
- ASTVec::iterator res_end = tmp_res.end();
- // copy LSBs directly from bbvec
- for (; res_it < res_ext; (res_it++, bb_it++))
- {
- *res_it = *bb_it;
- }
- // repeat zero to fill up rest of result.
- for (; res_it < res_end; (res_it++))
- {
- *res_it = ASTFalse;
- }
-
- // Temporary debugging code
- // cout << "Zero extending:" << endl
- // << " Vec ";
- // lpvec( bbarg.GetChildren() );
- // cout << " Extended to ";
- // cout << result;
- // cout << endl;
-
- result = CreateNode(BOOLVEC, tmp_res);
-
- break;
- }
-
case BVEXTRACT:
{
// bitblast the child, then extract the relevant bits.