Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Futil changes #1

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Futil changes #1

wants to merge 3 commits into from

Conversation

KarlJoad
Copy link

These are all the changes I made while debugging why this core would not complete a Verilator simulation. I used the provided memory files and program.

I needed to fix some Verilator lint failures, which is the slicing commit.

I needed to fix some simulation-time checks that the SystemVerilog has ifdef-ed to only run under Verilator.

At the end, I end up with a simulation problem because r_type.in has multiple drivers in a single clock cycle.

Below is a minimum transcript of what I did/was doing to reach this point.

$ pwd
~/calyx

$ ./target/debug/fud2 ./calyx-riscv/src/main.futil \
                      --from calyx \
                      -o test.exe \
                      -s sim.data=./calyx-riscv/data/simple.json \
                      --keep

$ python3 ./.fud2-working/json-dat.py \
          --from-json ./calyx-riscv/data/simple.json \
          --out_dir=sim_data/

$ ./test.exe +DATA=./sim_data +CYCLE_LIMIT=500

I am not sure why I needed this, because I am not sure if Calyx's
standard library of primitives has changed since this was written.

Some values were changed that get passed to the SystemVerilog
primitives as PARAMETERs, so that Verilator allows the design to pass
linting.
When simulating, there is a simulation-time check that Verilator
performs that fails in "comb group is_r_type" because "r_type.in" has
multiple drivers in the same cycle, despite the guard expression being
disjoint (mutually exclusive?).

The following commands produces the simulator and necessary memory
collateral.

$ pwd
~/calyx

$ ./target/debug/fud2 ./calyx-riscv/src/main.futil \
                      --from calyx \
                      -o test.exe \
                      -s sim.data=./calyx-riscv/data/simple.json \
                      --keep

$ python3 ./.fud2-working/json-dat.py \
          --from-json ./calyx-riscv/data/simple.json \
          --out_dir=sim_data/

$ ./test.exe +DATA=./sim_data +CYCLE_LIMIT=500
@sgpthomas
Copy link
Collaborator

sgpthomas commented Aug 26, 2024

I haven't looked closely at the changes yet. However, the changes seem to produce the wrong results on simple.s. Were you getting these values in the registers when you ran it? I was getting all zeros with your branch.

== registers ==
x0  zero: 0
x1    ra: xxxxxxxx
x2    sp: xxxxxxxx
x3    gp: xxxxxxxx
x4    tp: xxxxxxxx
x5    t0: 10
x6    t1: 10
x7    t2: 1
x8    fp: xxxxxxxx
x9    s1: xxxxxxxx
x10    a0: 10
x11    a1: 10
x12    a2: xxxxxxxx
x13    a3: xxxxxxxx
x14    a4: xxxxxxxx
x15    a5: xxxxxxxx
x16    a6: 0
x17    a7: 0
x18    s2: 0
x19    s3: 0
x20    s4: 0
x21    s5: 0
x22    s6: 0
x23    s7: 0
x24    s8: 0
x25    s9: 0
x26   s10: 0
x27   s11: 0
x28    t3: 0
x29    t4: 0
x30    t5: 0
x31    t6: 0

@KarlJoad
Copy link
Author

With my branch, yes. I get that exact output.

