public static (BitVecExpr result, BoolExpr cf, BoolExpr of, BoolExpr af) Addition( BitVecExpr a, BitVecExpr b, BoolExpr carry, Context ctx) { Contract.Requires(ctx != null); Contract.Requires(a != null); //if (carry.IsFalse) return Addition(a, b, ctx); uint nBits = a.SortSize; BitVecExpr bv0_1bit = ctx.MkBV(0, 1); BitVecExpr bv1_1bit = ctx.MkBV(1, 1); BitVecExpr ax = ctx.MkZeroExt(1, a); BitVecExpr bx = ctx.MkZeroExt(1, b); BitVecExpr carryBV = ctx.MkITE(carry, ctx.MkBV(1, nBits + 1), ctx.MkBV(0, nBits + 1)) as BitVecExpr; BitVecExpr bx2 = ctx.MkBVAdd(bx, carryBV); BitVecExpr rx = ctx.MkBVAdd(ax, bx2); BitVecExpr result = ctx.MkExtract(nBits - 1, 0, rx); BoolExpr cf = ToolsFlags.Create_CF_Add(ax, bx2, nBits, ctx); BoolExpr of = ToolsFlags.Create_OF_Add(ax, bx2, nBits, ctx); BoolExpr af = ToolsFlags.Create_AF_Add(ax, bx2, ctx); return(result : result, cf : cf, of : of, af : af); }
public static (BitVecExpr result, BoolExpr cf, BoolExpr of, BoolExpr af) Addition( BitVecExpr a, BitVecExpr b, Context ctx) { BitVecExpr result = ctx.MkBVAdd(a, b); BoolExpr cf = ToolsFlags.Create_CF_Add(a, b, a.SortSize, ctx); BoolExpr of = ToolsFlags.Create_OF_Add(a, b, a.SortSize, ctx); BoolExpr af = ToolsFlags.Create_AF_Add(a, b, ctx); return(result : result, cf : cf, of : of, af : af); }