Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
Can
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Minyong Li
Can
Commits
975a85f3
Verified
Commit
975a85f3
authored
4 years ago
by
Minyong Li
Browse files
Options
Downloads
Patches
Plain Diff
core: impl DataMemory{Test}
parent
ac1f3ec3
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/scala/uk/ac/soton/ecs/can/core/DataMemory.scala
+25
-0
25 additions, 0 deletions
src/main/scala/uk/ac/soton/ecs/can/core/DataMemory.scala
src/test/scala/uk/ac/soton/ecs/can/core/DataMemoryTest.scala
+51
-0
51 additions, 0 deletions
src/test/scala/uk/ac/soton/ecs/can/core/DataMemoryTest.scala
with
76 additions
and
0 deletions
src/main/scala/uk/ac/soton/ecs/can/core/DataMemory.scala
0 → 100644
+
25
−
0
View file @
975a85f3
package
uk.ac.soton.ecs.can.core
import
chisel3._
class
DataMemory
(
addrWidth
:
Int
,
dataWidth
:
Int
,
size
:
Int
)
extends
Module
{
val
io
=
IO
(
new
Bundle
{
val
read
=
new
Bundle
{
val
addr
=
Input
(
UInt
(
addrWidth
.
W
))
val
data
=
Output
(
UInt
(
dataWidth
.
W
))
}
val
write
=
new
Bundle
{
val
en
=
Input
(
Bool
())
val
addr
=
Input
(
UInt
(
addrWidth
.
W
))
val
data
=
Input
(
UInt
(
dataWidth
.
W
))
}
})
val
mem
=
SyncReadMem
(
size
,
UInt
(
dataWidth
.
W
))
io
.
read
.
data
:=
mem
(
io
.
read
.
addr
)
when
(
io
.
write
.
en
)
{
mem
(
io
.
write
.
addr
)
:=
io
.
write
.
data
}
}
This diff is collapsed.
Click to expand it.
src/test/scala/uk/ac/soton/ecs/can/core/DataMemoryTest.scala
0 → 100644
+
51
−
0
View file @
975a85f3
package
uk.ac.soton.ecs.can.core
import
org.scalatest._
import
chiseltest._
import
chisel3._
class
DataMemoryTest
extends
FlatSpec
with
ChiselScalatestTester
{
private
val
addrWidth
=
8
private
val
dataWidth
=
16
private
val
size
=
32
it
should
"store some values"
in
{
test
(
new
DataMemory
(
addrWidth
,
dataWidth
,
size
))
{
c
=>
c
.
io
.
write
.
addr
.
poke
(
"h01"
.
U
(
addrWidth
.
W
))
c
.
io
.
write
.
data
.
poke
(
"h1234"
.
U
(
dataWidth
.
W
))
c
.
io
.
write
.
en
.
poke
(
true
.
B
)
c
.
clock
.
step
(
2
)
c
.
io
.
write
.
en
.
poke
(
false
.
B
)
c
.
io
.
read
.
addr
.
poke
(
"h01"
.
U
(
addrWidth
.
W
))
c
.
clock
.
step
(
2
)
c
.
io
.
read
.
data
.
expect
(
"h1234"
.
U
(
dataWidth
.
W
))
c
.
io
.
write
.
addr
.
poke
(
"h0a"
.
U
(
addrWidth
.
W
))
c
.
io
.
write
.
data
.
poke
(
"hfefe"
.
U
(
dataWidth
.
W
))
c
.
io
.
write
.
en
.
poke
(
true
.
B
)
c
.
clock
.
step
(
2
)
c
.
io
.
write
.
en
.
poke
(
false
.
B
)
c
.
io
.
read
.
addr
.
poke
(
"h0a"
.
U
(
addrWidth
.
W
))
c
.
clock
.
step
(
2
)
c
.
io
.
read
.
data
.
expect
(
"hfefe"
.
U
(
dataWidth
.
W
))
}
}
it
should
"not write without write enable"
in
{
test
(
new
DataMemory
(
addrWidth
,
dataWidth
,
size
))
{
c
=>
c
.
io
.
write
.
addr
.
poke
(
"h06"
.
U
(
addrWidth
.
W
))
c
.
io
.
write
.
data
.
poke
(
"hcafe"
.
U
(
dataWidth
.
W
))
c
.
io
.
write
.
en
.
poke
(
true
.
B
)
c
.
clock
.
step
(
2
)
c
.
io
.
write
.
en
.
poke
(
false
.
B
)
c
.
io
.
read
.
addr
.
poke
(
"h06"
.
U
(
addrWidth
.
W
))
c
.
clock
.
step
(
2
)
c
.
io
.
read
.
data
.
expect
(
"hcafe"
.
U
(
dataWidth
.
W
))
c
.
io
.
write
.
data
.
poke
(
"hefac"
.
U
(
dataWidth
.
W
))
c
.
clock
.
step
(
8
)
c
.
io
.
read
.
data
.
expect
(
"hcafe"
.
U
(
dataWidth
.
W
))
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment