Example #1
0
def atom(wordlen: int, val: Val, signed: bool = True) -> Expr:
    output = cmn._fresh()
    if val is None:
        val = cmn._fresh()

    if isinstance(val, str):
        aig = cmn.identity_gate(wordlen, val, output)
    else:
        aig = cmn.source(wordlen, val, output, signed)

    return (SignedBVExpr if signed else UnsignedBVExpr)(aig)
Example #2
0
def test_source(int_value):
    var = common.source(wordlen=4, value=int_value, name='x')
    assert common.decode_int(var({})[0]['x']) == int_value
Example #3
0
 def _constk(expr):
     nonlocal size
     if size is None:
         size = expr.size
     return cmn.source(size, k, signed=False) \
         | cmn.sink(expr.size, expr.inputs)