Read file in FPGA

3.8k views Asked by At

Before I get started, please know that I am completely new to FPGA stuffs. I was wondering if it is possible to store a file (*.txt or *.csv) in a FPGA and read it line by line (i.e. file I/O operations). Please let me know. Any help would be appreciated.

I'll be coding in VHDL and probably using the Xilinx XUPV5 LX110T board.

2

There are 2 answers

6
pantelis300 On

It is possible to initialize Block RAM with an external data file, but this file must be pure binary or hexadecimal content with no comments or other information. Then you can read and write in one cycle from different addresses. You can configure the RAM as dual-port. For more information check the XST User Guide for Virtex-5. http://www.xilinx.com/support/documentation/sw_manuals/xilinx13_1/xst.pdf

0
FarhadA On

FPGA is not a micro controller, it does not have a file system or any other type of storage otions that some controller have.

But you can make the FPGA work like a controller by implementing a Soft CPU inside of it, like MicroBlaze or Neon. When you have that, you connect the CPU system to a SD card controller or connect via Uart or Ethernet to the place where your file is located, and read the file using the C code running on the SoftCore CPU.

Doing this in FPGA, for a person with no prior knowledge of how it works is going to be a very difficult task. You might be able to do this by creating a simple UART inside the FPGA and the have a state machine that receives the data from the UART and put it in the memory, but even that can be tricky and hard if you have never done this.

A third option is to convert the file into a binary and then convert that into a memory loadable file that you connect to a ROM or RAM inside the FPGA, but then, you have to recompile your project every time you want a new file!

There was a similar question on StackExchange some time ago: Transferring a 1MB bitstream to a FPGA and reading it out