llvm / llvm/circt

[Calyx Emitter] Avoid emitting redundant `write_en = 0` to satisfy `write_together` for reads

Open
#10,074 5 comments 1 reaction 0 assignees View on GitHub
Dominant language
C++
Stars
2.2k
Forks
524
Avg merge
3d 2h
Merged PRs (30d)
46

Description

Calyx specifies that, for a `seq_memory_d1` if the port `write_en` is driven then `write_data` must also be driven through the `write_together` spec.

However, when the port `content_en` is `1` and port `write_en` is `0`, it implies a read, so `write_data` need not be driven.

Since `write_together` is a safety mechanism can we just tell the emitter to not drive `write_en` when it is `0` and `content_en` is `1`.

For example:

Instead of emitting this (which `papercut` pass complains about):
```futil
group bb0_1 {
std_slice_10.in = for_2_induction_var_reg.out;
arg_mem_0.addr0 = std_slice_10.out;
arg_mem_0.content_en = 1'b1;
arg_mem_0.write_en = 1'd0; <- unnecessary
bb0_1[done] = arg_mem_0.done;
}
```
we emit:
```futil
group bb0_1 {
std_slice_10.in = for_2_induction_var_reg.out;
arg_mem_0.addr0 = std_slice_10.out;
arg_mem_0.content_en = 1'b1;
bb0_1[done] = arg_mem_0.done;
}
```
Since, by default the value will be set to `0`, these two will be equivalent and will satisfy the `write_together` spec as well.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the Calyx Emitter entry point and inspect handling of seq_memory_d1 ports under write_together; reproduce the papercut complaint with the shown read pattern. Confirm completion by emitting the read group without redundant write_en while retaining required write behavior, then run the relevant Calyx emitter and papercut checks.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.