基于FPGA+SDRAM+BT656视频解码移植总结
基于FPGA+SDRAM+BT656视频解码移植总结
一、硬件准备
1、TVP5150模块(模拟视频信号解码模块)。
2、模拟摄像头一个(PAL或NT格式输出 AV同轴)
3、FPGA开发板一块(EP4CE6+SDRAM+VGA)
实现功能:
模拟摄像头输出的视频信号为模拟信号,AV同轴线缆输出,通过转接线接到TVP5150模块,FPGA控制TVP5150模块,通过SDRAM缓存视频数据。FPGA解码BT656数据。FPGA控制VGA输出视频数据。
1 TVP5150原理图接口
参考原理图
TVP5150模块框图(参考数据手册)
FPGA仅需要9根信号线即可控制
PCLK、D0-D7(根据数据手册提供参考)
2 FPGA+SDRAM+VGA
本次选用的是层层惊涛工作室提供的开发板(核心板+底板结构)。
核心板原理图
底板原理图
主要移植需要注意的管脚分配:
时钟、VGA、DVP、SDRAM
具体管脚分配如下
set_location_assignment PIN_32 -to sdram_addr[0]
set_location_assignment PIN_31 -to sdram_addr[1]
set_location_assignment PIN_30 -to sdram_addr[2]
set_location_assignment PIN_28 -to sdram_addr[3]
set_location_assignment PIN_128 -to sdram_addr[4]
set_location_assignment PIN_129 -to sdram_addr[5]
set_location_assignment PIN_126 -to sdram_addr[6]
set_location_assignment PIN_127 -to sdram_addr[7]
set_location_assignment PIN_124 -to sdram_addr[8]
set_location_assignment PIN_125 -to sdram_addr[9]
set_location_assignment PIN_33 -to sdram_addr[10]
set_location_assignment PIN_120 -to sdram_addr[11]
set_location_assignment PIN_58 -to sdram_data[0]
set_location_assignment PIN_55 -to sdram_data[1]
set_location_assignment PIN_54 -to sdram_data[2]
set_location_assignment PIN_53 -to sdram_data[3]
set_location_assignment PIN_52 -to sdram_data[4]
set_location_assignment PIN_51 -to sdram_data[5]
set_location_assignment PIN_50 -to sdram_data[6]
set_location_assignment PIN_49 -to sdram_data[7]
set_location_assignment PIN_112 -to sdram_data[8]
set_location_assignment PIN_111 -to sdram_data[9]
set_location_assignment PIN_110 -to sdram_data[10]
set_location_assignment PIN_106 -to sdram_data[11]
set_location_assignment PIN_105 -to sdram_data[12]
set_location_assignment PIN_104 -to sdram_data[13]
set_location_assignment PIN_103 -to sdram_data[14]
set_location_assignment PIN_101 -to sdram_data[15]
set_location_assignment PIN_75 -to vga_vs
set_location_assignment PIN_59 -to vga_hs
set_location_assignment PIN_76 -to vga_clk
set_location_assignment PIN_77 -to vga_blank
set_location_assignment PIN_11 -to vga_rgb[2]
set_location_assignment PIN_10 -to vga_rgb[3]
set_location_assignment PIN_7 -to vga_rgb[4]
set_location_assignment PIN_100 -to vga_rgb[7]
set_location_assignment PIN_99 -to vga_rgb[8]
set_location_assignment PIN_98 -to vga_rgb[9]
set_location_assignment PIN_86 -to vga_rgb[12]
set_location_assignment PIN_85 -to vga_rgb[13]
set_location_assignment PIN_84 -to vga_rgb[14]
set_location_assignment PIN_115 -to sdr_cke[0]
set_location_assignment PIN_119 -to sdr_clk[0]
set_location_assignment PIN_23 -to clk
set_location_assignment PIN_88 -to bt656_clk_27m
set_location_assignment PIN_113 -to sdr_dqm[0]
set_location_assignment PIN_46 -to sdr_dqm[1]
set_location_assignment PIN_39 -to sdr_cs[0]
set_location_assignment PIN_43 -to sdr_cas[0]
set_location_assignment PIN_38 -to sdr_ba[0]
set_location_assignment PIN_34 -to sdr_ba[1]
set_location_assignment PIN_91 -to reset_n
set_location_assignment PIN_44 -to sdr_we[0]
set_location_assignment PIN_42 -to sdr_ras[0]
set_location_assignment PIN_60 -to bt656_data[0]
set_location_assignment PIN_64 -to bt656_data[1]
set_location_assignment PIN_65 -to bt656_data[2]
set_location_assignment PIN_66 -to bt656_data[3]
set_location_assignment PIN_67 -to bt656_data[4]
set_location_assignment PIN_68 -to bt656_data[5]
set_location_assignment PIN_69 -to bt656_data[6]
set_location_assignment PIN_70 -to bt656_data[7]
set_location_assignment PIN_141 -to i2c_clk
set_location_assignment PIN_142 -to i2c_data
set_location_assignment PIN_83 -to vga_rgb[15]
set_location_assignment PIN_87 -to vga_rgb[10]
set_location_assignment PIN_71 -to vga_rgb[5]
set_location_assignment PIN_114 -to vga_rgb[6]
set_location_assignment PIN_135 -to vga_rgb[11]
set_location_assignment PIN_132 -to vga_rgb[0]
set_location_assignment PIN_1 -to vga_rgb[1]
set_location_assignment PIN_121 -to sdram_addr[12]
可以通过TCL脚本直接导入
Verlog顶层设计
顶层模块设计
解码解析出YUV分离信号
bt656_rx bt656_rx_inst
(
.clk1(bt656_clk_27m) , // input clk1_sig
.reset_n(reset_n) , // input reset_n_sig
.din(bt656_data/*test_din[9:2]*/) , // input [7:0] din_sig
.lcc2(clk_13m5) , // output lcc2_sig
// .v_blank(v_blank_sig) , // output v_blank_sig
.field(bt656_field) , // output field_sig
.v(bt656_vs) , // output v_sig
.h(bt656_hs) , // output h_sig
.y(y) , // output [7:0] y_sig
.cb(cb) , // output [7:0] cb_sig
.cr(cr)
);
色彩转换模块
csc csc_0(
.clk(clk_13m5),
.y(y),
.cb(cb),
.cr(cr),
.r(red),
.g(green),
.b(blue)
);
VGA显示控制模块
vga vga_inst
(
.reset_n(reset_n) , // input reset_n_sig
.pixel_clock(clk_pixel) , // input pixel_clock_sig
.hs(hs_w/*vga_hs*/) , // output hs_sig
.vs(vs_w/*vga_vs*/) , // output vs_sig
// .blank(vga_blank) , // output blank_sig
// .rgb(vga_rgb), // output [23:0] rgb_sig
.de(vga_de) // output de_sig
);
二、硬件说明
硬件修改:
1、iic控制总线,通过fpga配置5150模块初始化参数
set_location_assignment PIN_141 -to i2c_clk
set_location_assignment PIN_142 -to i2c_data
R53、R54必须焊接0欧
VGA电阻全部焊接
三、测试效果
上面显示器为VGA显示器,为摄像头输出图像效果
常见问题处理:
1、采集不到图像。
摄像头模块未通电或铜线线缆接触不良。
2、图像质量较差,花屏
重新复位或重新上电或tvp5150模块接触不良。