Skip to content

Commit

Permalink
Towards fixing metrics test
Browse files Browse the repository at this point in the history
  • Loading branch information
tilk committed Feb 25, 2025
1 parent 7fcaae1 commit a4130d8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
22 changes: 11 additions & 11 deletions test/lib/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def elaborate(self, platform):

@def_method(m, self.method)
def _():
self.counter.incr(m)
self.counter.incr[0](m)

return m

Expand All @@ -43,7 +43,7 @@ def elaborate(self, platform):

@def_method(m, self.method)
def _(cond):
self.counter.incr(m, cond=cond)
self.counter.incr[0](m, enable_call=cond)

return m

Expand All @@ -59,7 +59,7 @@ def elaborate(self, platform):
m.submodules.counter = self.counter

with Transaction().body(m):
self.counter.incr(m, cond=self.cond)
self.counter.incr[0](m, enable_call=self.cond)

return m

Expand Down Expand Up @@ -155,7 +155,7 @@ def elaborate(self, platform):
m.submodules.counter = self.counter

with Transaction().body(m):
self.counter.incr(m, self.tag, cond=self.cond)
self.counter.incr(m, tag=self.tag, enable_call=self.cond)

return m

Expand Down Expand Up @@ -335,7 +335,7 @@ async def producer(sim: TestbenchContext):
ticks = DependencyContext.get().get_dependency(TicksKey())

for _ in range(200):
await m._start.call(sim)
await m.start[0].call(sim)

event_queue.put(sim.get(ticks))
await self.random_wait_geom(sim, 0.8)
Expand All @@ -346,7 +346,7 @@ async def consumer(sim: TestbenchContext):
ticks = DependencyContext.get().get_dependency(TicksKey())

while not finish:
await m._stop.call(sim)
await m.stop[0].call(sim)

latencies.append(sim.get(ticks) - event_queue.get())

Expand Down Expand Up @@ -396,7 +396,7 @@ async def producer(sim):
await sim.delay(1e-9)

slot_id = random.choice(free_slots)
await m._start.call(sim, slot=slot_id)
await m.start[0].call(sim, slot=slot_id)

events[slot_id] = sim.get(tick_count)
free_slots.remove(slot_id)
Expand All @@ -415,7 +415,7 @@ async def consumer(sim):

slot_id = random.choice(used_slots)

await m._stop.call(sim, slot=slot_id)
await m.stop[0].call(sim, slot=slot_id)

await sim.delay(2e-9)

Expand Down Expand Up @@ -447,9 +447,9 @@ def elaborate(self, platform):

@def_method(m, self.incr_counters)
def _(counter1, counter2, counter3):
self.counter1.incr(m, cond=counter1)
self.counter2.incr(m, cond=counter2)
self.counter3.incr(m, cond=counter3)
self.counter1.incr[0](m, enable_call=counter1)
self.counter2.incr[0](m, enable_call=counter2)
self.counter3.incr[0](m, enable_call=counter3)

return m

Expand Down
10 changes: 5 additions & 5 deletions transactron/core/method.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def body(
manager._add_method(self)

def __call__(
self, m: TModule, arg: Optional[AssignArg] = None, enable: ValueLike = C(1), /, **kwargs: AssignArg
self, m: TModule, arg: Optional[AssignArg] = None, /, enable_call: ValueLike = C(1), **kwargs: AssignArg
) -> MethodStruct:
"""Call a method.
Expand All @@ -261,7 +261,7 @@ def __call__(
Call argument. Can be passed as a `View` of the method's
input layout or as a dictionary. Alternative syntax uses
keyword arguments.
enable : Value
enable_call : Value
Configures the call as enabled in the current clock cycle.
Disabled calls still lock the called method in transaction
scheduling. Calls are by default enabled.
Expand Down Expand Up @@ -300,7 +300,7 @@ def __call__(
arg = kwargs

enable_sig = Signal(name=self.owned_name + "_enable")
m.d.av_comb += enable_sig.eq(enable)
m.d.av_comb += enable_sig.eq(enable_call)
m.d.top_comb += assign(arg_rec, arg, fields=AssignType.ALL)

caller = Body.get()
Expand Down Expand Up @@ -346,11 +346,11 @@ def layout_out(self):
return self._layout_out

def __call__(
self, m: TModule, arg: Optional[AssignArg] = None, enable: ValueLike = C(1), /, **kwargs: AssignArg
self, m: TModule, arg: Optional[AssignArg] = None, /, enable_call: ValueLike = C(1), **kwargs: AssignArg
) -> MethodStruct:
if len(self._methods) != 1:
raise RuntimeError("calling Methods only allowed when count=1")
return self._methods[0](m, arg, enable, **kwargs)
return self._methods[0](m, arg, enable_call, **kwargs)

@overload
def __getitem__(self, key: int) -> Method: ...
Expand Down
4 changes: 2 additions & 2 deletions transactron/lib/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,9 +567,9 @@ def elaborate(self, platform):

epoch_width = bits_for(self.max_latency)

self.fifos: list[FIFO] = []
self.fifos = [FIFO([("epoch", epoch_width)], self.slots_number) for _ in range(len(self.start))]
for k in range(len(self.start)):
m.submodules[f"fifo{k}"] = self.fifos[k] = FIFO([("epoch", epoch_width)], self.slots_number)
m.submodules[f"fifo{k}"] = self.fifos[k]

m.submodules.histogram = self.histogram

Expand Down

0 comments on commit a4130d8

Please sign in to comment.