Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tapasco
tapasco
Commits
0039dd2f
Commit
0039dd2f
authored
Dec 13, 2017
by
Jens Korinth
Browse files
Fix BitRange overlap logic in RegisterFile and provide better errors
parent
325673de
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/scala/axi4lite/RegisterFile.scala
View file @
0039dd2f
...
...
@@ -8,26 +8,27 @@ import org.scalactic.anyvals.PosInt
object
RegisterFile
{
/** Configuration object for RegisterFiles.
* @param addr
Granular
it
y
Smallest addressable bit width (default: 8, e.g., 1 byte).
* @param addr
essWordB
it
s
Smallest addressable bit width (default: 8, e.g., 1 byte).
* @param width Register data width (in bits).
* @param regs Map from offsets in addrGranularity to register implementations.
**/
case
class
Configuration
(
addr
Granular
it
y
:
Int
=
32
,
regs
:
Map
[
Int
,
ControlRegister
],
fifoDepth
:
PosInt
=
2
)
case
class
Configuration
(
addr
essWordB
it
s
:
Int
=
8
,
regs
:
Map
[
Int
,
ControlRegister
],
fifoDepth
:
PosInt
=
2
)
(
implicit
axi
:
Axi4Lite.Configuration
)
{
/* internal helpers: */
private
def
overlap
(
p
:
(
BitRange
,
BitRange
))
=
p
.
_1
.
overlapsWith
(
p
.
_2
)
private
def
makeRange
(
a
:
Int
)
:
BitRange
=
BitRange
(
a
*
addr
Granular
it
y
+
axi
.
dataWidth
.
toInt
-
1
,
a
*
addr
Granular
it
y
)
BitRange
(
a
*
addr
essWordB
it
s
+
axi
.
dataWidth
.
toInt
-
1
,
a
*
addr
essWordB
it
s
)
private
lazy
val
m
=
regs
.
keys
.
toList
.
sorted
map
makeRange
private
lazy
val
o
:
Seq
[
Boolean
]
=
(
m
.
take
(
m
.
length
-
1
)
zip
m
.
tail
)
map
overlap
private
lazy
val
o
=
(
m
.
take
(
m
.
length
-
1
)
zip
m
.
tail
)
map
{
case
(
r1
,
r2
)
=>
((
r1
,
r2
),
r1
.
overlapsWith
(
r2
))
}
o
filter
(
_
.
_2
)
foreach
{
case
((
r1
,
r2
),
_
)
=>
require
(!
r1
.
overlapsWith
(
r2
),
s
"$r1 and $r2 must not overlap"
)
}
/* constraint checking */
require
(
regs
.
size
>
0
,
"regs must not be empty"
)
require
(
regs
.
size
==
1
||
!(
o
reduce
(
_
||
_
)),
"ranges must not overlap: "
+
regs
)
require
(
regs
.
size
==
1
||
!(
o
map
(
_
.
_2
)
reduce
(
_
||
_
)),
"ranges must not overlap: "
+
regs
)
/** Minimum bit width of address lines. */
lazy
val
minAddrWidth
:
AddrWidth
=
AddrWidth
(
Seq
(
if
(
regs
.
size
*
axi
.
dataWidth
.
toInt
>=
regs
.
keys
.
max
)
{
log2Ceil
((
regs
.
size
*
axi
.
dataWidth
.
toInt
)
/
addr
Granular
it
y
)
log2Ceil
((
regs
.
size
*
axi
.
dataWidth
.
toInt
)
/
addr
essWordB
it
s
)
}
else
{
log2Ceil
(
regs
.
keys
.
max
)
},
1
).
max
)
...
...
Jens Korinth
@jk
mentioned in commit
17f0d672
·
Mar 05, 2018
mentioned in commit
17f0d672
mentioned in commit 17f0d67240ebf5d7e1d0be9162d272b04256c47d
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment