summaryrefslogtreecommitdiff
path: root/test/mono/flow_extend.sail
blob: 7e1189938310ee3e1c4454da9d7ed2fdad46e33d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
default Order dec
$include <prelude.sail>

val bitvector_cast_in = "zeroExtend" : forall 'n. bits('n) -> bits('n) effect pure
val bitvector_cast_out = "zeroExtend" : forall 'n. bits('n) -> bits('n) effect pure

val byte_extend : forall 'n, 'n >= 8. (bits(8), int('n)) -> bits('n)

function byte_extend (v, n) = if (n == 8) then v else sail_zero_extend(v, n)

val run : unit -> unit effect {escape}

function run() = {
  assert(byte_extend(0x12,8) == 0x12);
  assert(byte_extend(0x12,16) == 0x0012);
}