Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenXiangShan
XiangShan
提交
b3e4b50a
X
XiangShan
项目概览
OpenXiangShan
/
XiangShan
8 个月 前同步成功
通知
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 搜索 >>
提交
b3e4b50a
编写于
1月 26, 2021
作者:
L
Li Qianruo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added Debug Module Registers
上级
9471478b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
266 addition
and
0 deletion
+266
-0
src/main/scala/device/TLDebug.scala
src/main/scala/device/TLDebug.scala
+266
-0
未找到文件。
src/main/scala/device/TLDebug.scala
0 → 100644
浏览文件 @
b3e4b50a
package
device
import
chisel3._
import
chisel3.util._
import
freechips.rocketchip.tilelink._
import
chipsalliance.rocketchip.config._
import
freechips.rocketchip.diplomacy._
import
freechips.rocketchip.regmapper.RegField
import
utils.
{
HasTLDump
,
XSDebug
}
import
xiangshan.HasXSLog
trait
DebugConstants
{
val
abits
=
// TODO
}
class
dmiBundle
with
DebugConstants
{
val
req_valid
=
Input
(
Bool
())
val
req_ready
=
Input
(
Bool
())
val
req_address
=
Input
(
UInt
(
abits
.
W
))
val
req_data
=
Input
(
UInt
(
32.
W
))
val
req_op
=
Input
(
UInt
(
2.
W
))
val
rsp_valid
=
Output
(
Bool
())
val
rsp_ready
=
Output
(
Bool
())
val
rsp_data
=
Output
(
UInt
(
32.
W
))
val
rsp_op
=
Output
(
UInt
(
2.
W
))
}
class
TLDebug
(
address
:
Seq
[
AddressSet
],
sim
:
Boolean
)(
implicit
p
:
Parameters
)
extends
LazyModule
{
val
device
=
new
SimpleDevice
(
"debugModule"
,
Seq
(
"XiangShan"
,
"clint"
))
val
node
=
TLRegisterNode
(
address
,
device
,
beatBytes
=
8
)
val
NumCores
=
top
.
Parameters
.
get
.
socParameters
.
NumCores
lazy
val
module
=
new
LazyModuleImp
(
this
)
with
HasXSLog
with
HasTLDump
{
val
io
=
IO
(
new
Bundle
()
{
val
debugInt
=
Output
(
Vec
(
NumCores
,
Bool
()))
val
dmi
=
new
dmiBundle
})
//---------
// MMIO Regs for abstract commands and program buffer
//---------
// by writing 0s to these locations to indicate hart status
val
mmio_halted
=
Reg
(
Vec
(
NumCores
,
UInt
(
8.
W
)))
val
mmio_resumeack
=
Reg
(
Vec
(
NumCores
,
UInt
(
8.
W
)))
val
mmio_running
=
Reg
(
Vec
(
NumCores
,
UInt
(
8.
W
)))
val
mmio_havereset
=
Reg
(
Vec
(
NumCores
,
UInt
(
8.
W
)))
// Program buffer
// as described in manual
val
program_buffer
=
Reg
(
Vec
(
16
,
UInt
(
32.
W
)))
// Abstarct command
// For controlling halt and resume
val
abstract_command
=
Reg
(
Vec
(
16
,
UInt
(
32.
W
)))
// Abstract data
// as described in manual, and 16 more for other uses
val
abstract_data
=
Reg
(
Vec
(
12
,
UInt
(
32.
W
)))
//
//-------------
// DM registers
// They are visible to DTM
// Their fields are in dm_registers.scala
//-------------
val
dmstatus
=
RegInit
(
0.
U
(
32.
W
))
val
dmcontrol
=
RegInit
(
0.
U
(
32.
W
))
val
hartinfo
=
RegInit
(
0.
U
(
32.
W
))
val
haltsum
=
RegInit
(
0.
U
(
32.
W
))
val
dmabstractcs
=
RegInit
(
0.
U
(
32.
W
))
val
dmcommand
=
RegInit
(
0.
U
(
32.
W
))
val
abstractauto
=
RegInit
(
0.
U
(
32.
W
))
val
authdata
=
RegInit
(
0.
U
(
32.
W
))
val
haltsum1
=
RegInit
(
0.
U
(
32.
W
))
val
dmcs2
=
RegInit
(
0.
U
(
32.
W
))
//-----------
// system bus access
// TODO: init values
//-----------
val
sbaddress
=
RegInit
(
0.
U
(
64.
W
))
val
sbdata
=
RegInit
(
0.
U
(
64.
W
))
// general info about harts
val
havereset
=
Wire
(
Vec
(
NumCores
,
Bool
())
val
resumeack
=
Wire
(
Vec
(
NumCores
,
Bool
())
val
nonexistent
=
Wire
(
Vec
(
NumCores
,
Bool
())
val
unavail
=
Wire
(
Vec
(
NumCores
,
Bool
())
val
running
=
Wire
(
Vec
(
NumCores
,
Bool
())
val
halted
=
Wire
(
Vec
(
NumCores
,
Bool
())
// general commands. Note that these are commands
val
halt
=
Wire
(
Bool
())
val
resume
=
Wire
(
Bool
())
val
reset
=
Wire
(
Bool
())
val
ackhavereset
=
Wire
(
Bool
())
val
ackunavail
=
Wire
(
Bool
())
val
abstractBusy
:=
Wire
(
Bool
())
val
cmderr
:=
Wire
(
UInt
(
3.
W
))
//TODO: special
// dmstatus
// TODO: use mask, use loop to shorten code
//
val
authenticated
=
WireInit
(
false
.
B
)
val
dmstatusIn
=
Wire
(
new
DMSTATUSFields
)
dmstatusIn
.
reserved0
:=
0.
U
dmstatusIn
.
reserved1
:=
0.
U
dmstatusIn
.
version
:=
15.
U
dmstatusIn
.
hasresethaltreq
:=
true
.
B
// TODO
dmstatusIn
.
confstrptrvalid
:=
false
.
B
// TODO
dmstatusIn
.
anyhavereset
:=
havereset
.
reduce
(
_
|
_
).
asBools
dmstatusIn
.
allhavereset
:=
havereset
.
reduce
(
_
&
_
).
asBools
dmstatusIn
.
anyresumeack
:=
resumeack
.
reduce
(
_
|
_
).
asBools
dmstatusIn
.
allresumeack
:=
resumeack
.
reduce
(
_
&
_
).
asBools
dmstatusIn
.
anynonexistent
:=
nonexistent
.
reduce
(
_
|
_
).
asBools
dmstatusIn
.
allnonexistent
:=
nonexistent
.
reduce
(
_
&
_
).
asBools
dmstatusIn
.
anyunavail
:=
unavail
.
reduce
(
_
|
_
).
asBools
dmstatusIn
.
allunavail
:=
unavail
.
reduce
(
_
&
_
).
asBools
dmstatusIn
.
anyrunning
:=
running
.
reduce
(
_
|
_
).
asBools
dmstatusIn
.
allrunning
:=
running
.
reduce
(
_
&
_
).
asBools
dmstatusIn
.
anyhalted
:=
halted
.
reduce
(
_
|
_
).
asBools
dmstatusIn
.
allhalted
:=
halted
.
reduce
(
_
&
_
).
asBools
dmstatusIn
.
authenticated
:=
authenticated
.
asBools
dmstatus
:=
dmstatusIn
.
asTypeOf
(
UInt
(
32.
W
))
// dmcontrol
//
val
dmcontrolIn
=
Wire
(
UInt
(
32.
W
))
val
dmcontrolMask
=
0x5800003C
.
U
(
32.
W
)
dmcontrol
:=
dmcontrolIn
&
dmcontrolMask
// hartinfo
//
val
hartinfoIn
=
Wire
(
new
HARTINFOFields
)
hartinfoIn
.
reserved0
:=
0.
U
hartinfoIn
.
reserved1
:=
0.
U
hartinfoIn
.
nscratch
:=
0.
U
// TODO
hartinfoIn
.
dataaccess
:=
true
.
B
hartinfoIn
.
datasize
:=
12.
U
hartinfoIn
.
dataaddr
:=
1024.
U
// TODO: for different cores????
hartinfo
:=
hartinfoIn
.
asTypeOf
(
UInt
(
32.
W
))
// hawindowsel and hawindow are currently unimplemented
// abstractcs
val
abstractctsIn
=
Wire
(
new
ABSTRACTCSFields
)
abstractctsIn
.
reserved0
:=
0.
U
abstractctsIn
.
reserved1
:=
0.
U
abstractctsIn
.
reserved2
:=
0.
U
abstractctsIn
.
progbufsize
:=
16.
U
abstractctsIn
.
datacount
:=
12.
U
abstractctsIn
.
busy
:=
abstractBusy
abstractctsIn
.
cmderr
:=
when
(
abstractsctsClr
===
7.
U
(
3.
W
))
{
0.
U
(
3.
W
)
// TODO: what if clr and error comes at same time?
}.
otherwise
{
cmderr
}
abstractcts
:=
abstractctsIn
.
asTypeOf
(
UInt
(
32.
W
))
// command
command
:=
commandIn
// TODO
// abstractauto
// TODO
// data regs and prog buffer
val
errorBusy
=
(
dataaccess
&
abstractBusy
)
// dmcs2
val
dmcs2In
=
Wire
(
new
DMCS2Fields
)
dmcs2In
.
reserved0
:=
0.
U
dmcs2In
.
exttrigger
:=
0.
U
// TODO halt group stuff
// haltsum0
haltsum0
:=
halted
.
asUInt
// sbcs
sbbusyerror
:=
sbbusy
&
sbaccess
sberror
:=
Mux
()
// TODO
val
sbcsIn
=
Wire
(
new
sbcsFields
)
sbcsIn
.
sbversion
:=
1.
U
sbcsIn
.
reserved0
:=
0.
U
sbcsIn
.
sbbusyerror
:=
when
(
sbbusyerrorClr
)
{
false
.
B
}.
otherwise
{
sbbusyerror
}
sbcsIn
.
sbbusy
:=
sbbusy
sbcsIn
.
sbreadonaddr
:=
sbreadonaddr
sbcsIn
.
sbaccess
:=
sbaccess
sbcsIn
.
sberror
:=
when
(
sberrorClr
===
7.
U
(
3.
W
))
{
0.
U
(
3.
W
)
// TODO: what if clr and error comes at same time?
}.
otherwise
{
sberror
}
sbcsIn
.
sbasize
:=
64.
U
// TODO understand wtf system bus access is
(
sbcsIn
.
sbaccess128
,
sbcsIn
.
sbaccess64
,
sbcsIn
.
sbaccess32
,
sbcsIn
.
sbaccess16
,
sbcsIn
.
sbaccess8
)
:=
(
false
.
B
,
true
.
B
,
true
.
B
,
true
.
B
,
true
.
B
)
// sbaddress
// sbdata
//
val
mtime
=
RegInit
(
0.
U
(
64.
W
))
// unit: us
val
mtimecmp
=
Seq
.
fill
(
NumCores
)(
RegInit
(
0.
U
(
64.
W
)))
val
msip
=
Seq
.
fill
(
NumCores
)(
RegInit
(
0.
U
(
32.
W
)))
val
clk
=
(
if
(!
sim
)
40
/* 40MHz / 1000000 */
else
100
)
val
freq
=
RegInit
(
clk
.
U
(
16.
W
))
val
inc
=
RegInit
(
1.
U
(
16.
W
))
val
cnt
=
RegInit
(
0.
U
(
16.
W
))
val
nextCnt
=
cnt
+
1.
U
cnt
:=
Mux
(
nextCnt
<
freq
,
nextCnt
,
0.
U
)
val
tick
=
(
nextCnt
===
freq
)
when
(
tick
)
{
mtime
:=
mtime
+
inc
}
// Below are mapping
var
clintMapping
=
Seq
(
0x8000
->
RegField
.
bytes
(
freq
),
0x8008
->
RegField
.
bytes
(
inc
),
0xbff8
->
RegField
.
bytes
(
mtime
))
for
(
i
<-
0
until
NumCores
)
{
clintMapping
=
clintMapping
++
Seq
(
0x0000
+
i
*
4
->
RegField
.
bytes
(
msip
(
i
)),
0x4000
+
i
*
8
->
RegField
.
bytes
(
mtimecmp
(
i
))
)
}
node
.
regmap
(
mapping
=
clintMapping
:_
*
)
val
in
=
node
.
in
.
head
.
_1
when
(
in
.
a
.
valid
){
XSDebug
(
"[A] channel valid ready=%d "
,
in
.
a
.
ready
)
in
.
a
.
bits
.
dump
}
// val gtime = GTimer()
// printf(p"[$gtime][Timer] mtime=$mtime cnt=$cnt freq=$freq\n")
for
(
i
<-
0
until
NumCores
)
{
io
.
mtip
(
i
)
:=
RegNext
(
mtime
>=
mtimecmp
(
i
))
io
.
msip
(
i
)
:=
RegNext
(
msip
(
i
)
=/=
0.
U
)
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录