-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Document and add a test for bit-shift operator behavior.
This documents the current requirement that the right-hand operand of << and >> have type bit<32>. I tend to consider that a bug (see #1158), so I hope that it will be relaxed in the future (and the documentation updated). Signed-off-by: Ben Pfaff <[email protected]>
- Loading branch information
Showing
3 changed files
with
47 additions
and
0 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,7 @@ | ||
relation X(x: bit<10>, y: bit<10>) | ||
output relation Y(x: bit<10>, y: bit<10>, z: bit<10>) | ||
Y(x, y, x << (y as u32)) :- X(x, y). | ||
|
||
X(x, y) :- | ||
var x = FlatMap([0, 1, 2, 3]), | ||
var y = FlatMap([0, 1, 9, 10, 11, 15, 16, 17]). |
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 @@ | ||
Y: | ||
Y{.x = 0, .y = 0, .z = 0}: +1 | ||
Y{.x = 0, .y = 1, .z = 0}: +1 | ||
Y{.x = 0, .y = 9, .z = 0}: +1 | ||
Y{.x = 0, .y = 10, .z = 0}: +1 | ||
Y{.x = 0, .y = 11, .z = 0}: +1 | ||
Y{.x = 0, .y = 15, .z = 0}: +1 | ||
Y{.x = 0, .y = 16, .z = 0}: +1 | ||
Y{.x = 0, .y = 17, .z = 0}: +1 | ||
Y{.x = 1, .y = 0, .z = 1}: +1 | ||
Y{.x = 1, .y = 1, .z = 2}: +1 | ||
Y{.x = 1, .y = 9, .z = 512}: +1 | ||
Y{.x = 1, .y = 10, .z = 0}: +1 | ||
Y{.x = 1, .y = 11, .z = 0}: +1 | ||
Y{.x = 1, .y = 15, .z = 0}: +1 | ||
Y{.x = 1, .y = 16, .z = 1}: +1 | ||
Y{.x = 1, .y = 17, .z = 2}: +1 | ||
Y{.x = 2, .y = 0, .z = 2}: +1 | ||
Y{.x = 2, .y = 1, .z = 4}: +1 | ||
Y{.x = 2, .y = 9, .z = 0}: +1 | ||
Y{.x = 2, .y = 10, .z = 0}: +1 | ||
Y{.x = 2, .y = 11, .z = 0}: +1 | ||
Y{.x = 2, .y = 15, .z = 0}: +1 | ||
Y{.x = 2, .y = 16, .z = 2}: +1 | ||
Y{.x = 2, .y = 17, .z = 4}: +1 | ||
Y{.x = 3, .y = 0, .z = 3}: +1 | ||
Y{.x = 3, .y = 1, .z = 6}: +1 | ||
Y{.x = 3, .y = 9, .z = 512}: +1 | ||
Y{.x = 3, .y = 10, .z = 0}: +1 | ||
Y{.x = 3, .y = 11, .z = 0}: +1 | ||
Y{.x = 3, .y = 15, .z = 0}: +1 | ||
Y{.x = 3, .y = 16, .z = 3}: +1 | ||
Y{.x = 3, .y = 17, .z = 6}: +1 |