-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
retirement: Disable side effects on exception #493
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,8 @@ def __init__( | |
free_rf_put: Method, | ||
rf_free: Method, | ||
precommit: Method, | ||
exception_cause_get: Method | ||
exception_cause_get: Method, | ||
frat_rename: Method, | ||
): | ||
self.gen_params = gen_params | ||
self.rob_peek = rob_peek | ||
|
@@ -28,6 +29,7 @@ def __init__( | |
self.rf_free = rf_free | ||
self.precommit = precommit | ||
self.exception_cause_get = exception_cause_get | ||
self.rename = frat_rename | ||
|
||
self.instret_csr = DoubleCounterCSR(gen_params, CSRAddress.INSTRET, CSRAddress.INSTRETH) | ||
|
||
|
@@ -36,18 +38,23 @@ def elaborate(self, platform): | |
|
||
m.submodules.instret_csr = self.instret_csr | ||
|
||
side_fx = Signal(reset=1) | ||
|
||
with Transaction().body(m): | ||
# TODO: do we prefer single precommit call per instruction? | ||
# If so, the precommit method should send an acknowledge signal here. | ||
# Just calling once is not enough, because the insn might not be in relevant unit yet. | ||
rob_entry = self.rob_peek(m) | ||
self.precommit(m, rob_id=rob_entry.rob_id) | ||
self.precommit(m, rob_id=rob_entry.rob_id, side_fx=side_fx) | ||
|
||
with Transaction().body(m): | ||
rob_entry = self.rob_retire(m) | ||
|
||
# TODO: Trigger InterruptCoordinator (handle exception) when rob_entry.exception is set. | ||
with m.If(rob_entry.exception): | ||
with m.If(rob_entry.exception & side_fx): | ||
m.d.sync += side_fx.eq(0) | ||
# TODO: only set mcause/trigger IC if cause is actual exception and not e.g. | ||
# misprediction or pipeline flush after some fence.i or changing ISA | ||
mcause = self.gen_params.get(DependencyManager).get_dependency(GenericCSRRegistersKey()).mcause | ||
cause = self.exception_cause_get(m).cause | ||
entry = Signal(self.gen_params.isa.xlen) | ||
|
@@ -56,13 +63,24 @@ def elaborate(self, platform): | |
mcause.write(m, entry) | ||
|
||
# set rl_dst -> rp_dst in R-RAT | ||
rat_out = self.r_rat_commit(m, rl_dst=rob_entry.rob_data.rl_dst, rp_dst=rob_entry.rob_data.rp_dst) | ||
rat_out = self.r_rat_commit( | ||
m, rl_dst=rob_entry.rob_data.rl_dst, rp_dst=rob_entry.rob_data.rp_dst, side_fx=side_fx | ||
) | ||
|
||
rp_freed = Signal(self.gen_params.phys_regs_bits) | ||
with m.If(side_fx): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. First instruction with |
||
m.d.comb += rp_freed.eq(rat_out.old_rp_dst) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be assigned in |
||
with m.Else(): | ||
m.d.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) | ||
|
||
self.rf_free(m, rat_out.old_rp_dst) | ||
self.rf_free(m, rp_freed) | ||
|
||
# put old rp_dst to free RF list | ||
with m.If(rat_out.old_rp_dst): # don't put rp0 to free list - reserved to no-return instructions | ||
self.free_rf_put(m, rat_out.old_rp_dst) | ||
with m.If(rp_freed): # don't put rp0 to free list - reserved to no-return instructions | ||
self.free_rf_put(m, rp_freed) | ||
|
||
self.instret_csr.increment(m) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and that is additional source of possible side effects and should be considered in future FUs |
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
li x2, 2 | ||
li x1, 1 | ||
.4byte 0 /* should be unimp, but it would test nothing since unimp is system and stalls the fetcher >:( */ | ||
li x2, 9 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Data adress space: | ||
# 0x0 - one | ||
# 0x4 - two | ||
li x1, 1 | ||
sw x1, 0(x0) | ||
li x2, 2 | ||
sw x2, 4(x0) | ||
.4byte 0 /* should be unimp, but it would test nothing since unimp is system and stalls the fetcher >:( */ | ||
sw x1, 4(x0) /* TODO: actually check the side fx */ | ||
li x2, 9 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add "MMIO only" parameter to LSU. It could be easly done by disabling
is_load
part inwith m.If(instr_ready & (self.execute | is_load)):