File: assign_range.sail

package info (click to toggle)
sail-ocaml 0.19.1%2Bdfsg5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 18,008 kB
  • sloc: ml: 75,941; ansic: 8,848; python: 1,342; exp: 560; sh: 474; makefile: 218; cpp: 36
file content (32 lines) | stat: -rw-r--r-- 573 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
default Order dec
$include <prelude.sail>

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

function use(n) = {
  let x : bits('n) = sail_sign_extend(0x12, n);
  unsigned(x)
}

val test1 : forall 'n, 'n in {2,4}. int('n) -> int

function test1(n) = {
  size : {'m, 'm >= 8. int('m)} = n * 8;
  use(size)
}

val test2 : forall 'n, 'n in {2,4}. int('n) -> int

function test2(n) = {
  size : range(8,32) = n * 8;
  use(size)
}

val run : unit -> unit

function run () = {
  assert(test1(2) == 18);
  assert(test1(4) == 18);
  assert(test2(2) == 18);
  assert(test2(4) == 18);
}