File: two_mapping.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 (63 lines) | stat: -rw-r--r-- 941 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
default Order dec

$include <prelude.sail>
$include <string.sail>
$include <generic_equality.sail>

enum R = {X, Y, F, G}

val name : R -> string

function name X = "X"
and name Y = "Y"
and name F = "F"
and name G = "G"

register R1 : bool
register R2 : bool

val p1 : unit -> bool

function p1() = R1

val p2 : unit -> bool

function p2() = R2

val string1 : bits(1) <-> R

mapping string1 = {
  0b0 <-> X,
  0b1 <-> Y
}

val string2 : bits(1) <-> R

mapping string2 = {
  0b0 <-> F,
  0b1 <-> G
}

val test : bits(1) <-> R

mapping test = {
  string1(reg) if p1() <-> reg,
  string2(reg) if p2() <-> reg,
}

val main : unit -> unit

function main() = {
  R1 = true;
  R2 = false;
  print_endline(name(test(0b0)));
  print_endline(name(test(0b1)));
  R1 = false;
  R2 = true;
  print_endline(name(test(0b0)));
  print_endline(name(test(0b1)));
  R1 = true;
  R2 = true;
  print_endline(name(test(0b0)));
  print_endline(name(test(0b1)));
}