Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenXiangShan
XiangShan
提交
d78771d7
X
XiangShan
项目概览
OpenXiangShan
/
XiangShan
9 个月 前同步成功
通知
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 搜索 >>
提交
d78771d7
编写于
8月 09, 2021
作者:
L
Lingrui98
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ftq: mask cfiIndex.valid when the corresponding inst is not executed, code clean ups
上级
09371bb8
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
51 addition
and
44 deletion
+51
-44
src/main/scala/xiangshan/decoupled-frontend/NewFtq.scala
src/main/scala/xiangshan/decoupled-frontend/NewFtq.scala
+51
-44
未找到文件。
src/main/scala/xiangshan/decoupled-frontend/NewFtq.scala
浏览文件 @
d78771d7
...
...
@@ -676,31 +676,25 @@ class Ftq(implicit p: Parameters) extends XSModule with HasCircularQueuePtrHelpe
val
ftqIdx
=
new
FtqPtr
val
ftqOffset
=
UInt
(
4.
W
)
val
flushItSelf
=
Bool
()
def
apply
(
valid
:
Bool
,
idx
:
FtqPtr
,
offset
:
UInt
,
flushItSelf
:
Bool
=
false
.
B
)
=
{
this
.
valid
:=
valid
this
.
ftqIdx
:=
i
dx
this
.
ftqOffset
:=
o
ffset
this
.
flushItSelf
:=
flushItSelf
def
apply
(
redirect
:
Valid
[
Redirect
]
)
=
{
this
.
valid
:=
redirect
.
valid
this
.
ftqIdx
:=
redirect
.
bits
.
ftqI
dx
this
.
ftqOffset
:=
redirect
.
bits
.
ftqO
ffset
this
.
flushItSelf
:=
RedirectLevel
.
flushItself
(
redirect
.
bits
.
level
)
this
}
}
val
redirectVec
=
Wire
(
Vec
(
3
,
new
RedirectInfo
))
redirectVec
(
0
).
apply
(
roqFlush
.
valid
,
roqFlush
.
bits
.
ftqIdx
,
roqFlush
.
bits
.
ftqOffset
)
redirectVec
(
1
).
apply
(
stage2Redirect
.
valid
,
stage2Redirect
.
bits
.
ftqIdx
,
stage2Redirect
.
bits
.
ftqOffset
,
RedirectLevel
.
flushItself
(
stage2Redirect
.
bits
.
level
)
)
redirectVec
(
2
).
apply
(
fromIfuRedirect
.
valid
,
fromIfuRedirect
.
bits
.
ftqIdx
,
fromIfuRedirect
.
bits
.
ftqOffset
)
val
roqRedirect
=
Wire
(
Valid
(
new
Redirect
))
roqRedirect
:=
DontCare
roqRedirect
.
valid
:=
roqFlush
.
valid
roqRedirect
.
bits
.
ftqIdx
:=
roqFlush
.
bits
.
ftqIdx
roqRedirect
.
bits
.
ftqOffset
:=
roqFlush
.
bits
.
ftqOffset
roqRedirect
.
bits
.
level
:=
RedirectLevel
.
flushAfter
redirectVec
.
zip
(
Seq
(
roqRedirect
,
stage2Redirect
,
fromIfuRedirect
)).
map
{
case
(
ve
,
r
)
=>
ve
(
r
)
}
// when redirect, we should reset ptrs and status queues
when
(
redirectVec
.
map
(
r
=>
r
.
valid
).
reduce
(
_
||
_
)){
...
...
@@ -717,9 +711,6 @@ class Ftq(implicit p: Parameters) extends XSModule with HasCircularQueuePtrHelpe
s
:=
c_invalid
}
})
when
(
next
.
value
=/=
commPtr
.
value
){
// if next.value === commPtr.value, ftq is full
commitStateQueue
(
next
.
value
).
foreach
(
_
:=
c_invalid
)
}
}
}
...
...
@@ -745,15 +736,7 @@ class Ftq(implicit p: Parameters) extends XSModule with HasCircularQueuePtrHelpe
s
===
c_invalid
||
s
===
c_commited
})).
andR
()
// need one cycle to read mem and srams
val
do_commit
=
RegNext
(
canCommit
,
init
=
false
.
B
)
val
do_commit_ptr
=
RegNext
(
commPtr
)
when
(
canCommit
)
{
commPtr
:=
commPtr
+
1.
U
}
val
commit_hit
=
entry_hit_status
(
do_commit_ptr
.
value
)
val
commit_entry_taken
=
cfiIndex_vec
(
do_commit_ptr
.
value
).
valid
val
commit_valid
=
commit_hit
===
h_hit
||
commit_entry_taken
// hit or taken
// commit reads
ftq_pc_mem
.
io
.
raddr
.
last
:=
commPtr
.
value
val
commit_pc_bundle
=
ftq_pc_mem
.
io
.
rdata
.
last
ftq_hist_mem
.
io
.
raddr
.
last
:=
commPtr
.
value
...
...
@@ -769,6 +752,24 @@ class Ftq(implicit p: Parameters) extends XSModule with HasCircularQueuePtrHelpe
ftb_entry_mem
.
io
.
raddr
.
last
:=
commPtr
.
value
val
commit_ftb_entry
=
ftb_entry_mem
.
io
.
rdata
.
last
// need one cycle to read mem and srams
val
do_commit
=
RegNext
(
canCommit
,
init
=
false
.
B
)
val
do_commit_ptr
=
RegNext
(
commPtr
)
when
(
canCommit
)
{
commPtr
:=
commPtr
+
1.
U
}
val
commit_state
=
RegNext
(
commitStateQueue
(
commPtr
.
value
))
val
commit_cfi
=
WireInit
(
RegNext
(
cfiIndex_vec
(
commPtr
.
value
)))
when
(
commit_state
(
commit_cfi
.
bits
)
=/=
c_commited
)
{
commit_cfi
.
valid
:=
false
.
B
}
val
commit_mispredict
=
VecInit
((
RegNext
(
mispredict_vec
(
commPtr
.
value
))
zip
commit_state
).
map
{
case
(
mis
,
state
)
=>
mis
&&
state
===
c_commited
})
val
commit_hit
=
RegNext
(
entry_hit_status
(
commPtr
.
value
))
val
commit_target
=
RegNext
(
update_target
(
commPtr
.
value
))
val
commit_valid
=
commit_hit
===
h_hit
||
commit_cfi
.
valid
// hit or taken
io
.
toBpu
.
update
:=
DontCare
io
.
toBpu
.
update
.
valid
:=
commit_valid
&&
do_commit
val
update
=
io
.
toBpu
.
update
.
bits
...
...
@@ -788,29 +789,30 @@ class Ftq(implicit p: Parameters) extends XSModule with HasCircularQueuePtrHelpe
ftbEntryGen
.
start_addr
:=
commit_pc_bundle
.
startAddr
ftbEntryGen
.
old_entry
:=
commit_ftb_entry
ftbEntryGen
.
pd
:=
commit_pd
ftbEntryGen
.
cfiIndex
:=
c
fiIndex_vec
(
do_commit_ptr
.
value
)
ftbEntryGen
.
target
:=
update_target
(
do_commit_ptr
.
value
)
ftbEntryGen
.
cfiIndex
:=
c
ommit_cfi
ftbEntryGen
.
target
:=
commit_target
ftbEntryGen
.
hit
:=
commit_real_hit
ftbEntryGen
.
mispredict_vec
:=
mispredict_vec
(
do_commit_ptr
.
value
)
ftbEntryGen
.
mispredict_vec
:=
commit_mispredict
update_ftb_entry
:=
ftbEntryGen
.
new_entry
update
.
new_br_insert_pos
:=
ftbEntryGen
.
new_br_insert_pos
update
.
mispred_mask
:=
ftbEntryGen
.
mispred_mask
update
.
old_entry
:=
ftbEntryGen
.
is_old_entry
// Cfi Info
if
(!
env
.
FPGAPlatform
&&
env
.
EnablePerfDebug
)
{
for
(
i
<-
0
until
PredictWidth
)
{
val
pc
=
commit_pc_bundle
.
startAddr
+
(
i
*
instBytes
).
U
val
v
=
commit
StateQueue
(
do_commit_ptr
.
value
)
(
i
)
===
c_commited
val
v
=
commit
_state
(
i
)
===
c_commited
val
isBr
=
commit_pd
.
brMask
(
i
)
val
isJmp
=
commit_pd
.
jmpInfo
.
valid
&&
commit_pd
.
jmpOffset
===
i
.
U
val
isCfi
=
isBr
||
isJmp
val
isTaken
=
c
fiIndex_vec
(
do_commit_ptr
.
value
).
valid
&&
cfiIndex_vec
(
do_commit_ptr
.
value
)
.
bits
===
i
.
U
val
misPred
=
mispredict_vec
(
do_commit_ptr
.
value
)
(
i
)
val
isTaken
=
c
ommit_cfi
.
valid
&&
commit_cfi
.
bits
===
i
.
U
val
misPred
=
commit_mispredict
(
i
)
val
ghist
=
commit_ghist
.
predHist
val
predCycle
=
commit_meta
.
meta
(
63
,
0
)
XSDebug
(
v
&&
do_commit
&&
isCfi
,
p
"cfi_update: isBr(${!isJmp}) pc(${Hexadecimal(pc)}) taken(${isTaken}) mispred(${misPred}) cycle($predCycle) hist(${Hexadecimal(ghist)}) startAddr(${
commit_pc_bundle.startAddr
})\n"
)
XSDebug
(
v
&&
do_commit
&&
isCfi
,
p
"cfi_update: isBr(${!isJmp}) pc(${Hexadecimal(pc)}) taken(${isTaken}) mispred(${misPred}) cycle($predCycle) hist(${Hexadecimal(ghist)}) startAddr(${
Hexadecimal(commit_pc_bundle.startAddr)
})\n"
)
}
}
...
...
@@ -821,7 +823,7 @@ class Ftq(implicit p: Parameters) extends XSModule with HasCircularQueuePtrHelpe
preds
.
is_call
:=
update_ftb_entry
.
jmpValid
&&
update_ftb_entry
.
isCall
preds
.
is_ret
:=
update_ftb_entry
.
jmpValid
&&
update_ftb_entry
.
isRet
preds
.
call_is_rvc
:=
update_ftb_entry
.
jmpValid
&&
update_ftb_entry
.
isCall
&&
update_ftb_entry
.
last_is_rvc
preds
.
target
:=
update_target
(
do_commit_ptr
.
value
)
preds
.
target
:=
commit_target
preds
.
taken_mask
:=
ftbEntryGen
.
taken_mask
...
...
@@ -855,9 +857,14 @@ class Ftq(implicit p: Parameters) extends XSModule with HasCircularQueuePtrHelpe
).
foldLeft
(
Map
[
String
,
UInt
]())(
_
+
_
)
// commit perf counters
val
commit_inst_mask
=
VecInit
(
commit
StateQueue
(
do_commit_ptr
.
value
)
.
map
(
c
=>
c
===
c_commited
&&
do_commit
)).
asUInt
val
commit_mispred_mask
=
mispredict_vec
(
do_commit_ptr
.
value
)
.
asUInt
val
commit_inst_mask
=
VecInit
(
commit
_state
.
map
(
c
=>
c
===
c_commited
&&
do_commit
)).
asUInt
val
commit_mispred_mask
=
commit_mispredict
.
asUInt
val
commit_not_mispred_mask
=
~
commit_mispred_mask
val
commit_num_inst_recording_vec
=
(
1
to
PredictWidth
).
map
(
i
=>
PopCount
(
commit_inst_mask
)
===
i
.
U
)
val
commit_num_inst_map
=
(
1
to
PredictWidth
).
map
(
i
=>
f
"commit_num_inst_$i"
->
(
commit_num_inst_recording_vec
(
i
-
1
)
&&
do_commit
)
).
foldLeft
(
Map
[
String
,
UInt
]())(
_
+
_
)
val
commit_br_mask
=
commit_pd
.
brMask
.
asUInt
val
commit_jmp_mask
=
UIntToOH
(
commit_pd
.
jmpOffset
)
&
Fill
(
PredictWidth
,
commit_pd
.
jmpInfo
.
valid
.
asTypeOf
(
UInt
(
1.
W
)))
...
...
@@ -949,7 +956,7 @@ class Ftq(implicit p: Parameters) extends XSModule with HasCircularQueuePtrHelpe
"ftb_jalr_target_modified"
->
PopCount
(
ftb_modified_entry_jalr_target_modified
),
"ftb_modified_entry_br_full"
->
PopCount
(
ftb_modified_entry_br_full
)
)
++
ftb_init_entry_len_map
++
ftb_modified_entry_len_map
++
enq_entry_len_map
++
to_ifu_entry_len_map
to_ifu_entry_len_map
++
commit_num_inst_map
for
((
key
,
value
)
<-
perfCountsMap
)
{
XSPerfAccumulate
(
key
,
value
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录