-
Notifications
You must be signed in to change notification settings - Fork 5
/
U16.fm
112 lines (89 loc) · 2.06 KB
/
U16.fm
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
T U16
| U16.new(a: Word(16));
U16.0: U16
U16.new(Word.zero(16))
U16.add(a: U16, b: U16): U16
get a_val = a
get b_val = b
U16.new(Word.add<>(a_val, b_val))
U16.and(a: U16, b: U16): U16
get a_val = a
get b_val = b
U16.new(Word.and<>(a_val, b_val))
U16.concat(a: U16, b: U16): U32
get a_val = a
get b_val = b
U32.new(Word.concat<><>(a_val, b_val))
U16.div(a: U16, b: U16): U16
get a_val = a
get b_val = b
U16.new(Word.div<>(a_val, b_val))
// a == b
U16.eql(a: U16, b: U16): Bool
get a_val = a
get b_val = b
Word.eql<>(a_val, b_val)
// a >= b
U16.gte(a: U16, b: U16): Bool
get a_val = a
get b_val = b
Word.gte<>(a_val, b_val)
// a > b
U16.gtn(a: U16, b: U16): Bool
get a_val = a
get b_val = b
Word.gtn<>(a_val, b_val)
U16.inc(a: U16): U16
get a_val = a
U16.new(Word.inc<>(a_val))
// a <= b
U16.lte(a: U16, b: U16): Bool
get a_val = a
get b_val = b
Word.lte<>(a_val, b_val)
// a < b
U16.ltn(a: U16, b: U16): Bool
get a_val = a
get b_val = b
Word.ltn<>(a_val, b_val)
U16.mod(a: U16, b: U16): U16
get a_val = a
get b_val = b
U16.new(Word.mod<>(a_val, b_val))
U16.mul(a: U16, b: U16): U16
get a_val = a
get b_val = b
U16.new(Word.mul<>(a_val, b_val))
U16.or(a: U16, b: U16): U16
get a_val = a
get b_val = b
U16.new(Word.or<>(a_val, b_val))
U16.parse_hex(str: String): U16
U16.new(Word.from_bits(16, Bits.parse_hex(str)))
U16.pow(a: U16, b: U16): U16
get a_val = a
get b_val = b
U16.new(Word.pow<>(a_val, b_val))
U16.shl(n: Nat, a: U16): U16
get a_val = a
U16.new(Word.shift_left<>(n, a_val))
U16.shr(n: Nat, a: U16): U16
get a_val = a
U16.new(Word.shift_right<>(n, a_val))
U16.sub(a: U16, b: U16): U16
get a_val = a
get b_val = b
U16.new(Word.sub<>(a_val, b_val))
U16.to_bits(a: U16): Bits
get a_val = a
Word.to_bits<>(a_val)
U16.to_nat(a: U16): Nat
get a_val = a
Word.to_nat<>(a_val)
U16.xor(a: U16, b: U16): U16
get a_val = a
get b_val = b
U16.new(Word.xor<>(a_val, b_val))
U16.to_u32(a: U16): U32
case a:
| U32.new(Word.trim<16>(32, a.a));