projects
/
nmigen.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
58e39f9
)
back.rtlil: mask memory init values.
author
whitequark
<whitequark@whitequark.org>
Tue, 11 Jun 2019 03:43:09 +0000
(
03:43
+0000)
committer
whitequark
<whitequark@whitequark.org>
Tue, 11 Jun 2019 03:43:09 +0000
(
03:43
+0000)
This handles both init values that are too wide, which happens if
their magnitude is too high, or if they're negative.
Fixes #96.
nmigen/back/rtlil.py
patch
|
blob
|
history
diff --git
a/nmigen/back/rtlil.py
b/nmigen/back/rtlil.py
index 1a1fabc47f58d6bbc7442455523533dab8de5090..a33630abac558c2d6dc94fe4363a045db6f756d1 100644
(file)
--- a/
nmigen/back/rtlil.py
+++ b/
nmigen/back/rtlil.py
@@
-729,9
+729,10
@@
def convert_fragment(builder, fragment, hierarchy):
name=memory.name)
addr_bits = bits_for(memory.depth)
data_parts = []
+ data_mask = (1 << memory.width) - 1
for addr in range(memory.depth):
if addr < len(memory.init):
- data = memory.init[addr]
+ data = memory.init[addr]
& data_mask
else:
data = 0
data_parts.append("{:0{}b}".format(data, memory.width))