forked from rems-project/sail
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
trdthg
committed
Aug 5, 2024
1 parent
3ade8d8
commit 45851a0
Showing
14 changed files
with
4,992 additions
and
5 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>nested_mapping</title></head> | ||
<body> | ||
<h1>nested_mapping.sail (2/6) 33%</h1> | ||
<code style="display: block"> | ||
default Order dec<br> | ||
$include <prelude.sail><br> | ||
<br> | ||
union ast = {<br> | ||
B : (bool),<br> | ||
Z : unit<br> | ||
}<br> | ||
<br> | ||
mapping bool_not_bits2 : bool <-> bits(2) = {<br> | ||
<span style="background-color: hsl(0, 85%, 80%)">true</span> <-> 0b10,<br> | ||
<span style="background-color: hsl(0, 85%, 80%)">false</span> <-> 0b11<br> | ||
}<br> | ||
mapping encdec : bits(2) <-> ast = {<br> | ||
<span style="background-color: hsl(120, 85%, 80%)">0b00</span> <-> Z(),<br> | ||
<span style="background-color: hsl(0, 85%, 80%)">0b01</span> <-> Z(),<br> | ||
<span style="background-color: hsl(0, 85%, 80%)">bool_not_bits2(s)</span> <-> B(s),<br> | ||
}<br> | ||
<br> | ||
val main : unit -> unit<br> | ||
function main() = <span style="background-color: hsl(120, 85%, 80%)">{<br> | ||
let encdec_value = encdec(0b00)<br> | ||
}</span><br> | ||
</code> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>nested_mapping1</title></head> | ||
<body> | ||
<h1>nested_mapping1.sail (4/5) 80%</h1> | ||
<code style="display: block"> | ||
default Order dec<br> | ||
$include <prelude.sail><br> | ||
<br> | ||
union ast = {<br> | ||
B : (bool),<br> | ||
Z : unit<br> | ||
}<br> | ||
<br> | ||
mapping bool_not_bits2 : bool <-> bits(2) = {<br> | ||
true <-> 0b10,<br> | ||
false <-> 0b11<br> | ||
}<br> | ||
mapping encdec : bits(2) <-> ast = {<br> | ||
<span style="background-color: hsl(120, 85%, 80%)">0b01</span> if <span style="background-color: hsl(120, 85%, 80%)">true</span> <-> <span style="background-color: hsl(0, 85%, 80%)">Z()</span>,<br> | ||
0b00 <-> <span style="background-color: hsl(120, 85%, 80%)">Z()</span>,<br> | ||
}<br> | ||
<br> | ||
val main : unit -> unit<br> | ||
function main() = <span style="background-color: hsl(120, 85%, 80%)">{<br> | ||
let encdec_value = encdec(0b00)<br> | ||
}</span><br> | ||
</code> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
default Order dec | ||
$include <prelude.sail> | ||
|
||
union ast = { | ||
B : (bool), | ||
Z : unit | ||
} | ||
|
||
mapping bool_not_bits : bool <-> bits(1) = { | ||
true <-> 0b0, | ||
false <-> 0b1, | ||
} | ||
|
||
let false_val = false | ||
let false_2 = false == true | ||
|
||
mapping encdec : bits(2) <-> ast = { | ||
0b1 @ bool_not_bits(s) <-> B(s), | ||
0b01 if true <-> Z(), | ||
0b00 if false_val <-> Z(), | ||
0b00 if false_val == true <-> Z(), | ||
0b00 <-> Z(), | ||
} | ||
|
||
val main : unit -> unit | ||
function main() = { | ||
let encdec_value = encdec(0b00) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>nested_mapping2</title></head> | ||
<body> | ||
<h1>nested_mapping2.sail (2/5) 40%</h1> | ||
<code style="display: block"> | ||
default Order dec<br> | ||
$include <prelude.sail><br> | ||
<br> | ||
union ast = {<br> | ||
B : (bool),<br> | ||
Z : unit,<br> | ||
}<br> | ||
<br> | ||
mapping bool_not_bits : bool <-> bits(1) = {<br> | ||
<span style="background-color: hsl(0, 85%, 80%)">true</span> <-> 0b0,<br> | ||
<span style="background-color: hsl(0, 85%, 80%)">false</span> <-> 0b1,<br> | ||
}<br> | ||
<br> | ||
mapping encdec : bits(2) <-> ast = {<br> | ||
<span style="background-color: hsl(120, 85%, 80%)">0b00</span> <-> Z(),<br> | ||
<span style="background-color: hsl(0, 85%, 80%)">0b1 @ bool_not_bits(s)</span> <-> B(s),<br> | ||
}<br> | ||
<br> | ||
val main : unit -> unit<br> | ||
function main() = <span style="background-color: hsl(120, 85%, 80%)">{<br> | ||
let _ = encdec(0b00)<br> | ||
}</span><br> | ||
</code> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
default Order dec | ||
$include <prelude.sail> | ||
|
||
union ast = { | ||
B : (bool), | ||
Z : unit, | ||
} | ||
|
||
mapping bool_not_bits : bool <-> bits(1) = { | ||
true <-> 0b0, | ||
false <-> 0b1, | ||
} | ||
|
||
mapping encdec : bits(2) <-> ast = { | ||
0b00 <-> Z(), | ||
0b1 @ bool_not_bits(s) <-> B(s), | ||
} | ||
|
||
val main : unit -> unit | ||
function main() = { | ||
let _ = encdec(0b00) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>nested_mapping3</title></head> | ||
<body> | ||
<h1>nested_mapping3.sail (3/5) 60%</h1> | ||
<code style="display: block"> | ||
default Order dec<br> | ||
$include <prelude.sail><br> | ||
<br> | ||
union ast = {<br> | ||
B : (bool),<br> | ||
Z : unit,<br> | ||
}<br> | ||
<br> | ||
mapping bool_not_bits : bool <-> bits(1) = {<br> | ||
<span style="background-color: hsl(0, 85%, 80%)">true</span> <-> 0b0,<br> | ||
<span style="background-color: hsl(0, 85%, 80%)">false</span> <-> 0b1,<br> | ||
}<br> | ||
<br> | ||
mapping encdec : bits(2) <-> ast = {<br> | ||
<span style="background-color: hsl(120, 85%, 80%)">0b1 @ bool_not_bits(s)</span> <-> B(s),<br> | ||
<span style="background-color: hsl(120, 85%, 80%)">0b00</span> <-> Z(),<br> | ||
}<br> | ||
<br> | ||
val main : unit -> unit<br> | ||
function main() = <span style="background-color: hsl(120, 85%, 80%)">{<br> | ||
let _ = encdec(0b00)<br> | ||
}</span><br> | ||
</code> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
default Order dec | ||
$include <prelude.sail> | ||
|
||
union ast = { | ||
B : (bool), | ||
Z : unit, | ||
} | ||
|
||
mapping bool_not_bits : bool <-> bits(1) = { | ||
true <-> 0b0, | ||
false <-> 0b1, | ||
} | ||
|
||
mapping encdec : bits(2) <-> ast = { | ||
0b1 @ bool_not_bits(s) <-> B(s), | ||
0b00 <-> Z(), | ||
} | ||
|
||
val main : unit -> unit | ||
function main() = { | ||
let _ = encdec(0b00) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
default Order dec | ||
$include <prelude.sail> | ||
|
||
union ast = { | ||
B : (bool), | ||
Z : unit | ||
} | ||
|
||
mapping bool_not_bits : bool <-> bits(1) = { | ||
true <-> 0b0, | ||
false <-> 0b1 | ||
} | ||
|
||
mapping encdec : bits(2) <-> ast = { | ||
0b1 @ bool_not_bits(s) if true <-> B(s), | ||
0b00 <-> Z() | ||
} | ||
|
||
val main : unit -> unit | ||
function main() = { | ||
let _ = encdec(0b00) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
default Order dec | ||
$include <prelude.sail> | ||
|
||
union ast = { | ||
B : (bool), | ||
Z : unit, | ||
} | ||
|
||
mapping bool_not_bits : bool <-> bits(1) = { | ||
true <-> 0b0, | ||
false <-> 0b1, | ||
} | ||
|
||
let false_val = false | ||
let false_2 = false == true | ||
|
||
mapping encdec : bits(2) <-> ast = { | ||
0b1 @ bool_not_bits(s) <-> B(s), | ||
0b01 if true <-> Z(), | ||
0b00 if false_val <-> Z(), | ||
0b00 if false_val == true <-> Z(), | ||
0b0 @ bool_not_bits(s) if true <-> B(s), | ||
0b00 <-> Z(), | ||
} | ||
|
||
val main : unit -> unit | ||
function main() = { | ||
let _ = encdec(0b00) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
$[complete] | ||
function encdec_forwards arg# = let head_exp# = arg# in | ||
$[complete] $[mapping_match] match $[complete] match head_exp# { | ||
v__0 if and_bool( | ||
let mapping0# : bitvector(1) = | ||
$[overloaded { "name" = "vector_subrange", "is_infix" = false }] subrange_bits(v__0, 0, 0) | ||
in | ||
bool_not_bits_backwards_matches(mapping0#), | ||
$[overloaded { "name" = "==", "is_infix" = true }] | ||
eq_bits( | ||
$[overloaded { "name" = "vector_subrange", "is_infix" = false }] | ||
subrange_bits(v__0, 1, 1), [bitone]) | ||
) => | ||
let mapping0# : bitvector(1) = | ||
$[overloaded { "name" = "vector_subrange", "is_infix" = false }] subrange_bits(v__0, 0, 0) | ||
in | ||
$[complete] match bool_not_bits_backwards(mapping0#) { | ||
s => Some(B(s)), | ||
_ => None() | ||
}, | ||
_ => None() | ||
} { | ||
Some(result) => result, | ||
None(_) => $[incomplete] match head_exp# { | ||
b__0 if $[overloaded { "name" = "==", "is_infix" = true }] eq_bits(b__0, [bitzero, bitzero]) => Z() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
default Order dec | ||
$include <prelude.sail> | ||
|
||
union ast = { | ||
B : (bool), | ||
Z : unit, | ||
} | ||
|
||
mapping bool_not_bits : bool <-> bits(1) = { | ||
true <-> 0b0, | ||
false <-> 0b1, | ||
} | ||
|
||
mapping encdec : bits(2) <-> ast = { | ||
0b1 @ bool_not_bits(s) <-> B(s), | ||
0b00 <-> Z(), | ||
} | ||
|
||
val main : unit -> unit | ||
function main() = { | ||
let _ = encdec(0b00) | ||
} |