




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、fpga 驅(qū)動(dòng) vga 接口的 vhdl 語(yǔ)言實(shí)現(xiàn)轉(zhuǎn)載 來(lái)自于基于 FPGA 的嵌入式系統(tǒng)設(shè)計(jì)我使用 ep2c5的實(shí)驗(yàn)板作過(guò)了實(shí)驗(yàn),沒(méi)有問(wèn)題的,可惜只能顯示彩條,方格。 McMaster University 有一篇介紹 vga 接口協(xié)議的 vhdl 實(shí)現(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)生同步信號(hào)進(jìn)行行、場(chǎng)掃描,即顯示驅(qū)動(dòng) 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;-模式選擇單元:本測(cè)試程序我們使用了 4種模式,由 KEY_B2,KEY_B3控制, 當(dāng)選擇模式 "11" 時(shí),即不按下 B2, B3, VGA 顯示豎彩條;當(dāng)選擇模式 "00" 時(shí), 即同時(shí)按下 B2, B3時(shí), VGA 顯示全黑;當(dāng)選擇模式 "01" 時(shí),即只按下 B2時(shí), VGA 顯示橫彩條;當(dāng)選擇模式 "10&qu
7、ot; 時(shí),即只按下 B3時(shí), VGA 時(shí)顯示橫豎彩條。 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è)標(biāo)準(zhǔn)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; - 行計(jì)數(shù)器signal vcnt: std_logic_vector(9 downto 0; - 場(chǎng)計(jì)數(shù)器begin-產(chǎn)生行計(jì)數(shù)(記錄每行的點(diǎn)數(shù), H_PERIOD 為行周期計(jì)數(shù)值。A: process(clock, resetbegin-復(fù)位時(shí)行計(jì)數(shù)器清零if reset = '0'
12、 thenhcnt <= (others => '0'elsif (clock'event and clock = '1' then-當(dāng)行計(jì)數(shù)到達(dá)計(jì)數(shù)周期時(shí)將重置if hcnt < H_PERIOD thenhcnt <= hcnt + 1;elsehcnt <= (others => '0'end if;end if;end process;-產(chǎn)生場(chǎng)記數(shù)(記錄每幀中的行數(shù), V_PERIOD為場(chǎng)周期計(jì)數(shù)值B: process(hsyncb, resetbegin- 復(fù)位場(chǎng)計(jì)數(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ào), H_PIXELS為行顯示點(diǎn)數(shù), H_FRONT為前消隱點(diǎn)數(shù), H_S YNCTIME 為行同步點(diǎn)數(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)生場(chǎng)同步信號(hào), V_LINES為場(chǎng)顯示點(diǎn)數(shù), V_FRO
15、NT為前消隱點(diǎn)數(shù), V_SY NCTIME 場(chǎng)同步點(diǎn)數(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. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025至2030年中國(guó)雙層憑證行業(yè)投資前景及策略咨詢報(bào)告
- 2025至2030年中國(guó)印花汽車(chē)地毯行業(yè)投資前景及策略咨詢報(bào)告
- 2025至2030年中國(guó)人參香浴鹽行業(yè)投資前景及策略咨詢報(bào)告
- 2025至2030年中國(guó)二位二通常閉型磁提升式膜片閥行業(yè)投資前景及策略咨詢報(bào)告
- 2025年中國(guó)紫檀大屏風(fēng)市場(chǎng)調(diào)查研究報(bào)告
- 2025年洗砂機(jī)項(xiàng)目申請(qǐng)報(bào)告模范
- 2025年腫瘤類生物制品項(xiàng)目提案報(bào)告模范
- 小學(xué)生情緒課件
- 創(chuàng)業(yè)類工作面試題及答案
- 河南八省聯(lián)考地理試題及答案解析
- 【MOOC】老子的人生智慧-東北大學(xué) 中國(guó)大學(xué)慕課MOOC答案
- 科研倫理與學(xué)術(shù)規(guī)范(研究生)期末試題
- 鐵路工程地質(zhì)勘查階段監(jiān)理工作總結(jié)
- 北師大版三年級(jí)數(shù)學(xué)下冊(cè)第七單元《數(shù)據(jù)的整理和表示》教案教學(xué)設(shè)計(jì)(優(yōu)質(zhì)完整)
- 高中地理區(qū)域地理南亞和印度(共36張)課件
- 密碼模塊安全檢測(cè)要求
- 吊籃保養(yǎng)記錄月檢
- (中職中專)發(fā)動(dòng)機(jī)構(gòu)造與維修完整版課件匯總?cè)珪?shū)電子教案(最新)
- 食堂安全管理、操作培訓(xùn)考試題與答案
- 工序單位能耗地計(jì)算方法、及企業(yè)噸鋼可比能耗計(jì)算方法
- 低溫早強(qiáng)耐久混凝土的集中拌和施工
評(píng)論
0/150
提交評(píng)論