Skip to content

Commit

Permalink
initial risc-v core in Calyx
Browse files Browse the repository at this point in the history
  • Loading branch information
sgpthomas committed May 23, 2024
0 parents commit 6214528
Show file tree
Hide file tree
Showing 9 changed files with 1,714 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
target/
*.vcd
*.ron
46 changes: 46 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
* Experimenting with writing a simple processor in Calyx

* Some useful commands

Encode =simple.s= into Calyx data format.

#+begin_src async-shell :name encode :results none :dir ~/Research/calyx-processor/riscv-to-calyx
cargo run -- encode data/simple.s \
--data ram:16:32:1 \
--data reg_file:32:32 \
--data dbg:1:32 \
-o ../data/simple.json
#+end_src

Decode a calyx data file and read assembly instructions.

#+begin_src async-shell :name decode :results none :dir ~/Research/calyx-processor/riscv-to-calyx
cargo run -- decode ../data/simple.json
#+end_src

Simulate the design with icarus verilog (was having some issues with Verilator)

#+begin_src async-shell :name calyx-processor :results none
cargo run --manifest-path=riscv-to-calyx/Cargo.toml -- \
encode riscv-to-calyx/data/simple.s \
--data ram:16:32:1 \
--data reg_file:32:32 \
--data dbg:1:32 \
-o data/simple.json

fud e -q src/main.futil \
-s verilog.data data/simple.json \
--to dat --through icarus-verilog \
-s verilog.cycle_limit 100000 | cargo run --manifest-path=riscv-to-calyx/Cargo.toml -- decode
#+end_src

Debug the design with a lovely vcd file

#+begin_src async-shell :name gen-vcd :results none
fud e src/main.futil \
-s verilog.data data/simple.json \
--to vcd --through icarus-verilog \
-s calyx.flags " -p no-opt" \
-s verilog.cycle_limit 1000 \
-o dbg.vcd
#+end_src
100 changes: 100 additions & 0 deletions data/simple.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
{
"reg_file": {
"data": [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
"format": {
"numeric_type": "bitnum",
"is_signed": false,
"width": 32
}
},
"insts": {
"data": [
1299,
10487187,
659,
787,
11755107,
2298771,
7668659,
238467,
7504563,
1245971,
4271894639,
165139,
32871
],
"format": {
"numeric_type": "bitnum",
"is_signed": false,
"width": 32
}
},
"ram": {
"data": [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
],
"format": {
"numeric_type": "bitnum",
"is_signed": false,
"width": 32
}
},
"dbg": {
"data": [
0
],
"format": {
"numeric_type": "bitnum",
"is_signed": false,
"width": 32
}
}
}
Loading

0 comments on commit 6214528

Please sign in to comment.