Loopback video to FPGA isnt correct

Questions and discussions about the Xillybus IP core and drivers

Loopback video to FPGA isnt correct

Postby minhluance » Sat Apr 08, 2017 4:22 pm

I'm learning about Zybo Zynq-7000 ARM/FPGA SoC Trainer Board.
I'm doing loopback video from software-FPGA-software.
I use OpenCV to create mat of an video AVI format. I use fifo 32x512 loopback (default) from xillinux-eval-zybo-2.0a.
My loopback system is generated from xillinux-eval-zybo-2.0a. I use Vivadl 2016.1


My output frame is deviated from the original. Sometimes the loopback frame is right at the first few seconds, but then there is a deflection.
I do not understand what caused this. I only use the existing loopback system and do not edit anything
Here is my result (frame window is original video, frame1 is loopback video).
My job is just sending data down to the fpga and retrieving the data. I can not see the error in this case.
Video input 320*240 pixels. An error occurred at the beginning
Crop video to 200*130. Initially given the right result, the result is wrong later.
Period for erroneous results are not fixed. There are 4s, sometimes 20s, sometimes 60s

My code on xillinux

My module xillydemo.v
Posts: 1
Joined: Sat Apr 08, 2017 3:16 pm

Re: Loopback video to FPGA isnt correct

Postby support » Sat Apr 08, 2017 5:11 pm


It appears like xillydemo.v is exactly the code that arrives with the bundle. Please, when that is the case, say so. No point reading it through if it's just the same plain loopback.

As for the C++ code, I see two serious issues:

(1) You don't check the return value of neither read() or write() calls. Please refer to section 3.2 and 3.3 of the Xillybus host application programming guide for Linux (http://xillybus.com/downloads/doc/xilly ... _linux.pdf), and possibly compare with the sample streamread.c and streamwrite.c programs. read() and write() may handle less data than requested, and reflect that in the return value. This is standard UNIX coding practice. The reason to the picture jumping is most likely a partial read or write which your code failed to handle.

(2) You read() and write() in the same thread. That's a recipe for problems. People who do this often complain that the program hangs for no apparent reason. The reason is related to the partial read() and write() possible in UNIX causing an unbalance between reads and writes. Anyhow, since it appears like you're heading towards a coprocessing application, I suggest looking at section 6.6 in the Guide mentioned above. It's likely to save you some trouble ahead.

So -- consider a fork() for running reads and writes in separate processes, and following UNIX I/O practices to make sure data isn't lost.

Posts: 482
Joined: Tue Apr 24, 2012 3:46 pm

Return to Xillybus