-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a wrapper to the lean backend to be able to handle more functi…
…ons (#801) This adds a wrapper to the lean backend, which allows handling additional bitvector operations. The implemented operations are: length, signExtend, zeroExtend, truncate and truncateLSB. The wrapper functions are in the namespace Sail.BitVec to avoid collisions. The remaining unimplemented operations require translating type conditions into Lean, which is not handled for now.
- Loading branch information
Showing
13 changed files
with
118 additions
and
11 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,19 @@ | ||
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' | ||
|
||
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
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import Sail.sail | ||
|
||
inductive E where | A | B | C | ||
deriving Inhabited | ||
|
||
|
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,3 +1,5 @@ | ||
import Sail.sail | ||
|
||
def extern_add : Int := | ||
(Int.add 5 4) | ||
|
||
|
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,3 +1,5 @@ | ||
import Sail.sail | ||
|
||
def extern_const : BitVec 64 := | ||
(0xFFFF000012340000 : BitVec 64) | ||
|
||
|
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import Sail.sail | ||
|
||
def foo (y : Unit) : Unit := | ||
y | ||
|
||
|
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,3 +1,5 @@ | ||
import Sail.sail | ||
|
||
def tuple1 : (Int × Int × (BitVec 2 × Unit)) := | ||
(3, 5, ((0b10 : BitVec 2), ())) | ||
|
||
|