基于FPGA的GV7600驱动控制器设计,按照BT1120协议传输YCbCr数据
目錄
一、基于FPGA的GV7600驅(qū)動控制器設計,按照BT1120協(xié)議傳輸YCbCr數(shù)據(jù)
二、模塊名稱
三、模塊輸入輸出端口定義(interface)
四、模塊功能(functions)
五、模塊行為描述(behavior descriptions)
六、時序說明圖(diagrams)
七、注意事項
八、參考文獻及代碼
九、經(jīng)驗總結(jié)
一、基于FPGA的GV7600驅(qū)動控制器設計,按照BT1120協(xié)議傳輸YCbCr數(shù)據(jù)
二、模塊名稱
SDI Data Interface
三、模塊輸入輸出端口定義(interface)
PCB板號:176-A-1,根據(jù)10bit HD模式,在硬件pcb上配置如下4個引腳(紅色字體)
| 信號名稱 | 信號屬性 | 信號說明 |
| Sys_clk | input | 系統(tǒng)時鐘:30 MHz |
| Pclk | output | 鎖相環(huán)輸出給GV7600時鐘:148.5MHZ |
| Reset | output | GV7600低電平復位1.8ms |
| Sdi_data | output | 輸出數(shù)據(jù)給GV7600 |
| ? | ? | ? |
| DETECT_TRS | 硬件拉高 | 將H:V:F timing信號嵌入到并行輸入數(shù)據(jù)流 |
| 656_BYPASS | 硬件拉高 | 選擇video模式 |
| 20BIT/10BIT | 硬件拉低 | 選擇輸入10bit數(shù)據(jù)位數(shù) |
| RATE_SEL0 | 硬件拉低 | 根據(jù)分辨率要求 |
| ? | ? | ? |
?
四、模塊功能(functions)
根據(jù)項目需求,通過FPGA驅(qū)動GV7600輸出SDI信號
五、模塊行為描述(behavior descriptions)
(輸入:Sys_clk,
輸出:Pclk,Sdi_data,Reset);
?
(輸入:Clk,Sys_rstn,BT1120_data_out,
輸出:Pclk,Sdi_data,Reset,);
?
(輸入:Clk,Sys_rstn,
輸出:BT1120_data_out,);
?
(輸入:Sys_clk,
輸出:c0,locked,);
?
模塊分為4個子模塊:1.頂層模塊:做例化;2.驅(qū)動模塊:驅(qū)動GV7600芯片,FPGA輸出GV7600復位,時鐘和數(shù)據(jù)信號;3. BT1120模塊:按照BT1120協(xié)議傳輸數(shù)據(jù);4.鎖相環(huán)調(diào)用模塊:輸出148.5Mhz時鐘(根據(jù)分辨率決定時鐘頻率);
?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 圖1 SDI接口流程圖
?
六、時序說明圖(diagrams)
? ? ? ? ? ? ? ? ? ? ? ? ? 圖2 10bit復用 SDI接口時序
?
?
根據(jù)《GV7600-SDI并轉(zhuǎn)串datasheet》,FPGA主要實現(xiàn)驅(qū)動GV7600功能,具體需求如下:
??
?
七、注意事項
?
?
1080p
| ? | 20位 | 10位復用 |
| 并行數(shù)據(jù)流中的數(shù)字行 | 2200 | 4400 |
| 并行數(shù)據(jù)流中的數(shù)字行消隱 | 4+272+4 | 8+544+8 |
| 并行數(shù)據(jù)流中的有效行 | 1920 | 3840 |
?
10bit
| 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 |
| SAV0 | SAV1 | SAV2 | SAV3 | SAV4 | SAV5 | SAV6 | SAV7 |
`ifdef BT1120_1080P_30HZ
parameter ROW_MAX = 1124; ????????? //每場總計行數(shù)
parameter COL_MAX = 4399; ?????????? //每行總計像素點數(shù)
?
parameter ROW_BLACK_S = 41; ???? //開始場有效
parameter ROW_BLACK_E = 1121; //開始場消隱
?
parameter SAV_COL = 552;???????????????? //276*2
?
parameter BLANK_START = 7; ??????? //開始272*2=544個消隱區(qū)域
parameter SAV_START?? ? = 551; ???? //開始4*2=8個SAV定時基準碼
parameter VIDEO_START = 559;??? //開始每行有效像素點區(qū)域,560也可以正常顯示圖像?
parameter EAV_START?? ? = 4399; ?? //開始4*2=8個EAV定時基準碼
?
parameter DATA_CNT ? ??= 1919;???? //每行有效像素點
parameter VCNT_SUM??? ? = 1079;???? //每場有效行
`endif
八、參考文獻及代碼
文檔一:ITU-R BT.1120-7 建議書?
高清晰度電視演播室信號數(shù)字接(https://wenku.baidu.com/view/920afe2d2af90242a895e501.html)
文檔二:SMPTE? STANDARD? for Television — 1280 × 720 Progressive Image Sample Structure — Analog and Digital Representation and Analog Interface(https://wenku.baidu.com/view/8de63ec22cc58bd63186bd93.html)
文檔三:GV7600 Aviia? Transmitter 芯片手冊(http://www.doc88.com/p-2456927070001.html)
附核心模塊代碼(通過BT1120協(xié)議將YCbCr轉(zhuǎn)換SDI輸出)
// BT1120 Encoder //****************************************************************// //Company : ## //Author : MZH //Version : 1.0 //Data of Creation :2017/05/22 //****************************************************************// //BT1120 EAV, SAV Description //BIT6:F ODD EVEN Sign (ODD=0) //BIT5:V FIELD BLANKING Sign (1=BLANKING) //BIT4:H EAV SAV Sign (1=EAV) //BIT3-0 CRC BIT3=V(XOR)H;BIT2=F(XOR)H;BIT1=F(XOR)V;BIT0=F(XOR)V(XOR)H // //Bit7 Bit6 Bit5 Bit4 Bit3-0(P3P2P1P0) Hex Description // 1 0 0 0 0000 0x80 Odd,Active,SAV 10'h200 // 1 0 0 1 1101 0x9d Odd,Active,EAV 10'h274 // 1 0 1 0 1011 0xab Odd,Blank, SAV 10'h2AC // 1 0 1 1 0110 0xb6 Odd,Blank, EAV 10'h2d8// // Every line(4400Bytes): // EAV(8Bytes:3FF 3FF 000 000 000 000 XYZ XYZ) // LineBlanking(560Bytes: 80 10 80 10....) // SAV(8Bytes:3FF 3FF 000 000 000 000 XYZ XYZ) // ActiveVideo(3840Bytes:Cb0 Y0 Cr0 Y1 Cb2 Y2 Cr2 Y3 Cb4 Y4 Cr4 Y5 .... Cb1918 Y1918 Cr1918 Y1919 ) // // Every Field = 1125Lines // Line 0 - 40:odd field blanking // Line 41 - 1121:odd field active // Line 1122 - 1124:odd field blanking// // Clk: // 2200*1125 = 2475000 // 2475000 * 60 = 148.5M //****************************************************************// // COLORBAR DEFINE //生成顏色測試數(shù)據(jù) //`define COLOR_HOR_TEST //橫向漸變條紋 `define COLOR_VER_TEST //豎向漸變條紋 `define TB_DATA`define BT1120_1080P_30HZ //選用1280p 30hz//`define BT1120_720P_30HZ //選用720p 30hzmodule BT1120_1080p_720p (input Sys_rstn,input Clk,//input [7: 0] DataY_input,//input [7: 0] DataCb_input,//input [7: 0] DataCr_input,output reg Field_sync, //Odd signaloutput reg DataY_req, //1280x720 每場output reg DataCr_req, //640x720 每場output reg DataCb_req, //640x720 每場output [9: 0] BT1120_data_out);`ifdef BT1120_1080P_30HZ parameter ROW_MAX = 1124; //每場總計行數(shù) parameter COL_MAX = 4399; //每行總計像素點數(shù)parameter ROW_BLACK_S = 41; //開始場有效 parameter ROW_BLACK_E = 1121; //開始場消隱parameter SAV_COL = 552; //276*2parameter BLANK_START = 7; //開始272*2=544個消隱區(qū)域 parameter SAV_START = 551; //開始4*2=8個SAV定時基準碼 parameter VIDEO_START = 559; //開始每行有效像素點區(qū)域,560也可以正常顯示圖像 parameter EAV_START = 4399; //開始4*2=8個EAV定時基準碼parameter DATA_CNT = 1919; //每行有效像素點 parameter VCNT_SUM = 1079; //每場有效行 `endif`ifdef BT1120_720P_30HZ parameter ROW_MAX = 749; parameter COL_MAX = 6599;parameter ROW_BLACK_S = 25; parameter ROW_BLACK_E = 745;parameter SAV_COL = COL_MAX - 2567;// SAV_COL = 4032parameter BLANK_START = 7; parameter SAV_START = 4031; parameter VIDEO_START = 4039; parameter EAV_START = 6599;parameter DATA_CNT = 1279; parameter VCNT_SUM = 719; `endif`ifdef TB_DATA reg[7:0] DataY,DataCr,DataCb; reg[11:0] cnt_Y; //計數(shù):每行有效像素點數(shù) reg[11:0] cntt; //計數(shù):每場有效行數(shù)wire[7:0] DataY_input,DataCr_input,DataCb_input; assign DataY_input = DataY; assign DataCr_input = 8'd128; assign DataCb_input = 8'd128; `endif`ifdef COLOR_VER_TEST //豎條紋 always@(posedge Clk or negedge Sys_rstn)begin //create tb dataif(!Sys_rstn)beginDataY <= 255;cnt_Y <= 12'd0;end else if (DataY_req) beginif (cnt_Y==DATA_CNT) beginDataY <= 255;cnt_Y <= 12'd0;endelse beginDataY <= DataY-1;cnt_Y <= cnt_Y+1;endend end `endif`ifdef COLOR_HOR_TEST //橫條紋 always @(posedge Clk or negedge Sys_rstn) begin //creat tb dataif (!Sys_rstn) begincnt_Y <= 12'd0;endelse if (DataY_req) beginif (cnt_Y==DATA_CNT) begincnt_Y <= 12'd0;end else begincnt_Y <= cnt_Y+1;endend end always @(posedge Clk or negedge Sys_rstn) begin //creat tb dataif (!Sys_rstn) beginDataY <= 8'd0;cntt <= 12'd0;endelse if (DataY_req) beginif (cnt_Y==DATA_CNT) beginDataY <= DataY+1;cntt <= cntt+1; if (cntt==VCNT_SUM) beginDataY <= 0;cntt <= 0;endendend end `endifreg [12:0] hcnt; reg [11:0] vcnt; reg [9:0] data_out_temp;assign BT1120_data_out = data_out_temp;wire [9: 0] dataY_input_temp; wire [9: 0] dataCb_input_temp; wire [9: 0] dataCr_input_temp;// REAL DATA assign dataCb_input_temp = {DataCb_input,2'b00}; assign dataY_input_temp = {DataY_input,2'b00}; assign dataCr_input_temp = {DataCr_input,2'b00};always @ (posedge Clk or negedge Sys_rstn ) //行場計數(shù) beginif (!Sys_rstn) begin hcnt <= 13'd0;vcnt <= 12'd0; endelse beginif (hcnt == COL_MAX) begin hcnt <= 13'd0;vcnt <= (vcnt == ROW_MAX) ? 12'd0: (vcnt + 1'b1); endelse beginhcnt <= hcnt + 1'b1;endend endalways@(posedge Clk or negedge Sys_rstn)begin //輸出奇偶場同步if(!Sys_rstn)beginField_sync <= 1'b0;endelse beginField_sync <= ((hcnt==13'd0)&&((vcnt==12'd0)))? 1:0; end end reg V_VALID; always @ (posedge Clk or negedge Sys_rstn ) //輸出有效標志 beginif (!Sys_rstn) begin V_VALID = 1'b1;endelse begincase (vcnt)0: V_VALID = 1'b1;ROW_BLACK_S: V_VALID = 1'b0; //偶場有效區(qū)ROW_BLACK_E: V_VALID = 1'b1;default: V_VALID = V_VALID;endcaseend endreg[1:0] h_state; always@(posedge Clk or negedge Sys_rstn)begin //表示每行四個不同區(qū)間if(!Sys_rstn)beginh_state <= 2'd0;endelse if(hcnt==10'd0)beginh_state <= 2'd0;endelse begincase(h_state)2'd0:begin //EAVh_state <= (hcnt==BLANK_START)? 2'd1:2'd0;end2'd1:begin //BLANKh_state <= (hcnt==SAV_START)? 2'd2:2'd1;end 2'd2:begin //SAVh_state <= (hcnt==VIDEO_START)? 2'd3:2'd2;end 2'd3:begin //VIDEOh_state <= (hcnt==EAV_START)? 2'd0:2'd3; //每行有效數(shù)據(jù)區(qū)end default:beginh_state <= 2'd0;endendcaseend end always@(posedge Clk or negedge Sys_rstn)begin //產(chǎn)生輸入請求信號if(!Sys_rstn)beginDataY_req <= 1'b0;DataCr_req <= 1'b0;DataCb_req <= 1'b0;endelse beginif( h_state==2'd3 )beginDataY_req <= ( V_VALID == 1'b0 )? hcnt[0]:1'b0; DataCb_req <= ( V_VALID == 1'b0 )? (hcnt[1:0]==2'b00):1'b0;DataCr_req <= ( V_VALID == 1'b0 )? (hcnt[1:0]==2'b10):1'b0; end else beginDataY_req <= 1'b0;DataCr_req <= 1'b0;DataCb_req <= 1'b0;end end endalways @ (posedge Clk or negedge Sys_rstn ) //BT_1120協(xié)議 beginif (!Sys_rstn) begin data_out_temp <= 10'h200;endelse begin //發(fā)EAV和SAV前兩個數(shù)據(jù)if ((hcnt == 0 )|| (hcnt == 1) || (hcnt == SAV_COL) || (hcnt == (SAV_COL+1))) begin data_out_temp <= 10'h3FF;endelse if ( (hcnt == 2) || (hcnt == 3) ||(hcnt == 4) ||(hcnt == 5) || (hcnt == (SAV_COL+2)) || (hcnt == (SAV_COL+3))|| (hcnt == (SAV_COL+4))|| (hcnt == (SAV_COL+5)) ) begindata_out_temp <= 10'h000;end else if ((hcnt == 6) || (hcnt == 7)) begin //發(fā)EAV最后兩個數(shù)據(jù)//if (((vcnt >= 0) && (vcnt <= ROW_BLACK_S)) || ((vcnt >= ROW_BLACK_E) && (vcnt <= ROW_MAX))) begin if (V_VALID) begin data_out_temp <= 10'h2D8; //{8'hB6,2'b00}; EAV odd field blanking endelse begindata_out_temp <= 10'h274; //{8'h9D,2'b00}; EAV odd field active endend // BLACKINGelse if ((hcnt > 7) && (hcnt < SAV_COL) ) begindata_out_temp <= 10'h200;end else if ((hcnt == (SAV_COL+6)) || (hcnt == (SAV_COL+7))) begin //發(fā)SAV最后兩個數(shù)據(jù) if (V_VALID) begin data_out_temp <= 10'h2AC; //{8'hAB,2'b00}; SAV odd field blanking endelse begindata_out_temp <= 10'h200; //{8'h80,2'b00}; SAV odd field activeendend // DATAelse begin if (V_VALID) begin data_out_temp <= 10'h200;endelse begincase (hcnt[1:0])2'd0: begindata_out_temp <= dataCb_input_temp;end 2'd1,2'd3: begindata_out_temp <= dataY_input_temp;end 2'd2: begindata_out_temp <= dataCr_input_temp;end default: begindata_out_temp <= 10'h200;endendcaseend end end endendmodule/*-----------------------------------------------———————————————— 版權聲明:本文為CSDN博主「Davemissyou」的原創(chuàng)文章,遵循CC 4.0 BY-SA版權協(xié)議,轉(zhuǎn)載請附上原文出處鏈接及本聲明。 原文鏈接:https://blog.csdn.net/Davemissyou/article/details/89016374九、經(jīng)驗總結(jié)
SDI總結(jié)(調(diào)試包括:在不同分辨率下的BT656,BT1120)
? ? ? SDI調(diào)試的關鍵是行計數(shù),每行EAV和SAV的起始計數(shù)至關重要;10bit SDI_1080p和10bit SDI_sd存在兩方面差異:1、bt656和bt1120的協(xié)議不同,2、硬件Pcb上RATE_SEL0引腳配置不同;
1、每一行的組成
行(line)=結(jié)束碼(EAV)+水平消隱(Horizontal blanking)+起始碼(SAV)+有效數(shù)據(jù)(Active Video)
起始碼(SAV)和結(jié)束碼(EAV),它是標志著一行開始結(jié)束的重要標記,bt656協(xié)議:
? ? ? 圖3?10bit復用 SDI_sd接口時序
2、為什么一行中的有效數(shù)據(jù)是 1440 字節(jié),因為PAL制式的SDTV的分辨率為 720*576,即一行有720個有效點,由于采集的是彩色圖像,那么一行就是由亮度信息(Y)和色差信息(CbCr)組成的,由于YCbCr是422格式,故一行中有720列Y,720列CbCr,因此,一行的有效字節(jié)數(shù)就為 720 x 2 = 1440 字節(jié)。bt1120協(xié)議:
? ? 圖4??10bit復用 SDI_hd接口時序
3、定義行計數(shù)器時,需要明確每行的總數(shù)據(jù)和有效數(shù)據(jù),總數(shù)據(jù)和有效數(shù)據(jù)即(EAV和SAV的起始計數(shù))正確與否決定了是否顯示圖像,在整個模塊代碼編寫中查閱總數(shù)據(jù)和有效數(shù)據(jù)的數(shù)值花費了80%的時間,最終在(bt1120文檔(P12):數(shù)據(jù)流定時規(guī)范)中找到確定數(shù)值;
4、10bit復用時,每行有4400個數(shù)據(jù),3840個有效數(shù)據(jù),故一行中有1920列Y,1920列CbCr,分辨率:1920*1080
?
?
?
?
?
?
?
?
?
總結(jié)
以上是生活随笔為你收集整理的基于FPGA的GV7600驱动控制器设计,按照BT1120协议传输YCbCr数据的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C# 事件详解附实例分析
- 下一篇: 关注:Eclipse,转贴eclipse