File: dead_branch.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 (42 lines) | stat: -rw-r--r-- 854 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
default Order dec

$include <arith.sail>
$include <vector_dec.sail>

type xlen : Int = 32
type xlenbits = bits(xlen)

register reg : bits(64)

function read_xlen (arg : bool) -> xlenbits = {
  match (arg, sizeof(xlen)) {
    (_, 32) => reg[31 .. 0],
    (_, 64) => reg,
    (_, _)  => if   sizeof(xlen) == 32
               then reg[31 .. 0]
	       else reg[63 .. 32]
  }
}

type ylen : Int = 64
type ylenbits = bits(ylen)

function read_ylen (arg : bool) -> ylenbits = {
  match (arg, sizeof(ylen)) {
    (_, 32) => reg[31 .. 0],
    (_, 64) => reg,
    (_, _)  => if   sizeof(ylen) == 32
               then reg[31 .. 0]
	       else reg
  }
}

val main : unit -> unit effect {rreg, wreg}
function main() = {
  reg = 0xABCD_1234_5678_EF91;
  let v = read_xlen(true);
  print_bits("v = ", v);
  let v = read_ylen(true);
  print_bits("v = ", v);
  ()
}