Fix status checks: lint, format, typecheck, and tests (#8)
* Initial plan * Initial assessment - identifying issues to fix Co-authored-by: arnavsacheti <36746504+arnavsacheti@users.noreply.github.com> * Fix type check and test issues to pass all status checks Co-authored-by: arnavsacheti <36746504+arnavsacheti@users.noreply.github.com> * Add coverage.xml to .gitignore and remove from tracking Co-authored-by: arnavsacheti <36746504+arnavsacheti@users.noreply.github.com> * Use more specific pattern for coverage.xml in .gitignore Co-authored-by: arnavsacheti <36746504+arnavsacheti@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: arnavsacheti <36746504+arnavsacheti@users.noreply.github.com>
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -12,6 +12,7 @@
|
|||||||
**/*.pb
|
**/*.pb
|
||||||
**/.Xil
|
**/.Xil
|
||||||
**/.coverage.*
|
**/.coverage.*
|
||||||
|
coverage.xml
|
||||||
|
|
||||||
build/
|
build/
|
||||||
dist/
|
dist/
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
from typing import Protocol, Self
|
from typing import Protocol
|
||||||
|
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
|
|
||||||
class SupportsStr(Protocol):
|
class SupportsStr(Protocol):
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from textwrap import indent
|
from textwrap import indent
|
||||||
from types import EllipsisType
|
from types import EllipsisType
|
||||||
from typing import Self
|
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
from .body import Body, SupportsStr
|
from .body import Body, SupportsStr
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class APB3Cpuif(BaseCpuif):
|
|||||||
|
|
||||||
# Only add array dimensions if this should be treated as an array
|
# Only add array dimensions if this should be treated as an array
|
||||||
if self.check_is_array(child):
|
if self.check_is_array(child):
|
||||||
|
assert child.array_dimensions is not None
|
||||||
return f"{base} {''.join(f'[{dim}]' for dim in child.array_dimensions)}"
|
return f"{base} {''.join(f'[{dim}]' for dim in child.array_dimensions)}"
|
||||||
|
|
||||||
return base
|
return base
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class APB4Cpuif(BaseCpuif):
|
|||||||
|
|
||||||
# Only add array dimensions if this should be treated as an array
|
# Only add array dimensions if this should be treated as an array
|
||||||
if self.check_is_array(child):
|
if self.check_is_array(child):
|
||||||
|
assert child.array_dimensions is not None
|
||||||
return f"{base} {''.join(f'[{dim}]' for dim in child.array_dimensions)}"
|
return f"{base} {''.join(f'[{dim}]' for dim in child.array_dimensions)}"
|
||||||
|
|
||||||
return base
|
return base
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class AXI4LiteCpuif(BaseCpuif):
|
|||||||
|
|
||||||
# Only add array dimensions if this should be treated as an array
|
# Only add array dimensions if this should be treated as an array
|
||||||
if self.check_is_array(child):
|
if self.check_is_array(child):
|
||||||
|
assert child.array_dimensions is not None
|
||||||
return f"{base} {''.join(f'[{dim}]' for dim in child.array_dimensions)}"
|
return f"{base} {''.join(f'[{dim}]' for dim in child.array_dimensions)}"
|
||||||
|
|
||||||
return base
|
return base
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class AXI4LiteCpuifFlat(BaseCpuif):
|
|||||||
|
|
||||||
# Only add array dimensions if this should be treated as an array
|
# Only add array dimensions if this should be treated as an array
|
||||||
if self.check_is_array(child):
|
if self.check_is_array(child):
|
||||||
|
assert child.array_dimensions is not None
|
||||||
return f"{base} {''.join(f'[{dim}]' for dim in child.array_dimensions)}"
|
return f"{base} {''.join(f'[{dim}]' for dim in child.array_dimensions)}"
|
||||||
|
|
||||||
return base
|
return base
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from collections import deque
|
from collections import deque
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
from typing import cast
|
||||||
|
|
||||||
from systemrdl.node import AddressableNode
|
from systemrdl.node import AddressableNode
|
||||||
from systemrdl.walker import WalkerAction
|
from systemrdl.walker import WalkerAction
|
||||||
@@ -101,7 +102,8 @@ class DecodeLogicGenerator(BusDecoderListener):
|
|||||||
self._decode_stack.append(IfBody())
|
self._decode_stack.append(IfBody())
|
||||||
elif isinstance(self._decode_stack[-1], IfBody):
|
elif isinstance(self._decode_stack[-1], IfBody):
|
||||||
# non-arrayed component with if-body
|
# non-arrayed component with if-body
|
||||||
with self._decode_stack[-1].cm(condition) as b:
|
ifb = cast(IfBody, self._decode_stack[-1])
|
||||||
|
with ifb.cm(condition) as b:
|
||||||
b += f"{self._flavor.cpuif_select}.{get_indexed_path(self._ds.top_node, node)} = 1'b1;"
|
b += f"{self._flavor.cpuif_select}.{get_indexed_path(self._ds.top_node, node)} = 1'b1;"
|
||||||
else:
|
else:
|
||||||
raise RuntimeError("Invalid decode stack state")
|
raise RuntimeError("Invalid decode stack state")
|
||||||
@@ -128,7 +130,8 @@ class DecodeLogicGenerator(BusDecoderListener):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
if isinstance(self._decode_stack[-1], IfBody):
|
if isinstance(self._decode_stack[-1], IfBody):
|
||||||
with self._decode_stack[-1].cm(self._cond_stack.pop()) as parent_b:
|
ifb = cast(IfBody, self._decode_stack[-1])
|
||||||
|
with ifb.cm(self._cond_stack.pop()) as parent_b:
|
||||||
parent_b += b
|
parent_b += b
|
||||||
else:
|
else:
|
||||||
self._decode_stack[-1] += b
|
self._decode_stack[-1] += b
|
||||||
|
|||||||
@@ -56,11 +56,13 @@ def ref_is_internal(top_node: AddrmapNode, ref: Node | PropertyReference) -> boo
|
|||||||
|
|
||||||
For the sake of this exporter, root signals are treated as internal.
|
For the sake of this exporter, root signals are treated as internal.
|
||||||
"""
|
"""
|
||||||
|
current_node: Node | None
|
||||||
if isinstance(ref, PropertyReference):
|
if isinstance(ref, PropertyReference):
|
||||||
current_node = ref.node
|
current_node = ref.node
|
||||||
else:
|
else:
|
||||||
current_node = ref
|
current_node = ref
|
||||||
|
|
||||||
|
# pyrefly: ignore[bad-assignment] - false positive due to circular type checking
|
||||||
while current_node is not None:
|
while current_node is not None:
|
||||||
if current_node == top_node:
|
if current_node == top_node:
|
||||||
# reached top node without finding any external components
|
# reached top node without finding any external components
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ def test_unroll_disabled_creates_array_interface(sample_rdl):
|
|||||||
with TemporaryDirectory() as tmpdir:
|
with TemporaryDirectory() as tmpdir:
|
||||||
exporter = BusDecoderExporter()
|
exporter = BusDecoderExporter()
|
||||||
exporter.export(
|
exporter.export(
|
||||||
sample_rdl.top,
|
sample_rdl,
|
||||||
tmpdir,
|
tmpdir,
|
||||||
cpuif_cls=APB4Cpuif,
|
cpuif_cls=APB4Cpuif,
|
||||||
cpuif_unroll=False,
|
cpuif_unroll=False,
|
||||||
@@ -61,7 +61,7 @@ def test_unroll_enabled_creates_individual_interfaces(sample_rdl):
|
|||||||
with TemporaryDirectory() as tmpdir:
|
with TemporaryDirectory() as tmpdir:
|
||||||
exporter = BusDecoderExporter()
|
exporter = BusDecoderExporter()
|
||||||
exporter.export(
|
exporter.export(
|
||||||
sample_rdl.top,
|
sample_rdl,
|
||||||
tmpdir,
|
tmpdir,
|
||||||
cpuif_cls=APB4Cpuif,
|
cpuif_cls=APB4Cpuif,
|
||||||
cpuif_unroll=True,
|
cpuif_unroll=True,
|
||||||
@@ -95,7 +95,7 @@ def test_unroll_with_apb3(sample_rdl):
|
|||||||
with TemporaryDirectory() as tmpdir:
|
with TemporaryDirectory() as tmpdir:
|
||||||
exporter = BusDecoderExporter()
|
exporter = BusDecoderExporter()
|
||||||
exporter.export(
|
exporter.export(
|
||||||
sample_rdl.top,
|
sample_rdl,
|
||||||
tmpdir,
|
tmpdir,
|
||||||
cpuif_cls=APB3Cpuif,
|
cpuif_cls=APB3Cpuif,
|
||||||
cpuif_unroll=True,
|
cpuif_unroll=True,
|
||||||
@@ -138,7 +138,7 @@ def test_unroll_multidimensional_array(multidim_array_rdl):
|
|||||||
with TemporaryDirectory() as tmpdir:
|
with TemporaryDirectory() as tmpdir:
|
||||||
exporter = BusDecoderExporter()
|
exporter = BusDecoderExporter()
|
||||||
exporter.export(
|
exporter.export(
|
||||||
multidim_array_rdl.top,
|
multidim_array_rdl,
|
||||||
tmpdir,
|
tmpdir,
|
||||||
cpuif_cls=APB4Cpuif,
|
cpuif_cls=APB4Cpuif,
|
||||||
cpuif_unroll=True,
|
cpuif_unroll=True,
|
||||||
|
|||||||
Reference in New Issue
Block a user