-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
220 changed files
with
3,756 additions
and
14,263 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 |
---|---|---|
@@ -1,53 +1,94 @@ | ||
# The Calyx Interpreter | ||
# Cider: The Calyx Interpreter & Debugger | ||
|
||
The experimental Calyx interpreter resides in the `interp/` directory of the | ||
Cider resides in the `interp/` directory of the | ||
repository. | ||
The interpreter supports all Calyx programs—from high-level programs that | ||
Cider supports all Calyx programs—from high-level programs that | ||
make heavy use of control operators, to fully lowered Calyx programs. | ||
(RTL simulation, in contrast, only supports execution of fully lowered programs.) | ||
|
||
There are two ways to use the interpreter: you can directly invoke it, or you can use [fud][]. | ||
There are two ways to use the interpreter: you can directly invoke it, or you | ||
can use [fud2][]. The latter is generally recommended. | ||
|
||
## Basic Use | ||
|
||
To run an example program, try: | ||
|
||
cd interp && cargo run tests/control/if.futil | ||
|
||
You should see something like: | ||
|
||
Z{"top_level":"main","memories":[{"name":"mem","width":32,"size":1,"dimensions":{"D1":1}}]}% | ||
|
||
|
||
This output contains some header information and the raw binary data of the | ||
memories in the program and as such is not human readable. A separate tool, | ||
`cider-data-converter` is used to parse this dump into a human readable json and | ||
vice versa. Once you've compiled it, either by running `cargo build` in | ||
`tools/cider-data-converter` or by running `cargo build --all`, you can run: | ||
|
||
cargo run tests/control/if.futil | ../target/debug/cider-data-converter --to json | ||
|
||
which should produce | ||
```json | ||
{ | ||
"mem": [ | ||
4 | ||
] | ||
} | ||
``` | ||
|
||
|
||
|
||
You can see the available command-line options by typing `cargo run -- --help`. | ||
|
||
## Interpreting via fud | ||
|
||
The interpreter is available as a stage in [fud][], which lets you provide standard JSON data files as input and easily execute passes on the input Calyx program before interpretation. | ||
|
||
You'll want to build the interpreter first: | ||
The interpreter is available as a stage in [fud2][], which lets you provide | ||
standard JSON data files as input and easily execute passes on the input Calyx | ||
program before interpretation. | ||
|
||
cd interp && cargo build && cd .. | ||
You'll want to build the interpreter and compiler first: | ||
|
||
Now register the interpreter as a fud stage: | ||
cargo build && \ | ||
cd interp && cargo build && \ | ||
cd ../tools/cider-data-converter && cargo build && cd ../../ | ||
|
||
fud config stages.interpreter.exec <full path to Calyx repository>/target/debug/cider | ||
or just run | ||
|
||
Here's how to run a Calyx program: | ||
cargo build --all | ||
|
||
fud e --to interpreter-out interp/tests/control/if.futil | ||
Once you've installed and [configured](./fud2/index.md#configuration) `fud2` you | ||
can run the same program by invoking | ||
|
||
To provide input data, set the `verilog.data` variable, like so: | ||
fud2 tests/control/if.futil --to dat --through cider -s sim.data=tests/control/if.futil.data | ||
|
||
fud e --to interpreter-out \ | ||
-s verilog.data tests/correctness/while.futil.data \ | ||
tests/correctness/while.futil | ||
Data is provided in the standard Calyx json and `fud2` will automatically handle | ||
marshalling it to and from Cider's binary format, outputting the expected | ||
result. Note that `fud2` _requires_ a provided data file, so in cases where you | ||
do not initialize memory you will still need to provide the initial state of the | ||
memories. Such files can be generated via the | ||
[data gen tool](../tools/data-gen.md) or you can invoke Cider directly to bypass | ||
this constraint. | ||
|
||
By default, fud will not transform the Calyx code before feeding it to the interpreter. | ||
To run passes before the interpreter, use the `calyx.flags` variable in conjunction with the `-p` flag. | ||
For example, to fully lower the Calyx program before interpreting it: | ||
|
||
fud e --to interpreter-out \ | ||
-s calyx.flags '-p all' \ | ||
interp/tests/control/if.futil | ||
fud2 --to dat --through cider \ | ||
-s calyx.flags='-p all' \ | ||
-s sim.data=tests/control/if.futil.data \ | ||
tests/control/if.futil | ||
|
||
## Cider outputs | ||
By default, Cider's output memory dump will only contain the `@external` | ||
memories on the entrypoint component. If you want to see other memories in the | ||
main component, the flag `--all-memories` will force Cider to serialize all | ||
memories. For prototyping, it can occasionally be useful to serialize registers | ||
as well, this can be done by passing the flag `--dump-registers` which will | ||
cause Cider to serialize all registers in the main component as single entry | ||
memories. | ||
|
||
|
||
In particular, the interpreter does not currently support [`ref` cells][ref-cells]. | ||
To run the interpreter on a program that uses these, you must first compile them away by running the `compile-invoke` pass. | ||
|
||
[fud]: fud/index.md | ||
[fud2]: ./fud2/index.md | ||
[ref-cells]: ../lang/memories-by-reference.md#the-easy-way-ref-cells |
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
Oops, something went wrong.