-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Semantics for operation evaluation (#406)
* init * Unchecked_OP, Add, Sub, Mul done. * Signed overflow algorithm * Shift instructions * equality / comparisons * Set Version: 0.3.36 * Tidying * Update kmir/src/kmir/kdist/mir-semantics/utils.k Co-authored-by: Jost Berthold <[email protected]> * Set Version: 0.3.37 * removed unused MINT import * Set Version: 0.3.37 * fixed typo --------- Co-authored-by: devops <[email protected]> Co-authored-by: Jost Berthold <[email protected]>
- Loading branch information
1 parent
256abec
commit 99d812f
Showing
5 changed files
with
115 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" | |
|
||
[tool.poetry] | ||
name = "kmir" | ||
version = "0.3.36" | ||
version = "0.3.37" | ||
description = "" | ||
authors = [ | ||
"Runtime Verification, Inc. <[email protected]>", | ||
|
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,3 @@ | ||
from typing import Final | ||
|
||
VERSION: Final = '0.3.36' | ||
VERSION: Final = '0.3.37' |
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,56 @@ | ||
module UTILS-SYNTAX | ||
imports INT-SYNTAX | ||
imports BOOL-SYNTAX | ||
|
||
syntax Int ::= "#width_max" "(" Int "," Bool ")" [function] // params: width, signed. Calculates maximum number for the width. | ||
syntax Int ::= "#width_min" "(" Int "," Bool ")" [function] // params: width, signed. Calculates minimum number for the width. | ||
syntax Int ::= "#chop" "(" Int "," Int "," Bool ")" [function] // params: number, width, signed. Wraps a number into it's bound. | ||
endmodule | ||
|
||
module UTILS | ||
imports UTILS-SYNTAX | ||
imports INT | ||
imports BOOL | ||
|
||
// Unsigned | ||
rule #width_max(8, false) => 255 // 2^8 - 1 | ||
rule #width_max(16, false) => 65535 // 2^16 - 1 | ||
rule #width_max(32, false) => 4294967295 // 2^32 - 1 | ||
rule #width_max(64, false) => 18446744073709551615 // 2^64 - 1 | ||
rule #width_max(128, false) => 340282366920938463463374607431768211455 // 2^128 - 1 | ||
|
||
// Signed with two's complement | ||
rule #width_max(8, true) => 127 // 2^(8-1) - 1 | ||
rule #width_max(16, true) => 32767 // 2^(16-1) - 1 | ||
rule #width_max(32, true) => 2147483647 // 2^(32-1) - 1 | ||
rule #width_max(64, true) => 9223372036854775807 // 2^(64-1) - 1 | ||
rule #width_max(128, true) => 170141183460469231731687303715884105727 // 2^(128-1) - 1 | ||
|
||
// Unsigned (Can be collapsed when width is enum) | ||
rule #width_min(8, false) => 0 | ||
rule #width_min(16, false) => 0 | ||
rule #width_min(32, false) => 0 | ||
rule #width_min(64, false) => 0 | ||
rule #width_min(128, false) => 0 | ||
|
||
// Signed with two's complement | ||
rule #width_min(8, true) => -128 // -2^(8-1) | ||
rule #width_min(16, true) => -32768 // -2^(16-1) | ||
rule #width_min(32, true) => -2147483648 // -2^(32-1) | ||
rule #width_min(64, true) => -9223372036854775808 // -2^(64-1) | ||
rule #width_min(128, true) => -170141183460469231731687303715884105728 // -2^(128-1) | ||
|
||
// Unsigned | ||
rule #chop(NUM, WIDTH, false) => NUM %Int (#width_max(WIDTH, false) +Int 1) requires 0 <=Int NUM | ||
|
||
// Signed | ||
rule #chop(NUM, WIDTH, true) => // chopped number stays positive if in range | ||
NUM &Int #width_max(WIDTH, false) | ||
requires | ||
NUM &Int #width_max(WIDTH, false) <Int #width_max(WIDTH, true) | ||
|
||
rule #chop(NUM, WIDTH, true) => // chopped number wraps around if too large for signed WIDTH | ||
(NUM &Int #width_max(WIDTH, false)) -Int (#width_max(WIDTH, false) +Int 1) | ||
requires | ||
NUM &Int #width_max(WIDTH, false) >=Int #width_max(WIDTH, true) | ||
endmodule |
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 +1 @@ | ||
0.3.36 | ||
0.3.37 |