in which I think addr_width = (node.size-1).bit_length() is correct.
I see that under utils.py you have a clog2 function and I think it would be most appropriate to use that where possible.
Additionally, I'd think it would be appropriate to use clog2 in peakrdl_regblock/hwif/generators.py, under OutputStructGenerator_Hier::_add_external_block_members:
self.add_member("addr", (node.size - 1).bit_length()) should be (I think) self.add_member("addr", clog2(node.size)).
Hello,
I think there's an improper bit select within the external memory template when it comes to setting the external bus's address.
For the following RDL file:
The generated code gives the external memory interface struct as:
in where the
addr
field has the correct address width.However in the module file we see:
The bit select on
decoded_addr
is too wide and should be[9:0]
.The root of the issue seems to lie in
src/peakrdl_regblock/field_logic/generators.py
'sFieldLogicGenerator::assign_external_block_outputs
:in which I think
addr_width = (node.size-1).bit_length()
is correct.I see that under
utils.py
you have aclog2
function and I think it would be most appropriate to use that where possible.Additionally, I'd think it would be appropriate to use
clog2
inpeakrdl_regblock/hwif/generators.py
, underOutputStructGenerator_Hier::_add_external_block_members
:self.add_member("addr", (node.size - 1).bit_length())
should be (I think)self.add_member("addr", clog2(node.size))
.Thanks, Aylon