fpga驱动vga接口的vhdl语言实现_第1页
fpga驱动vga接口的vhdl语言实现_第2页
fpga驱动vga接口的vhdl语言实现_第3页
fpga驱动vga接口的vhdl语言实现_第4页
fpga驱动vga接口的vhdl语言实现_第5页
已阅读5页,还剩6页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、fpga 驱动 vga 接口的 vhdl 语言实现转载 来自于基于 FPGA 的嵌入式系统设计我使用 ep2c5的实验板作过了实验,没有问题的,可惜只能显示彩条,方格。 McMaster University 有一篇介绍 vga 接口协议的 vhdl 实现介绍 , 可以自己下载 参考。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 元件,产生同步信号进行行、场扫描,即显示驱动 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;-产生 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、定义相关常量,可参考 VGA 相关工业标准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; - 行计数器signal vcnt: std_logic_vector(9 downto 0; - 场计数器begin-产生行计数(记录每行的点数, H_PERIOD 为行周期计数值。A: process(clock, resetbegin-复位时行计数器清零if reset = '0'

12、 thenhcnt <= (others => '0'elsif (clock'event and clock = '1' then-当行计数到达计数周期时将重置if hcnt < H_PERIOD thenhcnt <= hcnt + 1;elsehcnt <= (others => '0'end if;end if;end process;-产生场记数(记录每帧中的行数, V_PERIOD为场周期计数值B: process(hsyncb, resetbegin- 复位场计数器清零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;-产生行同步信号, H_PIXELS为行显示点数, H_FRONT为前消隐点数, H_S YNCTIME 为行同步点数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;-产生场同步信号, V_LINES为场显示点数, V_FRO

15、NT为前消隐点数, V_SY NCTIME 场同步点数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. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论