Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenXiangShan
XiangShan
提交
10b26c4c
X
XiangShan
项目概览
OpenXiangShan
/
XiangShan
10 个月 前同步成功
通知
1183
Star
3914
Fork
526
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
XiangShan
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
10b26c4c
编写于
8月 01, 2020
作者:
J
jinyue110
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
uBTB: add Debug Info
上级
e0b1f2a4
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
28 addition
and
16 deletion
+28
-16
src/main/scala/xiangshan/frontend/uBTB.scala
src/main/scala/xiangshan/frontend/uBTB.scala
+28
-16
未找到文件。
src/main/scala/xiangshan/frontend/uBTB.scala
浏览文件 @
10b26c4c
...
...
@@ -26,21 +26,23 @@ class MicroBTB extends BasePredictor
val
isRVC
=
Vec
(
PredictWidth
,
Bool
())
}
class
MicroBTB
PredictMeta
extends
Meta
class
MicroBTB
BranchInfo
extends
Meta
{
val
writeWay
=
UInt
(
log2Ceil
(
nWays
).
W
)
val
writeWay
=
Vec
(
PredictWidth
,
UInt
(
log2Ceil
(
nWays
).
W
)
)
val
hits
=
Vec
(
PredictWidth
,
Bool
())
}
val
out_u
BTBMeta
=
Wire
(
new
MicroBTBPredictMeta
)
override
val
uBTBMetaLen
=
out_u
BTBMeta
.
asUInt
.
getWidth
val
out_u
btb_br_info
=
Wire
(
new
MicroBTBBranchInfo
)
override
val
uBTBMetaLen
=
out_u
btb_br_info
.
asUInt
.
getWidth
class
MicroBTBIO
extends
DefaultBasePredictorIO
{
val
out
=
Output
(
new
MicroBTBResp
)
//
val
uBTB
Meta
=
Output
(
new
MicroBTBPredictMeta
)
val
uBTB
BranchInfo
=
Output
(
new
MicroBTBBranchInfo
)
}
val
io
=
IO
(
new
MicroBTBIO
)
io
.
uBTBBranchInfo
<>
out_ubtb_br_info
io
.
out
.
targets
.
map
(
_
.
valid
:
false.B
)
def
getTag
(
pc
:
UInt
)
=
pc
>>
(
log2Ceil
(
PredictWidth
)
+
1
).
U
def
getBank
(
pc
:
UInt
)
=
pc
(
log2Ceil
(
PredictWidth
)
,
1
)
...
...
@@ -52,6 +54,7 @@ class MicroBTB extends BasePredictor
Mux
(
taken
,
old
+
1.
U
,
old
-
1.
U
)))
}
class
MicroBTBMeta
extends
XSBundle
{
val
is_Br
=
Bool
()
...
...
@@ -75,6 +78,8 @@ class MicroBTB extends BasePredictor
val
read_req_tag
=
getTag
(
io
.
pc
.
bits
)
val
read_req_basebank
=
getBank
(
io
.
pc
.
bits
)
val
read_mask
=
io
.
inMask
XSDebug
(
read_valid
,
"uBTB read req: pc:0x%x, tag:%x basebank:%d\n"
,
io
.
pc
.
bits
,
read_req_tag
,
read_req_basebank
)
class
ReadRespEntry
extends
XSBundle
{
...
...
@@ -105,18 +110,19 @@ class MicroBTB extends BasePredictor
val
uBTBMeta_resp
=
uBTBMeta
(
i
)(
read_hit_ways
(
i
))
val
btb_resp
=
uBTB
(
i
)(
read_hit_ways
(
i
))
var
index
=
0
read_resp
(
i
).
valid
:=
uBTBMeta_resp
.
valid
&&
read_hit_vec
(
i
)
&&
read_mask
(
index
)
read_resp
(
i
).
taken
:=
read_resp
(
i
).
valid
&&
uBTBMeta_resp
.
pred
(
1
)
read_resp
(
i
).
notTaken
:=
read_resp
(
i
).
valid
&&
!
uBTBMeta_resp
.
pred
(
1
)
read_resp
(
i
).
target
:=
(
io
.
pc
.
bits
).
asSInt
+
(
index
<<
1
).
S
+
btb_resp
.
offset
read_resp
(
index
).
valid
:=
uBTBMeta_resp
.
valid
&&
read_hit_vec
(
i
)
&&
read_mask
(
index
)
read_resp
(
index
).
taken
:=
read_resp
(
i
).
valid
&&
uBTBMeta_resp
.
pred
(
1
)
read_resp
(
index
).
notTaken
:=
read_resp
(
i
).
valid
&&
!
uBTBMeta_resp
.
pred
(
1
)
read_resp
(
index
).
target
:=
(
io
.
pc
.
bits
).
asSInt
+
(
index
<<
1
).
S
+
btb_resp
.
offset
read_resp
(
index
).
isRVC
:=
read_resp
(
index
).
valid
&&
uBTBMeta_resp
.
isRVC
index
+=
1
out_u
BTBMeta
.
hits
(
i
)
:=
read_hit_vec
(
i
)
out_u
btb_br_info
.
hits
(
i
)
:=
read_hit_vec
(
i
)
}
}
//TODO: way alloc algorithm
val
alloc_way
=
{
val
alloc_way
=
{
val
r_uBTBMetas
=
Cat
(
VecInit
(
uBTBMeta
.
map
(
e
=>
VecInit
(
e
.
map
(
_
.
tag
)))).
asUInt
,
(
read_req_tag
)(
tagSize
-
1
,
0
))
val
l
=
log2Ceil
(
nWays
)
val
nChunks
=
(
r_uBTBMetas
.
getWidth
+
l
-
1
)
/
l
...
...
@@ -125,8 +131,12 @@ class MicroBTB extends BasePredictor
}
chunks
.
reduce
(
_
^
_
)
}
val
out_uBTBMeta
.
writeWay
=
Mux
(
read_hit
,
read_hit_way
,
alloc_way
)
out_ubtb_br_info
.
writeWay
.
map
(
_
:=
Mux
(
read_hit
,
read_hit_way
,
alloc_way
))
XSDebug
(
read_valid
,
"uBTB read resp: read_hit_vec:%d, read_hit_way:%d alloc_way:%d\n"
,
read_hit_vec
,
read_hit_way
,
alloc_way
)
for
(
i
<-
0
until
PredictWidth
)
{
XSDebug
(
read_valid
,
"bank(%d) hit:%d way:%d valid:%d isRVC:%d taken:%d notTaken:%d target:0x%x\n"
,
i
.
U
,
read_hit_vec
(
i
),
read_hit_ways
(
i
),
read_resp
(
i
).
valid
,
read_resp
(
i
).
isRVC
,
read_resp
(
i
).
taken
,
read_resp
(
i
).
notTaken
,
read_resp
(
i
).
target
)
}
//response
//only when hit and instruction valid and entry valid can output data
for
(
i
<-
0
until
PredictWidth
)
...
...
@@ -160,7 +170,7 @@ class MicroBTB extends BasePredictor
val
update_taget_offset
=
io
.
update
.
bits
.
target
.
asSInt
-
update_br_pc
.
asSInt
val
update_is_BR_or_JAL
=
(
io
.
update
.
bits
.
pd
.
brType
===
BrType
.
branch
)
||
(
io
.
update
.
bits
.
pd
.
brType
===
BrType
.
jal
)
val
uBTB_write_valid
=
io
.
update
.
valid
&&
io
.
update
.
bits
.
isMisPred
val
uBTB_write_valid
=
io
.
update
.
valid
&&
io
.
update
.
bits
.
isMisPred
&&
update_is_BR_or_JAL
val
uBTB_Meta_write_valid
=
io
.
update
.
valid
&&
update_is_BR_or_JAL
//write btb target when miss prediction
when
(
uBTB_write_valid
)
...
...
@@ -181,8 +191,9 @@ class MicroBTB extends BasePredictor
satUpdate
(
uBTBMeta
(
update_bank
)(
update_write_way
).
pred
,
2
,
update_taken
)
)
}
//bypass:read-after-write
XSDebug
(
uBTB_Meta_write_valid
,
"uBTB update: update fetch pc:0x%x | real pc:0x%x | update hits%b | update_write_way:%d\n"
,
update_fetch_pc
,
update_br_pc
,
update_hits
,
update_write_way
)
//bypass:read-after-write
val
rawBypassHit
=
Wire
(
Vec
(
PredictWidth
,
Bool
()))
for
(
b
<-
0
until
PredictWidth
)
{
when
(
update_bank
===
b
.
U
&&
read_hit_vec
(
b
)
&&
uBTB_Meta_write_valid
&&
read_valid
...
...
@@ -192,6 +203,7 @@ class MicroBTB extends BasePredictor
io
.
out
.
takens
(
b
)
:=
io
.
update
.
bits
.
taken
io
.
out
.
isRVC
(
b
)
:=
io
.
update
.
bits
.
pd
.
isRVC
io
.
out
.
notTakens
(
b
)
:=
(
io
.
update
.
bits
.
pd
.
brType
===
BrType
.
branch
)
&&
(!
io
.
out
.
takens
(
b
))
XSDebug
(
"uBTB bypass hit!\n"
)
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录