parent
f7abe368a9
commit
31cd72c0b6
|
@ -826,7 +826,7 @@ def _convert_fragment(builder, fragment, name_map, hierarchy):
|
||||||
memory = param_value
|
memory = param_value
|
||||||
if memory not in memories:
|
if memory not in memories:
|
||||||
memories[memory] = module.memory(width=memory.width, size=memory.depth,
|
memories[memory] = module.memory(width=memory.width, size=memory.depth,
|
||||||
name=memory.name)
|
name=memory.name, attrs=memory.attrs)
|
||||||
addr_bits = bits_for(memory.depth)
|
addr_bits = bits_for(memory.depth)
|
||||||
data_parts = []
|
data_parts = []
|
||||||
data_mask = (1 << memory.width) - 1
|
data_mask = (1 << memory.width) - 1
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import operator
|
import operator
|
||||||
|
from collections import OrderedDict
|
||||||
|
|
||||||
from .. import tracer
|
from .. import tracer
|
||||||
from .ast import *
|
from .ast import *
|
||||||
|
@ -24,14 +25,17 @@ class Memory:
|
||||||
name : str
|
name : str
|
||||||
Name hint for this memory. If ``None`` (default) the name is inferred from the variable
|
Name hint for this memory. If ``None`` (default) the name is inferred from the variable
|
||||||
name this ``Signal`` is assigned to.
|
name this ``Signal`` is assigned to.
|
||||||
|
attrs : dict
|
||||||
|
Dictionary of synthesis attributes.
|
||||||
|
|
||||||
Attributes
|
Attributes
|
||||||
----------
|
----------
|
||||||
width : int
|
width : int
|
||||||
depth : int
|
depth : int
|
||||||
init : list of int
|
init : list of int
|
||||||
|
attrs : dict
|
||||||
"""
|
"""
|
||||||
def __init__(self, *, width, depth, init=None, name=None, simulate=True):
|
def __init__(self, *, width, depth, init=None, name=None, attrs=None, simulate=True):
|
||||||
if not isinstance(width, int) or width < 0:
|
if not isinstance(width, int) or width < 0:
|
||||||
raise TypeError("Memory width must be a non-negative integer, not {!r}"
|
raise TypeError("Memory width must be a non-negative integer, not {!r}"
|
||||||
.format(width))
|
.format(width))
|
||||||
|
@ -44,6 +48,7 @@ class Memory:
|
||||||
|
|
||||||
self.width = width
|
self.width = width
|
||||||
self.depth = depth
|
self.depth = depth
|
||||||
|
self.attrs = OrderedDict(() if attrs is None else attrs)
|
||||||
|
|
||||||
# Array of signals for simulation.
|
# Array of signals for simulation.
|
||||||
self._array = Array()
|
self._array = Array()
|
||||||
|
|
|
@ -42,6 +42,12 @@ class MemoryTestCase(FHDLTestCase):
|
||||||
"'str' object cannot be interpreted as an integer"):
|
"'str' object cannot be interpreted as an integer"):
|
||||||
m = Memory(width=8, depth=4, init=[1, "0"])
|
m = Memory(width=8, depth=4, init=[1, "0"])
|
||||||
|
|
||||||
|
def test_attrs(self):
|
||||||
|
m1 = Memory(width=8, depth=4)
|
||||||
|
self.assertEqual(m1.attrs, {})
|
||||||
|
m2 = Memory(width=8, depth=4, attrs={"ram_block": True})
|
||||||
|
self.assertEqual(m2.attrs, {"ram_block": True})
|
||||||
|
|
||||||
def test_read_port_transparent(self):
|
def test_read_port_transparent(self):
|
||||||
mem = Memory(width=8, depth=4)
|
mem = Memory(width=8, depth=4)
|
||||||
rdport = mem.read_port()
|
rdport = mem.read_port()
|
||||||
|
|
Loading…
Reference in a new issue