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 12, 2024
1 parent
48e0ca1
commit 814a274
Showing
4 changed files
with
81 additions
and
3 deletions.
There are no files selected for viewing
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,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,33 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>nested_mapping</title></head> | ||
<body> | ||
<h1>nested_mapping.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) | ||
} |