这次的实验现象如下:需要自己做一个VGA控制信号模块,并且显示在电脑屏幕上面,有问题的可以私聊,我们这个实验还没有做完,后续会继续更新,不希望有些人直接把代码拷走,还是要自己动脑子想想,25MHZ信号是通过直接设置锁相环生成的,我没有写具体的方法,你们的书上应该也有,拜拜吃饭去了!
例化语句的顶层代码 LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; ENTITY VGA_GAME IS PORT( CLK20MHZ: IN STD_LOGIC; Hs,Vs,r,g,b:OUT STD_LOGIC ); END VGA_GAME; ARCHITECTURE modelstru OF VGA_GAME IS COMPONENT SPORTS PORT( Q:IN STD_LOGIC; HS,VS,R,G,B:OUT STD_LOGIC ); END COMPONENT; COMPONENT PLL PORT ( inclk0 : IN STD_LOGIC := '0'; c0 : OUT STD_LOGIC ); END COMPONENT; SIGNAL NET1:STD_LOGIC; BEGIN U1:PLL PORT MAP(inclk0=>CLK20MHZ,c0 =>NET1); U2:SPORTS PORT MAP(Q=>NET1,HS=>Hs,VS=>Vs,R=>r,G=>g,B=>b); END modelstru;
VGA控制模块代码 LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; USE IEEE.STD_LOGIC_UNSIGNED.ALL; ENTITY SPORTS IS PORT( Q:IN STD_LOGIC; HS,VS,R,G,B:OUT STD_LOGIC ); END SPORTS; ARCHITECTURE ONE OF SPORTS IS SIGNAL HCNT:STD_LOGIC_VECTOR(0 to 9); SIGNAL VCNT:STD_LOGIC_VECTOR(0 to 9); BEGIN 场频的产生 PROCESS(Q)BEGIN IF(rising_edge(Q)) then IF(HCNT<800) THEN HCNT<=HCNT+1; ELSE HCNT<=(OTHERS=>'0'); END IF; END IF; END PROCESS; 行频的产生 PROCESS(Q) BEGIN IF(rising_edge(Q)) then IF(HCNT=640+8) THEN IF(VCNT<525)THEN VCNT<=VCNT+1; ELSE VCNT<=(OTHERS=>'0'); END IF; END IF; END IF; END PROCESS; PROCESS(Q)BEGIN IF(rising_edge(Q)) then IF((HCNT>=640+8+8)AND (HCNT<(640+8+8+96)))THEN HS<='0'; ELSE HS<='1'; END IF; END IF; END PROCESS; PROCESS(VCNT)BEGIN IF((VCNT>=480+8+2)AND (VCNT<(480+8+2+2)))THEN VS<='0'; ELSE VS<='1'; END IF; END PROCESS; PROCESS(Q) BEGIN IF(rising_edge(Q)) THEN IF(HCNT<640 and VCNT<60) THEN R <= '0'; G <= '0'; B <= '0'; ELSIF (HCNT<=62 and 60<VCNT AND VCNT<80)THEN R <= '0'; G <= '1'; B <= '1'; ELSIF (64<HCNT AND HCNT<126 and 60<VCNT AND VCNT<80)THEN R <= '0'; G <= '1'; B <= '1'; ELSIF (128<HCNT AND HCNT<190 and 60<VCNT AND VCNT<80)THEN R <= '0'; G <= '1'; B <= '1'; ELSIF (192<HCNT AND HCNT<254 and 60<VCNT AND VCNT<80)THEN R <= '0'; G <= '1'; B <= '1'; ELSIF (256<HCNT AND HCNT<318 and 60<VCNT AND VCNT<80)THEN R <= '0'; G <= '1'; B <= '1'; ELSIF (320<HCNT AND HCNT< 382 and 60<VCNT AND VCNT<80)THEN R <= '0'; G <= '1'; B <= '1'; ELSIF (384<HCNT AND HCNT< 446 and 60<VCNT AND VCNT<80)THEN R <= '0'; G <= '1'; B <= '1'; ELSIF (448<HCNT AND HCNT< 510 and 60<VCNT AND VCNT<80)THEN R <= '0'; G <= '1'; B <= '1'; ELSIF (512<HCNT AND HCNT< 574 and 60<VCNT AND VCNT<80)THEN R <= '0'; G <= '1'; B <= '1'; ELSIF (576<HCNT AND HCNT< 638 and 60<VCNT AND VCNT<80)THEN R <= '0'; G <= '1'; B <= '1'; ELSIF (HCNT<=62 and 82<VCNT AND VCNT<102)THEN R <= '1'; G <= '0'; B <= '1'; ELSIF (64<HCNT AND HCNT< 126 and 82<VCNT AND VCNT<102)THEN R <= '1'; G <= '0'; B <= '1'; ELSIF (128<HCNT AND HCNT< 190 and 82<VCNT AND VCNT<102)THEN R <= '1'; G <= '0'; B <= '1'; ELSIF (192<HCNT AND HCNT< 254 and 82<VCNT AND VCNT<102)THEN R <= '1'; G <= '0'; B <= '1'; ELSIF (256<HCNT AND HCNT< 318 and 82<VCNT AND VCNT<102)THEN R <= '1'; G <= '0'; B <= '1'; ELSIF (320<HCNT AND HCNT< 382 and 82<VCNT AND VCNT<102)THEN R <= '1'; G <= '0'; B <= '1'; ELSIF (384<HCNT AND HCNT< 446 and 82<VCNT AND VCNT<102)THEN R <= '1'; G <= '0'; B <= '1'; ELSIF (448<HCNT AND HCNT< 510 and 82<VCNT AND VCNT<102)THEN R <= '1'; G <= '0'; B <= '1'; ELSIF (512<HCNT AND HCNT< 574 and 82<VCNT AND VCNT<102)THEN R <= '1'; G <= '0'; B <= '1'; ELSIF (576<HCNT AND HCNT< 638 and 82<VCNT AND VCNT<102)THEN R <= '1'; G <= '0'; B <= '1'; ELSIF (HCNT<=62 and 104<VCNT AND VCNT<124)THEN R <= '1'; G <= '0'; B <= '0'; ELSIF (64<HCNT AND HCNT< 126 and 104<VCNT AND VCNT<124)THEN R <= '1'; G <= '0'; B <= '0'; ELSIF (128<HCNT AND HCNT< 190 and 104<VCNT AND VCNT<124)THEN R <= '1'; G <= '0'; B <= '0'; ELSIF (192<HCNT AND HCNT< 254 and 104<VCNT AND VCNT<124)THEN R <= '1'; G <= '0'; B <= '0'; ELSIF (256<HCNT AND HCNT< 318 and 104<VCNT AND VCNT<124)THEN R <= '1'; G <= '0'; B <= '0'; ELSIF (320<HCNT AND HCNT< 382 and 104<VCNT AND VCNT<124)THEN R <= '1'; G <= '0'; B <= '0'; ELSIF (384<HCNT AND HCNT< 446 and 104<VCNT AND VCNT<124)THEN R <= '1'; G <= '0'; B <= '0'; ELSIF (448<HCNT AND HCNT< 510 and 104<VCNT AND VCNT<124)THEN R <= '1'; G <= '0'; B <= '0'; ELSIF (512<HCNT AND HCNT< 574 and 104<VCNT AND VCNT<124)THEN R <= '1'; G <= '0'; B <= '0'; ELSIF (576<HCNT AND HCNT< 638 and 104<VCNT AND VCNT<124)THEN R <= '1'; G <= '0'; B <= '0'; ELSIF (HCNT<=62 and 126<VCNT AND VCNT<146)THEN R <= '0'; G <= '1'; B <= '0'; ELSIF (64<HCNT AND HCNT< 126 and 126<VCNT AND VCNT<146)THEN R <= '0'; G <= '1'; B <= '0'; ELSIF (128<HCNT AND HCNT< 190 and 126<VCNT AND VCNT<146)THEN R <= '0'; G <= '1'; B <= '0'; ELSIF (192<HCNT AND HCNT< 254 and 126<VCNT AND VCNT<146)THEN R <= '0'; G <= '1'; B <= '0'; ELSIF (256<HCNT AND HCNT< 318 and 126<VCNT AND VCNT<146)THEN R <= '0'; G <= '1'; B <= '0'; ELSIF (320<HCNT AND HCNT< 382 and 126<VCNT AND VCNT<146)THEN R <= '0'; G <= '1'; B <= '0'; ELSIF (384<HCNT AND HCNT< 446 and 126<VCNT AND VCNT<146)THEN R <= '0'; G <= '1'; B <= '0'; ELSIF (448<HCNT AND HCNT< 510 and 126<VCNT AND VCNT<146)THEN R <= '0'; G <= '1'; B <= '0'; ELSIF (512<HCNT AND HCNT< 574 and 126<VCNT AND VCNT<146)THEN R <= '0'; G <= '1'; B <= '0'; ELSIF (576<HCNT AND HCNT< 638 and 126<VCNT AND VCNT<146)THEN R <= '0'; G <= '1'; B <= '0'; ELSE R <='0'; G <='0'; B <='0'; END IF; END IF; END PROCESS; END ONE;