m-labs / migen

A Python toolbox for building complex digital hardware
https://m-labs.hk/migen
Other
1.23k stars 210 forks source link

Fix ECP5 BRAM packing #262

Open madscientist159 opened 2 years ago

madscientist159 commented 2 years ago

The ecpbram utility expects the ROM data file to be in a fixed width (i.e. zero-padded) format. migen should be able to adhere more strictly to that format without breaking other users of the ROM data file.

See https://bugs.libre-soc.org/show_bug.cgi?id=855#c45 for an example of the old data format failing when used with ecpbram.

sbourdeauducq commented 2 years ago

Why is it not already doing it? The formatter string is already designed to do this zero padding (see l. 389). Why the double - in your patch?

sbourdeauducq commented 2 years ago

Maybe you want it to emit one more digit when the memory width is not a multiple of 4? I suggest changing l.389 to (memory.width + 3)//4 in this case.