openhwgroup / cvw

CORE-V Wally is a configurable RISC-V Processor associated with RISC-V System-on-Chip Design textbook. Contains a 5-stage pipeline, support for A, B, C, D, F, M and Q extensions, and optional caches, BP, FPU, VM/MMU, AHB, RAMs, and peripherals.
Other
238 stars 175 forks source link

Remove flush from EBU critical path #771

Open davidharrishmc opened 4 months ago

davidharrishmc commented 4 months ago

The EBU receives flush signals (necessary to solve a logic bug). These are now on the critical path, but not in the version of the critical path reported in Chapter 6.

For example, buscachefsm has Flush affecting HTRANS. See the code and timing report below. In the timing report, a branch misprediction raises FlushD, which affects HTRANS. busfsm is similar.

Rose Thompson feels the right fix is to issue the transaction anyway in the Execute stage, but to send a signal in the memory stage for the controller to cancel the transaction via the AHB protocol. If this isn't feasible, it might be possible to kill HWSTRB in the memory stage so that transaction has no effect.

After the fix, rerun Linux boot in lock step, and regenerate Chapter 6 synthesis results.

  assign HTRANS = (CurrState == ADR_PHASE & HREADY & ((|BusRW) | (|CacheBusRW) | BusCMOZero) & ~Flush) |
                  (CurrState == ATOMIC_READ_DATA_PHASE) | 
                  (CacheAccess & FinalBeatCount & |CacheBusRW & HREADY & ~Flush) ? AHB_NONSEQ : // if we have a pipelined request
                  (CacheAccess & |BeatCount) ? (BURST_EN ? AHB_SEQ : AHB_NONSEQ) : AHB_IDLE;
