Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is conversion from OpenCV code to FPGA code is easier than Matlab code or not? [closed]

I want to do project on image processing. i want to know if i want to implement this project on FPGA, which tool should I choose at 1st stage Matlab or OPEN CV? and is it possible to convert code from Open CV to FPGA directly like code generator can be used from Matlab to FPGA directly??

like image 537
M.Naeem G Avatar asked Jul 25 '13 06:07

M.Naeem G


1 Answers

Firstly - why do you want to use an FPGA? Unless you have good reasons to, avoid it!

Good reasons can be things like:

  • cost
  • power
  • size
  • pre-existing hardware which must be re-used
  • personal interest
  • it's an assignment where FPGAs are mandated

Bad reasons include "image-processing... that must mean I need an FPGA!"


Think FPGA

If you want to implement on FPGA you need to think "FPGA" right from the beginning. They have very particular characteristics compared to conventional processors, which means that many "conventional" algorithms are very difficult to implement efficiently on FPGAs. And other algorithms which conventional processing will struggle with can actually be done quite simply on an FPGA.

One classic (non-image) example is CRC calculation, which is often implemented using lookup tables in software, but can be a trivial shift-register and XOR gate in FPGA.

Regarding code generators....

There used to be a product which Xilinx bought (AccelDSP) which could take (very carefully crafted) Matlab code and produce VHDL. It didn't do very well and was withdrawn.

Matlab have HDL-coder, which purports to do the same job, as well as doing Simulink diagrams too. I evaluated it quite a long time ago - I don't know how good it is now (although it was eye-wateringly expensive!). Looking at the web page ti still only seems to support Matlab functions (not user defined objects) which makes it a non-starter for anything which stores state in it (IMHO) as all the state must be stored outside the function, meaning you have to have an "in" and "out" struct with all your regs in. Same problem as AccelDSP had.

Xilinx System Generator and Altera's System Builder both use Simulink as a front-end to producing FPGA code. They can be quite successful, be be aware that you can't just throw arbitrary complex Simulink blocks down and hope to produce a synthsisable FPGA.

Again, you have to think FPGA from the start.

FPGA features

Wherever a comparative word is used, I am comparing to "conventional desktop processors"

  • FPGA's are memory poor but they have lots of small blocks, which means their aggregate internal bandwidth can be enormous, if you have enough small jobs to do. The memory is also very low latency (single clock-cycle), much like a processor's L1 cache
  • Selections (if..else like functionality) can be quite expensive in terms of FPGA area
  • multiplications are a limited resource, so it can sometimes pay to use algorithms from the "olden-days" when processors didn't have MUL instructions
  • bit widths can be arbitrary - no need to use 32 bit elements to represent the 18 bit result of a calculation. Much of the time, the tools can figure this out for you.

The development cycle is also different.

  • Simulations are relatively quick to compile and run. Ensure you do lots of this
  • Actually synthesising and place-and-route (the operations which get you to a "bitstream" which you can program into the FPGA chip itself) can be very long-running. My current compile (which is relatively small) just took 30 mins. You want to avoid doing this as much as possible!
like image 186
Martin Thompson Avatar answered Sep 28 '22 18:09

Martin Thompson