Skip to content

Commit

Permalink
Only reading/writing to ref memories don't need to be turned into an …
Browse files Browse the repository at this point in the history
…interface memory (#2200)
  • Loading branch information
jiahanxie353 authored Jul 31, 2024
1 parent efffa92 commit f53de4f
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 1 deletion.
2 changes: 1 addition & 1 deletion calyx-opt/src/passes/synthesis_papercut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl Visitor for SynthesisPapercut {
if self.memories.contains(parent) {
let has_external =
cell.get_attribute(ir::BoolAttr::External);
if has_external.is_none() {
if has_external.is_none() && !cell.is_reference() {
return Some(cell.name());
}
}
Expand Down
31 changes: 31 additions & 0 deletions tests/passes/papercut-ref-read-only.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import "primitives/memories/comb.futil";
component main(@go go: 1, @clk clk: 1, @reset reset: 1) -> (@done done: 1) {
cells {
@external mem_0 = comb_mem_d1(32, 4, 2);
read_only_instance = read_only();
}
wires {}
control {
seq {
invoke read_only_instance[ref_mem_0 = mem_0]()();
}
}
}
component read_only(@go go: 1, @clk clk: 1, @reset reset: 1) -> (@done done: 1) {
cells {
ref ref_mem_0 = comb_mem_d1(32, 4, 2);
}
wires {
group read_data {
ref_mem_0.write_en = 1'd1;
ref_mem_0.write_data = 32'd3;
ref_mem_0.addr0 = 2'd0;
read_data[done] = ref_mem_0.done;
}
}
control {
seq {
read_data;
}
}
}
36 changes: 36 additions & 0 deletions tests/passes/papercut-ref-read-only.futil
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// -p papercut

import "primitives/memories/comb.futil";

component main(@go go: 1, @clk clk: 1, @reset reset: 1) -> (@done done: 1) {
cells {
@external mem_0 = comb_mem_d1(32, 4, 2);
read_only_instance = read_only();
}
wires {
}
control {
seq {
invoke read_only_instance[ref_mem_0 = mem_0]()();
}
}
}

component read_only(@go go: 1, @clk clk: 1, @reset reset: 1) -> (@done done: 1) {
cells {
ref ref_mem_0 = comb_mem_d1(32, 4, 2);
}
wires {
group read_data {
ref_mem_0.write_en = 1'b1;
ref_mem_0.write_data = 32'd3;
ref_mem_0.addr0 = 2'b0;
read_data[done] = ref_mem_0.done;
}
}
control {
seq {
read_data;
}
}
}

0 comments on commit f53de4f

Please sign in to comment.