diff --git a/coreblocks/core_structs/rf.py b/coreblocks/core_structs/rf.py index e8c4e4ef3..d6d5e76e8 100644 --- a/coreblocks/core_structs/rf.py +++ b/coreblocks/core_structs/rf.py @@ -2,7 +2,7 @@ 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.lib.metrics import HwExpHistogram, TaggedLatencyMeasurer from transactron.utils.amaranth_ext.functions import popcount from transactron.utils.transactron_helpers import make_layout @@ -22,7 +22,7 @@ def __init__(self, *, gen_params: GenParams): self.write = Method(i=layouts.rf_write) self.free = Method(i=layouts.rf_free) - self.perf_rf_valid_time = IndexedLatencyMeasurer( + self.perf_rf_valid_time = TaggedLatencyMeasurer( "struct.rf.valid_time", description="Distribution of time registers are valid in RF", slots_number=2**gen_params.phys_regs_bits, diff --git a/coreblocks/func_blocks/fu/common/rs.py b/coreblocks/func_blocks/fu/common/rs.py index 6c418f226..1911690b4 100644 --- a/coreblocks/func_blocks/fu/common/rs.py +++ b/coreblocks/func_blocks/fu/common/rs.py @@ -6,7 +6,7 @@ from coreblocks.params import GenParams from coreblocks.frontend.decoder import OpType from coreblocks.interface.layouts import RSLayouts -from transactron.lib.metrics import HwExpHistogram, IndexedLatencyMeasurer +from transactron.lib.metrics import HwExpHistogram, TaggedLatencyMeasurer from transactron.utils import RecordDict from transactron.utils.amaranth_ext.functions import popcount from transactron.utils.transactron_helpers import make_layout @@ -44,7 +44,7 @@ def __init__( self.data = Array(Signal(self.internal_layout) for _ in range(self.rs_entries)) self.data_ready = Signal(self.rs_entries) - self.perf_rs_wait_time = IndexedLatencyMeasurer( + self.perf_rs_wait_time = TaggedLatencyMeasurer( f"fu.block_{rs_number}.rs.valid_time", description=f"Distribution of time instructions wait in RS {rs_number}", slots_number=2**self.rs_entries_bits, diff --git a/test/transactron/test_metrics.py b/test/transactron/test_metrics.py index 7005bc41a..6b0e4f738 100644 --- a/test/transactron/test_metrics.py +++ b/test/transactron/test_metrics.py @@ -319,7 +319,7 @@ class TestIndexedLatencyMeasurer(TestLatencyMeasurerBase): def test_latency_measurer(self): random.seed(42) - m = SimpleTestCircuit(IndexedLatencyMeasurer("latency", slots_number=self.slots_number, max_latency=300)) + m = SimpleTestCircuit(TaggedLatencyMeasurer("latency", slots_number=self.slots_number, max_latency=300)) DependencyContext.get().add_dependency(HwMetricsEnabledKey(), True) latencies: list[int] = [] diff --git a/transactron/lib/metrics.py b/transactron/lib/metrics.py index 68f7de00e..b7e36a86c 100644 --- a/transactron/lib/metrics.py +++ b/transactron/lib/metrics.py @@ -19,7 +19,7 @@ "HwCounter", "HwExpHistogram", "FIFOLatencyMeasurer", - "IndexedLatencyMeasurer", + "TaggedLatencyMeasurer", "HardwareMetricsManager", "HwMetricsEnabledKey", ] @@ -474,12 +474,12 @@ def metrics_enabled(self) -> bool: return DependencyContext.get().get_dependency(HwMetricsEnabledKey()) -class IndexedLatencyMeasurer(Elaboratable): +class TaggedLatencyMeasurer(Elaboratable): """ Measures duration between two events, e.g. request processing latency. It can track multiple events at the same time, i.e. the second event can be registered as started, before the first finishes. However, each event - needs to have an unique slot index. + needs to have an unique slot tag. The module exposes an exponential histogram of the measured latencies. """ @@ -571,7 +571,7 @@ def _(slot: Value): def start(self, m: TModule, *, slot: ValueLike): """ - Registers the start of an event for a given slot index. + Registers the start of an event for a given slot tag. Should be called in the body of either a transaction or a method. @@ -580,7 +580,7 @@ def start(self, m: TModule, *, slot: ValueLike): m: TModule Transactron module slot: ValueLike - The slot index of the event. + The slot tag of the event. """ if not self.metrics_enabled(): @@ -590,7 +590,7 @@ def start(self, m: TModule, *, slot: ValueLike): def stop(self, m: TModule, *, slot: ValueLike): """ - Registers the end of the event for a given slot index. + Registers the end of the event for a given slot tag. Should be called in the body of either a transaction or a method. @@ -599,7 +599,7 @@ def stop(self, m: TModule, *, slot: ValueLike): m: TModule Transactron module slot: ValueLike - The slot index of the event. + The slot tag of the event. """ if not self.metrics_enabled():