Skip to content

Commit

Permalink
Bump Amaranth even more!!!
Browse files Browse the repository at this point in the history
  • Loading branch information
tilk committed Sep 27, 2024
1 parent c2aaf6f commit 765e18d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion amaranth-stubs
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
./amaranth-stubs/ # can't use -e -- pyright doesn't see the stubs then :(
amaranth-yosys==0.38.0.0.post88
git+https://github.com/amaranth-lang/amaranth@6d65dc1366da2313e8e6a77d5093ddd6acdec8aa
amaranth-yosys==0.40.0.0.post100
git+https://github.com/amaranth-lang/amaranth@9bd536bbf96b07720d6e4a8709b30492af8ddd13
dataclasses-json==0.6.3
13 changes: 8 additions & 5 deletions test/transactron/test_assign.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from amaranth import *
from amaranth.lib import data
from amaranth.lib.enum import Enum
from amaranth.hdl._ast import ArrayProxy, Slice
from amaranth.hdl._ast import ArrayProxy, SwitchValue, Slice

from transactron.utils._typing import MethodLayout
from transactron.utils import AssignType, assign
Expand Down Expand Up @@ -143,11 +143,14 @@ def test_assign_a(self, name, layout1: MethodLayout, layout2: MethodLayout, atyp
self.assertIs_AP(alist[0].rhs, self.extrr(rhs).a)

def assertIs_AP(self, expr1, expr2): # noqa: N802
if isinstance(expr1, ArrayProxy) and isinstance(expr2, ArrayProxy):
expr1 = Value.cast(expr1)
expr2 = Value.cast(expr2)
if isinstance(expr1, SwitchValue) and isinstance(expr2, SwitchValue):
# new proxies are created on each index, structural equality is needed
self.assertIs(expr1.index, expr2.index)
assert len(expr1.elems) == len(expr2.elems)
for x, y in zip(expr1.elems, expr2.elems):
self.assertIs(expr1.test, expr2.test)
assert len(expr1.cases) == len(expr2.cases)
for (px, x), (py, y) in zip(expr1.cases, expr2.cases):
self.assertEqual(px, py)
self.assertIs_AP(x, y)
elif isinstance(expr1, Slice) and isinstance(expr2, Slice):
self.assertIs_AP(expr1.value, expr2.value)
Expand Down
4 changes: 4 additions & 0 deletions transactron/lib/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ def add_registers(self, regs: list[HwMetricRegister]):
def metrics_enabled(self) -> bool:
return DependencyContext.get().get_dependency(HwMetricsEnabledKey())

# To restore hashability lost by dataclass subclassing
def __hash__(self):
return object.__hash__(self)


class HwCounter(Elaboratable, HwMetric):
"""Hardware Counter
Expand Down
2 changes: 1 addition & 1 deletion transactron/utils/assign.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def has_explicit_shape(val: ValueLike):
if valuelike_shape(lhs) != valuelike_shape(rhs):
raise ValueError(
"Shapes not matching: lhs: {} {} rhs: {} {}".format(
valuelike_shape(lhs), lhs, valuelike_shape(rhs), rhs
valuelike_shape(lhs), repr(lhs), valuelike_shape(rhs), repr(rhs)
)
)

Expand Down

0 comments on commit 765e18d

Please sign in to comment.