Skip to content

Commit c179330

Browse files
committed
fpga directory
1 parent 6d80f46 commit c179330

File tree

5 files changed

+143
-0
lines changed

5 files changed

+143
-0
lines changed
Binary file not shown.
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include "top.h"
2+
void hls_sobel(AXI_STREAM_IN& input, AXI_STREAM_OUT& output, int rows, int cols) {
3+
#pragma HLS RESOURCE variable=input core=AXI4Stream metadata="-bus_bundle INPUT_STREAM"
4+
#pragma HLS RESOURCE variable=output core=AXI4Stream metadata="-bus_bundle OUTPUT_STREAM"
5+
#pragma HLS INTERFACE ap_none port=cols
6+
#pragma HLS INTERFACE ap_none port=rows
7+
//AP_CONTROL_BUS_AXI(CONTROL_BUS);
8+
//set_directive_interface -mode ap_ctrl_none hls_sobel
9+
#pragma HLS interface ap_ctrl_none port=return
10+
11+
RGB_IMAGE img_0(rows, cols);
12+
RGB_IMAGE img_1(rows, cols);
13+
#pragma HLS DATAFLOW // must use data flow to stream the data
14+
hls::AXIvideo2Mat(input, img_0); //read video stream by frames
15+
hls::Sobel<1,0,1>(img_0, img_1);//use Hls Sobel
16+
hls::Mat2AXIvideo(img_1, output); //write the frames to video stream
17+
18+
}

fpga/vivado2014.4_hls_src/top.h

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#ifndef _TOP_H_
2+
#define _TOP_H_
3+
#include "hls_video.h" //这里调用可以综合的视频库
4+
5+
// maximum image size
6+
#define MAX_WIDTH 1920
7+
#define MAX_HEIGHT 1080
8+
// I/O Image Settings
9+
#define INPUT_IMAGE "test_1080p.jpg"
10+
#define OUTPUT_IMAGE "result_1080p.jpg"
11+
#define OUTPUT_IMAGE_GOLDEN "result_1080p_golden.jpg"
12+
// typedef video library core structures
13+
typedef hls::stream<ap_axiu<24,1,1,1> > AXI_STREAM_IN;
14+
typedef hls::stream<ap_axiu<24,1,1,1> > AXI_STREAM_OUT;
15+
typedef hls::Mat<MAX_HEIGHT, MAX_WIDTH, HLS_8UC3> RGB_IMAGE;
16+
typedef hls::Mat<MAX_HEIGHT, MAX_WIDTH, HLS_8UC1> GRAY_IMAGE;
17+
// top level function for HW synthesis
18+
void hls_sobel(AXI_STREAM_IN& src_axi, AXI_STREAM_OUT& dst_axi, int rows, int cols);
19+
20+
#endif
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include "top.h"
2+
#include "opencv/cv.h"
3+
#include "opencv/cxcore.h"
4+
#include "opencv/highgui.h"
5+
#include "hls_opencv.h"
6+
int main (int argc, char** argv) {
7+
IplImage* src = cvLoadImage(INPUT_IMAGE);
8+
IplImage* dst = cvCreateImage(cvGetSize(src), src->depth, src->nChannels);
9+
AXI_STREAM_IN src_axi;
10+
AXI_STREAM_OUT dst_axi;
11+
IplImage2AXIvideo(src, src_axi); //½«Í¼ÏñתΪÊÓƵÁ÷½á¹¹
12+
hls_sobel(src_axi, dst_axi, src->height, src->width);
13+
AXIvideo2IplImage(dst_axi, dst);
14+
cvSaveImage(OUTPUT_IMAGE, dst);
15+
cvReleaseImage(&src);
16+
cvReleaseImage(&dst);
17+
}
+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/******************************************************************************
2+
*
3+
* Copyright (C) 2009 - 2014 Xilinx, Inc. All rights reserved.
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy
6+
* of this software and associated documentation files (the "Software"), to deal
7+
* in the Software without restriction, including without limitation the rights
8+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
* copies of the Software, and to permit persons to whom the Software is
10+
* furnished to do so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in
13+
* all copies or substantial portions of the Software.
14+
*
15+
* Use of the Software is limited solely to applications:
16+
* (a) running on a Xilinx device, or
17+
* (b) that interact with a Xilinx device through a bus or interconnect.
18+
*
19+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
24+
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25+
* SOFTWARE.
26+
*
27+
* Except as contained in this notice, the name of the Xilinx shall not be used
28+
* in advertising or otherwise to promote the sale, use or other dealings in
29+
* this Software without prior written authorization from Xilinx.
30+
*
31+
******************************************************************************/
32+
33+
/*
34+
* helloworld.c: simple test application
35+
*
36+
* This application configures UART 16550 to baud rate 9600.
37+
* PS7 UART (Zynq) is not initialized by this application, since
38+
* bootrom/bsp configures it to baud rate 115200
39+
*
40+
* ------------------------------------------------
41+
* | UART TYPE BAUD RATE |
42+
* ------------------------------------------------
43+
* uartns550 9600
44+
* uartlite Configurable only in HW design
45+
* ps7_uart 115200 (configured by bootrom/bsp)
46+
*/
47+
48+
#include <stdio.h>
49+
#include "platform.h"
50+
#include "xparameters.h"
51+
void print(char *str);
52+
53+
int main()
54+
{
55+
init_platform();
56+
57+
print("Hello World\n\r");
58+
59+
Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0x0, 0x4); //reset MM2S VDMA Control Register
60+
Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0x0, 0x8); //gen-lock
61+
Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0x5C, 0x04000000); //MM2S Start Addresses
62+
63+
Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0x54, 640*3);//MM2S HSIZE Register---buffer length
64+
Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0x58, 0x01000780);//S2MM FRMDELAY_STRIDE Register 1920*3=5760 对齐之后为8192=0x2000
65+
66+
Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0x0, 0x03);//MM2S VDMA Control Register
67+
68+
//Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0x50, 480);//MM2S_VSIZE 启动传输
69+
70+
71+
72+
73+
74+
Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0xAC, 0x08000000);//S2MM Start Addresses
75+
Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0xA4, 640*3);
76+
Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0xA8, 0x01000780);//S2MM Frame Delay and Stride
77+
Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0x30, 0x3);//S2MM VDMA Control Register
78+
79+
80+
81+
Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0x50, 480);//MM2S_VSIZE 启动传输
82+
Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0xA0, 480);//S2MM Vertical Size start an S2MM transfer
83+
84+
cleanup_platform();
85+
return 0;
86+
}
87+
88+

0 commit comments

Comments
 (0)