今天給大俠帶來(lái)基于FPGA的數(shù)字視頻信號(hào)處理器設(shè)計(jì),由于篇幅較長(zhǎng),分三篇。今天帶來(lái)第三篇,下篇,程序測(cè)試與運(yùn)行。話不多說(shuō),上貨。
之前也有圖像處理相關(guān)方面的文章,這里超鏈接幾篇,給各位大俠作為參考。
《岡薩雷斯數(shù)字圖像處理MATLAB版》中文版(第二版) 電子版
薦讀:FPGA設(shè)計(jì)經(jīng)驗(yàn)之圖像處理
基于FPGA的實(shí)時(shí)圖像邊緣檢測(cè)系統(tǒng)設(shè)計(jì)(下)
FPGA設(shè)計(jì)中 Verilog HDL實(shí)現(xiàn)基本的圖像濾波處理仿真
導(dǎo)讀
圖像是用各種觀測(cè)系統(tǒng)以不同形式和手段觀測(cè)客觀世界而獲得的,可以直接或間接作用于人眼進(jìn)而產(chǎn)生視知覺(jué)的實(shí)體。
隨著電子技術(shù)和計(jì)算機(jī)技術(shù)的飛速發(fā)展,數(shù)字圖像技術(shù)近年來(lái)得到極大的重視和長(zhǎng)足的發(fā)展,并在科學(xué)研究、工業(yè)生產(chǎn)、醫(yī)療衛(wèi)生、通信等方面得到廣泛的應(yīng)用。
視頻信號(hào)由一系列連續(xù)的圖像組成。對(duì)視頻信號(hào)的處理已經(jīng)成為數(shù)字圖像處理領(lǐng)域中重要的一部分。例如機(jī)器人模式識(shí)別的過(guò)程就是一個(gè)視頻信號(hào)處理的過(guò)程,電視制導(dǎo)導(dǎo)彈識(shí)別目標(biāo)就是充分利用視頻信號(hào)處理技術(shù)不斷判斷目標(biāo)是否和預(yù)先設(shè)定目標(biāo)圖像一致。本篇將講解如何用 FPGA 技術(shù)實(shí)現(xiàn)基本的視頻信號(hào)處理。本篇的例子可以作為各位大俠進(jìn)行視頻信號(hào)處理時(shí)的一個(gè)參考,也可以在這個(gè)基礎(chǔ)上根據(jù)需要進(jìn)行擴(kuò)展。
第三篇內(nèi)容摘要:本篇會(huì)介紹程序測(cè)試與運(yùn)行,包括測(cè)試程序、測(cè)試結(jié)果以及總結(jié)等相關(guān)內(nèi)容。
五、程序測(cè)試與運(yùn)行
由于整個(gè) FPGA 程序包括 3 部分:處于 TOP 的主體程序,控制其他各個(gè)部分程序的運(yùn)行;視頻圖像數(shù)據(jù)采集程序,從 SAA7113 獲得數(shù)字圖像數(shù)據(jù)并保存到 SRAM 中;SRAM 讀寫程序?qū)崿F(xiàn)對(duì) SRAM 的數(shù)據(jù)讀寫。測(cè)試程序需要仿真數(shù)據(jù)的全部流程。
5.1 測(cè)試程序
測(cè)試程序代碼如下:
`include “timescale.v”moduletst_saa7113(error,dsprst,xreset,saareset,ARDY,ED_O,ED_OEN_O,SRAM_1_EA,SRAM_2_EA,SRAM_1_O_ED,SRAM_2_O_ED); //內(nèi)部寄存器 reg reset; reg clk;//50MHz 時(shí)鐘 reg llck;//SAA7113 的時(shí)鐘 reg [7:0] vpo;//來(lái)自 saa7113 的圖像數(shù)據(jù) reg capture;//采集數(shù)據(jù)標(biāo)志 reg toggle;//總線切換標(biāo)志 reg [1:0] rst; //輸入 input error; input dsprst,xreset,saareset; input ARDY; input [7:0] ED_O; input ED_OEN_O; input [18:0] SRAM_1_EA; input [7:0] SRAM_1_O_ED; input [18:0] SRAM_2_EA; input [7:0] SRAM_2_O_ED; //來(lái)自 dsp 的信號(hào) reg CE3_; reg ARE_; reg AWE_; reg [21:2] EA; reg [7:0] ED_I; //TO SRAM reg [7:0] SRAM_1_IN_ED; reg [7:0] SRAM_2_IN_ED; //wires //from saa7113 wire SRAM_CE_; wire SRAM_OE_; wire SRAM_WE_; wire [18:0] la; wire [7:0] ld; //FROM DSP wire CE_SRAM; wire WE_SRAM; wire OE_SRAM; wire [7:0] ED_SRAM; wire [18:0] EA_SRAM; //連接各個(gè)子程序 LWBSAA7113 L_SAA7113 ( .reset(reset), .clk(clk), .llck(llck), .vpo(vpo), .rst(rst), .capture(capture), .error(error), .SRAM_CE_(SRAM_CE_), .SRAM_OE_(SRAM_OE_), .SRAM_WE_(SRAM_WE_), .la(la), .ld(ld) ); LWBDECODE L_DECODE ( .reset(reset), .CE3_(CE3_), .ARE_(ARE_), .AWE_(AWE_), .EA(EA), .ED_I(ED_I), .ED_O(ED_O), .ED_OEN_O(ED_OEN_O), .ARDY(ARDY), .EA_SRAM(EA_SRAM), .ED_SRAM(ED_SRAM), .CE_SRAM(CE_SRAM), .WE_SRAM(WE_SRAM), .OE_SRAM(OE_SRAM), .dsprst(dsprst), .xreset(xreset), .saareset(saareset) ); LWBBUSCHANGE L_BUSCHANGE ( .EA_SRAM(EA_SRAM), .ED_SRAM(ED_SRAM), .CE_SRAM(CE_SRAM), .WE_SRAM(WE_SRAM), .OE_SRAM(OE_SRAM), .la(la), .ld(ld), .SRAM_CE_(SRAM_CE_), .SRAM_WE_(SRAM_WE_), .SRAM_OE_(SRAM_OE_), .SRAM_1_IN_ED(SRAM_1_IN_ED), .SRAM_2_IN_ED(SRAM_2_IN_ED), .toggle(toggle), .SRAM_1_EA(SRAM_1_EA), .SRAM_1_O_ED(SRAM_1_O_ED), .SRAM_2_EA(SRAM_2_EA), .SRAM_2_O_ED(SRAM_2_O_ED) ); //產(chǎn)生時(shí)鐘信號(hào) always #10 clk=~clk; always #20 llck = ~llck; initial begin $display(“
status : %t TestBench of saa7113 started!
”,$time); //initial value clk = 0; #7; llck =0; //reset reset = 1; //dsp 初始化 ARE_ = 1; AWE_ = 1; CE3_ = 1; //初始化 capture = 0; toggle = 1; #2; reset = 0; repeat(20) @(posedge clk); reset = 1‘b1; // negate reset //dsp 讀取數(shù)據(jù)內(nèi)容 SRAM_1_IN_ED = 8’h1d; SRAM_2_IN_ED = 8‘h2d; //dsp 地址總線 EA[21:16] = 6’b000000; EA[15:7] = 9‘b000000000; EA[6:2]= 5’b00001; #5; CE3_ = 0; ARE_ = 0; //saa7113 輸出內(nèi)容 capture = 1; #5; @(posedge llck) vpo = 8‘haa; @(posedge llck) vpo = 8’hbb; @(posedge llck) vpo = 8‘hcc; @(posedge llck) vpo = 8’hdd; @(posedge llck) vpo = 8‘hee; //場(chǎng)同步信號(hào) //1 @(posedge llck) vpo = 8’hff;//begin @(posedge llck) vpo = 8‘h00; @(posedge llck) vpo = 8’h00; @(posedge llck) vpo = 8‘b00100000;//sav //2 @(posedge llck) vpo = 8’hff;//begin @(posedge llck) vpo = 8‘h00; @(posedge llck) vpo = 8’h00; @(posedge llck) vpo = 8‘b00100000; //數(shù)據(jù)開(kāi)始 @(posedge llck) vpo = 8’hff;//begin @(posedge llck) vpo = 8‘h00; @(posedge llck) vpo = 8’h00; @(posedge llck) vpo = 8‘b00000000; //data @(posedge llck) vpo = 8’h01;//Cb @(posedge llck) vpo = 8‘h02;//Yb @(posedge llck) vpo = 8’h03;//Cr @(posedge llck) vpo = 8‘h04;//Yr--1 @(posedge llck) vpo = 8’h05;//Cb @(posedge llck) vpo = 8‘h06;//Yb @(posedge llck) vpo = 8’h07;//Cr @(posedge llck) vpo = 8‘h08;//Yr--2 @(posedge llck) vpo = 8’h09;//Cb @(posedge llck) vpo = 8‘h0a;//Yb @(posedge llck) vpo = 8’h0b;//Cr @(posedge llck) vpo = 8‘h0c;//Yr--3 @(posedge llck) vpo = 8’h0d;//Cb @(posedge llck) vpo = 8‘h0e;//Yb @(posedge llck) vpo = 8’h0f;//Cr @(posedge llck) vpo = 8‘h10;//Yr--4 @(posedge llck) vpo = 8’h11;//Cb @(posedge llck) vpo = 8‘h12;//Yb @(posedge llck) vpo = 8’h13;//Cr @(posedge llck) vpo = 8‘h14;//Yr--5 @(posedge llck) vpo = 8’h15;//Cb @(posedge llck) vpo = 8‘h16;//Yb @(posedge llck) vpo = 8’h17;//Cr @(posedge llck) vpo = 8‘h18;//Yr--6 @(posedge llck) vpo = 8’h19;//Cb @(posedge llck) vpo = 8‘h1a;//Yb @(posedge llck) vpo = 8’h1b;//Cr @(posedge llck) vpo = 8‘h1c;//Yr--7 @(posedge llck) vpo = 8’h1d;//Cb @(posedge llck) vpo = 8‘h1e;//Yb @(posedge llck) vpo = 8’h1f;//Cr @(posedge llck) vpo = 8‘h20;//Yr--8 @(posedge llck) vpo = 8’h21;//Cb @(posedge llck) vpo = 8‘h22;//Yb @(posedge llck) vpo = 8’h23;//Cr @(posedge llck) vpo = 8‘h24;//Yr--9 @(posedge llck) vpo = 8’h25;//Cb @(posedge llck) vpo = 8‘h26;//Yb @(posedge llck) vpo = 8’h27;//Cr @(posedge llck) vpo = 8‘h28;//Yr--10 @(posedge llck) vpo = 8’h29;//Cb @(posedge llck) vpo = 8‘h3a;//Yb @(posedge llck) vpo = 8’h3b;//Cr @(posedge llck) vpo = 8‘h3c;//Yr--11 //數(shù)據(jù)結(jié)束 @(posedge llck) vpo = 8’hff;//ff @(posedge llck) vpo = 8‘h00;//00 @(posedge llck) vpo = 8’h00;//00 @(posedge llck) vpo = 8‘b01110000;//end of field 1 #20; ARE_ = 1; capture = 0; #200; //開(kāi)始切換 toggle = 0; #100; ARE_ = 0; //開(kāi)始采集數(shù)據(jù) capture = 1; //vertical blanking stage //1 @(posedge llck) vpo = 8’hff;//begin @(posedge llck) vpo = 8‘h00; @(posedge llck) vpo = 8’h00; @(posedge llck) vpo = 8‘b00100000;//sav //2 @(posedge llck) vpo = 8’hff;//begin @(posedge llck) vpo = 8‘h00; @(posedge llck) vpo = 8’h00; @(posedge llck) vpo = 8‘b00100000; //data start @(posedge llck) vpo = 8’hff;//begin @(posedge llck) vpo = 8‘h00; @(posedge llck) vpo = 8’h00; @(posedge llck) vpo = 8‘b00000000; //data @(posedge llck) vpo = 8’h01;//Cb @(posedge llck) vpo = 8‘h02;//Yb @(posedge llck) vpo = 8’h03;//Cr @(posedge llck) vpo = 8‘h04;//Yr--1 @(posedge llck) vpo = 8’h05;//Cb @(posedge llck) vpo = 8‘h06;//Yb @(posedge llck) vpo = 8’h07;//Cr @(posedge llck) vpo = 8‘h08;//Yr--2 @(posedge llck) vpo = 8’h09;//Cb @(posedge llck) vpo = 8‘h0a;//Yb @(posedge llck) vpo = 8’h0b;//Cr @(posedge llck) vpo = 8‘h0c;//Yr--3 @(posedge llck) vpo = 8’h0d;//Cb @(posedge llck) vpo = 8‘h0e;//Yb @(posedge llck) vpo = 8’h0f;//Cr @(posedge llck) vpo = 8‘h10;//Yr--4 @(posedge llck) vpo = 8’h11;//Cb @(posedge llck) vpo = 8‘h12;//Yb @(posedge llck) vpo = 8’h13;//Cr @(posedge llck) vpo = 8‘h14;//Yr--5 @(posedge llck) vpo = 8’h15;//Cb @(posedge llck) vpo = 8‘h16;//Yb @(posedge llck) vpo = 8’h17;//Cr @(posedge llck) vpo = 8‘h18;//Yr--6 @(posedge llck) vpo = 8’h19;//Cb @(posedge llck) vpo = 8‘h1a;//Yb @(posedge llck) vpo = 8’h1b;//Cr @(posedge llck) vpo = 8‘h1c;//Yr--7 @(posedge llck) vpo = 8’h1d;//Cb @(posedge llck) vpo = 8‘h1e;//Yb @(posedge llck) vpo = 8’h1f;//Cr @(posedge llck) vpo = 8‘h20;//Yr--8 @(posedge llck) vpo = 8’h21;//Cb @(posedge llck) vpo = 8‘h22;//Yb @(posedge llck) vpo = 8’h23;//Cr @(posedge llck) vpo = 8‘h24;//Yr--9 @(posedge llck) vpo = 8’h25;//Cb @(posedge llck) vpo = 8‘h26;//Yb @(posedge llck) vpo = 8’h27;//Cr @(posedge llck) vpo = 8‘h28;//Yr--10 @(posedge llck) vpo = 8’h29;//Cb @(posedge llck) vpo = 8‘h3a;//Yb @(posedge llck) vpo = 8’h3b;//Cr @(posedge llck) vpo = 8‘h3c;//Yr--11 //數(shù)據(jù)結(jié)束 @(posedge llck) vpo = 8’hff;//ff @(posedge llck) vpo = 8‘h00;//00 @(posedge llck) vpo = 8’h00;//00 @(posedge llck) vpo = 8‘b01110000;//end of field 1 #20; //結(jié)束數(shù)據(jù)采集 capture = 0; #200; //測(cè)試程序結(jié)束 $finish; endendmodule
5.2 測(cè)試結(jié)果開(kāi)始的“aa bb cc dd ee ff”是無(wú)效數(shù)據(jù),“ff 00 20”表示場(chǎng)同步信號(hào)。
經(jīng)過(guò) FPGA 處理后獲得有效圖像數(shù)據(jù)并產(chǎn)生相應(yīng)的地址信號(hào),由于只進(jìn)行灰度運(yùn)算,只取亮度信息,因此獲得數(shù)據(jù)為“04 08 0c”,同時(shí)產(chǎn)生地址信號(hào)“00 01 02”。
仿真結(jié)果表明整個(gè)視頻信號(hào)處理程序完成了預(yù)先設(shè)定的設(shè)計(jì)目標(biāo)。
七、總結(jié)
本篇首先介紹了視頻信號(hào)的基本原理、組成等,然后講解了進(jìn)行視頻信號(hào)處理的基本過(guò)程和框架。接下來(lái)結(jié)合實(shí)例講解用 FPGA 及其他芯片組成視頻處理的電路設(shè)計(jì)和 FPGA 的程序?qū)崿F(xiàn)。最后用 Modelsim 仿真和測(cè)試了程序。本篇為各位大俠提供了一種視頻信號(hào)處理的設(shè)計(jì)方案,僅供參考。
編輯:jq
-
FPGA
+關(guān)注
關(guān)注
1629文章
21738瀏覽量
603463
原文標(biāo)題:原創(chuàng)系統(tǒng)設(shè)計(jì)精選 | 基于FPGA的數(shù)字視頻信號(hào)處理器設(shè)計(jì)(附代碼)
文章出處:【微信號(hào):HK-FPGA_Dep,微信公眾號(hào):FPGA技術(shù)支持】歡迎添加關(guān)注!文章轉(zhuǎn)載請(qǐng)注明出處。
發(fā)布評(píng)論請(qǐng)先 登錄
相關(guān)推薦
評(píng)論