Rocket - core - structure/data/control hazard

https://mp.weixin.qq.com/s/sRYIPj9tlxuZAPZxwYpEYQ

 

简单介绍structure/data/control三大类hazard相关的实现。

 

参考链接:https://www.elsevier.com/__data/assets/powerpoint_doc/0004/273712/Chapter_04-RISC-V.ppt

 

1. 概述

 

Hazard是指Situations that prevent starting the next instruction in the next cycle。

主要分为三大类:

a. Structure hazards: A required resource is busy

b. Data hazard: Need to wait for previous instruction to complete its data read/write

c. Control hazard: Deciding on control action depends on previous instruction

 

2. structure hazard

 

在EX阶段有一个structure hazard,即replay_ex_structural:

包括两种情况:

a. 指令需要使用数据存储,但是数据存储没有ready,处于busy状态无法被使用;

b. 指令需要使用除法器,但是除法器没有ready,处于busy状态无法被使用;

 

在当前的实现中,对replay_ex_structural的处理方法是重新执行所需资源无法满足的指令。

 

3. data hazard

 

data hazard包括如下几种情况:

a. ID和EX阶段之间的hazard;

b. ID和MEM阶段之间的hazard;

c. ID和WB阶段之间的hazard;

d. ID和MEM阶段之间还有一种load-use hazard;

 

处理方法有如下几种:

a. 能bypass的则使用bypass;

b. 不能使用bypass,但是可以stall的,则将后续指令stall在ID阶段;

c. 如果后续指令已经前进到EX阶段,则将其kill掉,然后重新执行(replay);

 

4. control hazard

 

在MEM阶段有一个control hazard,即mem_misprediction:

如果分支预测错误,则需要重新取指。

 

posted @ 2022-03-21 20:19  wjcdx  阅读(221)  评论(0编辑  收藏  举报