Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenXiangShan
XiangShan
提交
846c5699
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,发现更多精彩内容 >>
提交
846c5699
编写于
7月 30, 2020
作者:
A
Allen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Let DCache pipeline pass meta down.
Added some debug logs.
上级
123bb4bc
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
55 addition
and
8 deletion
+55
-8
src/main/scala/xiangshan/mem/cache/dcache.scala
src/main/scala/xiangshan/mem/cache/dcache.scala
+35
-4
src/main/scala/xiangshan/mem/cache/mshrs.scala
src/main/scala/xiangshan/mem/cache/mshrs.scala
+12
-1
src/test/scala/xiangshan/backend/exu/DCacheTest.scala
src/test/scala/xiangshan/backend/exu/DCacheTest.scala
+8
-3
未找到文件。
src/main/scala/xiangshan/mem/cache/dcache.scala
浏览文件 @
846c5699
...
...
@@ -8,6 +8,8 @@ import xiangshan.mem.{DCacheReq, DCacheResp, LSUDMemIO}
import
xiangshan.utils.XSDebug
import
bus.tilelink._
import
_root_.utils.
{
Code
,
RandomReplacement
,
Transpose
}
import
xiangshan.mem.MemoryOpConstants
// DCache specific parameters
// L1 DCache is 64set, 8way-associative, with 64byte block, a total of 32KB
...
...
@@ -430,6 +432,17 @@ class DCache extends DCacheModule
}
}
def
dump_pipeline_valids
(
pipeline_stage_name
:
String
,
signal_name
:
String
,
valid
:
Vec
[
Bool
])
=
{
val
anyValid
=
valid
.
reduce
(
_
||
_
)
when
(
anyValid
)
{
(
0
until
memWidth
)
map
{
w
=>
when
(
valid
(
w
))
{
XSDebug
(
s
"$pipeline_stage_name channel %d: $signal_name\n"
,
w
.
U
)
}
}
}
}
// stage 0
val
s0_valid
=
Mux
(
io
.
lsu
.
req
.
fire
(),
VecInit
(
io
.
lsu
.
req
.
bits
.
map
(
_
.
valid
)),
Mux
(
mshrs
.
io
.
replay
.
fire
(),
VecInit
(
1.
U
(
memWidth
.
W
).
asBools
),
...
...
@@ -437,6 +450,9 @@ class DCache extends DCacheModule
val
s0_req
=
Mux
(
io
.
lsu
.
req
.
fire
(),
VecInit
(
io
.
lsu
.
req
.
bits
.
map
(
_
.
bits
)),
replay_req
)
val
s0_type
=
Mux
(
io
.
lsu
.
req
.
fire
(),
t_lsu
,
t_replay
)
val
s0_meta
=
Mux
(
io
.
lsu
.
req
.
fire
(),
VecInit
(
io
.
lsu
.
req
.
bits
.
map
(
_
.
bits
.
meta
)),
Mux
(
mshrs
.
io
.
replay
.
fire
(),
VecInit
(
mshrs
.
io
.
replay
.
bits
.
meta
,
0.
U
(
MemoryOpConstants
.
META_SZ
.
W
)),
VecInit
(
0.
U
(
MemoryOpConstants
.
META_SZ
.
W
),
0.
U
(
MemoryOpConstants
.
META_SZ
.
W
))))
dump_pipeline_reqs
(
"DCache s0"
,
s0_valid
,
s0_req
,
s0_type
)
...
...
@@ -451,9 +467,8 @@ class DCache extends DCacheModule
// we send a nack
// all pipeline requests requires response or nack
// only mshr replayed loads needs to send resp
val
s0_send_resp_or_nack
=
Mux
(
io
.
lsu
.
req
.
fire
(),
s0_valid
,
VecInit
(
Mux
(
mshrs
.
io
.
replay
.
fire
()
&&
isRead
(
mshrs
.
io
.
replay
.
bits
.
cmd
),
1.
U
(
memWidth
.
W
),
0.
U
(
memWidth
.
W
)).
asBools
))
// all requests should send response back
val
s0_send_resp_or_nack
=
s0_valid
// stage 1
val
s1_req
=
RegNext
(
s0_req
)
...
...
@@ -463,6 +478,7 @@ class DCache extends DCacheModule
val
s1_nack
=
VecInit
(
0.
U
(
memWidth
.
W
).
asBools
)
val
s1_send_resp_or_nack
=
RegNext
(
s0_send_resp_or_nack
)
val
s1_type
=
RegNext
(
s0_type
)
val
s1_meta
=
RegNext
(
s0_meta
)
// For replays, the metadata isn't written yet
val
s1_replay_way_en
=
RegNext
(
mshrs
.
io
.
replay
.
bits
.
way_en
)
...
...
@@ -479,6 +495,7 @@ class DCache extends DCacheModule
// stage 2
val
s2_req
=
RegNext
(
s1_req
)
val
s2_type
=
RegNext
(
s1_type
)
val
s2_meta
=
RegNext
(
s1_meta
)
val
s2_valid
=
widthMap
(
w
=>
RegNext
(
s1_valid
(
w
),
init
=
false
.
B
))
...
...
@@ -539,6 +556,14 @@ class DCache extends DCacheModule
for
(
w
<-
0
until
memWidth
)
assert
(!(
s2_send_resp
(
w
)
&&
s2_send_nack
(
w
)))
dump_pipeline_valids
(
"DCache s2"
,
"s2_hit"
,
s2_hit
)
dump_pipeline_valids
(
"DCache s2"
,
"s2_nack"
,
s2_nack
)
dump_pipeline_valids
(
"DCache s2"
,
"s2_nack_hit"
,
s2_nack_hit
)
dump_pipeline_valids
(
"DCache s2"
,
"s2_nack_set_busy"
,
s2_nack_set_busy
)
dump_pipeline_valids
(
"DCache s2"
,
"s2_nack_no_mshr"
,
s2_nack_no_mshr
)
dump_pipeline_valids
(
"DCache s2"
,
"s2_send_resp"
,
s2_send_resp
)
dump_pipeline_valids
(
"DCache s2"
,
"s2_send_nack"
,
s2_send_nack
)
// hits always send a response
// If MSHR is not available, LSU has to replay this request later
// If MSHR is available and this is only a store(not a amo), we don't need to wait for resp later
...
...
@@ -613,7 +638,7 @@ class DCache extends DCacheModule
for
(
w
<-
0
until
memWidth
)
{
cache_resp
(
w
).
valid
:=
s2_valid
(
w
)
&&
(
s2_send_resp
(
w
)
||
s2_send_nack
(
w
))
cache_resp
(
w
).
bits
.
data
:=
s2_data_word
(
w
)
cache_resp
(
w
).
bits
.
meta
:=
0.
U
cache_resp
(
w
).
bits
.
meta
:=
s2_meta
(
w
)
cache_resp
(
w
).
bits
.
nack
:=
s2_send_nack
(
w
)
}
...
...
@@ -622,6 +647,12 @@ class DCache extends DCacheModule
// 返回结果
for
(
w
<-
0
until
memWidth
)
{
io
.
lsu
.
resp
(
w
)
<>
resp
(
w
)
val
channel_resp
=
io
.
lsu
.
resp
(
w
).
bits
when
(
io
.
lsu
.
resp
(
w
).
valid
)
{
XSDebug
(
s
"DCache resp channel $w: data: %x meta: %d nack: %b\n"
,
channel_resp
.
data
,
channel_resp
.
meta
,
channel_resp
.
nack
)
}
}
// Store/amo hits
...
...
src/main/scala/xiangshan/mem/cache/mshrs.scala
浏览文件 @
846c5699
...
...
@@ -95,6 +95,8 @@ class MSHR extends DCacheModule
io
.
tag
.
bits
:=
req_tag
io
.
way
.
bits
:=
req
.
way_en
XSDebug
(
"mshr: %d state: %d idx_valid: %b\n"
,
io
.
id
,
state
,
io
.
idx
.
valid
)
// assign default values to output signals
io
.
req_pri_rdy
:=
false
.
B
...
...
@@ -335,6 +337,15 @@ class MSHRFile extends DCacheModule
idx_matches
(
w
)(
i
)
:=
mshr
.
io
.
idx
.
valid
&&
mshr
.
io
.
idx
.
bits
===
io
.
req
(
w
).
bits
.
addr
(
untagBits
-
1
,
blockOffBits
)
tag_matches
(
w
)(
i
)
:=
mshr
.
io
.
tag
.
valid
&&
mshr
.
io
.
tag
.
bits
===
io
.
req
(
w
).
bits
.
addr
>>
untagBits
way_matches
(
w
)(
i
)
:=
mshr
.
io
.
way
.
valid
&&
mshr
.
io
.
way
.
bits
===
io
.
req
(
w
).
bits
.
way_en
when
(
idx_matches
(
w
)(
i
))
{
XSDebug
(
s
"mshr: $i channel: $w idx_match\n"
)
}
when
(
tag_matches
(
w
)(
i
))
{
XSDebug
(
s
"mshr: $i channel: $w tag_match\n"
)
}
when
(
way_matches
(
w
)(
i
))
{
XSDebug
(
s
"mshr: $i channel: $w way_match\n"
)
}
}
wb_tag_list
(
i
)
:=
mshr
.
io
.
wb_req
.
bits
.
tag
...
...
@@ -398,7 +409,7 @@ class MSHRFile extends DCacheModule
// block hit
(
0
until
memWidth
)
map
{
w
=>
XSDebug
(
io
.
req
(
w
).
valid
&&
io
.
block_hit
(
w
),
"channel %d req block hit\n"
,
w
.
U
)
XSDebug
(
io
.
block_hit
(
w
),
"channel %d req block hit\n"
,
w
.
U
)
}
// print refill
...
...
src/test/scala/xiangshan/backend/exu/DCacheTest.scala
浏览文件 @
846c5699
...
...
@@ -154,10 +154,15 @@ class DCacheTest extends FlatSpec with ChiselScalatestTester with Matchers {
for
(
i
<-
0
to
1
)
{
val
resp
=
c
.
io
.
in
.
resp
(
i
)
if
(
resp
.
valid
.
peek
().
litToBoolean
)
{
println
(
s
"clock: $global_clock channel: $i resp: $resp"
)
val
original_req
=
all_requests
(
resp
.
bits
.
meta
.
peek
().
litValue
.
longValue
)
val
data
=
resp
.
bits
.
data
.
peek
().
litValue
.
longValue
val
meta
=
resp
.
bits
.
meta
.
peek
().
litValue
.
longValue
val
nack
=
resp
.
bits
.
nack
.
peek
().
litToBoolean
println
(
f
"clock: $global_clock%d channel: $i%d nack: $nack%b data: $data%x meta: $meta%x"
)
val
original_req
=
all_requests
(
meta
)
// needs to be replayed
if
(
resp
.
bits
.
nack
.
peek
().
litToBoolean
)
{
if
(
nack
)
{
issue_queue
.
enqueue
(
Array
[
Req
](
original_req
))
}
else
{
num_retired_reqs
+=
1
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录