Skip to content

Commit

Permalink
Avoid locking the rename method in retirement
Browse files Browse the repository at this point in the history
  • Loading branch information
tilk committed Nov 15, 2023
1 parent 79f2135 commit 22d1ca4
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions coreblocks/stages/retirement.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from amaranth import *
from coreblocks.params.dependencies import DependencyManager
from coreblocks.params.keys import GenericCSRRegistersKey
from coreblocks.params.layouts import CommonLayoutFields

from transactron.core import Method, Transaction, TModule
from coreblocks.params.genparams import GenParams
from coreblocks.structs_common.csr_generic import CSRAddress, DoubleCounterCSR
from transactron.lib.connectors import Forwarder


class Retirement(Elaboratable):
Expand Down Expand Up @@ -43,6 +45,9 @@ def elaborate(self, platform):

m.d.comb += side_fx_comb.eq(side_fx)

fields = self.gen_params.get(CommonLayoutFields)
m.submodules.frat_fix = frat_fix = Forwarder([fields.rl_dst, fields.rp_dst])

with Transaction().body(m):
# TODO: do we prefer single precommit call per instruction?
# If so, the precommit method should send an acknowledge signal here.
Expand Down Expand Up @@ -78,13 +83,17 @@ def elaborate(self, platform):
with m.Else():
m.d.av_comb += rp_freed.eq(rob_entry.rob_data.rp_dst)
# free the phys_reg with computed value and restore old reg into FRAT as well
# TODO: are method priorities enough?
self.rename(m, rl_s1=0, rl_s2=0, rl_dst=rob_entry.rob_data.rl_dst, rp_dst=rat_out.old_rp_dst)
# FRAT calls are in a separate transaction to avoid locking the rename method
frat_fix.write(m, rl_dst=rob_entry.rob_data.rl_dst, rp_dst=rat_out.old_rp_dst)

self.rf_free(m, rp_freed)

# put old rp_dst to free RF list
with m.If(rp_freed): # don't put rp0 to free list - reserved to no-return instructions
self.free_rf_put(m, rp_freed)

with Transaction().body(m):
data = frat_fix.read(m)
self.rename(m, rl_s1=0, rl_s2=0, rl_dst=data["rl_dst"], rp_dst=data["rp_dst"])

return m

0 comments on commit 22d1ca4

Please sign in to comment.