0
\$\begingroup\$

I am working on Image Processing on FPGAs using Verilog. In my design I store my processed result in a Block-RAM.

Is there a way in which data stored in a Block RAM be read out of it and stored as a text file ?

\$\endgroup\$
2
  • 2
    \$\begingroup\$ "text file" is a concept that requires some file system. Where does that reside? \$\endgroup\$ Commented Jul 2, 2021 at 20:42
  • \$\begingroup\$ I'm changing your question's title to be slightly more specific,. \$\endgroup\$ Commented Jul 2, 2021 at 20:51

3 Answers 3

1
\$\begingroup\$

Generally, yes, it's possible to take data from some form of memory attached to your digital logic and write it to permanent storage in a structured manner.

A "file" is something that exists within a file system, ie. a data structure meant to structure data on a larger storage device. Typically, dealing with such data structures is mostly sequential logic; therefore, the typical method of storing something e.g. on an SD card is giving the FPGA the ability to execute instructions from some memory (instead of trying to implement all this in logic hardware, which then quickly becomes rare). A digital logic state machine that executes instructions – that's a CPU.

  1. implement a softcore CPU in you FPGA. It doesn't have to be overly fast – you're most likely limited by the storage speed - and thus doesn't have to be resource intense. A picoRV32 might just do fine.
  2. give said CPU access to the block RAM, for example through the same DMA controller you use to write to that RAM from your image processing logic. This usually means there's some common bus (AMBA, wishbone...) that CPU and memory controller reside on
  3. implement (or use a hardware-implemented) communication interface to the storage device (e.g. a low-level SD controller that just keeps the timing correct and otherwise is a FIFO between SD card and CPU)
  4. connect that to the CPU, via some bus, or memory mapped through a DMA-controller.
  5. write software (in C, C++, Rust, assembler, …) that speaks the SD card protocol, and knows a file system. Typically, such code already exists in libraries, and you just need to write drivers for your specific buses and peripherals.
\$\endgroup\$
1
  • \$\begingroup\$ Thank you so much! I'll definitely try this. \$\endgroup\$ Commented Jul 5, 2021 at 16:57
1
\$\begingroup\$

One simple way which I used on board to do the same goes like:

  1. Design a glue logic to read data from each location of BRAM.
  2. Send each byte of the data through a UART module to PC using a USB-TTL/FTDI.
  3. Receive these bytes in real time using a serial terminal program in PC and dump this into a file.
\$\endgroup\$
1
\$\begingroup\$

There are many ways to give a host PC access to memory (and registers) located in an FPGA. Two that I have used in the past are:

  • USB: The FTDI FT2451 has a bidirectional parallel bus that is easy to connect to the FPGA. The host PC can treat this as a COM port (much faster than a UART, however), or use FTDI's D2XX drivers for more direct access.

  • SPI: A simple SPI slave module in the FPGA can be controlled with something like a "Bus Pirate" from the host PC. (Or in my case, a SPI master on another FPGA.)

Both of these are simpler to implement and perform faster than a UART interface.


1 This was a long time ago. They now have more modern chips with equivalent functionality.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.