1、基于VHDL语言的VGA显示与控制 EDA大作业实验报告基于VHDL语言的VGA显示与控制1111000079 田宇1111000081 王坤1 VGA显示原理1.1 VGA逐行扫描显示逐行扫描是扫描从屏幕左上角一点开始,从左像右逐点扫描,每扫描完一行,电子束回到屏幕的左边下一行的起始位置,在这期间,CRT对电子束进行消隐,每行结束时,用行同步信号进行同步;当扫描完所有的行,形成一帧,用场同步信号进行场同步,并使扫描回到屏幕左上方,同时进行场消隐,开始下一帧。1.2 VGA时序分析(图-1)2 时序部分的代码实现2.1 时序部分主要代码 if ckevent and ck=1 then H15
2、 and H110 then Hs=110 then Hs=160 and H800 then Hen=1; elsif H=800 then Hen=0; H=0; end if; end if; end if; if Hsevent and Hs=1 then V11 and V14 then Vs=14 then Vs=45 and V525 then Ven=1; elsif V=525 then Ven=0; V=0; end if; end if; end if; 此部分代码为时序部分主要代码。2.2 时序部分的实现2.2.1 行时序 H: 行HS: 行消隐信号Hen: 允许显示由
3、时序图(图-1)可以看出,行时序中需要有行消隐、行同步、显示前后沿等。其中有效显示信号为640个周期。2.2.2 场时序与行时序相类似。 3 控制部分的代码实现3.1 控制部分主要代码process(clk_d,sw) begin if clk_devent and clk_d=1 then if sw=11 then sw_t=sw_t+1; end if; if sw=01 then sw_t=sw_t-1; end if; end if; end process; process(sw_t) begin if sw_t=0000 then R=Rd(s);G=Gd(s);B=Bd(s);
4、 elsif sw_t=0001 then R=Rd(s+1);G=Gd(s+1);B=Bd(s+1); elsif sw_t=0010 then R=Rd(s+2);G=Gd(s+2);B=Bd(s+2); elsif sw_t=0011 then R=Rd(s+3);G=Gd(s+3);B=Bd(s+3); if s=5 and t=4 and (n=0 or m=0 or n=79 or m=59 or n=1 or m=1 or n=78 or m=58) then R=Rd(3);G=Gd(3);B=Bd(3); end if; elsif sw_t=0100 then R=Rd(s
5、+4);G=Gd(s+4);B=Bd(s+4); if s=3 and t=4 and (n=0 or m=0 or n=79 or m=59 or n=1 or m=1 or n=78 or m=58) then R=Rd(0);G=Gd(1);B=Bd(3); end if; elsif sw_t=0101 then R=Rd(s+5);G=Gd(s+5);B=Bd(s+5); if s=2 and t=4 and (n=0 or m=0 or n=79 or m=59 or n=1 or m=1 or n=78 or m=58) then R=Rd(3);G=Gd(2);B=Bd(0);
6、 end if; elsif sw_t=0110 then R=Rd(s+6);G=Gd(s+6);B=Bd(s+6); if s=1 and t=4 and (n=0 or m=0 or n=79 or m=59 or n=1 or m=1 or n=78 or m=58) then R=Rd(0);G=Gd(0);B=Bd(3); end if; elsif sw_t=0111 then R=Rd(s+7);G=Gd(s+7);B=Bd(s+7); if s=3 and t=5 and (n=0 or m=0 or n=79 or m=59 or n=1 or m=1 or n=78 or
7、 m=58) then R=Rd(0);G=Gd(0);B=Bd(0); end if; elsif sw_t=1000 then R=Rd(s+t)rem 8);G=Gd(s+t)rem 8);B=Bd(s+t)rem 8); elsif sw_t=1001 then R=Rd(s+t)rem 7);G=Gd(s+t)rem 7);B=Bd(s+t)rem 7); elsif sw_t=1010 then R=Rd(s+t)rem 6);G=Gd(s+t)rem 6);B=Bd(s+t)rem 6); elsif sw_t=1011 then R=Rd(s+t)rem 5);G=Gd(s+t
8、)rem 5);B=Bd(s+t)rem 5); elsif sw_t=1100 then R=Rd(s+t)rem 4);G=Gd(s+t)rem 4);B=Bd(s+t)rem 4); elsif sw_t=1101 then R=Rd(s+t)rem 3);G=Gd(s+t)rem 3);B=Bd(s+t)rem 3); elsif sw_t=1110 then R=Rd(s+t)rem 2);G=Gd(s+t)rem 2);B=Bd(s+t)rem 2); elsif sw_t=1111 then R=Rd(s+t)rem 1);G=Gd(s+t)rem 1);B=Bd(s+t)rem
9、 1); - if s=5 and t=4 and (n=0 or m=0 or n=79 or m=59 or n=1 or m=1 or n=78 or m=58) then R=Rd(3);G=Gd(3);B=Bd(3); - end if; - if s=4 and t=4 and (n=0 or m=0 or n=79 or m=59 or n=1 or m=1 or n=78 or m=58) then R=Rd(3);G=Gd(3);B=Bd(3); - end if; - if s=3 and t=4 and (n=0 or m=0 or n=79 or m=59 or n=1
10、 or m=1 or n=78 or m=58) then R=Rd(3);G=Gd(3);B=Bd(3); - end if; - if s=2 and t=4 and (n=0 or m=0 or n=79 or m=59 or n=1 or m=1 or n=78 or m=58) then R=Rd(3);G=Gd(3);B=Bd(3); - end if; - if s=1 and t=4 and (n=0 or m=0 or n=79 or m=59 or n=1 or m=1 or n=78 or m=58) then R=Rd(3);G=Gd(3);B=Bd(3); - end
11、 if; - if s=3 and t=5 and (n=0 or m=0 or n=79 or m=59 or n=1 or m=1 or n=78 or m=58) then R=Rd(3);G=Gd(3);B=Bd(3); - end if; if s=1 and t=6 then R=Rd(3);G=Gd(3);B=Bd(3); end if; if s=2 and t=6 then R=Rd(3);G=Gd(3);B=Bd(3); end if; if s=3 and t=6 then R=Rd(3);G=Gd(3);B=Bd(3); end if; if s=4 and t=6 t
12、hen R=Rd(3);G=Gd(3);B=Bd(3); end if; if s=5 and t=6 then R=Rd(3);G=Gd(3);B=Bd(3); end if; if s=3 and t=6 then R=Rd(3);G=Gd(3);B=Bd(3); end if; if s=3 and t=5 then R=Rd(3);G=Gd(3);B=Bd(3); end if; if s=3 and t=4 then R=Rd(3);G=Gd(3);B=Bd(3); end if; if s=3 and t=3 then R=Rd(3);G=Gd(3);B=Bd(3); end if
13、; if s=3 and t=2 then R=Rd(3);G=Gd(3);B=Bd(3); end if; if s=3 and t=1 then R=Rd(3);G=Gd(3);B=Bd(3); end if; if s=1 and t=3 then R=Rd(3);G=Gd(3);B=Bd(3); end if; if s=2 and t=3 then R=Rd(3);G=Gd(3);B=Bd(3); end if; if s=3 and t=3 then R=Rd(3);G=Gd(3);B=Bd(3); end if; if s=4 and t=3 then R=Rd(3);G=Gd(
14、3);B=Bd(3); end if; if s=5 and t=3 then R=Rd(3);G=Gd(3);B=Bd(3); end if; if s=6 and t=3 then R=Rd(3);G=Gd(3);B=Bd(3); end if; if s=1 and t=1 then R=Rd(3);G=Gd(3);B=Bd(3); end if; if s=2 and t=1 then R=Rd(3);G=Gd(3);B=Bd(3); end if; if s=3 and t=1 then R=Rd(3);G=Gd(3);B=Bd(3); end if; if s=4 and t=1
15、then R=Rd(3);G=Gd(3);B=Bd(3); end if; if s=5 and t=1 then R=Rd(3);G=Gd(3);B=Bd(3); end if; if s=6 and t=1 then R=Rd(3);G=Gd(3);B=Bd(3); end if; if s=1 and t=1 then R=Rd(3);G=Gd(3);B=Bd(3); end if; if s=1 and t=2 then R=Rd(3);G=Gd(3);B=Bd(3); end if; if s=1 and t=3 then R=Rd(3);G=Gd(3);B=Bd(3); end i
16、f; if s=1 and t=4 then R=Rd(3);G=Gd(3);B=Bd(3); end if; if s=1 and t=5 then R=Rd(3);G=Gd(3);B=Bd(3); end if; if s=1 and t=6 then R=Rd(3);G=Gd(3);B=Bd(3); end if; if s=6 and t=1 then R=Rd(3);G=Gd(3);B=Bd(3); end if; if s=6 and t=2 then R=Rd(3);G=Gd(3);B=Bd(3); end if; if s=6 and t=3 then R=Rd(3);G=Gd
17、(3);B=Bd(3); end if; if s=6 and t=4 then R=Rd(3);G=Gd(3);B=Bd(3); end if; if s=6 and t=5 then R=Rd(3);G=Gd(3);B=Bd(3); end if; if s=6 and t=6 then R=Rd(3);G=Gd(3);B=Bd(3); end if; if m=7 and n=5 and(m=15 or n=10) then R=Rd(3);G=Gd(3);B=Bd(3); end if; end if; end process; 3.2 控制部分的实现3.2.1 彩条与彩格通过对行信号、场信号计数,打印出彩条。通过拨码开关,控制彩条向左走或向右走。通过REM对信号求余,打印出彩格。3.2.2 字体显示与彩格控制类似。4. 硬件平台实验
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1