-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into cider/clock-comb-prop
- Loading branch information
Showing
9 changed files
with
108 additions
and
36 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,12 +1,35 @@ | ||
# Queues Library | ||
|
||
See the [docs](https://docs.calyxir.org/frontends/queues.html) for more details. | ||
See the [docs][docs] for more details. | ||
|
||
## Installation | ||
To use our queues: | ||
1. Install [flit](https://flit.readthedocs.io/en/latest/#install) | ||
1. Install [flit][flit] | ||
2. Install the `queues` package: | ||
``` | ||
$ cd frontends/queues/ | ||
$ flit install --symlink | ||
``` | ||
|
||
## Converting Tests to Calyx | ||
|
||
To convert any of our [randomized tests][testing-harness] to a single Calyx file and their associated data and expect files: | ||
|
||
0. Follow the [installation instructions](#installation) | ||
1. Choose a test by picking a `.py` file in [`tests/`][tests-dir] | ||
2. Convert the test to Calyx: | ||
``` | ||
python3 <queue_name>_test.py 20000 --keepgoing > <queue_name>_test.futil | ||
``` | ||
3. Run the script [`gen_test_data.sh`][gen_test_data.sh] to generate data and expect files: | ||
``` | ||
./gen_test_data.sh | ||
``` | ||
|
||
The files `<queue_name>_test.py`, `<queue_name>_test.data`, and `<queue_name>_test.expect` contain the Calyx program, input data, and expected outputs for the test. | ||
|
||
[docs]: https://docs.calyxir.org/frontends/queues.html | ||
[flit]: https://flit.readthedocs.io/en/latest/#install | ||
[testing-harness]: https://docs.calyxir.org/frontends/queues.html#shared-testing-harness | ||
[tests-dir]: ./tests/ | ||
[gen_test_data.sh]: ./test_data_gen/gen_test_data.sh |
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,2 @@ | ||
[toolchain] | ||
channel = "1.82.0" |
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,32 @@ | ||
use num_bigint::BigUint; | ||
use std::str::FromStr; | ||
|
||
pub struct IntermediateRepresentation { | ||
pub sign: bool, | ||
pub mantissa: BigUint, | ||
pub exponent: i64, // Arbitrary precision exponent | ||
} | ||
|
||
impl IntermediateRepresentation { | ||
// Function to check if the value is NaN | ||
pub fn is_nan(&self, bit_width: usize) -> bool { | ||
let max_exponent_value = (1 << (bit_width - 1)) - 1; // Max exponent for NaN | ||
self.exponent == max_exponent_value as i64 && !self.mantissa.is_zero() | ||
} | ||
|
||
// Function to check if the value is infinity | ||
pub fn is_infinity(&self, bit_width: usize) -> bool { | ||
let max_exponent_value = (1 << (bit_width - 1)) - 1; // Max exponent for infinity | ||
self.exponent == max_exponent_value as i64 && self.mantissa.is_zero() | ||
} | ||
|
||
// Function to check if the value is denormalized | ||
pub fn is_denormalized(&self) -> bool { | ||
self.exponent == 0 && !self.mantissa.is_zero() | ||
} | ||
|
||
// Function to check if the value is zero | ||
pub fn is_zero(&self) -> bool { | ||
self.exponent == 0 && self.mantissa.is_zero() | ||
} | ||
} |