$ fud2 riscv-to-calyx/data/simple.s --to riscv-decode --keep
ERROR:root:Memory contains the value: `0xxxxxxxxx', which is uninitialized. This happens when the Calyx design attempts to read a port that is not connected to anything. Try to generate a VCD file using `--to vcd` and look for signals that are not driven in a given cycle.
ERROR:root:Memory contains the value: `0xxxxxxxxx', which is uninitialized. This happens when the Calyx design attempts to read a port that is not connected to anything. Try to generate a VCD file using `--to vcd` and look for signals that are not driven in a given cycle.
ERROR:root:Memory contains the value: `0xxxxxxxxx', which is uninitialized. This happens when the Calyx design attempts to read a port that is not connected to anything. Try to generate a VCD file using `--to vcd` and look for signals that are not driven in a given cycle.
ERROR:root:Memory contains the value: `0xxxxxxxxx', which is uninitialized. This happens when the Calyx design attempts to read a port that is not connected to anything. Try to generate a VCD file using `--to vcd` and look for signals that are not driven in a given cycle.
ERROR:root:Memory contains the value: `0xxxxxxxxx', which is uninitialized. This happens when the Calyx design attempts to read a port that is not connected to anything. Try to generate a VCD file using `--to vcd` and look for signals that are not driven in a given cycle.
ERROR:root:Memory contains the value: `0xxxxxxxxx', which is uninitialized. This happens when the Calyx design attempts to read a port that is not connected to anything. Try to generate a VCD file using `--to vcd` and look for signals that are not driven in a given cycle.
ERROR:root:Memory contains the value: `0xxxxxxxxx', which is uninitialized. This happens when the Calyx design attempts to read a port that is not connected to anything. Try to generate a VCD file using `--to vcd` and look for signals that are not driven in a given cycle.
ERROR:root:Memory contains the value: `0xxxxxxxxx', which is uninitialized. This happens when the Calyx design attempts to read a port that is not connected to anything. Try to generate a VCD file using `--to vcd` and look for signals that are not driven in a given cycle.
ERROR:root:Memory contains the value: `0xxxxxxxxx', which is uninitialized. This happens when the Calyx design attempts to read a port that is not connected to anything. Try to generate a VCD file using `--to vcd` and look for signals that are not driven in a given cycle.
ERROR:root:Memory contains the value: `0xxxxxxxxx', which is uninitialized. This happens when the Calyx design attempts to read a port that is not connected to anything. Try to generate a VCD file using `--to vcd` and look for signals that are not driven in a given cycle.
ERROR:root:Memory contains the value: `0xxxxxxxxx', which is uninitialized. This happens when the Calyx design attempts to read a port that is not connected to anything. Try to generate a VCD file using `--to vcd` and look for signals that are not driven in a given cycle.
Took 263 cycles

== instructions ==
  0: addi x10, x0, 0
  1: addi x11, x0, 10
  2: addi x5, x0, 0
  3: addi x6, x0, 0
  4: bge x6, x11, 1c
  5: slli x7, x6, 2
  6: add x7, x10, x7
  7: lw xxx
  8: add x5, x5, x7
  9: addi x6, x6, 1
 10: J { opcode: 111, rd: 0, imm: 1042943 }
 11: addi x10, x5, 0
 12: I { opcode: 103, rd: 0, funct3: 0, rs1: 1, imm: 0 }

== registers ==
x0  zero: 0
x1    ra: xxxxxxxx
x2    sp: xxxxxxxx
x3    gp: xxxxxxxx
x4    tp: xxxxxxxx
x5    t0: 0
x6    t1: xxxxxxxx
x7    t2: 0
x8    fp: xxxxxxxx
x9    s1: xxxxxxxx
x10    a0: 0
x11    a1: 0
x12    a2: xxxxxxxx
x13    a3: xxxxxxxx
x14    a4: xxxxxxxx
x15    a5: xxxxxxxx
x16    a6: 0
x17    a7: 0
x18    s2: 0
x19    s3: 0
x20    s4: 0
x21    s5: 0
x22    s6: 0
x23    s7: 0
x24    s8: 0
x25    s9: 0
x26   s10: 0
x27   s11: 0
x28    t3: 0
x29    t4: 0
x30    t5: 0
x31    t6: 0

But this simulation is going through Icarus, while all my simulation-time errors were coming from Verilator.

@sgpthomas
Copy link
Collaborator

The zeros for t0, t1, t2 and a0, a1 are incorrect. They should be all 10, with exception for t2 which should be 1. Can you figure out why your implementation is not producing the correct answer?

@KarlJoad
Copy link
Author

The incorrectness comes from the last commit (cbe67d8), because I change r_type.in in the decoder. But that is one spot where Verilator was giving me a multiple-driver issue when I tried to manually simulate with Verilator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants