Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tilk committed Mar 28, 2024
1 parent 18119ab commit 472adfb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
7 changes: 2 additions & 5 deletions coreblocks/core_structs/rf.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import operator
from amaranth import *
from functools import reduce
from transactron import Method, Transaction, def_method, TModule
from coreblocks.interface.layouts import RFLayouts
from coreblocks.params import GenParams
from transactron.lib.metrics import HwExpHistogram, IndexedLatencyMeasurer
from transactron.utils.amaranth_ext.functions import popcount
from transactron.utils.transactron_helpers import make_layout

__all__ = ["RegisterFile"]
Expand Down Expand Up @@ -85,9 +84,7 @@ def _(reg_id: Value):
if self.perf_num_valid.metrics_enabled():
num_valid = Signal(self.gen_params.phys_regs_bits + 1)
m.d.comb += num_valid.eq(
reduce(
operator.add, (self.entries[reg_id].valid for reg_id in range(2**self.gen_params.phys_regs_bits))
)
popcount(Cat(self.entries[reg_id].valid for reg_id in range(2**self.gen_params.phys_regs_bits)))
)
with Transaction(name="perf").body(m):
self.perf_num_valid.add(m, num_valid)
Expand Down
7 changes: 2 additions & 5 deletions coreblocks/func_blocks/fu/common/rs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import operator
from functools import reduce
from collections.abc import Iterable
from typing import Optional
from amaranth import *
Expand All @@ -10,6 +8,7 @@
from coreblocks.interface.layouts import RSLayouts
from transactron.lib.metrics import HwExpHistogram, IndexedLatencyMeasurer
from transactron.utils import RecordDict
from transactron.utils.amaranth_ext.functions import popcount
from transactron.utils.transactron_helpers import make_layout

__all__ = ["RS"]
Expand Down Expand Up @@ -130,9 +129,7 @@ def _() -> RecordDict:

if self.perf_num_full.metrics_enabled():
num_full = Signal(self.rs_entries_bits + 1)
m.d.comb += num_full.eq(
reduce(operator.add, (self.data[entry_id].rec_full for entry_id in range(self.rs_entries)))
)
m.d.comb += num_full.eq(popcount(Cat(self.data[entry_id].rec_full for entry_id in range(self.rs_entries))))
with Transaction(name="perf").body(m):
self.perf_num_full.add(m, num_full)

Expand Down

0 comments on commit 472adfb

Please sign in to comment.