iT邦幫忙

2026 iThome 鐵人賽

DAY 23
0
Software Development

猴子都寫得出來的 RISC-V OoO CPU系列 第 23 篇

CPU Branch Stalled Behavior

  • 分享至 

  • xImage
  •  

我們這次就用下面這個例子來做測試

  addi x10,x0,80
  addi x11,x0,2
  div  x1, x10, x11       # Eventually x1 = 40
  beq  x1, x0, done       # Waits for DIV; ultimately not taken
  addi x2, x0, 7
  addi x3, x0, 9
  mul  x4, x2, x3
  add  x5, x4, x2
  done:
  add  x6, x5, x0

老方法
一樣先用一道指令讓 fetch 不會成為瓶頸
然後我們可以很明顯地看到採用 block 的 前面三個實作都會卡在同一個地方
只有最後一個能夠 recover rename map 的設計才能夠提前執行後面的指令
讓 branch 不會成為 out of order CPU 的限制

run log:

/workspace/rtl/build/rtl/rtl_single_inorder_tests
6: [PASS] divide-dependent branch with multiply [normal] rtl_cycles=112 systemc_cycles=112 retired=9
...
/workspace/rtl/build/rtl/rtl_dual_inorder_tests
7: [PASS] divide-dependent branch with multiply [stalled] rtl_cycles=123 systemc_cycles=123 retired=9
...
/workspace/rtl/build/rtl/rtl_dual_ooo_tests
8: [PASS] divide-dependent branch with multiply [normal] rtl_cycles=111 systemc_cycles=111 retired=9
...
/workspace/rtl/build/rtl/rtl_dual_ooo_retire_tests
9: [PASS] divide-dependent branch with multiply [normal] rtl_cycles=100 systemc_cycles=100 retired=9

git link with tag: https://github.com/hsufit/TINY5_OOO/tree/ithome2026_D23


上一篇
Branch Instruction Implementation
下一篇
Combination of Branch Sequence
系列文
猴子都寫得出來的 RISC-V OoO CPU 共 24 篇
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言