Relationship between xapp1167 and TRD14.4
xapp1167 and TRD14.4 are the best reference designs for learning Zynq. are based on ZC702, not Zedboard, if you want to use Zedboard then you must modify the hardware configuration, because in the 702 board of HDMI with a soft core, and Zedboard with the chip, as well as a network card and so on are not the same configuration.
1:xapp1167:http://xgoogle.xilinx.com/search?getfields=*&numgm=5&filter=0&proxystylesheet=xilinx_c &client=xilinx_c&site=entiresite_c&btng=google+search&ie=utf-8&oe=utf-8&output=xml_no_ dtd&requiredfields=-archived%3atrue&sort=date%3ad%3al%3ad1&q=xapp1167. Zip&lang2search=
2:trd14:http://www.wiki.xilinx.com/zynq+base+trd+14.3
3: There is a better information is workshop:http://china.xilinx.com/support/university/professors.html
Trd
TRD contains 5 files, including Hw_platform, ZYNQ_FSBL, standalone_bsp, plus uboot.elf for boot.bin generation, SOBEL_QT for interface applications, SOBEL_ CMD contains the software implementation of the Sobel code implementation and the VDMA driver, and so on, but not in the Linux environment compiled, using the SDK in the compilation environment, in fact, the compiler or the Linux compilation chain.
TRD is a sobel FPGA hardware IP core and software implementation Sobel algorithm comparison, if Sobel hardware core input output is Axi-stream stream, with a VDMA (HP interface) as a video stream and DDR data exchange
The following is the function of software implementation Sobel in TRD IMG_FILTERS.C
/***************************************************************************** * * @file img_filters.h * * Implementation of software Sobel filter. * ******************************************************************************/#include <stdio.h># Include <malloc.h> #include "img_filters.h" static znq_u8 line_buffer[3][1920];//considering Max width as 1920x1080 TODO : "Change" in the more professional way.unsigned char rgb2y (znq_u8 R, Znq_u8 G, znq_u8 B) {unsigned char y;y = ((* R + 12 9 * G + + * B + +) >> 8) + 16;return y;} void Img_process (Znq_s32 *rgb_data_in, znq_s32 *rgb_data_out, int height, int width, int stride) {Short X_weight;short y_we Ight;short Edge_weight; Znq_u8 Edge_val; Znq_u8 In_r, In_g, In_b; Znq_int pix_i = 0, Pix_j = 0;/* Clearing 0th row:sobel filter is not applied on 0th row:to has consistent data flow */ for (Pix_j = 0; pix_j < width; pix_j++) {Rgb_data_out[pix_j] = 0;} Rgb_data_out = rgb_data_out + stride;/* Convert initial (i-1 & i) 2-rows of RGB pixel data into line buffers after conv. into Y (luminance) */for (pix_j = 0; Pix_j < (width + 1); pix_j++) {//line_buff Er[0][pix_j] = (((znq_int) (In_pix[0][pix_j]. R + In_pix[0][pix_j]. G + In_pix[0][pix_j]. B) + >> 2); In_b = ((*rgb_data_in) & 0x000000ff) In_g = (((*rgb_data_in) >>8) & 0x000000ff); In_r = (((*rgb_data_in) >>16) & 0X000000FF); Line_buffer[0][pix_j] = rgb2y (In_r, In_g, in_b); rgb_data_in++;} rgb_data_in = rgb_data_in + stride-width-1;/* in-case Stride is different from width of the row */for (pix_j = 0; pix_ J < (width + 1); pix_j++)/* 1st row */{/* Line_buffer[1][pix_j] = (((znq_int) (In_pix[1][pix_j]. R + In_pix[1][pix_j]. G + In_pix[1][pix_j]. B) + +) >> 2); */in_b = ((*rgb_data_in) & 0x000000ff) In_g = (((*rgb_data_in) >>8) & 0x000000ff); In_r = (((*rgb_data_in) &G t;>16) & 0X000000FF); Line_buffer[1][pix_j] = rgb2y (In_r, In_g, in_b); rgb_data_in++;} rgb_data_in = rgb_data_in + stride-width-1;/* In-casE Stride is different from WIDTH of the row *//* + + went 1beyond so ( -1) */for (pix_i = 2; pix_i < height; pix_i++) {/* C Opy (pix_i) row into Line_buffer, i.e:line_buffer[2] <--row[pix_i] */for (pix_j = 0; Pix_j < (width + 1); pix_j++) { /* Line_buffer[2][pix_j] = (((znq_int) (In_pix[pix_i][pix_j]. R + In_pix[pix_i][pix_j]. G + In_pix[pix_i][pix_j]. B) + >> 2); *///new pixel...rgb2y (TEMP1); In_b = ((*rgb_data_in) & 0x000000ff); In_g = (((*rgb_data_in) >& gt;8) & 0x000000ff) In_r = (((*rgb_data_in) >>16) & 0X000000FF); Line_buffer[2][pix_j] = rgb2y (In_R, In_G, I N_b); rgb_data_in++;} rgb_data_in = rgb_data_in + stride-width-1;/* in-case Stride is different from width of the row */*rgb_data_out = 0; Making first pixel zero./* compute Sobel filtering over (pix_i-1) pixels, i.e:sobel_filtering (&line_buffer[1][0] ) */for (Pix_j = 1; pix_j < (width + 1); pix_j++) {x_weight = line_buffer[0][pix_j-1]* ( -1) + line_buffer[0][pix_j+1] + line_buffer[1][pix_j-1]* ( -2) + line_buffer[1][pix_j+1]* (2) + line_buffer[2][pix_j-1]* ( -1) + line_buffer[2][pix_j+1];//x_weight = window[0][0]* ( -1) + window[0][2] + window[1][0]* ( -2) + window[1][2]* (2) + window[2][0]* ( -1) + window[2][2] ; y_weight = line_buffer[0][pix_j-1] + line_buffer[0][pix_j]* (2) + line_buffer[0][pix_j+1] + line_buffer[2][pix_j-1]* ( -1) + line_buffer[2][pix_j]* ( -2) + line_buffer[2][pix_j+1]* ( -1);//y_weight = window[0][0] + window[0][1]* (2) + WINDOW[0][2] + window[2][0]* ( -1) + window[2][1]* ( -2) + window[2][2]* ( -1); edge_weight = ABS (x_weight) + ABS (y_weight);//added RGB fix-06-dec-12if (Edge_weight < 255) Edge_val = (255-(unsigned char) (edge_weight)); Elseedge _val = 0;if (Edge_val > GB) edge_val = 255;else if (Edge_val < +) Edge_val = 0;//out_pix2_ptr = & (Out_pix2[0][0]) ;//Out_pix2[pix_i-1][pix_j]. R = Out_pix2[pix_i-1][pix_j]. G = Out_pix2[pix_i-1][pix_j]. B = edge_val;//Write the edge value into rgb//////////////////////////{rgb_data_out++;/* col starts from 1 not 0 ...??? *be careful here */*rgb_data_out = (Edge_val) | (edge_val<<8) | (edge_val<<16) | 0xff000000;}} /*--sobel_filtering (Row[pix_i-1]) Complete */rgb_data_out = rgb_data_out + stride-width;/* in-case Stride is differe NT from WIDTH of the row *//* copy the history of Pixel data *//* row[pix_i-2] <--row[pix_i-1], I.e:line_buf[0] & lt;--line_buf[1] *//* row[pix_i-1] <--row[pix_i], i.e:line_buf[1] <--line_buf[2] */for (pix_j = 0; Pix_j < ( Width/* PBJ no need of ' + 1 ' */); pix_j++) {Line_buffer[0][pix_j] = Line_buffer[1][pix_j]; Line_buffer[1][pix_j] = Line_buffer[2][pix_j];}} Clearing the last Linefor (pix_j=0; pix_j < width; pix_j++) {Rgb_data_out[pix_j] = 0;}}
XAPP1167
Accelerating OpenCV applications with Zynq-7000 all Programmable SoC using Vivado HLS Video Libraries
xapp1167 is mainly using HLS to implement the Sobel algorithm, written in HLS OpenCV Library, and then generate Pcore to join EDK,
XAPP1167 contains
4. DESIGN FILE HIERARCHY
=========================
The directory structure underneath this top-level folder is described
Below
|--boot_image/
| |--bootgen.sh # Script to build Boot.bin
| |--bootimage.bif # Include file names to create boot image
| |--System.bit # Hardware bitstream to configure the FPGA
| |--u-boot.elf # u-boot Boot Loader executable
| |--Zynq_fsbl.elf # ZYNQ First stage boot loader executable
|
|--hw/
| |--xps_proj/# XPS Hardware project for TRD design
|
|--opencv_install/
| |--arm_linux/# OpenCV Libraries and header files for arm
|
|--sd_image/
| |--Boot.bin # Zynq BOOT Image, which is created from
| | FSBL, hardware bitstream and U-boot
| |--DEVICETREE.DTB # Linux device tree binary, loaded into
| | Memory by U-boot (1080p resolution)
| |--init.sh # Script to set up environment, sourced at the
| | End of the boot process
| |--opencv_lib.img # pre-compiled OPENCV Libraries required to
| | Run the application
| |--run.sh # Wrapper script for application
| |--uramdisk.image.gz # Ramdisk image, loaded into memory by U-boot
| |--uimage # Linux kernel image, loaded into memory by
| | U-boot
| |--Video_library_cmd # cmd line based Linux application executable
|
|--sw/
| |--demo/# Demo design for Opencv-acceleration
| |--fast-corner/# corner-detection Design for Opencv-acceleration
| |--share/# Shared source files for ARM Linux application
|
|--README.txt # This file
|
|--Video_library_windows.bat # The batch file to start TRD on Windows
To enable easily building the reference designs, a Makefile is also provided
With the following targets:
' Make elf '--build SW (Video_library_cmd)
' Make sim '--build and run Csim test
' Make core '--synthesis and export Pcore
' Make bitstream '--Generate Bistream (system.bit)
' Make boot '--Generate boot image (Boot.bin)
' Make all '--build SW and HW, generate Sd_image
Running ' Make all ' from the Linux command line or the Vivado HLS command Prompt under Windows This launched by provided BA TCH file rebuilds the entire design and generates an SD card image of can be run. Detailed instructions to Build Hardware and software for this TRD is provided in XAPP1167.
We'll go in with the Vivado HLS Command Window E:\vivado_project\xapp1167_ise\sw\demo
Make all
Then generate all the hard software source files in the directory, including Edk,hls. Engineering
This last sentence we finally understand:
XAPP1167 is a detailed explanation of how to implement the TRD software and hardware process, and TRD is only an operating procedure flowchart description, without any specific implementation
HLS OPENCV implements Sobel
/#include "top.h" void Image_filter ( axi_stream& Input_stream, axi_stream& output_stream, int rows, int cols) {//create AXI streaming interfaces fo R the Core#pragma HLS INTERFACE axis port=input_stream#pragma HLS INTERFACE axis port=output_stream#pragma HLS RESOURCE Co Re=axi_slave variable=rows metadata= "-bus_bundle control_bus" #pragma HLS RESOURCE core=axi_slave variable=cols Metadata= "-bus_bundle control_bus" #pragma HLS RESOURCE core=axi_slave variable=return metadata= "-bus_bundle CONTROL_ BUS "#pragma hls INTERFACE ap_stable port=rows#pragma hls INTERFACE ap_stable port=cols rgb_image img_0 (rows, cols); Rgb_image img_1 (rows, cols); Rgb_image img_2 (rows, cols); Rgb_image img_3 (rows, cols); Rgb_image img_4 (rows, cols); Rgb_image img_5 (rows, cols); Rgb_pixel pix (a), #pragma HLS dataflow hls::axivideo2mat (Input_stream, img_0); Hls::sobel<1,0,3> (Img_0, img_1); hlS::subs (img_1, pix, img_2); Hls::scale (Img_2, Img_3, 2, 0); Hls::erode (Img_3, img_4); HLS::D ilate (Img_4, img_5); Hls::mat2axivideo (Img_5, output_stream);}
Reference
==============
Xapp1167-accelerating OpenCV applications with Zynq-7000 all Programmable SoC using Vivado HLS Video Libraries
Ug902-vivado Design Suite User guide:high-level Synthesis
Us873-zynq concepts, Tools and techniques
Ug798-xilinx Design tools:installation and Licensing Guide
ug926-zynq-7000 ZC702 Evaluation Kit Getting Started Guide
ug850-zc702 Evaluation Board User Guide
http://www.wiki.xilinx.com/Zynq+Base+TRD+14.5
Relationship between xapp1167 and TRD14.4