When synthesized for ICE40, RAMController.v's maximum clock frequency is ~130 MHz allowing for a maximum throughput of ~248 MB/sec. (These numbers are from Photon's top-level Verilog synthesized with the Yosys/icestorm toolchain.)
RAMController.v should work with any FPGA, but it's been specifically tested and used with the ICE40 and the Yosys/icestorm toolchain.
RAMController.v abstracts away the inconvenient details of managing an SDRAM, such as:
RAMController.v breaks the SDRAM into a configurable number of "blocks". For example, Photon's SDRAM is large enough to hold two images, so it's broken into two blocks.
input wire[1:0] cmd, input wire[N:0] cmd_block,
Valid values: None
, Read
, Write
, Stop
Only applies for cmd
= Read
/ Write
Read
command is issued on the Command port. output wire read_ready, input wire read_trigger, output wire[N:0] read_data,
read_data
holds a valid word cmd_block
Write
command is issued on the Command port. output wire write_ready, input wire write_trigger, input wire[N:0] write_data,
write_data
can be written write_data
should be written While deasserted, writing is paused at the current position within cmd_block
cmd_block
It's for this reason that the read_ready
and write_ready
outputs are provided. The client must properly handle these signals by ensuring that its state machine does not advance when read_ready=0
or write_ready=0
, which could occur during any read or write, or while the SDRAM is first being initialized.
ClkFreq
: the frequency of the clock provided to the SDRAM chip; used to calculate the various delays (such as the delay between refresh commands) BlockCount
: the number of blocks that the SDRAM is broken into (Photon uses BlockCount=2
) WordWidth
: the width of a word, as defined by the SDRAM chip BankWidth
: the width of the bank address, as defined by the SDRAM chip RowWidth
: the width of the row address, as defined by the SDRAM chip ColWidth
: the width of the column address, as defined by the SDRAM chip DQMWidth
: the width of the DQM signals, as defined by the SDRAM chip