Skip to content

Commit

Permalink
Systolic Array takes dynamic contraction dimension (#1642)
Browse files Browse the repository at this point in the history
* variable k works now

* dynamic k value for systolic array

* formatting / rewrote test cases
  • Loading branch information
calebmkim authored Jul 28, 2023
1 parent f9b2881 commit 89ffcd9
Show file tree
Hide file tree
Showing 13 changed files with 1,531 additions and 830 deletions.
16 changes: 16 additions & 0 deletions calyx-py/calyx/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ def control(self, builder: Union[ast.Control, ControlBuilder]):
else:
self.component.controls = builder

def get_port_width(self, name: str) -> int:
for input in self.component.inputs:
if input.id.name == name:
return input.width
for output in self.component.outputs:
if output.id.name == name:
return output.width
raise Exception(f"couldn't find port {name} on component {self.component.name}")

def get_cell(self, name: str) -> CellBuilder:
"""Retrieve a cell builder by name."""
out = self.index.get(name)
Expand Down Expand Up @@ -218,6 +227,10 @@ def reg(self, name: str, size: int, is_ref=False) -> CellBuilder:
"""Generate a StdReg cell."""
return self.cell(name, ast.Stdlib.register(size), False, is_ref)

def slice(self, name: str, in_width: int, out_width, is_ref=False) -> CellBuilder:
"""Generate a StdReg cell."""
return self.cell(name, ast.Stdlib.slice(in_width, out_width), False, is_ref)

def const(self, name: str, width: int, value: int) -> CellBuilder:
"""Generate a StdConstant cell."""
return self.cell(name, ast.Stdlib.constant(width, value))
Expand Down Expand Up @@ -713,6 +726,9 @@ def infer_width(expr):

# Otherwise, it's a `cell.port` lookup.
assert isinstance(expr, ast.Atom)
if isinstance(expr.item, ast.ThisPort):
name = expr.item.id.name
return group_builder.comp.get_port_width(name)
cell_name = expr.item.id.name
port_name = expr.item.name

Expand Down
Loading

0 comments on commit 89ffcd9

Please sign in to comment.