Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenXiangShan
XiangShan
提交
b03ddc86
X
XiangShan
项目概览
OpenXiangShan
/
XiangShan
9 个月 前同步成功
通知
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 搜索 >>
提交
b03ddc86
编写于
1月 14, 2021
作者:
W
wangkaifan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
perfcnt, csr: support hardware mcycle & minstret
上级
7ec59831
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
46 addition
and
25 deletion
+46
-25
src/main/scala/xiangshan/XSCore.scala
src/main/scala/xiangshan/XSCore.scala
+1
-0
src/main/scala/xiangshan/backend/IntegerBlock.scala
src/main/scala/xiangshan/backend/IntegerBlock.scala
+3
-0
src/main/scala/xiangshan/backend/brq/Brq.scala
src/main/scala/xiangshan/backend/brq/Brq.scala
+11
-11
src/main/scala/xiangshan/backend/exu/JumpExeUnit.scala
src/main/scala/xiangshan/backend/exu/JumpExeUnit.scala
+4
-0
src/main/scala/xiangshan/backend/fu/CSR.scala
src/main/scala/xiangshan/backend/fu/CSR.scala
+23
-14
src/main/scala/xiangshan/backend/roq/Roq.scala
src/main/scala/xiangshan/backend/roq/Roq.scala
+4
-0
未找到文件。
src/main/scala/xiangshan/XSCore.scala
浏览文件 @
b03ddc86
...
...
@@ -425,6 +425,7 @@ class XSCoreImp(outer: XSCore) extends LazyModuleImp(outer)
integerBlock
.
io
.
csrio
.
memExceptionVAddr
<>
memBlock
.
io
.
lsqio
.
exceptionAddr
.
vaddr
integerBlock
.
io
.
csrio
.
externalInterrupt
<>
io
.
externalInterrupt
integerBlock
.
io
.
csrio
.
tlb
<>
memBlock
.
io
.
tlbCsr
integerBlock
.
io
.
csrio
.
perfinfo
<>
ctrlBlock
.
io
.
roqio
.
toCSR
.
perfinfo
integerBlock
.
io
.
fenceio
.
sfence
<>
memBlock
.
io
.
sfence
integerBlock
.
io
.
fenceio
.
sbuffer
<>
memBlock
.
io
.
fenceToSbuffer
...
...
src/main/scala/xiangshan/backend/IntegerBlock.scala
浏览文件 @
b03ddc86
...
...
@@ -82,6 +82,9 @@ class IntegerBlock
val
memExceptionVAddr
=
Input
(
UInt
(
VAddrBits
.
W
))
// from lsq
val
externalInterrupt
=
new
ExternalInterruptIO
// from outside
val
tlb
=
Output
(
new
TlbCsrBundle
)
// from tlb
val
perfinfo
=
new
Bundle
{
val
retiredInstr
=
Input
(
UInt
(
3.
W
))
}
}
val
fenceio
=
new
Bundle
{
val
sfence
=
Output
(
new
SfenceBundle
)
// to front,mem
...
...
src/main/scala/xiangshan/backend/brq/Brq.scala
浏览文件 @
b03ddc86
...
...
@@ -269,16 +269,16 @@ class Brq extends XSModule with HasCircularQueuePtrHelper {
val
mbpRWrong
=
predWrong
&&
isRType
if
(!
env
.
FPGAPlatform
){
ExcitingUtils
.
addSource
(
mbpInstr
,
"perfCntCond
Mb
pInstr"
,
Perf
)
ExcitingUtils
.
addSource
(
mbpRight
,
"perfCntCond
Mb
pRight"
,
Perf
)
ExcitingUtils
.
addSource
(
mbpWrong
,
"perfCntCond
Mb
pWrong"
,
Perf
)
ExcitingUtils
.
addSource
(
mbpBRight
,
"perfCntCond
Mb
pBRight"
,
Perf
)
ExcitingUtils
.
addSource
(
mbpBWrong
,
"perfCntCond
Mb
pBWrong"
,
Perf
)
ExcitingUtils
.
addSource
(
mbpJRight
,
"perfCntCond
Mb
pJRight"
,
Perf
)
ExcitingUtils
.
addSource
(
mbpJWrong
,
"perfCntCond
Mb
pJWrong"
,
Perf
)
ExcitingUtils
.
addSource
(
mbpIRight
,
"perfCntCond
Mb
pIRight"
,
Perf
)
ExcitingUtils
.
addSource
(
mbpIWrong
,
"perfCntCond
Mb
pIWrong"
,
Perf
)
ExcitingUtils
.
addSource
(
mbpRRight
,
"perfCntCond
Mb
pRRight"
,
Perf
)
ExcitingUtils
.
addSource
(
mbpRWrong
,
"perfCntCond
Mb
pRWrong"
,
Perf
)
ExcitingUtils
.
addSource
(
mbpInstr
,
"perfCntCond
B
pInstr"
,
Perf
)
ExcitingUtils
.
addSource
(
mbpRight
,
"perfCntCond
B
pRight"
,
Perf
)
ExcitingUtils
.
addSource
(
mbpWrong
,
"perfCntCond
B
pWrong"
,
Perf
)
ExcitingUtils
.
addSource
(
mbpBRight
,
"perfCntCond
B
pBRight"
,
Perf
)
ExcitingUtils
.
addSource
(
mbpBWrong
,
"perfCntCond
B
pBWrong"
,
Perf
)
ExcitingUtils
.
addSource
(
mbpJRight
,
"perfCntCond
B
pJRight"
,
Perf
)
ExcitingUtils
.
addSource
(
mbpJWrong
,
"perfCntCond
B
pJWrong"
,
Perf
)
ExcitingUtils
.
addSource
(
mbpIRight
,
"perfCntCond
B
pIRight"
,
Perf
)
ExcitingUtils
.
addSource
(
mbpIWrong
,
"perfCntCond
B
pIWrong"
,
Perf
)
ExcitingUtils
.
addSource
(
mbpRRight
,
"perfCntCond
B
pRRight"
,
Perf
)
ExcitingUtils
.
addSource
(
mbpRWrong
,
"perfCntCond
B
pRWrong"
,
Perf
)
}
}
src/main/scala/xiangshan/backend/exu/JumpExeUnit.scala
浏览文件 @
b03ddc86
...
...
@@ -21,6 +21,9 @@ class JumpExeUnit extends Exu(jumpExeUnitCfg)
val
memExceptionVAddr
=
Input
(
UInt
(
VAddrBits
.
W
))
val
externalInterrupt
=
new
ExternalInterruptIO
val
tlb
=
Output
(
new
TlbCsrBundle
)
val
perfinfo
=
new
Bundle
{
val
retiredInstr
=
Input
(
UInt
(
3.
W
))
}
})
val
fenceio
=
IO
(
new
Bundle
{
val
sfence
=
Output
(
new
SfenceBundle
)
...
...
@@ -42,6 +45,7 @@ class JumpExeUnit extends Exu(jumpExeUnitCfg)
}.
get
csr
.
csrio
.
perf
<>
DontCare
csr
.
csrio
.
perf
.
retiredInstr
<>
csrio
.
perfinfo
.
retiredInstr
csr
.
csrio
.
fpu
.
fflags
<>
csrio
.
fflags
csr
.
csrio
.
fpu
.
isIllegal
:=
false
.
B
csr
.
csrio
.
fpu
.
dirty_fs
<>
csrio
.
dirty_fs
...
...
src/main/scala/xiangshan/backend/fu/CSR.scala
浏览文件 @
b03ddc86
...
...
@@ -58,6 +58,7 @@ class FpuCsrIO extends XSBundle {
class
PerfCounterIO
extends
XSBundle
{
val
retiredInstr
=
Input
(
UInt
(
3.
W
))
val
value
=
Input
(
UInt
(
XLEN
.
W
))
}
...
...
@@ -66,7 +67,7 @@ class CSR extends FunctionUnit with HasCSRConst
val
csrio
=
IO
(
new
Bundle
{
// output (for func === CSROpType.jmp)
val
redirectOut
=
ValidIO
(
UInt
(
VAddrBits
.
W
))
val
perf
=
Vec
(
NumPerfCounters
,
new
PerfCounterIO
)
val
perf
=
new
PerfCounterIO
val
isPerfCnt
=
Output
(
Bool
())
// to FPU
val
fpu
=
Flipped
(
new
FpuCsrIO
)
...
...
@@ -331,6 +332,10 @@ class CSR extends FunctionUnit with HasCSRConst
val
perfCnts
=
List
.
fill
(
nrPerfCnts
)(
RegInit
(
0.
U
(
XLEN
.
W
)))
val
perfEvents
=
List
.
fill
(
nrPerfCnts
)(
RegInit
(
0.
U
(
XLEN
.
W
)))
val
mcountinhibit
=
RegInit
(
0.
U
(
XLEN
.
W
))
val
mcycle
=
RegInit
(
0.
U
(
XLEN
.
W
))
mcycle
:=
mcycle
+
1.
U
val
minstret
=
RegInit
(
0.
U
(
XLEN
.
W
))
minstret
:=
minstret
+
RegNext
(
csrio
.
perf
.
retiredInstr
)
// CSR reg map
val
basicPrivMapping
=
Map
(
...
...
@@ -405,7 +410,11 @@ class CSR extends FunctionUnit with HasCSRConst
MaskedRegMap
(
PmpaddrBase
+
3
,
pmpaddr3
)
)
var
perfCntMapping
=
Map
(
MaskedRegMap
(
Mcountinhibit
,
mcountinhibit
))
var
perfCntMapping
=
Map
(
MaskedRegMap
(
Mcountinhibit
,
mcountinhibit
),
MaskedRegMap
(
Mcycle
,
mcycle
),
MaskedRegMap
(
Minstret
,
minstret
),
)
val
MhpmcounterStart
=
Mhpmcounter3
val
MhpmeventStart
=
Mhpmevent3
for
(
i
<-
0
until
nrPerfCnts
)
{
...
...
@@ -708,17 +717,17 @@ class CSR extends FunctionUnit with HasCSRConst
val
emuPerfCntList
=
Map
(
// "Mcycle" -> (0x1000, "perfCntCondMcycle" ),
// "Minstret" -> (0x1002, "perfCntCondMinstret" ),
"
MbpInstr"
->
(
0x1003
,
"perfCntCondMb
pInstr"
),
"
MbpRight"
->
(
0x1004
,
"perfCntCondMb
pRight"
),
"
MbpWrong"
->
(
0x1005
,
"perfCntCondMb
pWrong"
),
"
MbpBRight"
->
(
0x1006
,
"perfCntCondMb
pBRight"
),
"
MbpBWrong"
->
(
0x1007
,
"perfCntCondMb
pBWrong"
),
"
MbpJRight"
->
(
0x1008
,
"perfCntCondMb
pJRight"
),
"
MbpJWrong"
->
(
0x1009
,
"perfCntCondMb
pJWrong"
),
"
MbpIRight"
->
(
0x100a
,
"perfCntCondMb
pIRight"
),
"
MbpIWrong"
->
(
0x100b
,
"perfCntCondMb
pIWrong"
),
"
MbpRRight"
->
(
0x100c
,
"perfCntCondMb
pRRight"
),
"
MbpRWrong"
->
(
0x100d
,
"perfCntCondMb
pRWrong"
),
"
BpInstr"
->
(
0x1003
,
"perfCntCondB
pInstr"
),
"
BpRight"
->
(
0x1004
,
"perfCntCondB
pRight"
),
"
BpWrong"
->
(
0x1005
,
"perfCntCondB
pWrong"
),
"
BpBRight"
->
(
0x1006
,
"perfCntCondB
pBRight"
),
"
BpBWrong"
->
(
0x1007
,
"perfCntCondB
pBWrong"
),
"
BpJRight"
->
(
0x1008
,
"perfCntCondB
pJRight"
),
"
BpJWrong"
->
(
0x1009
,
"perfCntCondB
pJWrong"
),
"
BpIRight"
->
(
0x100a
,
"perfCntCondB
pIRight"
),
"
BpIWrong"
->
(
0x100b
,
"perfCntCondB
pIWrong"
),
"
BpRRight"
->
(
0x100c
,
"perfCntCondB
pRRight"
),
"
BpRWrong"
->
(
0x100d
,
"perfCntCondB
pRWrong"
),
"RoqWalk"
->
(
0x100f
,
"perfCntCondRoqWalk"
),
"DTlbReqCnt0"
->
(
0x1015
,
"perfCntDtlbReqCnt0"
),
"DTlbReqCnt1"
->
(
0x1016
,
"perfCntDtlbReqCnt1"
),
...
...
@@ -740,7 +749,7 @@ class CSR extends FunctionUnit with HasCSRConst
// "ExitLoop1" -> (0x102c, "CntExitLoop1"),
// "ExitLoop2" -> (0x102d, "CntExitLoop2"),
// "ExitLoop3" -> (0x102e, "CntExitLoop3")
// "
Ml2cacheHit" -> (0x1023, "perfCntCondMl
2cacheHit")
// "
L2cacheHit" -> (0x1023, "perfCntCondL
2cacheHit")
)
++
(
(
0
until
dcacheParameters
.
nMissEntries
).
map
(
i
=>
(
"DCacheMissQueuePenalty"
+
Integer
.
toString
(
i
,
10
),
(
0x102d
+
i
,
"perfCntDCacheMissQueuePenaltyEntry"
+
Integer
.
toString
(
i
,
10
)))
...
...
src/main/scala/xiangshan/backend/roq/Roq.scala
浏览文件 @
b03ddc86
...
...
@@ -38,6 +38,9 @@ class RoqCSRIO extends XSBundle {
val
fflags
=
Output
(
Valid
(
UInt
(
5.
W
)))
val
dirty_fs
=
Output
(
Bool
())
val
perfinfo
=
new
Bundle
{
val
retiredInstr
=
Output
(
UInt
(
3.
W
))
}
}
class
RoqEnqIO
extends
XSBundle
{
...
...
@@ -721,6 +724,7 @@ class Roq(numWbPorts: Int) extends XSModule with HasCircularQueuePtrHelper {
val
instrCnt
=
RegInit
(
0.
U
(
64.
W
))
val
retireCounter
=
Mux
(
state
===
s_idle
,
commitCnt
,
0.
U
)
instrCnt
:=
instrCnt
+
retireCounter
io
.
csr
.
perfinfo
.
retiredInstr
:=
RegNext
(
retireCounter
);
XSDebug
(
difftestIntrNO
=/=
0.
U
,
"difftest intrNO set %x\n"
,
difftestIntrNO
)
val
retireCounterFix
=
Mux
(
io
.
redirectOut
.
valid
,
1.
U
,
retireCounter
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录