Skip to content

Commit

Permalink
Another fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tilk committed Feb 26, 2025
1 parent a4130d8 commit 7a97902
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion test/lib/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def elaborate(self, platform):
m.submodules.counter = self.counter

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

return m

Expand Down
10 changes: 5 additions & 5 deletions transactron/lib/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,17 +479,17 @@ def _(k: int, sample):
def sample_or_default(method: Method, default: Value) -> Value:
return Mux(method.run, method.data_in.sample, default)

method_min_samples = (sample_or_default(m, C(-1, self.sample_width)) for m in self.add)
method_max_samples = (sample_or_default(m, C(0, self.sample_width)) for m in self.add)
method_min_samples = list(sample_or_default(m, C((1 << self.sample_width)) - 1) for m in self.add)
method_max_samples = list(sample_or_default(m, C(0)) for m in self.add)

min_sample = min_value(self.min.value, method_min_samples)
max_sample = max_value(self.max.value, method_max_samples)
sample_sum = sum_value(method_max_samples)
sample_sum = sum_value(self.sum.value, method_max_samples)

m.d.sync += self.max.value.eq(max_sample)
m.d.sync += self.min.value.eq(min_sample)
m.d.sync += self.max.value.eq(max_sample)
m.d.sync += self.count.value.eq(self.count.value + popcount(Cat(m.run for m in self.add)))
m.d.sync += self.sum.value.eq(self.sum.value + sample_sum)
m.d.sync += self.sum.value.eq(sample_sum)

for i, bucket in enumerate(self.buckets):
m.d.sync += bucket.value.eq(bucket.value + popcount(bucket_incrs[i]))
Expand Down

0 comments on commit 7a97902

Please sign in to comment.