Skip to content
New issue

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

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

Already on GitHub? # to your account

Single Port Memories #1610

Merged
merged 195 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
195 commits
Select commit Hold shift + click to select a range
3fa217e
True single port memories
andrewb1999 Jul 16, 2023
61a4556
Cleanup futil declarations
andrewb1999 Jul 16, 2023
a00d947
Merge branch 'master' into single-port-mem
andrewb1999 Jul 16, 2023
7be913b
update the interpreter versions of seq_mem
EclecticGriffin Jul 17, 2023
72645ee
Merge branch 'master' into single-port-mem
andrewb1999 Jul 19, 2023
9bfa876
fix confusing comma errors
rachitnigam Jul 19, 2023
c348915
Merge branch 'master' into single-port-mem
rachitnigam Jul 19, 2023
52340b8
Merge branch 'master' into single-port-mem
rachitnigam Jul 24, 2023
d825fd3
remove fuzz (#1627)
rachitnigam Jul 25, 2023
4869749
Builder: tidy correctness examples (#1630)
anshumanmohan Jul 25, 2023
e6ac677
Docs: fix two links (#1639)
anshumanmohan Jul 25, 2023
4339375
Dont require `@clk` and `@reset` ports in comb components (#1641)
rachitnigam Jul 26, 2023
9b60205
Systolic Array takes dynamic contraction dimension (#1642)
calebmkim Jul 28, 2023
938f782
Reduce Register Usage for Separate Static Islands (#1632)
calebmkim Jul 31, 2023
898e227
locked build for playground
rachitnigam Jul 31, 2023
643f468
locked build for playground
rachitnigam Jul 31, 2023
748474c
locked build for playground
rachitnigam Jul 31, 2023
4e8751d
FIFO: catch up to new interface, and expose command `peek` (#1643)
anshumanmohan Aug 8, 2023
5918769
Leaky Relu Post Op to Systolic Array (#1644)
calebmkim Aug 9, 2023
3ea0014
`dead-assign-removal` considers continuous assignments (#1652)
rachitnigam Aug 10, 2023
e25dc21
Support inlining `ref` cells (#1651)
rachitnigam Aug 10, 2023
a7adeee
Inling does not generate assignments for clk and reset ports (#1654)
rachitnigam Aug 10, 2023
7b93167
Get the file path and respond to initialization requests (#1647)
Basant-khalil Aug 10, 2023
1c221c0
Attempt to fix `compile-ref` bug (#1650)
rachitnigam Aug 10, 2023
597aadc
`comb-prop`: Disable rewrites when wire output is used (#1656)
rachitnigam Aug 11, 2023
e07d145
PIFO in Calyx (#1625)
anshumanmohan Aug 15, 2023
ab41bc5
PIFO, FIFO: command `peek` (#1657)
anshumanmohan Aug 15, 2023
d6b2bf8
PIFO: modularize eDSL code (#1658)
anshumanmohan Aug 15, 2023
2e11cb6
PIFO Tree in Calyx (#1659)
anshumanmohan Aug 15, 2023
ef33b4b
Clarify that 10 is magic number (#1663)
anshumanmohan Aug 16, 2023
ca0e206
Update MrXL one-pager (#1669)
anshumanmohan Aug 17, 2023
96243ca
Queues: more expressive common interface (#1662)
anshumanmohan Aug 17, 2023
fa90848
Remove `PortDef::into` (#1671)
rachitnigam Aug 18, 2023
cdd90db
Builder: optional names for cells (#1664)
anshumanmohan Aug 18, 2023
4539202
Builder: rehome `builder_util` (#1665)
anshumanmohan Aug 18, 2023
75250ac
Builder: sugary variants of `if` and `while` (#1666)
anshumanmohan Aug 18, 2023
ecd2756
Massage away magic width 32 (#1677)
anshumanmohan Aug 18, 2023
1fb49f4
Builder: make PyLint a little happier (#1674)
anshumanmohan Aug 19, 2023
0c87664
Builder: trim docstrings for readability (#1675)
anshumanmohan Aug 19, 2023
56c1845
Catch up gen_exp
anshumanmohan Aug 20, 2023
de49ca3
Revert "Catch up gen_exp"
anshumanmohan Aug 20, 2023
7ff9213
Builder: use register to make the queue nicer (#1681)
anshumanmohan Aug 21, 2023
6eaee6c
Include the primitive implements with `calyx` binary (#1678)
rachitnigam Aug 22, 2023
f8de521
Remove the `futil` binary (#1685)
rachitnigam Aug 22, 2023
0dbdc64
Builder: perform op and store in reg (#1682)
anshumanmohan Aug 22, 2023
ed05431
bump version
rachitnigam Aug 22, 2023
861c2ad
Builder: catch up `gen_exp` to new features of eDSL (#1684)
anshumanmohan Aug 22, 2023
83faabd
Install primitives in global folder (#1687)
rachitnigam Aug 22, 2023
eb6edb5
version 0.5.1
rachitnigam Aug 23, 2023
4395468
run cell sharing before compile ref (#1688)
rachitnigam Aug 23, 2023
14e735c
remove `debug_name` field for WRC in release mode (#1689)
rachitnigam Aug 23, 2023
0e1e815
Deprecate `Cell::find_with_attr` (#1690)
rachitnigam Aug 23, 2023
73c2422
Redesign `ir::Rewriter` interface (#1691)
rachitnigam Aug 23, 2023
8452458
Compile-invoke compiles `ref` cells as well (#1692)
rachitnigam Aug 24, 2023
691bd55
[Cider] Patch ref-cell bug (#1695)
EclecticGriffin Aug 25, 2023
0022741
generate `calyx.undefined` for `undef` ops (#1704)
rachitnigam Aug 30, 2023
52b85b5
allow trailing comma in attribute list (#1703)
rachitnigam Aug 30, 2023
181cd7a
add version information for the compiler (#1705)
rachitnigam Aug 30, 2023
4721169
move backend code into separate dir (#1706)
rachitnigam Aug 30, 2023
0330cb3
Bump dependent crates (#1707)
rachitnigam Aug 31, 2023
437ecdc
bump runt version (#1708)
rachitnigam Aug 31, 2023
5b210a8
more expressive `guard!` macro (#1709)
rachitnigam Aug 31, 2023
3701a53
Rename `interp` to `cider` (#1686)
rachitnigam Aug 31, 2023
5b4379f
Remove calyx lib.rs so it does not expose any thing (#1711)
rachitnigam Aug 31, 2023
c64cbed
define `ir::rrc` to build RRCs (#1710)
rachitnigam Aug 31, 2023
3339f51
version 0.6.0
rachitnigam Aug 31, 2023
67e1131
Systolic Array MM and Post Op Separated into Separate Components (#1…
calebmkim Sep 1, 2023
e098eae
Builder: infer more widths (#1683)
anshumanmohan Sep 6, 2023
17c6002
Move `numeric_types.py` from `fud/verilator` to `calyx-py` (#1715)
calebmkim Sep 7, 2023
d62ffb3
Revert "Move `numeric_types.py` from `fud/verilator` to `calyx-py` (#…
calebmkim Sep 7, 2023
71d0abe
Cleaner Systolic Array Code (#1716)
calebmkim Sep 7, 2023
d74e7ff
Add Regular ReLU Post Op for Systolic Arrays (#1720)
calebmkim Sep 11, 2023
750a7c9
Dynamic Implementation of ReLU (#1727)
calebmkim Sep 22, 2023
bd2382d
[fud] Fix environment variables for real-FPGA runs (#1728)
sampsyo Sep 24, 2023
6a0636a
Improve Static Inline (#1734)
calebmkim Oct 10, 2023
17d164e
Create IDL Backend (#1729)
nathanielnrn Oct 10, 2023
b94c733
Improve systolic array (#1735)
calebmkim Oct 11, 2023
0f42f5d
disable playground workflow
rachitnigam Oct 11, 2023
e35b086
add signext primitive (#1739)
rachitnigam Oct 12, 2023
b6758d9
Schedule compaction (#1722)
paili0628 Oct 12, 2023
eb383ae
[Cider Adapter] Fix missing `package.json` and minor tweaks (#1741)
EclecticGriffin Oct 12, 2023
cee9e69
fix checking for large constants (#1743)
rachitnigam Oct 13, 2023
b2ff090
version 0.6.1
rachitnigam Oct 15, 2023
266c1bf
Static Systolic Array (#1740)
calebmkim Oct 16, 2023
77adcc2
Add width parameter to `pipelined_mult` primitive (#1748)
matth2k Oct 20, 2023
89e3e7f
Automate SystemVerilog to BTOR conversion for Calyx Primitives (#1757)
NgaiJustin Oct 31, 2023
cb30ead
Share cells in more situations (#1753)
bcarlet Oct 31, 2023
a086796
Promotion Heurisitcs (subsumes #1750) (#1758)
calebmkim Nov 3, 2023
9b5f23f
Systolic Generation Optimization (#1760)
calebmkim Nov 7, 2023
c56b5a0
`fifo`: better testing (#1762)
anshumanmohan Nov 8, 2023
13028ba
Schedule Compaction Minimizes Par Threads (#1774)
calebmkim Nov 11, 2023
51c54cd
Static interface (#1759)
paili0628 Nov 12, 2023
38f3449
`fud` stages for HLS place and route (#1773)
bcarlet Nov 13, 2023
b2c990a
Cider-dap changes (#1768)
eliascxstro Nov 14, 2023
cf6bea2
Converted extension.js to typescript (#1772)
kadenlei Nov 15, 2023
51acaaf
[Cider 2.0] random grab bag of stuff (#1778)
EclecticGriffin Nov 15, 2023
c81a4ac
`pifo`: better testing (#1763)
anshumanmohan Nov 16, 2023
44c0a67
`pifo tree`: better testing (#1765)
anshumanmohan Nov 16, 2023
3d27b0f
Queues: collect magic numbers, pass 100 commands (#1771)
anshumanmohan Nov 16, 2023
52ec28c
Queues: option for no errors (#1779)
anshumanmohan Nov 16, 2023
9e6eedd
PIFO Trees: Telemetry (#1736)
anshumanmohan Nov 16, 2023
8135e8f
No peeks (#1781)
anshumanmohan Nov 16, 2023
cad5d5d
Add Priya, Anshuman to list of contributors (#1782)
anshumanmohan Nov 17, 2023
accb594
fix (#1784)
calebmkim Nov 19, 2023
1cc5c43
Piezo, PIFOTree: static option! (#1783)
anshumanmohan Nov 20, 2023
73d88a6
Remove unnecessary par in SDN (#1786)
anshumanmohan Nov 20, 2023
ebc1198
More thoughtful data gen for Piezo (#1787)
anshumanmohan Nov 24, 2023
991f382
Piezo, PIFO tree: new `.data` and `.expect` files (#1788)
anshumanmohan Nov 24, 2023
8216bd4
Fix some typos and rephrase some `axi-gen.md` documentation (#1789)
nathanielnrn Nov 25, 2023
145039b
Piezo, PIFO tree: 10000 pushes and pops (#1790)
anshumanmohan Nov 26, 2023
a22fdd0
Simplify logic on static designs (#1775)
calebmkim Nov 27, 2023
7d4f42c
Queues: more `if then else` (#1791)
anshumanmohan Nov 28, 2023
c5ff18b
Add back the vscode settings (#1799)
EclecticGriffin Dec 4, 2023
6b0742a
Fix pretty-printing for static invokes (#1795) (#1800)
sampsyo Dec 4, 2023
91df50d
Cider changes (#1798)
eliascxstro Dec 5, 2023
0f2a28c
Implemented Single session (#1797)
kadenlei Dec 5, 2023
e137459
Cider debugger logging (#1802)
kadenlei Dec 11, 2023
4c5a3dc
Use runt version 0.4.0 (#1804)
rachitnigam Dec 13, 2023
bceade5
bump rust version number (#1812)
EclecticGriffin Dec 18, 2023
15d1b5c
Initial code and tests for Calyx-to-FIRRTL backend (#1806)
ayakayorihiro Dec 18, 2023
1deea04
SDN correctness (#1796)
anshumanmohan Dec 21, 2023
64079b5
Queues: unified, nicer runner method (#1816)
anshumanmohan Dec 21, 2023
f5cd79b
[Calyx-FIRRTL backend] Guards and non-primitive Cells (#1817)
ayakayorihiro Dec 21, 2023
8ee390a
Better parsing and help for pass options (#1819)
rachitnigam Dec 21, 2023
0667a0a
Add that in guards ports can be literals to docs (#1821)
nathanielnrn Dec 22, 2023
10e5db3
Add Ayaka to list of contributors (#1822)
ayakayorihiro Dec 23, 2023
248f1a2
rename cucapra/calyx to calyxir/calyx (#1823)
rachitnigam Dec 24, 2023
039a9f7
Build docker image if dockerfile changes (#1824)
rachitnigam Dec 24, 2023
cdf192c
Register options for `cell-share` (#1826)
rachitnigam Dec 26, 2023
d86a5bd
Update SA docs and command-line opts (#1829)
rachitnigam Dec 26, 2023
d5ba289
make stability check a warning (#1830)
rachitnigam Dec 27, 2023
b84823f
Remove `tdst` (#1831)
rachitnigam Dec 27, 2023
8d7bda8
Promote if branches that don't have else stmts (#1792)
calebmkim Jan 2, 2024
2434c6a
[Calyx-FIRRTL backend] Primitive Cells (#1835)
ayakayorihiro Jan 3, 2024
02ebf99
[Calyx-FIRRTL] Primitive cell bug fix (#1838)
ayakayorihiro Jan 5, 2024
97a05a5
Working Calyx Implementation of AXI Read channels (#1820)
nathanielnrn Jan 6, 2024
1d9dd52
[Calyx-Firrtl] Fix undefined values bug by initializing to zero (#1841)
ayakayorihiro Jan 10, 2024
96bf129
Promote AXI-Read implementation to a complete AXI wrapper (#1842)
nathanielnrn Jan 12, 2024
be69d53
Compaction Accounts for Continuous Assignments (#1847)
calebmkim Jan 12, 2024
192d8f0
Document Calyx RTL interface requirements (#1843)
nathanielnrn Jan 16, 2024
6c2af34
Fix read channel data_received write_en (#1851)
nathanielnrn Jan 17, 2024
d9061fd
Simplify Calyx AXI wrapper -- `xVALID` signals and reg `invokes` (#1…
nathanielnrn Jan 18, 2024
c918bb3
Add parens around guard exprs (#1858)
rachitnigam Jan 19, 2024
ebdc28d
Add support for using python builder `invoke` with integer literals (…
nathanielnrn Jan 21, 2024
201735c
Decouple AXI `base_addr` and calyx memories' `curr_addr` in hardcoded…
nathanielnrn Jan 21, 2024
97ba200
Add parentheses around `==` and `!=` in builder (#1859)
nathanielnrn Jan 21, 2024
1992a46
[Docs] tiny addition about github practices (#1840)
EclecticGriffin Jan 22, 2024
f478b49
Backend for listing instantiations of primitives (#1860)
ayakayorihiro Jan 23, 2024
8e2fe15
Add `calyx-py` AXI generator address channels (#1855)
nathanielnrn Jan 23, 2024
d08d239
Add `calyx-py` AXI generator read channel (#1856)
nathanielnrn Jan 23, 2024
d8a6af6
Add `calyx-py` AXI generator write channel (#1861)
nathanielnrn Jan 23, 2024
cfe4c8a
[Cider 2.0] Partial checkpoint (#1868)
EclecticGriffin Jan 24, 2024
3331177
[Cider-dap] Fix cider extension (#1869)
EclecticGriffin Jan 24, 2024
017a37a
Dont panic if insufficient parameters provided (#1876)
rachitnigam Jan 28, 2024
59a581b
Clean up AXI generator channels (#1867)
nathanielnrn Jan 28, 2024
766c472
Initial fud2 import (#1877)
sampsyo Jan 28, 2024
20f0dfc
add logging to fud2 (#1881)
rachitnigam Jan 29, 2024
9527cd9
Add subcommand to edit configuration (#1882)
rachitnigam Jan 29, 2024
85164ec
Ignore fud2 build folder
rachitnigam Jan 29, 2024
c88c913
[Calyx-FIRRTL] Support for template FIRRTL primitives (#1864)
ayakayorihiro Jan 29, 2024
ee6ae1e
Small tweaks to fud2 (#1879)
sampsyo Jan 29, 2024
f227a93
Separate Inference and Promotion into Separate Passes (#1871)
calebmkim Jan 29, 2024
718dc21
Reorder Compaction (#1884)
calebmkim Feb 1, 2024
18f1301
Docs: static keyword (#1872)
anshumanmohan Feb 1, 2024
f2ae18f
Docs: multicomponent tutorial fud command fix (#1891)
eys29 Feb 4, 2024
5f70f23
Reorganize `fud2` directory (#1883)
rachitnigam Feb 4, 2024
e4df535
Deploy docs on `main` (#1892)
rachitnigam Feb 4, 2024
51de164
fud2 docs (#1893)
rachitnigam Feb 4, 2024
6fab070
Fix tiny typo for fud2 doc (#1895)
ayakayorihiro Feb 5, 2024
9973656
Move `numeric_types.py` from `fud/verilator` to `calyx-py` (another a…
calebmkim Feb 5, 2024
5f262c3
Remove versions/ folder (#1900)
rachitnigam Feb 6, 2024
a7a109d
Reorganize memories in primitives (#1901)
rachitnigam Feb 6, 2024
deeae3e
[Calyx-FIRRTL] Debugged FIRRTL implementations of primitives (#1907)
ayakayorihiro Feb 7, 2024
35ca202
Deprecate `@static` (#1897)
calebmkim Feb 9, 2024
fbcf573
Remove `@static` from docs (#1911)
calebmkim Feb 12, 2024
6802fbd
[Cider 2.0] Basic Simulation flow (#1912)
EclecticGriffin Feb 12, 2024
3773b05
std-bit-slice implementation (#1906)
anthonyabeo Feb 15, 2024
0a8630e
merge and fix
rachitnigam Feb 16, 2024
92b5d89
Merge branch 'main' into single-port-mem
rachitnigam Feb 16, 2024
f5304a8
fix test
rachitnigam Feb 16, 2024
6c65f57
Update dahlia version
rachitnigam Feb 16, 2024
634e1d8
update error tests
rachitnigam Feb 16, 2024
b92d175
fetch required because of caching
rachitnigam Feb 16, 2024
6bd4a70
content en
rachitnigam Feb 16, 2024
bb49fe6
update Dahlia
rachitnigam Feb 16, 2024
1b60407
Add names to fields in `ir::Canonical`
rachitnigam Feb 16, 2024
fd37296
Define `ReadWriteSet::PortIterator` and provide methods for nicer cha…
rachitnigam Feb 16, 2024
08737c5
More changes to the ReadWriteSet interface
rachitnigam Feb 16, 2024
4e12766
work on default assigns pass
rachitnigam Feb 16, 2024
50ffb34
Merge branch 'main' into single-port-mem
rachitnigam Feb 17, 2024
ff9d32d
default assign pass works
rachitnigam Feb 17, 2024
cc8b502
update test
rachitnigam Feb 17, 2024
242adac
update test
rachitnigam Feb 18, 2024
7444365
redo tests
calebmkim Feb 19, 2024
0c0b56d
update ports for SeqMem in calyx-py
rachitnigam Feb 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ RUN python3 setup.py bdist_wheel && python3 -m pip install --user dist/tvm-*.whl
WORKDIR /home
RUN git clone https://github.com/cucapra/dahlia.git
WORKDIR /home/dahlia
## Checkout specific version
RUN git checkout 51954e7
## Checkout specific version. Fetch before checkout because clone might be cached.
RUN git fetch --all && git checkout 88e05e5
RUN sbt "; getHeaders; assembly"

# Add the Calyx source code from the build context
Expand Down
4 changes: 2 additions & 2 deletions calyx-ir/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ impl<T: GetName> WRC<T> {
pub fn upgrade(&self) -> RRC<T> {
let Some(r) = self.internal.upgrade() else {
#[cfg(debug_assertions)]
unreachable!("weak reference points to a dropped. Original object's name: `{}'", self.debug_name);
unreachable!("weak reference points to a dropped value. Original object's name: `{}'", self.debug_name);
#[cfg(not(debug_assertions))]
unreachable!("weak reference points to a dropped.");
unreachable!("weak reference points to a dropped value.");
};
r
}
Expand Down
10 changes: 9 additions & 1 deletion calyx-ir/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,14 @@ impl Component {
self.namegen.gen_name(prefix)
}

/// Check whether this component is purely structural, i.e. has no groups or control
pub fn is_structural(&self) -> bool {
self.groups.is_empty()
&& self.comb_groups.is_empty()
&& self.static_groups.is_empty()
&& self.control.borrow().is_empty()
}

/// Check whether this is a static component.
/// A static component is a component which has a latency field.
pub fn is_static(&self) -> bool {
Expand Down Expand Up @@ -316,7 +324,7 @@ impl Component {
#[derive(Debug)]
pub struct IdList<T: GetName>(LinkedHashMap<Id, RRC<T>>);

/// Simple into-iter impl delegating to the [`Values`](linked_hash_map::Values).
/// Simple iter impl delegating to the [`Values`](linked_hash_map::Values).
impl<'a, T: GetName> IntoIterator for &'a IdList<T> {
type Item = &'a RRC<T>;

Expand Down
8 changes: 5 additions & 3 deletions calyx-opt/src/default_passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use crate::passes::{
AddGuard, Canonicalize, CellShare, ClkInsertion, CollapseControl, CombProp,
CompileInvoke, CompileRepeat, CompileStatic, CompileStaticInterface,
CompileSync, CompileSyncWithoutSyncReg, ComponentInliner, DataPathInfer,
DeadAssignmentRemoval, DeadCellRemoval, DeadGroupRemoval, DiscoverExternal,
Externalize, GoInsertion, GroupToInvoke, GroupToSeq, HoleInliner,
InferShare, LowerGuards, MergeAssign, Papercut, ParToSeq,
DeadAssignmentRemoval, DeadCellRemoval, DeadGroupRemoval, DefaultAssigns,
DiscoverExternal, Externalize, GoInsertion, GroupToInvoke, GroupToSeq,
HoleInliner, InferShare, LowerGuards, MergeAssign, Papercut, ParToSeq,
RegisterUnsharing, RemoveIds, ResetInsertion, SimplifyStaticGuards,
SimplifyWithControl, StaticInference, StaticInliner, StaticPromotion,
SynthesisPapercut, TopDownCompileControl, UnrollBounded, WellFormed,
Expand Down Expand Up @@ -59,6 +59,7 @@ impl PassManager {
pm.register_pass::<ResetInsertion>()?;
pm.register_pass::<MergeAssign>()?;
pm.register_pass::<WrapMain>()?;
pm.register_pass::<DefaultAssigns>()?;

// Enabled in the synthesis compilation flow
pm.register_pass::<SynthesisPapercut>()?;
Expand Down Expand Up @@ -134,6 +135,7 @@ impl PassManager {
ClkInsertion,
ResetInsertion,
MergeAssign,
DefaultAssigns,
]
);

Expand Down
129 changes: 129 additions & 0 deletions calyx-opt/src/passes/default_assigns.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
use crate::analysis::AssignmentAnalysis;
use crate::traversal::{Action, ConstructVisitor, Named, VisResult, Visitor};
use calyx_ir::{self as ir, LibrarySignatures};
use calyx_utils::{CalyxResult, Error};
use itertools::Itertools;
use std::collections::HashMap;

/// Adds default assignments to all non-`@data` ports of an instance.
pub struct DefaultAssigns {
/// Mapping from component to data ports
data_ports: HashMap<ir::Id, Vec<ir::Id>>,
}

impl Named for DefaultAssigns {
fn name() -> &'static str {
"default-assigns"
}

fn description() -> &'static str {
"adds default assignments to all non-`@data` ports of an instance."
}
}

impl ConstructVisitor for DefaultAssigns {
fn from(ctx: &ir::Context) -> CalyxResult<Self>
where
Self: Sized,
{
let data_ports = ctx
.lib
.signatures()
.map(|sig| {
let ports = sig.signature.iter().filter_map(|p| {
if p.direction == ir::Direction::Input
&& !p.attributes.has(ir::BoolAttr::Data)
&& !p.attributes.has(ir::BoolAttr::Clk)
&& !p.attributes.has(ir::BoolAttr::Reset)
{
Some(p.name())
} else {
None
}
});
(sig.name, ports.collect())
})
.collect();
Ok(Self { data_ports })
}

fn clear_data(&mut self) {
/* shared across components */
}
}

impl Visitor for DefaultAssigns {
fn start(
&mut self,
comp: &mut ir::Component,
sigs: &LibrarySignatures,
_comps: &[ir::Component],
) -> VisResult {
if !comp.is_structural() {
return Err(Error::pass_assumption(
Self::name(),
format!("component {} is not purely structural", comp.name),
));
}

// We only need to consider write set of the continuous assignments
let writes = comp
.continuous_assignments
.iter()
.analysis()
.writes()
.group_by_cell();

let mut assigns = Vec::new();

let mt = vec![];
let cells = comp.cells.iter().cloned().collect_vec();
let mut builder = ir::Builder::new(comp, sigs);

for cr in &cells {
let cell = cr.borrow();
let Some(typ) = cell.type_name() else {
continue;
};
let Some(required) = self.data_ports.get(&typ) else {
continue;
};

// For all the assignments not in the write set, add a default assignment
let cell_writes = writes
.get(&cell.name())
.unwrap_or(&mt)
.iter()
.map(|p| {
let p = p.borrow();
p.name
})
.collect_vec();

assigns.extend(
required.iter().filter(|p| !cell_writes.contains(p)).map(
|name| {
let port = cell.get(name);
let zero = builder.add_constant(0, port.borrow().width);
let assign: ir::Assignment<ir::Nothing> = builder
.build_assignment(
cell.get(name),
zero.borrow().get("out"),
ir::Guard::True,
);
log::info!(
"Adding {}",
ir::Printer::assignment_to_str(&assign)
);
assign
},
),
);
}

comp.continuous_assignments.extend(assigns);

// Purely structural pass
Ok(Action::Stop)
}
}
2 changes: 2 additions & 0 deletions calyx-opt/src/passes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ mod sync;
mod add_guard;
mod compile_static_interface;
mod data_path_infer;
mod default_assigns;
mod discover_external;
mod simplify_with_control;
mod synthesis_papercut;
Expand Down Expand Up @@ -81,6 +82,7 @@ pub use sync::CompileSyncWithoutSyncReg;
// pub use simplify_guards::SimplifyGuards;
pub use add_guard::AddGuard;
pub use compile_static_interface::CompileStaticInterface;
pub use default_assigns::DefaultAssigns;
pub use synthesis_papercut::SynthesisPapercut;
pub use top_down_compile_control::TopDownCompileControl;
pub use unroll_bound::UnrollBounded;
Expand Down
65 changes: 47 additions & 18 deletions calyx-opt/src/passes/papercut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,30 @@ pub struct Papercut {
cont_cells: HashSet<ir::Id>,
}

impl Papercut {
#[allow(unused)]
/// String representation of the write together and read together specifications.
/// Used for debugging. Should not be relied upon by external users.
fn fmt_write_together_spec(&self) -> String {
self.write_together
.iter()
.map(|(prim, writes)| {
let writes = writes
.iter()
.map(|write| {
write
.iter()
.sorted()
.map(|port| format!("{port}"))
.join(", ")
})
.join("; ");
format!("{}: [{}]", prim, writes)
})
.join("\n")
}
}

impl ConstructVisitor for Papercut {
fn from(ctx: &ir::Context) -> CalyxResult<Self> {
let write_together =
Expand Down Expand Up @@ -232,7 +256,7 @@ impl Papercut {
.join(", ");
let msg =
format!("Required signal not driven inside the group.\
\nWhen read the port `{}.{}', the ports [{}] must be written to.\
\nWhen reading the port `{}.{}', the ports [{}] must be written to.\
\nThe primitive type `{}' requires this invariant.",
inst,
read,
Expand All @@ -245,30 +269,35 @@ impl Papercut {
}
for ((inst, comp_type), writes) in all_writes {
if let Some(spec) = self.write_together.get(&comp_type) {
// For each write together spec.
for required in spec {
// It should either be the case that:
// 1. `writes` contains no writes that overlap with `required`
// In which case `required - writes` == `required`.
// 2. `writes` contains writes that overlap with `required`
// In which case `required - writes == {}`
let mut diff = required - &writes;
if !diff.is_empty() && diff != *required {
let first = writes.iter().sorted().next().unwrap();
let missing = diff
.drain()
.sorted()
.map(|port| format!("{}.{}", inst, port))
.join(", ");
let msg =
format!("Required signal not driven inside the group.\
\nWhen writing to the port `{}.{}', the ports [{}] must also be written to.\
\nThe primitive type `{}' requires this invariant.",
inst,
first,
missing,
comp_type);
return Err(Error::papercut(msg));
let mut diff: HashSet<_> =
required.difference(&writes).copied().collect();
if diff.is_empty() || diff == *required {
continue;
}

let first =
writes.intersection(required).sorted().next().unwrap();
let missing = diff
.drain()
.sorted()
.map(|port| format!("{}.{}", inst, port))
.join(", ");
let msg =
format!("Required signal not driven inside the group. \
When writing to the port `{}.{}', the ports [{}] must also be written to. \
The primitive type `{}' specifies this using a @write_together spec.",
inst,
first,
missing,
comp_type);
return Err(Error::papercut(msg));
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions calyx-py/calyx/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,8 +599,8 @@ def mem_read_seq_d1(self, mem, i, groupname=None):
groupname = groupname or f"read_from_{mem.name()}"
with self.group(groupname) as read_grp:
mem.addr0 = i
mem.read_en = 1
read_grp.done = mem.read_done
mem.content_en = 1
read_grp.done = mem.done
return read_grp

def mem_write_seq_d1_to_reg(self, mem, reg, groupname=None):
Expand All @@ -625,7 +625,8 @@ def mem_store_seq_d1(self, mem, i, val, groupname=None):
mem.addr0 = i
mem.write_en = 1
mem.write_data = val
store_grp.done = mem.write_done
mem.content_en = 1
store_grp.done = mem.done
return store_grp

def mem_load_to_mem(self, mem, i, ans, j, groupname=None):
Expand Down Expand Up @@ -1093,7 +1094,7 @@ def infer_width(self, port_name) -> int:
return inst.args[2]
if port_name == "in":
return inst.args[0]
if prim == "seq_mem_d1" and port_name == "read_en":
if prim == "seq_mem_d1" and port_name == "content_en":
return 1
if prim in (
"std_mult_pipe",
Expand Down
2 changes: 2 additions & 0 deletions examples/futil/dot-product.expect
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ component main(@go go: 1, @clk clk: 1, @reset reset: 1) -> (@done done: 1) {
A_read0_0.reset = reset;
A_read0_0.in = fsm.out == 4'd0 & early_reset_static_seq_go.out ? A0.read_data;
A_read0_0.in = fsm.out == 4'd4 & early_reset_static_seq_go.out ? mult_pipe0.out;
A0.write_en = 1'd0;
B0.write_en = 1'd0;
}
control {}
}
2 changes: 2 additions & 0 deletions examples/futil/vectorized-add.expect
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ component main(@go go: 1, @clk clk: 1, @reset reset: 1) -> (@done done: 1) {
A_read0_0.clk = clk;
A_read0_0.reset = reset;
A_read0_0.in = fsm.out == 3'd0 & early_reset_static_seq_go.out ? A0.read_data;
A0.write_en = 1'd0;
B0.write_en = 1'd0;
}
control {}
}
Loading
Loading