My current iCE40 FPGA project includes an 8-bit (soft IP) microprocessor connected to a 4Kx8 RAM which is composed from 8 2Kx2 block RAMs. It would be useful to be able to load new programs (for the 8-bit micro) into the 4kx8 RAM without requiring an FPGA recompile or reroute. The proposed flow would need to a) analyze the FPGA netlist to figure out how the 8 2Kx2 block RAMs (that compose the 4Kx8 RAM) are arranged and named. b) split the Intel hex file that contains the new program (for the 8-bit-micro) into 8 sections. c) find each of the 8 block RAM data sections in the bitstream and replace the current content of each section with the new program content. Can anyone from the icestorm or yosys projects please comment if this proposed flow is possible (or if a solution already exists).
1 Answers
Edit: There is now a tool in IceStorm to do this: icebram
Example usage:
Generate a random hex file for synthesis. Say we have a memory that is 8 bits wide x 512 words deep:
icebram -g 8 512 > datafile_syn.hex
Run synthesis (Yosys) and place&route (arachne-pnr). Use
$readmemh("datafile_syn.hex", memory);
in your Verilog code to initialize the memory.Replace memory content in the generated IceStorm .asc file:
icebram datafile_syn.hex datafile.hex < synout.asc > final.asc
Pack final IceStorm .asc file into binary bit-stream with
icepack
.
Simply repeat steps 3. and 4. whenever you got a new datafile.hex
.
Theoretically this is possible of course, but it's not implemented yet. Afaics the following changes would be required:
1) Yosys' memory_bram
pass would need to somehow store the information how a memory in the original design is broken up into individual SB_RAM40_4K cells, preferably by storing this information in attributes on the cells.
2) Arachne-pnr already can create a placelist. This should be extended to also write a file that contains the information from the attributes in 1) plus the relevant placement information.
3) A tool must be written that is using this information to patch the memory content of IceStorm .asc files.
I can do 1) but it would be nice if somebody else would do 2) and 3).