Skip to content

Commit

Permalink
Split property helpers to their own file
Browse files Browse the repository at this point in the history
  • Loading branch information
nwf committed Nov 20, 2024
1 parent 7805dcb commit 4936443
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 34 deletions.
3 changes: 2 additions & 1 deletion properties/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ SRCS+=${TOP}/sail-riscv/model/riscv_xlen32.sail
SRCS+=${TOP}/src/cheri_prelude.sail
SRCS+=${TOP}/src/cheri_types.sail
SRCS+=${TOP}/src/cheri_cap_common.sail
SRCS+=proplib.sail
SRCS+=props.sail

all: generate_smt run_smt

generate_smt:
sail -smt ${SRCS}
sail ${SAIL_FLAGS} -smt ${SRCS}

run_smt:
@failure=0; \
Expand Down
32 changes: 32 additions & 0 deletions properties/proplib.sail
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@


/* Syntactic sugar */

infixr 1 -->

type operator -->('p: Bool, 'q: Bool) -> Bool = not('p) | 'q
val operator --> : forall ('p 'q: Bool). (bool('p), bool('q)) -> bool('p --> 'q)
function operator --> (p, q) = not_bool(p) | q

infix 1 <-->

type operator <-->('p: Bool, 'q: Bool) -> Bool = ('p --> 'q) & ('q --> 'p)
val operator <--> : forall ('p 'q: Bool). (bool('p), bool('q)) -> bool('p <--> 'q)
function operator <--> (p, q) = (p --> q) & (q --> p)

/* Useful functions */

/*!
* THIS is a helper function to compress and then decompress a Capability.
* The [Capability] struct can hold non-encodable values therefore some
* properties encode then decode a Capability to check the effect that
* compression / decompression has. In general the bounds, address and tag
* should be unaffected but the permissions and otype might change.
*/
function encodeDecode(c : Capability) -> Capability = capBitsToCapability(c.tag, capToBits(c))

/*!
* THIS is a helper to check that the given Capability is unaffected by
* compression / decompression.
*/
function capEncodable(c : Capability) -> bool = c == encodeDecode(c)
33 changes: 0 additions & 33 deletions properties/props.sail
Original file line number Diff line number Diff line change
@@ -1,36 +1,3 @@


/* Syntactic sugar */

infixr 1 -->

type operator -->('p: Bool, 'q: Bool) -> Bool = not('p) | 'q
val operator --> : forall ('p 'q: Bool). (bool('p), bool('q)) -> bool('p --> 'q)
function operator --> (p, q) = not_bool(p) | q

infix 1 <-->

type operator <-->('p: Bool, 'q: Bool) -> Bool = ('p --> 'q) & ('q --> 'p)
val operator <--> : forall ('p 'q: Bool). (bool('p), bool('q)) -> bool('p <--> 'q)
function operator <--> (p, q) = (p --> q) & (q --> p)

/* Useful functions */

/*!
* THIS is a helper function to compress and then decompress a Capability.
* The [Capability] struct can hold non-encodable values therefore some
* properties encode then decode a Capability to check the effect that
* compression / decompression has. In general the bounds, address and tag
* should be unaffected but the permissions and otype might change.
*/
function encodeDecode(c : Capability) -> Capability = capBitsToCapability(c.tag, capToBits(c))

/*!
* THIS is a helper to check that the given Capability is unaffected by
* compression / decompression.
*/
function capEncodable(c : Capability) -> bool = c == encodeDecode(c)

// $property
/*
* THIS is not actually an invariant but is useful for characterising unusable
Expand Down

0 comments on commit 4936443

Please sign in to comment.