Electronic – Transferring a 1MB bitstream to a FPGA and reading it out

flashfpgamemoryspartan

I am using Spartan 3E Starter Kit and I need to store a sequence of bits around 1MB long. It is a constant bitstream and will be known to me at the time of programming the board. I need to be able to read out one bit at a time from this stream. I believe I need to put this sequence of bits in the flash memory on the board since I need it to be persistent even when power is not given to the board. Any clue how that is to be done?

Can someone point me to a tutorial on how to put this data on the flash and how to read it out to some other module that processes it?

Xilinx Devices:

  • Spartan-3E FPGA (XC3S500E-4FG320C)
  • CoolRunnerâ„¢-II CPLD (XC2C64A-5VQ44C)
  • Platform Flash (XCF04S-VO20C)
  • Clocks: 50 MHz crystal clock oscillator

Memory:

  • 128 Mbit Parallel Flash (28F256)
  • 16 Mbit SPI Flash (M25P16)
  • 64 MByte DDR SDRAM (MT46V16M16)

Best Answer

Method 1: Create ROMs in your FPGA design

Because you have the same data in every board, one option is to use block RAMs in the FPGA, configured as ROM. To do this you instantiate a block RAM, but don't connect to the write pins. Use a synthesis directive in your HDL code or UCF file to specify the initial contents of the RAM. Read the Spartan-3 Generation User's Guide (Chapter 4) to see how to instantiate the RAM and how to access the data from the RAM. If you use Xilinx ISE, there is probably also a "wizard" to generate the RAM block and set up the initial contents for you.

Unfortunately, the Spartan-3E you are using has only 350 kbits of block RAM, not 8 Mbits like you require. For this to work then, you'll have to work out a scheme to compress your data to fit in 350 kbits. The details of how to do this depend on what kind of data you have. If your data is especially random, it might not be reasonable to get this much compression.

Method 2: Store data in external memory

You say you have a 128 Mbit parallel flash and a 16 Mbit SPI flash. You will need to read the datasheets for these parts and understand how they work. Then write a state machine into your FPGA that can access these devices. But this is your job as the FPGA designer. Some random strangers on the internet are not going to design your FPGA for you.

To store the data onto the flash initially you have two choices. First would be, if you are building these boards in volume, you can have your board assembly shop pre-program the flash devices before assembling them onto the boards. Typically you give them a data file in some format they request, and they charge you some small extra fee to have the data flashed in before assembly.

Second option: Read the datasheet for the flash device. Write an FPGA design that allows you to send data from some other interface available on your board (Ethernet, USB, SPI, I2C, whatever), and load it into the flash. At manufacturing time, you load this design temporarily into your FPGA and program your flash; then you store a different "run-time" FPGA design into the on-board configuration PROM, that doesn't have the ability to modify the FLASH, and your users won't have the ability to mess up the data.