Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenXiangShan
XiangShan
提交
63934268
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,发现更多精彩内容 >>
提交
63934268
编写于
8月 15, 2020
作者:
L
linjiawei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rewrite AXI4Timer, Add AXI4Timer Test
上级
0f26349f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
85 addition
and
34 deletion
+85
-34
src/main/scala/device/AXI4SlaveModule.scala
src/main/scala/device/AXI4SlaveModule.scala
+1
-1
src/main/scala/device/AXI4Timer.scala
src/main/scala/device/AXI4Timer.scala
+41
-33
src/test/scala/device/AXI4TimerTest.scala
src/test/scala/device/AXI4TimerTest.scala
+43
-0
未找到文件。
src/main/scala/device/AXI4SlaveModule.scala
浏览文件 @
63934268
...
@@ -36,7 +36,7 @@ class AXI4SlaveModuleImp[T<:Data](outer: AXI4SlaveModule[T])
...
@@ -36,7 +36,7 @@ class AXI4SlaveModuleImp[T<:Data](outer: AXI4SlaveModule[T])
extends
LazyModuleImp
(
outer
)
extends
LazyModuleImp
(
outer
)
{
{
val
io
=
IO
(
new
Bundle
{
val
io
=
IO
(
new
Bundle
{
val
extra
=
Option
(
outer
.
_extra
)
val
extra
=
Option
(
outer
.
_extra
.
cloneType
)
})
})
val
(
in
,
edge
)
=
outer
.
node
.
in
.
head
val
(
in
,
edge
)
=
outer
.
node
.
in
.
head
...
...
src/main/scala/device/AXI4Timer.scala
浏览文件 @
63934268
package
device
package
device
import
chisel3._
import
chisel3._
import
chisel3.util._
import
chisel3.util.experimental.BoringUtils
import
chisel3.util.experimental.BoringUtils
import
bus.axi4._
import
chipsalliance.rocketchip.config.Parameters
import
freechips.rocketchip.diplomacy.AddressSet
import
utils._
import
utils._
class
TimerIO
extends
Bundle
{
class
TimerIO
extends
Bundle
{
val
mtip
=
Output
(
Bool
())
val
mtip
=
Output
(
Bool
())
}
}
class
AXI4Timer
(
sim
:
Boolean
=
false
)
extends
AXI4SlaveModule
(
new
AXI4Lite
,
new
TimerIO
)
{
class
AXI4Timer
val
mtime
=
RegInit
(
0.
U
(
64.
W
))
// unit: us
(
val
mtimecmp
=
RegInit
(
0.
U
(
64.
W
))
sim
:
Boolean
=
false
,
address
:
AddressSet
val
clk
=
(
if
(!
sim
)
40
/* 40MHz / 1000000 */
else
10000
)
)(
implicit
p
:
Parameters
)
val
freq
=
RegInit
(
clk
.
U
(
16.
W
))
extends
AXI4SlaveModule
(
address
,
executable
=
false
,
_extra
=
new
TimerIO
)
val
inc
=
RegInit
(
1000.
U
(
16.
W
))
{
override
lazy
val
module
=
new
AXI4SlaveModuleImp
[
TimerIO
](
this
){
val
cnt
=
RegInit
(
0.
U
(
16.
W
))
val
mtime
=
RegInit
(
0.
U
(
64.
W
))
// unit: us
val
nextCnt
=
cnt
+
1.
U
val
mtimecmp
=
RegInit
(
0.
U
(
64.
W
))
cnt
:=
Mux
(
nextCnt
<
freq
,
nextCnt
,
0.
U
)
val
tick
=
(
nextCnt
===
freq
)
val
clk
=
(
if
(!
sim
)
40
/* 40MHz / 1000000 */
else
10000
)
when
(
tick
)
{
mtime
:=
mtime
+
inc
}
val
freq
=
RegInit
(
clk
.
U
(
16.
W
))
val
inc
=
RegInit
(
1000.
U
(
16.
W
))
if
(
sim
)
{
val
isWFI
=
WireInit
(
false
.
B
)
val
cnt
=
RegInit
(
0.
U
(
16.
W
))
BoringUtils
.
addSink
(
isWFI
,
"isWFI"
)
val
nextCnt
=
cnt
+
1.
U
when
(
isWFI
)
{
mtime
:=
mtime
+
100000.
U
}
cnt
:=
Mux
(
nextCnt
<
freq
,
nextCnt
,
0.
U
)
val
tick
=
(
nextCnt
===
freq
)
when
(
tick
)
{
mtime
:=
mtime
+
inc
}
if
(
sim
)
{
val
isWFI
=
WireInit
(
false
.
B
)
BoringUtils
.
addSink
(
isWFI
,
"isWFI"
)
when
(
isWFI
)
{
mtime
:=
mtime
+
100000.
U
}
}
val
mapping
=
Map
(
RegMap
(
0x4000
,
mtimecmp
),
RegMap
(
0x8000
,
freq
),
RegMap
(
0x8008
,
inc
),
RegMap
(
0xbff8
,
mtime
)
)
def
getOffset
(
addr
:
UInt
)
=
addr
(
15
,
0
)
RegMap
.
generate
(
mapping
,
getOffset
(
raddr
),
in
.
r
.
bits
.
data
,
getOffset
(
waddr
),
in
.
w
.
fire
(),
in
.
w
.
bits
.
data
,
MaskExpand
(
in
.
w
.
bits
.
strb
))
io
.
extra
.
get
.
mtip
:=
RegNext
(
mtime
>=
mtimecmp
)
}
}
val
mapping
=
Map
(
RegMap
(
0x4000
,
mtimecmp
),
RegMap
(
0x8000
,
freq
),
RegMap
(
0x8008
,
inc
),
RegMap
(
0xbff8
,
mtime
)
)
def
getOffset
(
addr
:
UInt
)
=
addr
(
15
,
0
)
RegMap
.
generate
(
mapping
,
getOffset
(
raddr
),
in
.
r
.
bits
.
data
,
getOffset
(
waddr
),
in
.
w
.
fire
(),
in
.
w
.
bits
.
data
,
MaskExpand
(
in
.
w
.
bits
.
strb
))
io
.
extra
.
get
.
mtip
:=
RegNext
(
mtime
>=
mtimecmp
)
}
}
src/test/scala/device/AXI4TimerTest.scala
0 → 100644
浏览文件 @
63934268
package
device
import
chipsalliance.rocketchip.config._
import
chisel3._
import
chiseltest._
import
freechips.rocketchip.amba.axi4.
{
AXI4Deinterleaver
,
AXI4UserYanker
}
import
org.scalatest.
{
FlatSpec
,
Matchers
}
import
freechips.rocketchip.tilelink._
import
freechips.rocketchip.diplomacy._
import
utils.DebugIdentityNode
class
AXI4TimerTestTop
(
implicit
p
:
Parameters
)
extends
LazyModule
{
val
addressSet
=
AddressSet
(
0x38000000
L
,
0x0000ffff
L
)
val
fuzz
=
LazyModule
(
new
TLFuzzer
(
nOperations
=
10
,
overrideAddress
=
Some
(
addressSet
),
inFlight
=
1
))
val
ident
=
LazyModule
(
new
DebugIdentityNode
())
val
axiTimer
=
LazyModule
(
new
AXI4Timer
(
sim
=
true
,
addressSet
))
axiTimer
.
node
:=
AXI4UserYanker
()
:=
TLToAXI4
()
:=
ident
.
node
:=
fuzz
.
node
lazy
val
module
=
new
LazyModuleImp
(
this
){
val
finished
=
IO
(
Output
(
Bool
()))
finished
:=
fuzz
.
module
.
io
.
finished
}
}
class
AXI4TimerTest
extends
FlatSpec
with
Matchers
with
ChiselScalatestTester
{
it
should
"run"
in
{
implicit
val
p
=
Parameters
.
empty
test
(
LazyModule
(
new
AXI4TimerTestTop
()).
module
){
c
=>
while
(!
c
.
finished
.
peek
().
litToBoolean
){
c
.
clock
.
step
(
1
)
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录