




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、fpga 驅(qū)動 vga 接口的 vhdl 語言實現(xiàn)轉(zhuǎn)載 來自于基于 FPGA 的嵌入式系統(tǒng)設計我使用 ep2c5的實驗板作過了實驗,沒有問題的,可惜只能顯示彩條,方格。 McMaster University 有一篇介紹 vga 接口協(xié)議的 vhdl 實現(xiàn)介紹 , 可以自己下載 參考。library IEEE;entity vgacore isPort ( clk : in std_logic;reset : in std_logic;md : in std_logic_vector(1 downto 0;hs : out std_logic;vs : out std_logic;r : ou
2、t std_logic_vector(1 downto 0;g : out std_logic_vector(2 downto 0;b : out std_logic_vector(2 downto 0;end vgacore;architecture Behavioral of vgacore issignal sysclk : std_logic;signal hsyncb : std_logic;signal vsyncb : std_logic;signal enable : std_logic;signal hloc : std_logic_vector(9 downto 0;sig
3、nal vloc : std_logic_vector(9 downto 0;signal rgbx,rgby,rgbp,rgb: std_logic_vector(7 downto 0;-定義 VGASIG 元件,產(chǎn)生同步信號進行行、場掃描,即顯示驅(qū)動 component vgasigPort (clock : in std_logic;reset : in std_logic;hsyncb : buffer std_logic;vsyncb : out std_logic;enable : out std_logic;Xaddr : out std_logic_vector(9 downt
4、o 0;Yaddr : out std_logic_vector(9 downto 0;end component;-定義 colormap 元件,確定顏色及位置信息component colormapPort (hloc : in std_logic_vector(9 downto 0;vloc : in std_logic_vector(9 downto 0;rgbx : out std_logic_vector(7 downto 0;rgby : out std_logic_vector(7 downto 0;end component;beginrgb(7 <= rgbp(7 a
5、nd enable;rgb(6 <= rgbp(6 and enable;rgb(5 <= rgbp(5 and enable;rgb(4 <= rgbp(4 and enable;rgb(3 <= rgbp(3 and enable;rgb(2 <= rgbp(2 and enable;rgb(1 <= rgbp(1 and enable;rgb(0 <= rgbp(0 and enable;-產(chǎn)生 25Mhz 的像素輸出頻率divclk: process(clk,resetbeginif reset='0' thensysclk &
6、lt;= '0'elsif clk'event and clk='1' thensysclk <= not sysclk;end if;end process;-模式選擇單元:本測試程序我們使用了 4種模式,由 KEY_B2,KEY_B3控制, 當選擇模式 "11" 時,即不按下 B2, B3, VGA 顯示豎彩條;當選擇模式 "00" 時, 即同時按下 B2, B3時, VGA 顯示全黑;當選擇模式 "01" 時,即只按下 B2時, VGA 顯示橫彩條;當選擇模式 "10&qu
7、ot; 時,即只按下 B3時, VGA 時顯示橫豎彩條。 modchoice: process(md,rgbx,rgbybeginif md="11" then rgbp <= rgbx;elsif md="01" then rgbp <= rgby;elsif md="10" then rgbp <= rgbx xor rgby; else rgbp <= "00000000"end if;end process;makesig: vgasig Port map(clock => s
8、ysclk,reset => reset,hsyncb => hsyncb,vsyncb => vsyncb,enable => enable,Xaddr => hloc,Yaddr => vloc;makergb: colormap Port map(hloc => hloc,vloc => vloc,rgbx => rgbx,rgby => rgby;hs <= hsyncb;vs <= vsyncb;r <= rgb(7 downto 6;g <= rgb(5 downto 3;b <= rgb(2
9、 downto 0;end Behavioral;library IEEE;entity vgasig isPort ( clock : in std_logic;reset : in std_logic;hsyncb: buffer std_logic;vsyncb: out std_logic;enable: out std_logic;Xaddr : out std_logic_vector(9 downto 0;Yaddr : out std_logic_vector(9 downto 0;end vgasig;architecture Behavioral of vgasig is-
10、定義相關(guān)常量,可參考 VGA 相關(guān)工業(yè)標準constant H_PIXELS: INTEGER:=640;constant H_FRONT: INTEGER:=16;constant H_BACK: INTEGER:=48;constant H_SYNCTIME:INTEGER:=96;constant H_PERIOD: INTEGER:= H_SYNCTIME + H_PIXELS + H_FRON T + H_BACK;constant V_LINES: INTEGER:=480;constant V_FRONT: INTEGER:=11;constant V_BACK: INTEGER
11、:=32;constant V_SYNCTIME: INTEGER:=2;constant V_PERIOD: INTEGER:= V_SYNCTIME + V_LINES + V_FRONT + V_BACK;signal hcnt: std_logic_vector(9 downto 0; - 行計數(shù)器signal vcnt: std_logic_vector(9 downto 0; - 場計數(shù)器begin-產(chǎn)生行計數(shù)(記錄每行的點數(shù), H_PERIOD 為行周期計數(shù)值。A: process(clock, resetbegin-復位時行計數(shù)器清零if reset = '0'
12、 thenhcnt <= (others => '0'elsif (clock'event and clock = '1' then-當行計數(shù)到達計數(shù)周期時將重置if hcnt < H_PERIOD thenhcnt <= hcnt + 1;elsehcnt <= (others => '0'end if;end if;end process;-產(chǎn)生場記數(shù)(記錄每幀中的行數(shù), V_PERIOD為場周期計數(shù)值B: process(hsyncb, resetbegin- 復位場計數(shù)器清零if reset=&
13、#39;0' thenvcnt <= (others => '0'elsif (hsyncb'event and hsyncb = '1' thenif vcnt < V_PERIOD thenvcnt <= vcnt + 1;elsevcnt <= (others => '0'end if;end if;end process;-產(chǎn)生行同步信號, H_PIXELS為行顯示點數(shù), H_FRONT為前消隱點數(shù), H_S YNCTIME 為行同步點數(shù)C: process(clock, resetbe
14、ginif reset = '0' thenhsyncb <= '1'elsif (clock'event and clock = '1' thenif (hcnt >= (H_PIXELS + H_FRONT and hcnt < (H_PIXELS + H_SYNC TIME + H_FRONT thenhsyncb <= '0'elsehsyncb <= '1'end if;end if;end process;-產(chǎn)生場同步信號, V_LINES為場顯示點數(shù), V_FRO
15、NT為前消隱點數(shù), V_SY NCTIME 場同步點數(shù)D: process(hsyncb, resetbeginif reset = '0' thenvsyncb <= '1'elsif (hsyncb'event and hsyncb = '1' thenif (vcnt >= (V_LINES + V_FRONT and vcnt < (V_LINES + V_SYNCTI ME + V_FRONT thenvsyncb <= '0'elsevsyncb <= '1'end
16、 if;when "100" => rgbx <= "00111000" when "101" => rgbx <= "11000111" when "110" => rgbx <= "11111000" when "111" => rgbx <= "11111111" when others => rgbx <= "00000000" end case;
17、case vloc(7 downto 5 is when "000" => rgby <= "10101010" when when when when "001" "010" "011" "100" => => => => rgby rgby rgby rgby <= <= <= <= "01010101" "11001110" "00110001" "00101110&qu
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- TY/T 1111-2024路跑賽事活動指南
- 甘肅小學數(shù)學課題申報書
- 聾啞人群探究課題申報書
- 課題立項申報書范文思政
- 廳級課題申報書范例
- 賣樓房定金合同范例
- 環(huán)保類課題申報書
- 省級文旅課題申報書
- 取水證合同范本
- 化肥訂單合同范本
- 人教版二年級數(shù)學下冊全冊單元測試題
- 2025年湖南城建職業(yè)技術(shù)學院單招職業(yè)適應性測試題庫及答案一套
- 2025年黑龍江商業(yè)職業(yè)學院單招職業(yè)技能測試題庫及答案一套
- 教科版科學三下開學第一課《科學家這樣做-童第周》
- 護理質(zhì)量與護理安全積分管理考核標準
- 2024年汶川縣欣禹林業(yè)有限責任公司工作人員招聘考試真題
- 國家安全教育大學生讀本高教社2024年8月版教材講義-第一章完全準確領(lǐng)會總體國家安全觀
- 疲勞斷裂材料性能優(yōu)化-深度研究
- 2025年廣州市黃埔區(qū)文沖街招聘“村改居”社區(qū)治安聯(lián)防隊員36人歷年高頻重點模擬試卷提升(共500題附帶答案詳解)
- 國家電網(wǎng)新聞宣傳與企業(yè)文化管理專責考試題及答案
- 土建類專職安全生產(chǎn)管理人員練習題+參考答案
評論
0/150
提交評論