Rocket - core - fence, fence_i, sfence
https://mp.weixin.qq.com/s/Nzm5m0Ub6SmQ-CWf4kaFKQ
简单介绍fence, fence_i, sfence的差异。
1. IntCtrlSigs
IntCtrlSigs中包含了fence和fence_i的定义:
FENCE指令的信号值如下:
其中:fence_i = N, fence = Y.
FENCE_I指令的信号值如下:
其中:fence_i = Y, fence = Y.
SFENCE_VMA指令的信号值如下:
其中,fence_i = N, fence = N.
从中可以看出:
a. id_ctrl.fence_i表示指令为fence_i指令;
b. id_ctrl.fence表示指令为fence或fence_i指令,具有fence效果;
c. id_ctrl.fence和id_ctrl.fence_i无法标识sfence.vma指令;
因为只有sfence.vma指令的mem_cmd=M_SFENCE,所以可以使用这个信号来标识sfence.vma指令。
2. id_ctrl.fence和id_ctrl.fence_i
id_do_fence的值根据id_ctrl.fence和id_ctrl.fence_i生成:
进而更新ctrl_stalld的值:
导致id阶段被暂停。
3. id_ctrl.mem和id_ctrl.mem_cmd
sfence.vma指令触发id_csr_flush:
id_csr_flush进而导致流水线被刷新。
相较于fence_i指令,不同之处在于sfence.vma还有其他的效果。