Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenXiangShan
XiangShan
提交
9435fd6f
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 搜索 >>
提交
9435fd6f
编写于
10月 26, 2021
作者:
Z
zoujr
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
BPU: Change the u in the TAGE from register to SRAM implementation
上级
c8967b56
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
59 addition
and
16 deletion
+59
-16
src/main/scala/utils/SRAMTemplate.scala
src/main/scala/utils/SRAMTemplate.scala
+32
-0
src/main/scala/xiangshan/frontend/Tage.scala
src/main/scala/xiangshan/frontend/Tage.scala
+27
-16
未找到文件。
src/main/scala/utils/SRAMTemplate.scala
浏览文件 @
9435fd6f
...
...
@@ -150,6 +150,38 @@ class SRAMTemplate[T <: Data](gen: T, set: Int, way: Int = 1,
}
class
FoldedSRAMTemplate
[
T
<:
Data
](
gen
:
T
,
set
:
Int
,
width
:
Int
=
4
,
shouldReset
:
Boolean
=
false
,
holdRead
:
Boolean
=
false
,
singlePort
:
Boolean
=
false
,
bypassWrite
:
Boolean
=
false
)
extends
Module
{
val
io
=
IO
(
new
Bundle
{
val
r
=
Flipped
(
new
SRAMReadBus
(
gen
,
set
,
1
))
val
w
=
Flipped
(
new
SRAMWriteBus
(
gen
,
set
,
1
))
})
require
(
width
>
0
&&
isPow2
(
width
))
require
(
set
%
width
==
0
)
val
nRows
=
set
/
width
val
array
=
Module
(
new
SRAMTemplate
(
gen
,
set
=
nRows
,
way
=
width
,
shouldReset
=
shouldReset
,
holdRead
=
holdRead
,
singlePort
=
singlePort
))
io
.
r
.
req
.
ready
:=
array
.
io
.
r
.
req
.
ready
io
.
w
.
req
.
ready
:=
array
.
io
.
w
.
req
.
ready
val
raddr
=
io
.
r
.
req
.
bits
.
setIdx
>>
log2Ceil
(
width
)
val
ridx
=
RegNext
(
io
.
r
.
req
.
bits
.
setIdx
(
log2Ceil
(
width
)-
1
,
0
))
val
ren
=
io
.
r
.
req
.
valid
array
.
io
.
r
.
req
.
valid
:=
ren
array
.
io
.
r
.
req
.
bits
.
setIdx
:=
raddr
io
.
r
.
resp
.
data
(
0
)
:=
array
.
io
.
r
.
resp
.
data
(
ridx
)
val
wen
=
io
.
w
.
req
.
valid
val
wdata
=
VecInit
(
Seq
.
fill
(
width
)(
io
.
w
.
req
.
bits
.
data
(
0
)))
val
waddr
=
io
.
w
.
req
.
bits
.
setIdx
>>
log2Ceil
(
width
)
val
wmask
=
UIntToOH
(
io
.
w
.
req
.
bits
.
setIdx
(
log2Ceil
(
width
)-
1
,
0
))
array
.
io
.
w
.
apply
(
wen
,
wdata
,
waddr
,
wmask
)
}
class
SRAMTemplateWithArbiter
[
T
<:
Data
](
nRead
:
Int
,
gen
:
T
,
set
:
Int
,
way
:
Int
=
1
,
shouldReset
:
Boolean
=
false
)
extends
Module
{
val
io
=
IO
(
new
Bundle
{
...
...
src/main/scala/xiangshan/frontend/Tage.scala
浏览文件 @
9435fd6f
...
...
@@ -37,6 +37,7 @@ trait TageParams extends HasBPUConst with HasXSParameter {
val
TageBanks
=
numBr
val
UBitPeriod
=
256
val
TageCtrBits
=
3
val
uFoldedWidth
=
8
val
TotalBits
=
BankTageTableInfos
.
map
{
info
=>
info
.
map
{
...
...
@@ -310,8 +311,8 @@ class TageTable
// val s1_pc = io.req.bits.pc
val
req_unhashed_idx
=
getUnhashedIdx
(
io
.
req
.
bits
.
pc
)
val
hi_us
=
Module
(
new
Folded
1WDataModuleTemplate
(
Bool
(),
nRows
,
numRead
=
1
,
isSync
=
true
,
width
=
8
))
val
lo_us
=
Module
(
new
Folded
1WDataModuleTemplate
(
Bool
(),
nRows
,
numRead
=
1
,
isSync
=
true
,
width
=
8
))
val
hi_us
=
Module
(
new
Folded
SRAMTemplate
(
Bool
(),
nRows
,
width
=
uFoldedWidth
,
shouldReset
=
true
,
holdRead
=
true
))
val
lo_us
=
Module
(
new
Folded
SRAMTemplate
(
Bool
(),
nRows
,
width
=
uFoldedWidth
,
shouldReset
=
true
,
holdRead
=
true
))
val
table
=
Module
(
new
SRAMTemplate
(
new
TageEntry
,
set
=
nRows
,
way
=
1
,
shouldReset
=
true
,
holdRead
=
true
,
singlePort
=
false
))
...
...
@@ -320,14 +321,16 @@ class TageTable
table
.
io
.
r
.
req
.
valid
:=
io
.
req
.
valid
table
.
io
.
r
.
req
.
bits
.
setIdx
:=
s0_idx
hi_us
.
io
.
raddr
(
0
)
:=
s0_idx
lo_us
.
io
.
raddr
(
0
)
:=
s0_idx
hi_us
.
io
.
r
.
req
.
valid
:=
io
.
req
.
valid
hi_us
.
io
.
r
.
req
.
bits
.
setIdx
:=
s0_idx
lo_us
.
io
.
r
.
req
.
valid
:=
io
.
req
.
valid
lo_us
.
io
.
r
.
req
.
bits
.
setIdx
:=
s0_idx
val
s1_idx
=
RegEnable
(
s0_idx
,
io
.
req
.
valid
)
val
s1_tag
=
RegEnable
(
s0_tag
,
io
.
req
.
valid
)
val
hi_us_r
=
hi_us
.
io
.
r
data
(
0
)
// s1
val
lo_us_r
=
lo_us
.
io
.
r
data
(
0
)
// s1
val
hi_us_r
=
hi_us
.
io
.
r
.
resp
.
data
(
0
)
val
lo_us_r
=
lo_us
.
io
.
r
.
resp
.
data
(
0
)
val
table_r
=
table
.
io
.
r
.
resp
.
data
(
0
)
// s1
...
...
@@ -366,16 +369,24 @@ class TageTable
val
update_lo_wdata
=
Wire
(
Bool
())
val
hi_wen
=
io
.
update
.
uMask
||
doing_clear_u_hi
hi_us
.
io
.
wen
:=
hi_wen
hi_us
.
io
.
wdata
:=
Mux
(
doing_clear_u_hi
,
false
.
B
,
update_hi_wdata
)
hi_us
.
io
.
waddr
:=
Mux
(
doing_clear_u_hi
,
clear_u_idx
,
update_idx
)
val
hi_us_wdata
=
Mux
(
doing_clear_u_hi
,
false
.
B
,
update_hi_wdata
)
val
hi_us_setIdx
=
Mux
(
doing_clear_u_hi
,
clear_u_idx
,
update_idx
)
hi_us
.
io
.
w
.
apply
(
valid
=
hi_wen
,
data
=
hi_us_wdata
,
setIdx
=
hi_us_setIdx
,
waymask
=
true
.
B
)
val
lo_wen
=
io
.
update
.
uMask
||
doing_clear_u_lo
lo_us
.
io
.
wen
:=
lo_wen
lo_us
.
io
.
wdata
:=
Mux
(
doing_clear_u_lo
,
false
.
B
,
update_lo_wdata
)
lo_us
.
io
.
waddr
:=
Mux
(
doing_clear_u_lo
,
clear_u_idx
,
update_idx
)
val
lo_us_wdata
=
Mux
(
doing_clear_u_lo
,
false
.
B
,
update_lo_wdata
)
val
lo_us_setIdx
=
Mux
(
doing_clear_u_lo
,
clear_u_idx
,
update_idx
)
lo_us
.
io
.
w
.
apply
(
valid
=
lo_wen
,
data
=
lo_us_wdata
,
setIdx
=
lo_us_setIdx
,
waymask
=
true
.
B
)
class
WrBypass
extends
XSModule
{
...
...
@@ -693,7 +704,7 @@ class Tage(implicit p: Parameters) extends BaseTage {
}
// update base table if used base table to predict
when
(
updateValid
)
{
when
(
updateValid
)
{
when
(
updateMeta
.
provider
.
valid
)
{
when
(~
up_altpredhit
&&
updateMisPred
&&
(
updateMeta
.
predcnt
===
3.
U
||
updateMeta
.
predcnt
===
4.
U
))
{
baseupdate
(
w
)
:=
true
.
B
...
...
@@ -710,7 +721,7 @@ class Tage(implicit p: Parameters) extends BaseTage {
baseupdate
(
w
)
:=
false
.
B
}
updatebcnt
(
w
)
:=
updateMeta
.
basecnt
// if mispredicted and not the case that
// provider offered correct target but used altpred due to unconfident
when
(
updateValid
&&
updateMisPred
&&
~((
updateMeta
.
predcnt
===
3.
U
&&
~
isUpdateTaken
||
updateMeta
.
predcnt
===
4.
U
&&
isUpdateTaken
)
&&
updateMeta
.
provider
.
valid
))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录