memory = param_value
if memory not in memories:
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)
data_parts = []
data_mask = (1 << memory.width) - 1
import operator
+from collections import OrderedDict
from .. import tracer
from .ast import *
name : str
Name hint for this memory. If ``None`` (default) the name is inferred from the variable
name this ``Signal`` is assigned to.
+ attrs : dict
+ Dictionary of synthesis attributes.
Attributes
----------
width : int
depth : 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:
raise TypeError("Memory width must be a non-negative integer, not {!r}"
.format(width))
self.width = width
self.depth = depth
+ self.attrs = OrderedDict(() if attrs is None else attrs)
# Array of signals for simulation.
self._array = Array()
"'str' object cannot be interpreted as an integer"):
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):
mem = Memory(width=8, depth=4)
rdport = mem.read_port()