lib.memory: Allow setting Memory.init
.
The `init` property is already mutable, so this adds no actual new functionality, just convenience.
This commit is contained in:
parent
cb96b15b8c
commit
455a7bc6c8
|
@ -408,6 +408,10 @@ class Memory(wiring.Component):
|
||||||
def init(self):
|
def init(self):
|
||||||
return self._init
|
return self._init
|
||||||
|
|
||||||
|
@init.setter
|
||||||
|
def init(self, init):
|
||||||
|
self._init = Memory.Init(init, shape=self._shape, depth=self._depth)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def attrs(self):
|
def attrs(self):
|
||||||
return self._attrs
|
return self._attrs
|
||||||
|
|
|
@ -311,6 +311,8 @@ class MemoryTestCase(FHDLTestCase):
|
||||||
self.assertEqual(m.init._raw, [0, 2, 0, 0])
|
self.assertEqual(m.init._raw, [0, 2, 0, 0])
|
||||||
m.init[2:] = [4, 5]
|
m.init[2:] = [4, 5]
|
||||||
self.assertEqual(list(m.init), [0, 2, 4, 5])
|
self.assertEqual(list(m.init), [0, 2, 4, 5])
|
||||||
|
m.init = [6, 7]
|
||||||
|
self.assertEqual(list(m.init), [6, 7, 0, 0])
|
||||||
|
|
||||||
def test_init_set_shapecastable(self):
|
def test_init_set_shapecastable(self):
|
||||||
m = Memory(shape=MyStruct, depth=4, init=[])
|
m = Memory(shape=MyStruct, depth=4, init=[])
|
||||||
|
|
Loading…
Reference in a new issue