Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenXiangShan
XiangShan
提交
ccd497e4
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,发现更多精彩内容 >>
提交
ccd497e4
编写于
11月 22, 2019
作者:
Z
zhanglinjuan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add prefetcher into l2cache
上级
7beb900d
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
37 addition
and
35 deletion
+37
-35
src/main/scala/noop/Cache.scala
src/main/scala/noop/Cache.scala
+4
-4
src/main/scala/noop/NOOP.scala
src/main/scala/noop/NOOP.scala
+1
-4
src/main/scala/system/Prefetcher.scala
src/main/scala/system/Prefetcher.scala
+27
-15
src/main/scala/system/SoC.scala
src/main/scala/system/SoC.scala
+4
-11
src/main/scala/utils/Debug.scala
src/main/scala/utils/Debug.scala
+1
-1
未找到文件。
src/main/scala/noop/Cache.scala
浏览文件 @
ccd497e4
...
@@ -406,15 +406,15 @@ sealed class CacheStage3(implicit val cacheConfig: CacheConfig) extends CacheMod
...
@@ -406,15 +406,15 @@ sealed class CacheStage3(implicit val cacheConfig: CacheConfig) extends CacheMod
Mux
(
hit
||
req
.
isWrite
(),
io
.
out
.
fire
(),
(
state
===
s_wait_resp
)
&&
(
io
.
out
.
fire
()
||
alreadyOutFire
))
Mux
(
hit
||
req
.
isWrite
(),
io
.
out
.
fire
(),
(
state
===
s_wait_resp
)
&&
(
io
.
out
.
fire
()
||
alreadyOutFire
))
)
)
io
.
in
.
ready
:=
io
.
out
.
ready
&&
(
state
===
s_idle
)
&&
!
miss
&&
!
probe
io
.
in
.
ready
:=
io
.
out
.
ready
&&
(
state
===
s_idle
&&
!
hitReadBurst
)
&&
!
miss
&&
!
probe
io
.
dataReadRespToL1
:=
hitReadBurst
&&
(
state
===
s_idle
&&
io
.
out
.
ready
||
state
===
s_release
&&
state2
===
s2_dataOK
)
io
.
dataReadRespToL1
:=
hitReadBurst
&&
(
state
===
s_idle
&&
io
.
out
.
ready
||
state
===
s_release
&&
state2
===
s2_dataOK
)
assert
(!(
metaHitWriteBus
.
req
.
valid
&&
metaRefillWriteBus
.
req
.
valid
))
assert
(!(
metaHitWriteBus
.
req
.
valid
&&
metaRefillWriteBus
.
req
.
valid
))
assert
(!(
dataHitWriteBus
.
req
.
valid
&&
dataRefillWriteBus
.
req
.
valid
))
assert
(!(
dataHitWriteBus
.
req
.
valid
&&
dataRefillWriteBus
.
req
.
valid
))
assert
(!(!
ro
.
B
&&
io
.
flush
),
"only allow to flush icache"
)
assert
(!(!
ro
.
B
&&
io
.
flush
),
"only allow to flush icache"
)
Debug
(
debug
)
{
Debug
(
debug
)
{
printf
(
"%d: ["
+
cacheName
+
" stage3]: in.ready = %d, in.valid = %d, out.valid = %d, out.ready = %d, state = %d, addr = %x, mem.req.valid = %d, mem.req.ready = %d\n\n"
,
printf
(
"%d: ["
+
cacheName
+
" stage3]: in.ready = %d, in.valid = %d, out.valid = %d, out.ready = %d, state = %d,
cmd = %x,
addr = %x, mem.req.valid = %d, mem.req.ready = %d\n\n"
,
GTimer
(),
io
.
in
.
ready
,
io
.
in
.
valid
,
io
.
out
.
valid
,
io
.
out
.
ready
,
state
,
req
.
addr
,
io
.
mem
.
req
.
valid
,
io
.
mem
.
req
.
ready
)
GTimer
(),
io
.
in
.
ready
,
io
.
in
.
valid
,
io
.
out
.
valid
,
io
.
out
.
ready
,
state
,
req
.
cmd
,
req
.
addr
,
io
.
mem
.
req
.
valid
,
io
.
mem
.
req
.
ready
)
}
}
}
}
...
@@ -451,7 +451,7 @@ class Cache(implicit val cacheConfig: CacheConfig) extends CacheModule {
...
@@ -451,7 +451,7 @@ class Cache(implicit val cacheConfig: CacheConfig) extends CacheModule {
io
.
out
.
mem
<>
s3
.
io
.
mem
io
.
out
.
mem
<>
s3
.
io
.
mem
io
.
mmio
<>
s3
.
io
.
mmio
io
.
mmio
<>
s3
.
io
.
mmio
io
.
in
.
resp
.
valid
:=
Mux
(
s3
.
io
.
out
.
bits
.
isPrefetch
(),
false
.
B
,
s3
.
io
.
out
.
valid
||
s3
.
io
.
dataReadRespToL1
)
io
.
in
.
resp
.
valid
:=
Mux
(
s3
.
io
.
out
.
valid
&&
s3
.
io
.
out
.
bits
.
isPrefetch
(),
false
.
B
,
s3
.
io
.
out
.
valid
||
s3
.
io
.
dataReadRespToL1
)
if
(
hasCoh
)
{
if
(
hasCoh
)
{
val
cohReq
=
io
.
out
.
coh
.
req
.
bits
val
cohReq
=
io
.
out
.
coh
.
req
.
bits
...
...
src/main/scala/noop/NOOP.scala
浏览文件 @
ccd497e4
...
@@ -43,8 +43,7 @@ class NOOP(implicit val p: NOOPConfig) extends NOOPModule {
...
@@ -43,8 +43,7 @@ class NOOP(implicit val p: NOOPConfig) extends NOOPModule {
val
imem
=
new
SimpleBusC
val
imem
=
new
SimpleBusC
val
dmem
=
new
SimpleBusC
val
dmem
=
new
SimpleBusC
val
mmio
=
new
SimpleBusUC
val
mmio
=
new
SimpleBusUC
val
prefetchReq
=
Decoupled
(
new
SimpleBusReqBundle
)
})
})
val
ifu
=
Module
(
new
IFU
)
val
ifu
=
Module
(
new
IFU
)
val
idu1
=
Module
(
new
IDU1
)
val
idu1
=
Module
(
new
IDU1
)
...
@@ -91,7 +90,5 @@ class NOOP(implicit val p: NOOPConfig) extends NOOPModule {
...
@@ -91,7 +90,5 @@ class NOOP(implicit val p: NOOPConfig) extends NOOPModule {
io
.
imem
<>
Cache
(
ifu
.
io
.
imem
,
mmioXbar
.
io
.
in
(
0
),
Fill
(
2
,
ifu
.
io
.
flushVec
(
0
)
|
ifu
.
io
.
bpFlush
))(
io
.
imem
<>
Cache
(
ifu
.
io
.
imem
,
mmioXbar
.
io
.
in
(
0
),
Fill
(
2
,
ifu
.
io
.
flushVec
(
0
)
|
ifu
.
io
.
bpFlush
))(
CacheConfig
(
ro
=
true
,
name
=
"icache"
,
userBits
=
AddrBits
*
2
+
4
))
// userBits = AddrBits + BrIdxBits
CacheConfig
(
ro
=
true
,
name
=
"icache"
,
userBits
=
AddrBits
*
2
+
4
))
// userBits = AddrBits + BrIdxBits
io
.
dmem
<>
Cache
(
exu
.
io
.
dmem
,
mmioXbar
.
io
.
in
(
1
),
"b00"
.
U
,
enable
=
HasDcache
)(
CacheConfig
(
ro
=
false
,
name
=
"dcache"
))
io
.
dmem
<>
Cache
(
exu
.
io
.
dmem
,
mmioXbar
.
io
.
in
(
1
),
"b00"
.
U
,
enable
=
HasDcache
)(
CacheConfig
(
ro
=
false
,
name
=
"dcache"
))
io
.
prefetchReq
.
bits
:=
exu
.
io
.
dmem
.
req
.
bits
io
.
prefetchReq
.
valid
:=
exu
.
io
.
dmem
.
req
.
valid
io
.
mmio
<>
mmioXbar
.
io
.
out
io
.
mmio
<>
mmioXbar
.
io
.
out
}
}
src/main/scala/system/Prefetcher.scala
浏览文件 @
ccd497e4
...
@@ -3,6 +3,7 @@ package system
...
@@ -3,6 +3,7 @@ package system
import
noop.
{
NOOP
,
NOOPConfig
,
HasNOOPParameter
,
Cache
,
CacheConfig
}
import
noop.
{
NOOP
,
NOOPConfig
,
HasNOOPParameter
,
Cache
,
CacheConfig
}
import
bus.axi4.
{
AXI4
,
AXI4Lite
}
import
bus.axi4.
{
AXI4
,
AXI4Lite
}
import
bus.simplebus._
import
bus.simplebus._
import
utils._
import
chisel3._
import
chisel3._
import
chisel3.util._
import
chisel3.util._
...
@@ -17,19 +18,30 @@ class Prefetcher extends Module with HasPrefetcherParameter {
...
@@ -17,19 +18,30 @@ class Prefetcher extends Module with HasPrefetcherParameter {
val
in
=
Flipped
(
Decoupled
(
new
SimpleBusReqBundle
))
val
in
=
Flipped
(
Decoupled
(
new
SimpleBusReqBundle
))
val
out
=
Decoupled
(
new
SimpleBusReqBundle
)
val
out
=
Decoupled
(
new
SimpleBusReqBundle
)
})
})
/*
val
getNewReq
=
RegInit
(
false
.
B
)
io.in.ready := !io.in.valid || io.out.fire()
val
prefetchReq
=
RegNext
(
io
.
in
.
bits
)
val lastReq = RegEnable(io.in.bits, io.in.fire())
prefetchReq
.
cmd
:=
SimpleBusCmd
.
prefetch
val lastAddr = lastReq.addr
prefetchReq
.
addr
:=
io
.
in
.
bits
.
addr
+
XLEN
.
U
io.out.bits := lastReq
io.out.bits.cmd := SimpleBusCmd.prefetch
val
lastReqAddr
=
(
RegEnable
(
io
.
in
.
bits
.
addr
,
io
.
in
.
fire
()))
io.out.bits.addr := lastAddr + Cat(Cat(0.U((TagBits + IndexBits - 1).W), 1.U(1.W)), 0.U(OffsetBits.W))
val
thisReqAddr
=
io
.
in
.
bits
.
addr
io.out.valid := io.in.valid
val
lineMask
=
Cat
(
Fill
(
AddrBits
-
6
,
1.
U
(
1.
W
)),
0.
U
(
6.
W
))
*/
val
neqAddr
=
(
thisReqAddr
&
lineMask
)
=/=
(
lastReqAddr
&
lineMask
)
io
.
out
.
bits
:=
io
.
in
.
bits
io
.
out
.
bits
.
cmd
:=
SimpleBusCmd
.
prefetch
when
(!
getNewReq
)
{
// io.out.bits.addr := io.in.bits.addr + Cat(Cat(0.U((TagBits + IndexBits - 1).W), 1.U(1.W)), 0.U(OffsetBits.W))
io
.
out
.
bits
<>
io
.
in
.
bits
io
.
out
.
bits
.
addr
:=
io
.
in
.
bits
.
addr
+
64.
U
(
32.
W
)
io
.
out
.
valid
:=
io
.
in
.
valid
io
.
out
.
valid
:=
io
.
in
.
valid
io
.
in
.
ready
:=
!
io
.
in
.
valid
||
io
.
out
.
fire
()
io
.
in
.
ready
:=
!
io
.
in
.
valid
||
io
.
out
.
fire
()
getNewReq
:=
io
.
in
.
fire
()
&&
io
.
in
.
bits
.
isBurst
()
&&
neqAddr
}.
otherwise
{
io
.
out
.
bits
<>
prefetchReq
io
.
out
.
valid
:=
true
.
B
io
.
in
.
ready
:=
false
.
B
getNewReq
:=
!
io
.
out
.
fire
()
}
Debug
()
{
printf
(
"%d: [Prefetcher]: in(%d,%d), out(%d,%d), in.bits.addr = %x\n"
,
GTimer
(),
io
.
in
.
valid
,
io
.
in
.
ready
,
io
.
out
.
valid
,
io
.
out
.
ready
,
io
.
in
.
bits
.
addr
)
}
}
}
src/main/scala/system/SoC.scala
浏览文件 @
ccd497e4
...
@@ -11,7 +11,7 @@ import chisel3.util.experimental.BoringUtils
...
@@ -11,7 +11,7 @@ import chisel3.util.experimental.BoringUtils
trait
HasSoCParameter
{
trait
HasSoCParameter
{
val
EnableILA
=
false
val
EnableILA
=
false
val
HasL2cache
=
true
val
HasL2cache
=
true
val
HasPrefetch
=
fals
e
val
HasPrefetch
=
tru
e
}
}
class
ILABundle
extends
Bundle
{
class
ILABundle
extends
Bundle
{
...
@@ -44,12 +44,9 @@ class NOOPSoC(implicit val p: NOOPConfig) extends Module with HasSoCParameter {
...
@@ -44,12 +44,9 @@ class NOOPSoC(implicit val p: NOOPConfig) extends Module with HasSoCParameter {
val
l2cacheOut
=
Wire
(
new
SimpleBusC
)
val
l2cacheOut
=
Wire
(
new
SimpleBusC
)
val
l2cacheIn
=
if
(
HasPrefetch
)
{
val
l2cacheIn
=
if
(
HasPrefetch
)
{
val
prefetcher
=
Module
(
new
Prefetcher
)
val
prefetcher
=
Module
(
new
Prefetcher
)
prefetcher
.
io
.
in
<>
noop
.
io
.
prefetchReq
val
l2cacheIn
=
Wire
(
new
SimpleBusUC
)
val
l2cacheIn
=
Wire
(
new
SimpleBusUC
)
val
l2cacheInReqArb
=
Module
(
new
Arbiter
(
chiselTypeOf
(
noop
.
io
.
prefetchReq
.
bits
),
2
))
prefetcher
.
io
.
in
<>
xbar
.
io
.
out
.
req
l2cacheInReqArb
.
io
.
in
(
0
)
<>
xbar
.
io
.
out
.
req
l2cacheIn
.
req
<>
prefetcher
.
io
.
out
l2cacheInReqArb
.
io
.
in
(
1
)
<>
prefetcher
.
io
.
out
l2cacheIn
.
req
<>
l2cacheInReqArb
.
io
.
out
xbar
.
io
.
out
.
resp
<>
l2cacheIn
.
resp
xbar
.
io
.
out
.
resp
<>
l2cacheIn
.
resp
l2cacheIn
l2cacheIn
}
else
xbar
.
io
.
out
}
else
xbar
.
io
.
out
...
@@ -63,10 +60,6 @@ class NOOPSoC(implicit val p: NOOPConfig) extends Module with HasSoCParameter {
...
@@ -63,10 +60,6 @@ class NOOPSoC(implicit val p: NOOPConfig) extends Module with HasSoCParameter {
io
.
mem
<>
xbar
.
io
.
out
.
toAXI4
()
io
.
mem
<>
xbar
.
io
.
out
.
toAXI4
()
}
}
if
(!
HasPrefetch
)
{
noop
.
io
.
prefetchReq
.
ready
:=
true
.
B
}
noop
.
io
.
imem
.
coh
.
resp
.
ready
:=
true
.
B
noop
.
io
.
imem
.
coh
.
resp
.
ready
:=
true
.
B
noop
.
io
.
imem
.
coh
.
req
.
valid
:=
false
.
B
noop
.
io
.
imem
.
coh
.
req
.
valid
:=
false
.
B
noop
.
io
.
imem
.
coh
.
req
.
bits
:=
DontCare
noop
.
io
.
imem
.
coh
.
req
.
bits
:=
DontCare
...
...
src/main/scala/utils/Debug.scala
浏览文件 @
ccd497e4
...
@@ -7,7 +7,7 @@ import noop.NOOPConfig
...
@@ -7,7 +7,7 @@ import noop.NOOPConfig
object
Debug
{
object
Debug
{
def
apply
(
flag
:
Boolean
=
NOOPConfig
().
EnableDebug
,
cond
:
Bool
=
true
.
B
)(
body
:
=>
Unit
)
:
Any
=
def
apply
(
flag
:
Boolean
=
NOOPConfig
().
EnableDebug
,
cond
:
Bool
=
true
.
B
)(
body
:
=>
Unit
)
:
Any
=
if
(
flag
)
{
when
(
cond
&&
GTimer
()
>
7392
00.
U
)
{
body
}
}
if
(
flag
)
{
when
(
cond
&&
GTimer
()
>
1
00.
U
)
{
body
}
}
}
}
object
ShowType
{
object
ShowType
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录