基于VHDL语言的VGA显示与控制Word下载.docx
《基于VHDL语言的VGA显示与控制Word下载.docx》由会员分享,可在线阅读,更多相关《基于VHDL语言的VGA显示与控制Word下载.docx(13页珍藏版)》请在冰豆网上搜索。
15andH<
110thenHs<
='
;
elsifH>
=110thenHs<
0'
ifH>
=160andH<
800thenHen<
elsifH=800thenHen<
H<
=0;
endif;
endif;
endif;
ifHs'
eventandHs='
thenV<
=V+1;
ifV>
11andV<
14thenVs<
elsifV>
=14thenVs<
ifV>
=45andV<
525thenVen<
elsifV=525thenVen<
V<
此部分代码为时序部分主要代码。
2.2时序部分的实现
2.2.1行时序
H:
行
HS:
行消隐信号
Hen:
允许显示
由时序图(图-1)可以看出,行时序中需要有行消隐、行同步、显示前后沿等。
其中有效显示信号为640个周期。
2.2.2场时序
与行时序相类似。
3.控制部分的代码实现
3.1控制部分主要代码
process(clk_d,sw)
begin
ifclk_d'
eventandclk_d='
then
ifsw="
11"
sw_t<
=sw_t+1;
01"
=sw_t-1;
endif;
endprocess;
process(sw_t)
begin
ifsw_t="
0000"
thenR<
=Rd(s);
G<
=Gd(s);
B<
=Bd(s);
elsifsw_t="
0001"
=Rd(s+1);
=Gd(s+1);
=Bd(s+1);
0010"
=Rd(s+2);
=Gd(s+2);
=Bd(s+2);
0011"
=Rd(s+3);
=Gd(s+3);
=Bd(s+3);
ifs=5andt=4and(n=0orm=0orn=79orm=59orn=1orm=1orn=78orm=58)thenR<
=Rd(3);
=Gd(3);
=Bd(3);
0100"
=Rd(s+4);
=Gd(s+4);
=Bd(s+4);
ifs=3andt=4and(n=0orm=0orn=79orm=59orn=1orm=1orn=78orm=58)thenR<
=Rd(0);
=Gd
(1);
0101"
=Rd(s+5);
=Gd(s+5);
=Bd(s+5);
ifs=2andt=4and(n=0orm=0orn=79orm=59orn=1orm=1orn=78orm=58)thenR<
=Gd
(2);
=Bd(0);
0110"
=Rd(s+6);
=Gd(s+6);
=Bd(s+6);
ifs=1andt=4and(n=0orm=0orn=79orm=59orn=1orm=1orn=78orm=58)thenR<
=Gd(0);
0111"
=Rd(s+7);
=Gd(s+7);
=Bd(s+7);
ifs=3andt=5and(n=0orm=0orn=79orm=59orn=1orm=1orn=78orm=58)thenR<
1000"
=Rd((s+t)rem8);
=Gd((s+t)rem8);
=Bd((s+t)rem8);
1001"
=Rd((s+t)rem7);
=Gd((s+t)rem7);
=Bd((s+t)rem7);
1010"
=Rd((s+t)rem6);
=Gd((s+t)rem6);
=Bd((s+t)rem6);
1011"
=Rd((s+t)rem5);
=Gd((s+t)rem5);
=Bd((s+t)rem5);
1100"
=Rd((s+t)rem4);
=Gd((s+t)rem4);
=Bd((s+t)rem4);
1101"
=Rd((s+t)rem3);
=Gd((s+t)rem3);
=Bd((s+t)rem3);
1110"
=Rd((s+t)rem2);
=Gd((s+t)rem2);
=Bd((s+t)rem2);
1111"
=Rd((s+t)rem1);
=Gd((s+t)rem1);
=Bd((s+t)rem1);
--ifs=5andt=4and(n=0orm=0orn=79orm=59orn=1orm=1orn=78orm=58)thenR<
--endif;
--ifs=4andt=4and(n=0orm=0orn=79orm=59orn=1orm=1orn=78orm=58)thenR<
--ifs=3andt=4and(n=0orm=0orn=79orm=59orn=1orm=1orn=78orm=58)thenR<
--ifs=2andt=4and(n=0orm=0orn=79orm=59orn=1orm=1orn=78orm=58)thenR<
--ifs=1andt=4and(n=0orm=0orn=79orm=59orn=1orm=1orn=78orm=58)thenR<
--ifs=3andt=5and(n=0orm=0orn=79orm=59orn=1orm=1orn=78orm=58)thenR<
ifs=1andt=6thenR<
ifs=2andt=6thenR<
ifs=3andt=6thenR<
ifs=4andt=6thenR<
ifs=5andt=6thenR<
ifs=3andt=5thenR<
ifs=3andt=4thenR<
ifs=3andt=3thenR<
ifs=3andt=2thenR<
ifs=3andt=1thenR<
ifs=1andt=3thenR<
ifs=2andt=3thenR<
ifs=4andt=3thenR<
ifs=5andt=3thenR<
ifs=6andt=3thenR<
ifs=1andt=1thenR<
ifs=2andt=1thenR<
ifs=4andt=1thenR<
ifs=5andt=1thenR<
ifs=6andt=1thenR<
ifs=1andt=2thenR<
ifs=1andt=4thenR<
ifs=1andt=5thenR<
ifs=6andt=2thenR<
ifs=6andt=4thenR<
ifs=6andt=5thenR<
ifs=6andt=6thenR<
ifm=7andn=5and(m=15orn=10)thenR<
endprocess;
3.2控制部分的实现
3.2.1彩条与彩格
通过对行信号、场信号计数,打印出彩条。
通过拨码开关,控制彩条向左走或向右走。
通过REM对信号求余,打印出彩格。
3.2.2字体显示
与彩格控制类似。
4.硬件平台实验