back.rtlil: use one $meminit cell, not one per word.

This is *far* more efficient.
This commit is contained in:
whitequark 2018-12-24 09:30:47 +00:00
parent 98f554aa08
commit d47c1f8a8a

View file

@ -644,21 +644,23 @@ def convert_fragment(builder, fragment, name, top):
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)
addr_bits = bits_for(memory.depth) addr_bits = bits_for(memory.depth)
data_parts = ["{}'".format(memory.width * memory.depth)]
for addr in range(memory.depth): for addr in range(memory.depth):
if addr < len(memory.init): if addr < len(memory.init):
data = memory.init[addr] data = memory.init[addr]
else: else:
data = 0 data = 0
module.cell("$meminit", ports={ data_parts.append("{:0{}b}".format(data, memory.width))
"\\ADDR": rhs_compiler(ast.Const(addr, addr_bits)), module.cell("$meminit", ports={
"\\DATA": rhs_compiler(ast.Const(data, memory.width)), "\\ADDR": rhs_compiler(ast.Const(0, addr_bits)),
}, params={ "\\DATA": "".join(data_parts),
"MEMID": memories[memory], }, params={
"ABITS": addr_bits, "MEMID": memories[memory],
"WIDTH": memory.width, "ABITS": addr_bits,
"WORDS": 1, "WIDTH": memory.width,
"PRIORITY": 0, "WORDS": memory.depth,
}) "PRIORITY": 0,
})
param_value = memories[memory] param_value = memories[memory]