From 483def6a407c6e730d9fdf902642d21903edbc6f Mon Sep 17 00:00:00 2001 From: Iain Robertson Date: Fri, 31 Jan 2025 15:56:58 +0000 Subject: [PATCH] Update reference algorithm to cover missing trap handling case - Issue 187 --- exampleAlgorithm.adoc | 14 +- testAlgo.svg | 1766 +++++++++++++++++++++-------------------- 2 files changed, 891 insertions(+), 889 deletions(-) diff --git a/exampleAlgorithm.adoc b/exampleAlgorithm.adoc index 6834b73..8a98386 100644 --- a/exampleAlgorithm.adoc +++ b/exampleAlgorithm.adoc @@ -9,7 +9,7 @@ A reference algorithm for compressed branch trace is given in * _te_inst._ The name of the packet type emitted by the encoder (see <>); * _inst._ Abbreviation for 'instruction'; -* _exception. Exception or interrupt signalled;_ +* _trap. Exception or interrupt signalled;_ * _updiscon._ Uninferable PC discontinuity. This identifies an instruction that causes the program counter to be changed by an amount that cannot be predicted from the source code alone (*itype* values 8, @@ -24,11 +24,7 @@ not; reported precisely or treated as an uninferable PC discontinuity (see <>); * _ppccd_br._ As above, but branch map not empty; -* _er_n._ Instruction retirement and exception signalled on the same -cycle, or Trace notify trigger (see -<>); -* _exc_only._ Exception or interrupt signalled without simultaneous -retirement; +* _ntf._ Trace notify trigger (see <>); * _cci._ context change that can be reported imprecisely (see <>); * _rpt_br._ Report branches due to full branch map or misprediction; @@ -36,9 +32,7 @@ retirement; the decoder; * _pbc._ Correctly predicted branches count (always zero if branch predictor disabled or not present); -* _Reported?_ "Exception previous" reported with *thaddr* = 0 on the -cycle it occured because it was preceded by an updiscon or immediately -followed by another exception; +* _trep_ Previous trap already reported with *thaddr* = 0 because it was preceded by an updiscon or immediately followed by another exception; * _resync count._ A counter used to keep track of when it is necessary to send a synchronization packet (see <>); * _max_resync._ The resync counter value that schedules a @@ -52,7 +46,7 @@ would be seen in a single-retirement system only. Whilst the core to encoder interface allows the RISC-V hart to provide information on multiple retiring instructions simultaneously, the resultant packet sequence generated by the encoder must be the same as if retiring one -instruction at a time. +instruction at a time. Note that even with a single-retirement system it is possible to retire an instruction and report a trap simultaneously (*itype* = 1 or 2 and *iretire* = 1). In this case the flow diagram must be traversed twice, first for the retired instruction, and then for the trap. A 3-stage pipeline within the encoder is assumed, such that the encoder has visibility of the current, previous and next instructions. All diff --git a/testAlgo.svg b/testAlgo.svg index 834c9a3..1372d66 100755 --- a/testAlgo.svg +++ b/testAlgo.svg @@ -1,656 +1,882 @@ - - + + + xmlns:v="http://schemas.microsoft.com/visio/2003/SVGExtensions/" width="4.73056in" height="6.93028in" + viewBox="0 0 340.6 498.98" xml:space="preserve" color-interpolation-filters="sRGB" class="st16"> - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - Page-1 + + Delta v1 ret+except - - Decision.8 - Last cycle was unpred discon? - - - - - - - - - - - - - - - - - Lastcycle was unpred discon? - - Terminator.108 - Start of cycle - - - - - - - - - - - - - - - - - Start of cycle - - Decision.111 - Qualified? - - - - - - - - - - - - - - - - - Qualified? - - Dynamic connector - - - - - - - - Terminator.138 - End of cycle - - - - - - - - - - - - - - - - - End of cycle - - Sheet.6 - - - - - - + + Sheet.139 + + Decision.8 + Updiscon previous? + + + + + + + + + + + + Updiscon previous? + + Terminator.108 + Start + + + + + + + + + + + + Start + + Decision.111 + Qualified? + + + + + + + + + + + + Qualified? + + Dynamic connector + - - - - Sheet.7 - N - - - - - - - - N - - Sheet.8 - Y - - - - - - - - Y - - Sheet.9 - Y - - - - - - - - Y - - Sheet.10 - N - - - - - - - - N - - Process.3 - Send te_inst: format 3 subformat 0 resync count = 0 - - - - - - - - - - - - - - - - - Send te_inst: format 3 subformat 0resync count = 0 - - Sheet.12 - - - - - - + + Terminator.138 + End + + + + + + + + + + + + End + + Sheet.145 + - - - - Process.163 - Send te_inst: format 3 subformat 1 resync count = 0 - - - - - - - - - - - - - - - - - Send te_inst: format 3 subformat 1resync count = 0 - - Dynamic connector.164 - - - - - - - - Sheet.15 - Y - - - - - - - - Y - - Sheet.16 - N - - - - - - - - N - - Sheet.17 - - - - - - + + Sheet.146 + N + + + + N + + Sheet.147 + Y + + + + Y + + Sheet.148 + Y + + + + Y + + Sheet.149 + N + + + + N + + Process.3 + Send te_inst: format 3, subformat 0 resync count = 0 + + + + + + + + + + + + Send te_inst: format 3, subformat 0resync count = 0 + + Sheet.151 + - - - - Dynamic connector.18 - - - - - - - - Sheet.19 - Y - - - - - - - - Y - - Sheet.20 - N - - - - - - - - N - - Dynamic connector.140 - - - - - - - - Process.180 - Send te_inst: format 3 subformat 2 resync count ++ - - - - - - - - - - - - - - - - - Send te_inst: format 3 subformat 2resync count ++ - - Sheet.23 - Y - - - - - - - - Y - - Decision.177 - Context change? - - - - - - - - - - - - - - - - - Contextchange? - - Dynamic connector.181 - - - - - - - - Sheet.26 - - - - - - + + Process.163 + Send te_inst: format 3, subformat 1 thaddr = 1 resync count = 0 + + + + + + + + + + + + Send te_inst: format 3, subformat 1 thaddr = 1resync count = 0 + + Dynamic connector.164 + - - - - Process.33 - Send te_inst: format 0/1/2 resync count ++ - - - - - - - - - - - - - - - - - Send te_inst: format 0/1/2resync count ++ - - Dynamic connector.80 - - - - - - - - Sheet.29 - Y - - - - - - - - Y - - Sheet.30 - N - - - - - - - - N - - Decision.27 - Next cycle is halt, exception, privilege change, or unqualifi... - - - - - - - - - - - - - - - - - Next cycleis halt, exception,privilege change, or unqualified? - - Dynamic connector.32 - - - - - - - - Dynamic connector.47 - - - - - - - - Decision.1 - Resync pend && Branches > 0? - - - - - - - - - - - - - - - - - Resync pend &&Branches > 0? - - Sheet.35 - Y - - - - - - - - Y - - Sheet.36 - N - - - - - - - - N - - Dynamic connector.37 - - - - - - - - Sheet.38 - - - - - - + + Sheet.154 + Y + + + + Y + + Sheet.155 + N + + + + N + + Sheet.156 + - - - - Sheet.39 - N - - - - - - - - N - - Dynamic connector.85 - - - - - - - - Dynamic connector.16 - - - - - - - - Dynamic connector.9 - - - - - + + Dynamic connector.25 + + + + Sheet.158 + Y + + + + Y + + Sheet.159 + N + + + + N + + Dynamic connector.140 + + + + Process.180 + Send te_inst: format 3, subformat 2 + + + + + + + + + + + + Send te_inst: format 3, subformat 2 + + Sheet.162 + Y + + + + Y + + Dynamic connector.181 + + + + Sheet.164 + + + + Process.33 + Send te_inst: format 0/1/2 + + + + + + + + + + + + Send te_inst: format 0/1/2 + + Dynamic connector.80 + + + + Sheet.167 + Y + + + + Y + + Sheet.168 + N + + + + N + + Dynamic connector.30 + + + + Dynamic connector.31 + + + + Decision.1 + resync2_br or ntf? + + + + + + + + + + + + resync2_bror ntf? + + Sheet.172 + Y + + + + Y + + Sheet.173 + N + + + + N + + Dynamic connector.16 + + + + Sheet.175 + + + + Sheet.176 + N + + + + N + + Dynamic connector.85 + + + + Dynamic connector.42 + + + + Dynamic connector.9 + + + + Decision.65 + Branch? + + + + + + + + + + + + Branch? + + Sheet.181 + Y + + + + Y + + Sheet.182 + N + + + + N + + Dynamic connector.38 + + + + Process.55 + Update branch map/predictor + + + + + + + + + + + + Update branch map/predictor + + Dynamic connector.70 + + + + Dynamic connector.52 + + + + Dynamic connector.14 + + + + Sheet.188 + Y + + + + Y + + Sheet.189 + N + + + + N + + Process.28 + Send te_inst: format 0 if pbc ≥ 31 format 1 if pbc < 31 no ad... + + + + + + + + + + + + Send te_inst: format 0 if pbc ≥ 31 format 1 if pbc < 31 no address + + Sheet.191 + + + + Dynamic connector.56 + + + + Dynamic connector.17 + + + + Dynamic connector.29 + + + + Dynamic connector.62 + + + + Decision.39 + Trap previous? + + + + + + + + + + + + Trapprevious? + + Sheet.197 + privilege change, precise ppccd_br: context change or context... + + + + privilege change, preciseppccd_br: context change or context change with discontinuity, and branch map not empty + + Sheet.198 + resync2_br: resync FSM state 2 and branch map not empty ntf: ... + + + + resync2_br: resync FSM state 2 and branch map not empty ntf: notify + + Sheet.199 + privilege change, precise ppccd: context change or context ch... + + + + privilege change, preciseppccd: context change or context change with discontinuity + + Sheet.200 + cci: imprecise context change + + + + cci: imprecise context change + + Sheet.201 + + Process.69 + + + + + + + + + + + + Sheet.203 + Decision or action based on previous instruction + + + + Decision or action based on previous instruction + + Process.71 + + + + + + + + + + + + Sheet.205 + Decision or action based on current instruction + + + + Decision or action based on current instruction + + Sheet.206 + Key: + + + + Key: + + Process.76 + + + + + + + + + + + + Sheet.208 + Decision based on next instruction + + + + Decision based on next instruction + + + Sheet.209 + rpt_br: branches=31 & pbc < 31, or pbc ≥ 31 and prediction fa... + + + + rpt_br: branches=31 & pbc < 31, or pbc and prediction failed + + Decision.84 + Trap + + + + + + + + + + + + Trap + + Sheet.211 + Y + + + + Y + + Sheet.212 + N + + + + N + + Process.88 + Send te_inst: format 3, subformat 1 thaddr = 0 resync count = 0 + + + + + + + + + + + + Send te_inst: format 3, subformat 1 thaddr = 0resync count = 0 + + Sheet.215 + + + + Decision.92 + trep? + + + + + + + + + + + + trep? + + Sheet.217 + Y + + + + Y + + Sheet.218 + N + + + + N + + Decision.99 + Trap + + + + + + + + + + + + Trap + + Dynamic connector.100 + + + + Dynamic connector.101 + + + + Sheet.223 + Y + + + + Y + + Sheet.224 + N + + + + N + + Dynamic connector.104 + + + + Decision.105 + Next inst is trap, ppccd_br, or unqualified? + + + + + + + + + + + + Next inst istrap, ppccd_br, or unqualified? + + Decision.106 + Inst is 1st qualified, ppccd or resync3 + + + + + + + + + + + + Inst is1st qualified, ppccd or resync3 + + Decision.107 + rpt_br? + + + + + + + + + + + + rpt_br? + + Decision.108 + cci? + + + + + + + + + + + + cci? + + Process.111 + Send te_inst: format 3, subformat 1 thaddr = 0 resync count = 0 + + + + + + + + + + + + Send te_inst: format 3, subformat 1 thaddr = 0resync count = 0 + + Sheet.231 + + + + Process.114 + ecause/int tval + + + + + + + + + + + + ecause/inttval + + Process.115 + ecause/int tval + + + + + + + + + + + + ecause/inttval + + Process.116 + ecause/int tval + + + + + + + + + + + + ecause/inttval - - Decision.65 - Branch? + + Decision.92 + trep? @@ -658,270 +884,52 @@ - - - - - - - - Branch? - - Sheet.44 - Y - - - - - - - - Y - - Sheet.45 + + + trep? + + Sheet.237 N - - - - - - - N - - Dynamic connector.38 - - - - - - - - Process.47 - Update branch map - - - - - - - - - - - - - - - - - Update branch map - - Dynamic connector.69 - - - - - - - - Dynamic connector.70 - - - - - - - - Decision.12 - 1st cycle qualified or unhalted, or privilege change or resyn... - - - - - - - - - - - - - - - - - 1st cyclequalified or unhalted, or privilege change or resync_nh? - - Dynamic connector.30 - - - - - - - - Dynamic connector.14 - - - - - - - - Sheet.53 + + + N + + Sheet.239 Y - - - - - - - - Y - - Sheet.54 - N - - - - - - - N - - Process.28 - Send te_inst: format 0 no address resync count ++ - - - - - - - - - - - - - - - - - Send te_inst: format 0 no addressresync count ++ - - Sheet.56 - - - - - - - - - - - Decision.54 - Branch map full? - - - - - - - - - - - - - - - - - Branch map full? - - Dynamic connector.56 - - - - - + + + Y + + Dynamic connector.240 + - - Dynamic connector.17 - - - - - - - - Dynamic connector.29 - - - - - + + Sheet.241 + trep: previous trap already reported + + + + trep: previous trap already reported + + Dynamic connector.242 + - - Dynamic connector.31 - - - - - + + Dynamic connector.243 + - - Decision.39 - Last cycle was exception? - - - - - - - - - - - - - - - - - Last cycle was exception? - - Sheet.63 - resync_nh: Resync pending and branch map holds no history fro... - - - - + + Sheet.245 + resync3: resync FSM state 3 - - - resync_nh: Resync pending and branch map holds no history from previous instructions + + + resync3: resync FSM state 3