Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenXiangShan
XiangShan
提交
5d3e5332
X
XiangShan
项目概览
OpenXiangShan
/
XiangShan
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
5d3e5332
编写于
12月 24, 2020
作者:
L
Lingrui98
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
icache: change handshake logic
上级
82d5679c
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
18 addition
and
17 deletion
+18
-17
src/main/scala/xiangshan/cache/icache.scala
src/main/scala/xiangshan/cache/icache.scala
+18
-17
未找到文件。
src/main/scala/xiangshan/cache/icache.scala
浏览文件 @
5d3e5332
...
...
@@ -116,7 +116,7 @@ trait ICacheBase extends HasICacheParameters
//----------------------------
// Stage 1
//----------------------------
val
s1_valid
=
WireInit
(
false
.
B
)
//
val s1_valid = WireInit(false.B)
val
s1_req_pc
=
Wire
(
UInt
(
VAddrBits
.
W
))
val
s1_req_mask
=
Wire
(
UInt
(
PredictWidth
.
W
))
val
s1_fire
=
WireInit
(
false
.
B
)
...
...
@@ -280,21 +280,21 @@ class ICache extends ICacheModule
//----------------------------
// Stage 1
//----------------------------
s1_
valid
:=
io
.
req
.
fire
()
s1_
fire
:=
io
.
req
.
fire
()
s1_req_pc
:=
io
.
req
.
bits
.
addr
s1_req_mask
:=
io
.
req
.
bits
.
mask
s2_ready
:=
WireInit
(
false
.
B
)
s1_fire
:=
s1_valid
&&
(
s2_ready
||
s2_flush
)
//
s1_fire := s1_valid && (s2_ready || s2_flush)
// SRAM(Meta and Data) read request
val
s1_idx
=
get_idx
(
s1_req_pc
)
metaArray
.
io
.
read
.
valid
:=
s1_
valid
metaArray
.
io
.
read
.
valid
:=
s1_
fire
metaArray
.
io
.
read
.
bits
:=
s1_idx
dataArray
.
io
.
read
.
valid
:=
s1_
valid
dataArray
.
io
.
read
.
valid
:=
s1_
fire
dataArray
.
io
.
read
.
bits
:=
s1_idx
XSDebug
(
"[Stage 1]
v : r : f (%d %d %d) request pc: 0x%x mask: %b\n"
,
s1_valid
,
s2_ready
,
s1_fire
,
s1_req_pc
,
s1_req_mask
)
XSDebug
(
"[Stage 1]
r : f (%d %d) request pc: 0x%x mask: %b\n"
,
s2_ready
,
s1_fire
,
s1_req_pc
,
s1_req_mask
)
XSDebug
(
"[Stage 1] index: %d\n"
,
s1_idx
)
...
...
@@ -306,10 +306,11 @@ class ICache extends ICacheModule
val
s2_tag
=
get_tag
(
s2_tlb_resp
.
paddr
)
val
s2_hit
=
WireInit
(
false
.
B
)
val
s2_access_fault
=
WireInit
(
false
.
B
)
s2_fire
:=
s2_valid
&&
s3_ready
&&
!
s2_flush
&&
io
.
tlb
.
resp
.
fire
()
when
(
s2_flush
)
{
s2_valid
:=
s1_fire
}
.
elsewhen
(
s1_fire
)
{
s2_valid
:=
s1_valid
}
.
elsewhen
(
s2_fire
)
{
s2_valid
:=
false
.
B
}
val
s2_allValid
=
s2_valid
&&
io
.
tlb
.
resp
.
valid
s2_fire
:=
s2_allValid
&&
s3_ready
when
(
s1_fire
)
{
s2_valid
:=
true
.
B
}
.
elsewhen
(
s2_flush
)
{
s2_valid
:=
false
.
B
}
.
elsewhen
(
s2_fire
)
{
s2_valid
:=
false
.
B
}
//physical address < 0x80000000
//TODO: May have bugs
...
...
@@ -331,7 +332,7 @@ class ICache extends ICacheModule
val
waymask
=
Mux
(
s2_hit
,
hitVec
.
asUInt
,
Mux
(
hasInvalidWay
,
refillInvalidWaymask
,
victimWayMask
))
s2_hit
:=
ParallelOR
(
hitVec
)
||
s2_tlb_resp
.
excp
.
pf
.
instr
||
s2_access_fault
s2_ready
:=
s
2_fire
||
!
s2_valid
||
s2_flush
s2_ready
:=
s
3_ready
&&
io
.
tlb
.
resp
.
valid
||
!
s2_valid
XSDebug
(
"[Stage 2] v : r : f (%d %d %d) pc: 0x%x mask: %b acf:%d\n"
,
s2_valid
,
s3_ready
,
s2_fire
,
s2_req_pc
,
s2_req_mask
,
s2_access_fault
)
XSDebug
(
p
"[Stage 2] tlb req: v ${io.tlb.req.valid} r ${io.tlb.req.ready} ${io.tlb.req.bits}\n"
)
...
...
@@ -352,7 +353,7 @@ class ICache extends ICacheModule
val
s3_idx
=
get_idx
(
s3_req_pc
)
val
s3_access_fault
=
RegEnable
(
s2_access_fault
,
init
=
false
.
B
,
enable
=
s2_fire
)
when
(
s3_flush
)
{
s3_valid
:=
false
.
B
}
.
elsewhen
(
s2_fire
)
{
s3_valid
:=
s2_valid
}
.
elsewhen
(
s2_fire
&&
!
s2_flush
)
{
s3_valid
:=
true
.
B
}
.
elsewhen
(
io
.
resp
.
fire
())
{
s3_valid
:=
false
.
B
}
val
refillDataReg
=
Reg
(
Vec
(
refillCycles
,
UInt
(
beatBits
.
W
)))
...
...
@@ -421,7 +422,7 @@ class ICache extends ICacheModule
val
refillDataVec
=
icacheMissQueue
.
io
.
resp
.
bits
.
data
.
asTypeOf
(
Vec
(
blockWords
,
UInt
(
wordBits
.
W
)))
val
refillDataOut
=
cutHelper
(
refillDataVec
,
s3_req_pc
(
5
,
1
),
s3_req_mask
)
s3_ready
:=
((
io
.
resp
.
fire
()
||
!
s3_valid
)
&&
!
blocking
)
||
(
blocking
&&
icacheMissQueue
.
io
.
resp
.
fire
()
)
s3_ready
:=
((
io
.
resp
.
ready
&&
s3_hit
||
!
s3_valid
)
&&
!
blocking
)
||
(
blocking
&&
icacheMissQueue
.
io
.
resp
.
valid
&&
io
.
resp
.
ready
)
//TODO: coherence
XSDebug
(
"[Stage 3] valid:%d pc: 0x%x mask: %b ipf:%d acf:%d \n"
,
s3_valid
,
s3_req_pc
,
s3_req_mask
,
s3_tlb_resp
.
excp
.
pf
.
instr
,
s3_access_fault
)
...
...
@@ -441,7 +442,7 @@ class ICache extends ICacheModule
// Out Put
//----------------------------
//icache request
io
.
req
.
ready
:=
metaArray
.
io
.
read
.
ready
&&
dataArray
.
io
.
read
.
ready
&&
s2_ready
io
.
req
.
ready
:=
s2_ready
//icache response: to pre-decoder
io
.
resp
.
valid
:=
s3_valid
&&
(
s3_hit
||
icacheMissQueue
.
io
.
resp
.
valid
)
...
...
@@ -452,7 +453,7 @@ class ICache extends ICacheModule
io
.
resp
.
bits
.
acf
:=
s3_access_fault
//to itlb
io
.
tlb
.
resp
.
ready
:=
s3_ready
io
.
tlb
.
resp
.
ready
:=
true
.
B
// DontCare
io
.
tlb
.
req
.
valid
:=
s2_valid
io
.
tlb
.
req
.
bits
.
vaddr
:=
s2_req_pc
io
.
tlb
.
req
.
bits
.
cmd
:=
TlbCmd
.
exec
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录