Skip to content

Commit 164d78f

Browse files
committed
ibex: Branch predict
Also adapt the current bp column logic. This will be a major rewrite anyways, I assume.
1 parent ab86f77 commit 164d78f

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

pipelineviewer/ibex.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from attrdict import AttrDict
55

66
class PipelineIbex(Pipeline):
7-
event_name = {"IF": 0, "IDEX": 1, "WB": 2, "DONE": 3}
7+
event_name = {"IF": 0, "IDEX": 1, "WB": 2, "DONE": 3, "BRANCH_PREDICT": 4, "BRANCH_UPDATE": 5}
88

99
def __init__(self, tracepath):
1010
log = {}
@@ -31,7 +31,7 @@ def __init__(self, tracepath):
3131
if "insn_type" in keys:
3232
insn_type = str(event["insn_type"])
3333
log[event["insn_id"]] = AttrDict(
34-
{"pc": pc, "insn_type": insn_type, "insn": insn, "mode": riscv_priv_modes[event["mode"]], "IF": timestamp, "IDEX": None, "WB": None, "end": None})
34+
{"pc": pc, "insn_type": insn_type, "insn": insn, "mode": riscv_priv_modes[event["mode"]], "IF": timestamp, "IDEX": None, "WB": None, "end": None, "BP": None})
3535

3636
elif id_str == "IDEX":
3737
# single cycle idex in the standard pipeline
@@ -43,6 +43,10 @@ def __init__(self, tracepath):
4343
elif id_str == "DONE":
4444
# idex starts in the pipeline with
4545
log[event["insn_id"]]["end"] = event["timestamp"]
46+
elif id_str == "BRANCH_PREDICT":
47+
log[event["insn_id"]]["BP"] = AttrDict(taken=event["taken"], mispredict=False)
48+
elif id_str == "BRANCH_UPDATE":
49+
log[event["insn_id"]]["BP"].mispredict = (event["mispredict"] != 0)
4650

4751
self.log = log
4852

pipelineviewer/main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,11 @@ def render(pipeline, args):
175175
elif c == "b":
176176
if "BP" in i and i.BP:
177177
if i.BP.taken:
178-
line += ", BP taken @{} ({})".format(i.BP.index,
179-
i.BP.type)
178+
line += ", BP taken"
180179
else:
181-
line += ", BP not taken @{} ({})".format(
182-
i.BP.index, i.BP.type)
180+
line += ", BP not taken"
181+
if i.BP.mispredict:
182+
line += " (mispredict)"
183183
if "BHT" in i and i.BHT:
184184
if i.BHT.taken:
185185
line += ", BHT @{} taken ({:02b}->{:02b})".format(

0 commit comments

Comments
 (0)