-
Notifications
You must be signed in to change notification settings - Fork 119
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
Showing
5 changed files
with
68 additions
and
30 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
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,25 @@ | ||
namespace Sail | ||
namespace BitVec | ||
|
||
def length {w: Nat} (_: BitVec w): Nat := w | ||
|
||
def signExtend {w: Nat} (x: BitVec w) (w': Nat) : BitVec w' := | ||
x.signExtend w' | ||
|
||
def zeroExtend {w: Nat} (x: BitVec w) (w': Nat) : BitVec w' := | ||
x.zeroExtend w' | ||
|
||
def truncate {w: Nat} (x: BitVec w) (w': Nat) : BitVec w' := | ||
x.truncate w' | ||
|
||
def truncateLSB {w: Nat} (x: BitVec w) (w': Nat) : BitVec w' := | ||
x.extractLsb' 0 w' | ||
|
||
def extractLsb {w: Nat} (x: BitVec w) (hi lo: Nat) : BitVec (hi - lo + 1) := | ||
x.extractLsb hi lo | ||
|
||
def update_subrange {w: Nat} (x: BitVec w) (hi lo: Nat) (y: BitVec (hi - lo + 1)) : BitVec w := | ||
sorry | ||
|
||
end BitVec | ||
end Sail |
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 @@ | ||
|
||
inductive register where | ||
| Register : String → /- name -/ | ||
Nat → /- length -/ | ||
Nat → /- start index -/ | ||
Bool → /- is increasing -/ | ||
List register_field_index | ||
→ register | ||
| UndefinedRegister : Nat → register /- length -/ | ||
| RegisterPair : register → register → register | ||
|
||
structure register_ref (regstate regval a: Type) where | ||
name: String | ||
read_from: regstate -> a | ||
write_to: a -> regstate -> regstate | ||
of_regval: regval -> Option a | ||
regval_of: a -> regval | ||
|
||
def read_reg {s rv a e} (reg : register_ref s rv a) : Monad e := | ||
let k v := | ||
match reg.of_regval v with | ||
| some v => some v | ||
| none => none | ||
Read_reg reg.(name) k. | ||
|
||
def reg_deref {s rv a e} := @read_reg s rv a e. | ||
|
||
def write_reg {s rv a e} (reg : register_ref s rv a) (v : a) : monad rv unit e := | ||
Write_reg reg.(name) (reg.(regval_of) v) (Done tt). |
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 |
---|---|---|
@@ -1,25 +1,2 @@ | ||
namespace Sail | ||
namespace BitVec | ||
|
||
def length {w: Nat} (_: BitVec w): Nat := w | ||
|
||
def signExtend {w: Nat} (x: BitVec w) (w': Nat) : BitVec w' := | ||
x.signExtend w' | ||
|
||
def zeroExtend {w: Nat} (x: BitVec w) (w': Nat) : BitVec w' := | ||
x.zeroExtend w' | ||
|
||
def truncate {w: Nat} (x: BitVec w) (w': Nat) : BitVec w' := | ||
x.truncate w' | ||
|
||
def truncateLSB {w: Nat} (x: BitVec w) (w': Nat) : BitVec w' := | ||
x.extractLsb' 0 w' | ||
|
||
def extractLsb {w: Nat} (x: BitVec w) (hi lo: Nat) : BitVec (hi - lo + 1) := | ||
x.extractLsb hi lo | ||
|
||
def update_subrange {w: Nat} (x: BitVec w) (hi lo: Nat) (y: BitVec (hi - lo + 1)) : BitVec w := | ||
sorry | ||
|
||
end BitVec | ||
end Sail | ||
import Sail.bitvec | ||
import Sail.registers |