Skip to content

Commit

Permalink
Fix instruction cache refilling bug (kuznia-rdzeni/coreblocks#636)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakub Urbańczyk authored Apr 1, 2024
1 parent 95119bc commit 6896604
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
8 changes: 8 additions & 0 deletions transactron/lib/fifo.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ class BasicFifo(Elaboratable):
read: Method
Reads from the FIFO. Accepts an empty argument, returns a structure.
Ready only if the FIFO is not empty.
peek: Method
Returns the element at the front (but not delete). Ready only if the FIFO
is not empty. The method is nonexclusive.
write: Method
Writes to the FIFO. Accepts a structure, returns empty result.
Ready only if the FIFO is not full.
Expand Down Expand Up @@ -40,6 +43,7 @@ def __init__(self, layout: MethodLayout, depth: int, *, src_loc: int | SrcLoc =

src_loc = get_src_loc(src_loc)
self.read = Method(o=self.layout, src_loc=src_loc)
self.peek = Method(o=self.layout, nonexclusive=True, src_loc=src_loc)
self.write = Method(i=self.layout, src_loc=src_loc)
self.clear = Method(src_loc=src_loc)
self.head = Signal(from_method_layout(layout))
Expand Down Expand Up @@ -93,6 +97,10 @@ def _() -> ValueLike:
m.d.sync += self.read_idx.eq(next_read_idx)
return self.head

@def_method(m, self.peek, self.read_ready)
def _() -> ValueLike:
return self.head

@def_method(m, self.clear)
def _() -> None:
m.d.sync += self.read_idx.eq(0)
Expand Down
9 changes: 7 additions & 2 deletions transactron/lib/reqres.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from amaranth import *
from ..core import *
from ..utils import SrcLoc, get_src_loc, MethodLayout
from .connectors import Forwarder, FIFO
from .connectors import Forwarder
from transactron.lib import BasicFifo
from amaranth.utils import *

Expand Down Expand Up @@ -39,6 +39,8 @@ class ArgumentsToResultsZipper(Elaboratable):
Attributes
----------
peek_arg: Method
A nonexclusive method to read (but not delete) the head of the arg queue.
write_args: Method
Method to write arguments with `args_layout` format to 2-FIFO.
write_results: Method
Expand All @@ -65,14 +67,15 @@ def __init__(self, args_layout: MethodLayout, results_layout: MethodLayout, src_
self.args_layout = args_layout
self.output_layout = [("args", self.args_layout), ("results", results_layout)]

self.peek_arg = Method(o=self.args_layout, nonexclusive=True, src_loc=self.src_loc)
self.write_args = Method(i=self.args_layout, src_loc=self.src_loc)
self.write_results = Method(i=self.results_layout, src_loc=self.src_loc)
self.read = Method(o=self.output_layout, src_loc=self.src_loc)

def elaborate(self, platform):
m = TModule()

fifo = FIFO(self.args_layout, depth=2, src_loc=self.src_loc)
fifo = BasicFifo(self.args_layout, depth=2, src_loc=self.src_loc)
forwarder = Forwarder(self.results_layout, src_loc=self.src_loc)

m.submodules.fifo = fifo
Expand All @@ -92,6 +95,8 @@ def _():
results = forwarder.read(m)
return {"args": args, "results": results}

self.peek_arg.proxy(m, fifo.peek)

return m


Expand Down

0 comments on commit 6896604

Please sign in to comment.