Electrical – FPGA, accessing data in RAM


I'm using an Altera Cyclone V DE1-SoC for an image processing project and to be able to do the "processing" on the FPGA, I thought I probably needed to store the image data on the FPGA first. So I went ahead and converted a sample image I want to use to a .mif file and used the Memory Compiler megafunction (RAM:1-PORT option). I chose the .mif file I created and made sure the number of words and bit widths match. Everything seems to have worked fine so far but… how do I actually use this data now? The .mif file contains the tone values of a 240×320 grayscale image and I need to go through these values one by one to apply Sobel edge detection. I did this using MATLAB without any built-in functions so I think I'll be able to write the necessary code in Verilog as well, just need to access the data. I'm pretty new to FPGA stuff so I'm sorry if this has a very simple answer.

(Also, if there are any methods that are more straightforward than initializing memory, please suggest them. I may be overcomplicating things unnecessarily but am not sure.)

Any help is appreciated! Thanks in advance.

Best Answer

Two things:

  • there're Altera documents on embedded RAM describing how you access the RAM - for read and write; in your image processing circuit you will need state machine which would track address needed to be read, and waited for specific time to capture data outputted by the RAM;
  • it seems that you are currently hard-coding the data into the FPGA RAM (and RAM will be initialized with this data image after FPGA configuration). If you will develop your applications further when image can be loaded "outside" of the FPGA, I recommend you considering using 2-port RAM - one port is used for loading image (and connected to one state machine), and another port is used for processing the image (and connected to another state machine).