Add genvar declaration to addrmap

This commit is contained in:
Dennis Potter 2021-06-03 18:07:17 +02:00
parent f4432f5b49
commit 21abdefac0
Signed by: Dennis
GPG Key ID: 186A8AD440942BAF
3 changed files with 24 additions and 0 deletions

View File

@ -147,6 +147,14 @@ class AddrMap(Component):
inputs = '\n'.join(input_ports_rtl),
outputs = '\n'.join(output_ports_rtl)))
# Append genvars
genvars = ''.join([
'\ngenvar ',
','.join([chr(97+i) for i in range(self.get_max_dim_depth())]),
';\n'
])
self.rtl_header.append(genvars)
# Add endmodule keyword
self.rtl_footer.append('endmodule')

View File

@ -65,6 +65,21 @@ class Component():
return self.ports[port_type]
def get_max_dim_depth(self) -> int:
try:
total_dimensions = self.total_dimensions
total_array_dimensions = self.total_array_dimensions
except AttributeError:
total_dimensions = 0
total_array_dimensions = []
self.logger.debug("Return depth '{}' for dimensions (including "\
"parents) '{}'".format(total_dimensions, total_array_dimensions))
return max([
total_dimensions,
*[x.get_max_dim_depth() for x in self.children]
])
def get_signals(self):
self.logger.debug("Return signal list")

View File

@ -145,6 +145,7 @@ class Field(Component):
# Save dimensions of unpacked dimension
self.array_dimensions = array_dimensions
self.total_array_dimensions = array_dimensions
self.total_dimensions = len(self.total_array_dimensions)
# Calculate how many genvars shall be added
genvars = ['[{}]'.format(chr(97+i)) for i in range(len(array_dimensions))]