avl.IndexedScoreboard

Inheritance diagram of avl._core.scoreboard_indexed

Indexed scoreboards for interfaces or buses where the data may be out of order within the bus, but is actually constructed from multiple in-order streams. This applies to any threaded interface such as AXI or PCIe.

The indexed scoreboard automatically constructs multiple in-order scoreboards and compares the items in the correct order.

The user must simply implement the IndexedScoreboard.get_index and call the IndexedScoreboard.set_indices to definethe individual streams and assign the item to the correct instance.

../_images/avl_scoreboard_indexed.png

Example

# Copyright 2024 Apheleia
#
# Description:
# Apheleia scoreboard example


import random

import avl
import cocotb
from cocotb.triggers import Timer


class example_item(avl.Object):
    def __init__(self, name, parent):
        super().__init__(name, parent)
        self.value = None


class example_sb(avl.IndexedScoreboard):
    def __init__(self, name, parent):
        super().__init__(name, parent)

    def get_index(self, item):
        return item.value


class example_env(avl.Env):
    def __init__(self, name, parent):
        super().__init__(name, parent)

        self.sb = example_sb("sb", self)
        self.sb.set_verbose(True)
        self.sb.set_indices(range(10))

    async def run_phase(self):
        self.raise_objection()

        before = []
        after = []
        for i in range(10):
            item = example_item("item" + str(i), None)
            item.value = i
            before.append(item)
            after.append(item)

        random.shuffle(before)

        while len(before) > 0:
            await Timer(1, "ns")
            self.sb.before_port.append(before.pop(0))
            self.sb.after_port.append(after.pop(0))

        self.drop_objection()


@cocotb.test
async def test(dut):
    e = example_env("env", None)
    await e.start()