diff options
| author | Alasdair Armstrong | 2019-04-11 18:02:32 +0100 |
|---|---|---|
| committer | Alasdair Armstrong | 2019-04-11 18:07:49 +0100 |
| commit | c6e9b167b43332464f8d066034bf4604cb37d182 (patch) | |
| tree | 79aea2ef5f837cffdbf9cddb1308e9c4ee31a2b8 /test/smt/rv_add_decode.unsat.sail | |
| parent | 7cb8cfe50e44e9984b83526baa97aa5946182ad6 (diff) | |
SMT: Add property and counterexample directive
Rather than generating SMT from a function called check_sat, now find
any function with a $property directive and generate SMT for it, e.g.
$property
function prop_cap_round_trip(cap: bits(128)) -> bool = {
let cap_rt = capToBits(capBitsToCapability(true, cap));
cap == cap_rt
}
$property
function prop_base_lteq_top(capbits: bits(128)) -> bool = {
let c = capBitsToCapability(true, capbits);
let (base, top) = getCapBounds(c);
let e = unsigned(c.E);
e >= 51 | base <= top
}
The file property.ml has a function for gathering all the properties
in a file, as well as a rewrite-pass for properties with type
quantifiers, which allows us to handle properties like
function prop forall 'n, 'n <= 100. (bv: bits('n)) -> bool = exp
by rewriting to (conceptually)
function prop(bv: bits(MAX_BIT_WIDTH)) -> bool =
if length(bv) > 100 then true else exp
The function return is now automatically negated (i.e. always true =
unsat, sometimes false = sat), which makes sense for quickcheck-type
properties.
Diffstat (limited to 'test/smt/rv_add_decode.unsat.sail')
| -rw-r--r-- | test/smt/rv_add_decode.unsat.sail | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/test/smt/rv_add_decode.unsat.sail b/test/smt/rv_add_decode.unsat.sail index d5952e09..01653c6f 100644 --- a/test/smt/rv_add_decode.unsat.sail +++ b/test/smt/rv_add_decode.unsat.sail @@ -17,9 +17,10 @@ function clause decode imm : bits(12) @ rs1 : regbits @ 0b000 @ rd : regbits @ 0 function clause decode _ = None() -function check_sat(imm: bits(12), rs1: regbits, rd: regbits) -> bool = { +$property +function prop(imm: bits(12), rs1: regbits, rd: regbits) -> bool = { match decode(imm @ rs1 @ 0b000 @ rd @ 0b0010011) { - Some(ITYPE(_)) => false, - _ => true + Some(ITYPE(_)) => true, + _ => false } }
\ No newline at end of file |
