Skip to content

Commit

Permalink
Lint and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tilk committed Dec 10, 2024
1 parent e0cc9bf commit 4532478
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 27 deletions.
4 changes: 1 addition & 3 deletions coreblocks/backend/annoucement.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ class ResultAnnouncement(Elaboratable):
`ManyToOneConnectTrans` to a FIFO.
"""

def __init__(
self, *, gen_params: GenParams, get_result: Method, rob_mark_done: Method, announce: Method
):
def __init__(self, *, gen_params: GenParams, get_result: Method, rob_mark_done: Method, announce: Method):
"""
Parameters
----------
Expand Down
5 changes: 1 addition & 4 deletions coreblocks/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,7 @@ def elaborate(self, platform):
m.submodules.announce_unifiers = ModuleConnector(**announce_unifier)

self.announcement = ResultAnnouncement(
gen_params=self.gen_params,
get_result=func_get_result,
rob_mark_done=self.ROB.mark_done,
announce=announce
gen_params=self.gen_params, get_result=func_get_result, rob_mark_done=self.ROB.mark_done, announce=announce
)

m.submodules.scheduler = Scheduler(
Expand Down
1 change: 0 additions & 1 deletion coreblocks/func_blocks/fu/common/rs_func_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from coreblocks.scheduler.wakeup_select import WakeupSelect
from transactron import Method, TModule
from coreblocks.func_blocks.interface.func_protocols import FuncUnit, FuncBlock
from transactron.lib import Collector
from coreblocks.arch import OpType
from coreblocks.interface.layouts import RSLayouts, FuncUnitLayouts
from coreblocks.interface.keys import AnnounceKey, FuncUnitResultKey
Expand Down
1 change: 0 additions & 1 deletion coreblocks/func_blocks/interface/func_blocks_unifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from coreblocks.params import GenParams, BlockComponentParams
from transactron import TModule
from transactron.lib import MethodProduct

__all__ = ["FuncBlocksUnifier"]

Expand Down
27 changes: 9 additions & 18 deletions test/backend/test_annoucement.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,8 @@ def elaborate(self, platform):
)

# Create stubs for interfaces used by result announcement
self.rs_announce_val_tbio = TestbenchIO(Adapter(i=self.lay_rs_write, o=self.lay_rs_write))
m.submodules.rs_announce_val_tbio = self.rs_announce_val_tbio
self.rf_announce_val_tbio = TestbenchIO(Adapter(i=self.lay_rf_write, o=self.lay_rf_write))
m.submodules.rf_announce_val_tbio = self.rf_announce_val_tbio
self.announce_val_tbio = TestbenchIO(Adapter(i=self.lay_rs_write, o=self.lay_rs_write))
m.submodules.announce_val_tbio = self.announce_val_tbio
self.rob_mark_done_tbio = TestbenchIO(Adapter(i=self.lay_rob_mark_done, o=self.lay_rob_mark_done))
m.submodules.rob_mark_done_tbio = self.rob_mark_done_tbio

Expand All @@ -61,8 +59,7 @@ def elaborate(self, platform):
gen_params=self.gen_params,
get_result=serialized_results_fifo.read,
rob_mark_done=self.rob_mark_done_tbio.adapter.iface,
rs_update=self.rs_announce_val_tbio.adapter.iface,
rf_write=self.rf_announce_val_tbio.adapter.iface,
announce=self.announce_val_tbio.adapter.iface,
)

return m
Expand Down Expand Up @@ -116,30 +113,24 @@ async def producer(sim: TestbenchContext):

async def consumer(self, sim: TestbenchContext):
# TODO: this test doesn't do anything, fix it!
self.m.rs_announce_val_tbio.enable(sim)
self.m.rob_mark_done_tbio.enable(sim)
while reduce(and_, self.producer_end, True):
# All 3 methods (in RF, RS and ROB) need to be enabled for the result
# All 2 methods (RF/RS announcement and ROB) need to be enabled for the result
# announcement transaction to take place. We want to have at least one
# method disabled most of the time, so that the transaction is performed
# only when we enable it inside the loop. Otherwise the transaction could
# get executed at any time, particularly when we wouldn't be monitoring it
self.m.rf_announce_val_tbio.enable(sim)
self.m.announce_val_tbio.enable(sim)

rf_result = self.m.rf_announce_val_tbio.get_outputs(sim)
rs_result = self.m.rs_announce_val_tbio.get_outputs(sim)
ann_result = self.m.announce_val_tbio.get_outputs(sim)
rob_result = self.m.rob_mark_done_tbio.get_outputs(sim)

self.m.rf_announce_val_tbio.disable(sim)
self.m.announce_val_tbio.disable(sim)

assert rf_result is not None
assert rs_result is not None
assert ann_result is not None
assert rob_result is not None

assert rf_result["reg_val"] == rs_result["value"]
assert rf_result["reg_id"] == rs_result["reg_id"]

t = (rob_result["rob_id"], rf_result["reg_val"], rf_result["reg_id"])
t = (rob_result["rob_id"], ann_result["reg_val"], ann_result["reg_id"])
assert t in self.expected_output
if self.expected_output[t] == 1:
del self.expected_output[t]
Expand Down

0 comments on commit 4532478

Please sign in to comment.