PCSrcE (net)                                        0.005546            0.000000   2.174526 r
  ifu/PCSrcE (ifu__598949)                                                0.000000   2.174526 r
  ifu/PCSrcE (net)                                    0.005546            0.000000   2.174526 r
  ifu/U5/Y (sky130_osu_sc_12T_ms__buf_1)                        0.076231  0.110984   2.285510 r
  ifu/BPWrongE (net)                            2     0.007587            0.000000   2.285510 r
  ifu/BPWrongE (ifu__598949)                                              0.000000   2.285510 r
  BPWrongE (net)                                      0.007587            0.000000   2.285510 r
  hzu/BPWrongE (hazard__598949)                                           0.000000   2.285510 r
  hzu/BPWrongE (net)                                  0.007587            0.000000   2.285510 r
  hzu/U4/Y (sky130_osu_sc_12T_ms__inv_2)                        0.036381  0.048787   2.334297 f
  hzu/n8 (net)                                  3     0.009074            0.000000   2.334297 f
  hzu/U3/Y (sky130_osu_sc_12T_ms__inv_2)                        0.052211  0.057438   2.391736 r
  hzu/FlushD (net)                              4     0.010859            0.000000   2.391736 r
  hzu/FlushD (hazard__598949)                                             0.000000   2.391736 r
  FlushD (net)                                        0.010859            0.000000   2.391736 r
  ifu/FlushD (ifu__598949)                                                0.000000   2.391736 r
  ifu/FlushD (net)                                    0.010859            0.000000   2.391736 r
  ifu/bus.passthrough.ahbinterface/Flush (ahbinterface_32_0)              0.000000   2.391736 r
  ifu/bus.passthrough.ahbinterface/Flush (net)        0.010859            0.000000   2.391736 r
  ifu/bus.passthrough.ahbinterface/busfsm/Flush (busfsm_1)                0.000000   2.391736 r
  ifu/bus.passthrough.ahbinterface/busfsm/Flush (net) 0.010859            0.000000   2.391736 r
  ifu/bus.passthrough.ahbinterface/busfsm/U29/Y (sky130_osu_sc_12T_ms__nor2_1)
                                                                0.040983  0.046972   2.438707 f
  ifu/bus.passthrough.ahbinterface/busfsm/HTRANS[1] (net)
                                                2     0.004385            0.000000   2.438707 f
  ifu/bus.passthrough.ahbinterface/busfsm/HTRANS[1] (busfsm_1)            0.000000   2.438707 f
  ifu/bus.passthrough.ahbinterface/HTRANS[1] (net)    0.004385            0.000000   2.438707 f
  ifu/bus.passthrough.ahbinterface/HTRANS[1] (ahbinterface_32_0)          0.000000   2.438707 f
  ifu/IFUHTRANS[1] (net)                              0.004385            0.000000   2.438707 f
  ifu/IFUHTRANS[1] (ifu__598949)                                          0.000000   2.438707 f
  IFUHTRANS[1] (net)                                  0.004385            0.000000   2.438707 f
  ebu.ebu/IFUHTRANS[1] (ebu__598949)                                      0.000000   2.438707 f
  ebu.ebu/IFUHTRANS[1] (net)                          0.004385            0.000000   2.438707 f
  ebu.ebu/IFUInput/HTRANSIn[1] (controllerinput_PA_BITS34)                0.000000   2.438707 f
  ebu.ebu/IFUInput/HTRANSIn[1] (net)                  0.004385            0.000000   2.438707 f
  ebu.ebu/IFUInput/genblk1.RestorMux/d0[35] (mux2_WIDTH43)                0.000000   2.438707 f
  ebu.ebu/IFUInput/genblk1.RestorMux/d0[35] (net)     0.004385            0.000000   2.438707 f
  ebu.ebu/IFUInput/genblk1.RestorMux/U4/Y (sky130_osu_sc_12T_ms__oai21_l)
                                                                0.140213  0.116030   2.554738 r
  ebu.ebu/IFUInput/genblk1.RestorMux/n12 (net)
                                                1     0.004894            0.000000   2.554738 r
  ebu.ebu/IFUInput/genblk1.RestorMux/U3/Y (sky130_osu_sc_12T_ms__inv_2)
                                                                0.055106  0.071135   2.625873 f
  ebu.ebu/IFUInput/genblk1.RestorMux/y[35] (net)
                                                5     0.012306            0.000000   2.625873 f
  ebu.ebu/IFUInput/genblk1.RestorMux/y[35] (mux2_WIDTH43)                 0.000000   2.625873 f
  ebu.ebu/IFUInput/N0 (net)                           0.012306            0.000000   2.625873 f
  ebu.ebu/IFUInput/Request (controllerinput_PA_BITS34)                    0.000000   2.625873 f
  ebu.ebu/IFUReq (net)                                0.012306            0.000000   2.625873 f
  ebu.ebu/ebufsmarb/IFUReq (ebufsmarb)                                    0.000000   2.625873 f
  ebu.ebu/ebufsmarb/IFUReq (net)                      0.012306            0.000000   2.625873 f
  ebu.ebu/ebufsmarb/U16/Y (sky130_osu_sc_12T_ms__nand2_1)       0.057364  0.067131   2.693004 r
  ebu.ebu/ebufsmarb/n6 (net)                    1     0.004894            0.000000   2.693004 r
  ebu.ebu/ebufsmarb/U17/Y (sky130_osu_sc_12T_ms__inv_2)         0.039137  0.050475   2.743479 f
  ebu.ebu/ebufsmarb/IFUSave (net)               4     0.011732            0.000000   2.743479 f
  ebu.ebu/ebufsmarb/IFUSave (ebufsmarb)                                   0.000000   2.743479 f
  ebu.ebu/IFUSave (net)                               0.011732            0.000000   2.743479 f
  ebu.ebu/IFUInput/Save (controllerinput_PA_BITS34)                       0.000000   2.743479 f
  ebu.ebu/IFUInput/Save (net)                         0.011732            0.000000   2.743479 f
  ebu.ebu/IFUInput/genblk1.SaveReg/en (flopenr_WIDTH43)                   0.000000   2.743479 f
  ebu.ebu/IFUInput/genblk1.SaveReg/en (net)           0.011732            0.000000   2.743479 f
  ebu.ebu/IFUInput/genblk1.SaveReg/U52/Y (sky130_osu_sc_12T_ms__inv_2)
                                                                0.029795  0.042582   2.786060 r
  ebu.ebu/IFUInput/genblk1.SaveReg/n32 (net)
                                                2     0.005157            0.000000   2.786060 r
  ebu.ebu/IFUInput/genblk1.SaveReg/U17/Y (sky130_osu_sc_12T_ms__nand2_1)
                                                                0.088478  0.080056   2.866116 f
  ebu.ebu/IFUInput/genblk1.SaveReg/n20 (net)
                                                1     0.008764            0.000000   2.866116 f
  ebu.ebu/IFUInput/genblk1.SaveReg/U5/Y (sky130_osu_sc_12T_ms__inv_4)
                                                                0.087029  0.102538   2.968654 r
  ebu.ebu/IFUInput/genblk1.SaveReg/n98 (net)
                                               18     0.035834            0.000000   2.968654 r
  ebu.ebu/IFUInput/genblk1.SaveReg/U61/Y (sky130_osu_sc_12T_ms__nand2_l)
                                                                0.070212  0.062284   3.030937 f
  ebu.ebu/IFUInput/genblk1.SaveReg/n38 (net)
                                                1     0.002488            0.000000   3.030937 f
  ebu.ebu/IFUInput/genblk1.SaveReg/U31/Y (sky130_osu_sc_12T_ms__nand2_1)
                                                                0.048481  0.059047   3.089985 r
  ebu.ebu/IFUInput/genblk1.SaveReg/n46 (net)
                                                1     0.002852            0.000000   3.089985 r
  ebu.ebu/IFUInput/genblk1.SaveReg/q_reg[8]/D (sky130_osu_sc_12T_ms__dff_1)
                                                                0.048481  0.000000   3.089985 r
  data arrival time                                                                  3.089985

  clock clk (rise edge)                                                   2.525253   2.525253
  clock network delay (ideal)                                             0.000000   2.525253
  ebu.ebu/IFUInput/genblk1.SaveReg/q_reg[8]/CK (sky130_osu_sc_12T_ms__dff_1)
                                                                          0.000000   2.525253 r
  library setup time                                                      -0.135478  2.389775
  data required time                                                                 2.389775
  ----------------------------------------------------------------------------------------------
  data required time                                                                 2.389775
  data arrival time                                                                  -3.089985
  ----------------------------------------------------------------------------------------------
  slack (VIOLATED)                                                                   -0.700210
davidharrishmc commented 1 week ago

Could be solved with an extra cycle of latency on bus requests.