Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenXiangShan
XiangShan
提交
4a6bcc32
X
XiangShan
项目概览
OpenXiangShan
/
XiangShan
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
4a6bcc32
编写于
10月 18, 2020
作者:
J
jinyue110
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
icache: fix bug that page fault cause wrong MMIO request in icache
上级
91861c32
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
4 addition
and
38 deletion
+4
-38
src/main/scala/xiangshan/cache/icache.scala
src/main/scala/xiangshan/cache/icache.scala
+4
-38
未找到文件。
src/main/scala/xiangshan/cache/icache.scala
浏览文件 @
4a6bcc32
...
...
@@ -254,14 +254,11 @@ class ICacheImp(outer: ICache) extends ICacheModule(outer)
val
s3_hit
=
RegEnable
(
next
=
s2_hit
,
init
=
false
.
B
,
enable
=
s2_fire
)
val
s3_wayMask
=
RegEnable
(
next
=
waymask
,
init
=
0.
U
,
enable
=
s2_fire
)
val
s3_miss
=
s3_valid
&&
!
s3_hit
val
s3_mmio
=
s3_valid
&&
AddressSpace
.
isMMIO
(
s3_tlb_resp
.
paddr
)
when
(
io
.
flush
(
1
))
{
s3_valid
:=
false
.
B
}
.
elsewhen
(
s2_fire
)
{
s3_valid
:=
s2_valid
}
.
elsewhen
(
io
.
resp
.
fire
())
{
s3_valid
:=
false
.
B
}
val
refillDataReg
=
Reg
(
Vec
(
refillCycles
,
UInt
(
beatBits
.
W
)))
assert
(!(
s3_hit
&&
s3_mmio
),
"MMIO address should not hit in ICache!"
)
// icache hit
// simply cut the hit cacheline
val
dataHitWay
=
s3_data
.
map
(
b
=>
Mux1H
(
s3_wayMask
,
b
).
asUInt
)
...
...
@@ -269,15 +266,10 @@ class ICacheImp(outer: ICache) extends ICacheModule(outer)
outPacket
:=
cutHelper
(
VecInit
(
dataHitWay
),
s3_req_pc
(
5
,
1
).
asUInt
,
s3_req_mask
.
asUInt
)
//icache miss
val
s_idle
::
s_m
mioReq
::
s_mmioResp
::
s_memReadReq
::
s_memReadResp
::
s_wait_resp
::
Nil
=
Enum
(
6
)
val
s_idle
::
s_m
emReadReq
::
s_memReadResp
::
s_wait_resp
::
Nil
=
Enum
(
4
)
val
state
=
RegInit
(
s_idle
)
val
readBeatCnt
=
Counter
(
refillCycles
)
//uncache request
val
mmioBeatCnt
=
Counter
(
blockWords
)
val
mmioAddrReg
=
RegInit
(
0.
U
(
PAddrBits
.
W
))
val
mmioReg
=
Reg
(
Vec
(
blockWords
/
2
,
UInt
(
blockWords
.
W
)))
//pipeline flush register
val
needFlush
=
RegInit
(
false
.
B
)
when
(
io
.
flush
(
1
)
&&
(
state
=/=
s_idle
)
&&
(
state
=/=
s_wait_resp
)){
needFlush
:=
true
.
B
}
...
...
@@ -295,35 +287,14 @@ class ICacheImp(outer: ICache) extends ICacheModule(outer)
// state change to wait for a cacheline refill
val
countFull
=
readBeatCnt
.
value
===
(
refillCycles
-
1
).
U
val
mmioCntFull
=
mmioBeatCnt
.
value
===
(
blockWords
-
1
).
U
switch
(
state
){
is
(
s_idle
){
when
(
s3_mmio
&&
io
.
flush
===
0.
U
){
state
:=
s_mmioReq
mmioBeatCnt
.
value
:=
0.
U
mmioAddrReg
:=
s3_tlb_resp
.
paddr
}
.
elsewhen
(
s3_miss
&&
io
.
flush
===
0.
U
){
when
(
s3_miss
&&
io
.
flush
===
0.
U
){
state
:=
s_memReadReq
readBeatCnt
.
value
:=
0.
U
}
}
//mmio request
is
(
s_mmioReq
){
when
(
bus
.
a
.
fire
()){
state
:=
s_mmioResp
mmioAddrReg
:=
mmioAddrReg
+
8.
U
//consider MMIO response 64 bits valid data
}
}
is
(
s_mmioResp
){
when
(
edge
.
hasData
(
bus
.
d
.
bits
)
&&
bus
.
d
.
fire
())
{
mmioBeatCnt
.
inc
()
assert
(
refill_done
,
"MMIO response should be one beat only!"
)
mmioReg
(
mmioBeatCnt
.
value
)
:=
bus
.
d
.
bits
.
data
(
wordBits
-
1
,
0
)
state
:=
Mux
(
mmioCntFull
,
s_wait_resp
,
s_mmioReq
)
}
}
// memory request
is
(
s_memReadReq
){
...
...
@@ -355,7 +326,6 @@ class ICacheImp(outer: ICache) extends ICacheModule(outer)
val
refillFinalOneBeat
=
(
state
===
s_memReadResp
)
&&
bus
.
d
.
fire
()
&&
refill_done
val
wayNum
=
OHToUInt
(
waymask
)
val
validPtr
=
Cat
(
get_idx
(
s3_req_pc
),
wayNum
)
//metaWrite.tag := get_tag(s3_req_pc)
metaWrite
.
tag
:=
s3_tag
metaArray
.
io
.
w
.
req
.
valid
:=
refillFinalOneBeat
metaArray
.
io
.
w
.
req
.
bits
.
apply
(
data
=
metaWrite
,
setIdx
=
get_idx
(
s3_req_pc
),
waymask
=
s3_wayMask
)
...
...
@@ -446,16 +416,12 @@ class ICacheImp(outer: ICache) extends ICacheModule(outer)
bus
.
b
.
ready
:=
true
.
B
bus
.
c
.
valid
:=
false
.
B
bus
.
e
.
valid
:=
false
.
B
bus
.
a
.
valid
:=
(
state
===
s_memReadReq
)
||
(
state
===
s_mmioReq
)
bus
.
a
.
valid
:=
(
state
===
s_memReadReq
)
val
memTileReq
=
edge
.
Get
(
fromSource
=
cacheID
.
U
,
toAddress
=
groupPC
(
s3_tlb_resp
.
paddr
),
lgSize
=
(
log2Up
(
cacheParams
.
blockBytes
)).
U
).
_2
val
mmioTileReq
=
edge
.
Get
(
fromSource
=
cacheID
.
U
,
toAddress
=
mmioAddrReg
,
lgSize
=
(
log2Up
(
wordBits
)).
U
).
_2
bus
.
a
.
bits
:=
Mux
((
state
===
s_mmioReq
),
mmioTileReq
,
memTileReq
)
bus
.
a
.
bits
:=
memTileReq
bus
.
d
.
ready
:=
true
.
B
XSDebug
(
"[flush] flush_0:%d flush_1:%d\n"
,
io
.
flush
(
0
),
io
.
flush
(
1
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录