-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lean: add support for register definitions (#894)
* New monad definition * Registers in the state monad Co-authored-by: Jakob von Raumer <[email protected]>
- Loading branch information
Showing
6 changed files
with
255 additions
and
39 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
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 |
---|---|---|
|
@@ -9,3 +9,5 @@ bitfield cr_type : bits(8) = { | |
CR1 : 3 .. 2, | ||
CR3 : 1 .. 0 | ||
} | ||
|
||
register R : cr_type |
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,36 @@ | ||
import Out.Sail.Sail | ||
|
||
open Sail | ||
|
||
inductive Register : Type where | ||
| BIT | ||
| NAT | ||
| BOOL | ||
| INT | ||
| R1 | ||
| R0 | ||
deriving DecidableEq, Hashable | ||
open Register | ||
|
||
abbrev RegisterType : Register → Type | ||
| .BIT => (BitVec 1) | ||
| .NAT => Nat | ||
| .BOOL => Bool | ||
| .INT => Int | ||
| .R1 => (BitVec 64) | ||
| .R0 => (BitVec 64) | ||
|
||
abbrev SailM := PreSailM RegisterType | ||
|
||
def test : SailM Int := do | ||
writeReg INT (HAdd.hAdd (← readReg INT) 1) | ||
readReg INT | ||
|
||
def initialize_registers : SailM Unit := do | ||
writeReg R0 sorry | ||
writeReg R1 sorry | ||
writeReg INT sorry | ||
writeReg BOOL sorry | ||
writeReg NAT sorry | ||
writeReg BIT sorry | ||
|
Oops, something went wrong.