ram/lattice_nx: Add init parameter and rename method to add_init.
When init is not empty, call add_init automatically (similar to Memory).
This commit is contained in:
parent
869b5c24a8
commit
7179d88e8c
|
@ -49,7 +49,7 @@ def initval_parameters(contents, width):
|
||||||
|
|
||||||
|
|
||||||
class NXLRAM(Module):
|
class NXLRAM(Module):
|
||||||
def __init__(self, width=32, size=128*kB):
|
def __init__(self, width=32, size=128*kB, init=[]):
|
||||||
self.bus = wishbone.Interface(width)
|
self.bus = wishbone.Interface(width)
|
||||||
assert width in [32, 64]
|
assert width in [32, 64]
|
||||||
self.width = width
|
self.width = width
|
||||||
|
@ -100,7 +100,10 @@ class NXLRAM(Module):
|
||||||
|
|
||||||
self.sync += self.bus.ack.eq(self.bus.stb & self.bus.cyc & ~self.bus.ack)
|
self.sync += self.bus.ack.eq(self.bus.stb & self.bus.cyc & ~self.bus.ack)
|
||||||
|
|
||||||
def add_initial_value(self, data):
|
if init != []:
|
||||||
|
self.add_init(init)
|
||||||
|
|
||||||
|
def add_init(self, data):
|
||||||
# Pad it out to make slicing easier below.
|
# Pad it out to make slicing easier below.
|
||||||
data += [0] * (self.size // self.width * 8 - len(data))
|
data += [0] * (self.size // self.width * 8 - len(data))
|
||||||
for d in range(self.depth_cascading):
|
for d in range(self.depth_cascading):
|
||||||
|
|
Loading…
Reference in New Issue