基于fpga,ps2 vga电子琴

合集下载
相关主题
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY DZQIN IS
POR(CLK50MHz,PS2CLK,PS2DATA,CLK4HZ,SK,:IN STD_LOGIC;

SPKOUT:OUT STD_LOGIC; ------------声音输出
HS,VS,R,G,B:OUT STD_LOGIC);
END DZQIN;
ARCHITECTURE ONE OF SONGER IS




SIGNAL C0,C1,C2,SK: STD_LOGIC;
------SIGNAL IN_CLK: STD_LOGIC;


SIGNAL PS2CLK_R: STD_LOGIC_VECTOR(2 DOWNTO 0);
SIGNAL RESET,CLK,PS2CLK: STD_LOGIC;
SIGNAL PS2DATA,,PS2CLKFALL: STD_LOGIC;
SIGNAL PS2DOUT:STD_LOGIC_VECTOR(7 DOWNTO 0);
SIGNAL PS2REG: STD_LOGIC_VECTOR(11 DOWNTO 0);-----12位移位寄存器
SIGNA PS2_DATA: STD_LOGIC_VECTOR(11 DOWNTO 0);

SIGNAL CODE0, CODE1,CODE2,CODE3 ,CODE4,CODE5,CODE6,: STD_LOGIC; ------VGA显示音调
SIGNAL CODE7,CODE8,CODE9,CODE10,CODE11,CODE512,CODE13: STD_LOGIC;------VGA显示中音调
SIGNAL CODE14,CODE15,CODE16,CODE17,CODE18,CODE519,CODE20,CODE21: STD_LOGIC;------显示低音调

SIGNAL COUNT1:INTEGER RANGE 138 TO 0;
SIGNAL COUNT3:INTEGER RANGE 31 TO 0;
----- SIGNAL COUNT2, COUNT4,COUNT5,:INTEGER RANGE 31 TO 0;
SIGNAL TOO,toneindex: INTEGER RANGE 2047 TO 0; --------音符对应的输出 输入信号标志

---- SIGNAL TN: STD_LOGIC_VECTOR(10 DOWNTO 0);-------11位可预置寄存器
SIGNAL SPKOUT: STD_LOGIC;
--- SIGNAL D,Q,H: STD_LOGIC;
SIGNAL HS1,VS1: STD_LOGIC;
SIGNAL HC3,VC3: STD_LOGIC_VECTOR(9 DOWNTO 0);----行场扫描计数器

SIGNAL CLK1MHZ,CLK25MHZ,CLK4HZ: STD_LOGIC;

SIGNAL A1,A2,A3,A4,A5,A6,A7: INTEGER RANGE 10 TO 0;
SIGNAL VGA_1,VGA_2,VGA_3:: STD_LOGIC;
--- SIGNAL A,S1,D1,F1,G1,H1,J1,Q1,W1,E1,R1,T1,Y1,U1,Z1,X1,C1,V1,B1,
N1,M1: STD_LOGIC; ------A1~J1中音1~7按键标志位,W1~U1中音,Z1~M1低音
---- SIGNAL A11,S11,D11,F11,G11,H11,J11,Q11,W1UP,E11,R11,T11L,U11,Z11,X11,C11
,V11,B11,N11,M11:STD_LOGIC;
--------------------------按键标志位键上键沿的提取

SIGNAL HIGH1:STD_LOGIC_VECTOR(2 DOWNTO 0);
SIGNAL WXP1,WXP2,WXP3,WXP4,WXP5,CSJM,HEIS0,HEIS1,HEIS2,HEIS3,BAIS4,BAIS5,BAIS6,BAIS7 :STD_LOGIC;

BEGIN
P0:PROCESS(CLK50MHZ) BEGIN ----------------------二分频为25MHZ
IF CLK50MHZ'EVENT AND CLK50MHZ='1' THEN
CLK<=NOT CLK;
END IF;
END PROCESS P0;






P1: PROCESS(CLK)BEGIN ----------------------行扫描
IF(RISING_EDGE(CLK))THEN
IF(HC3<799)THEN
HC3=HC3+1;
ELSE HC3<=(OTHERS=>0);
END IF;
END PROCESS P1;

P2:PROCESS(CLK) BEGIN ------------------场扫描
IF (RISING_EDGE(CLK)) THEN
IF(HC3=639+8) THEN
IF(VC3<524) THEN VC3<=VC3+1;
ELSE VC3<=(OTHERS=>'0');
END IF;

END IF;
END IF;
END PROCESS P2;


P3:PROCESS(CLK)BEGIN
IF(RISING_EDGE(CLK))THEN ----------行同步
IF(HC3>=640+8+8)AND(HC3<640+8+8+96)THEN
HS1<='0';
ELSE HS1<='1';
END IF;
END IF;
END PROCESS P3;
P4: PROCESS(VC3) BEGIN --------------场同步
IF((VC3>=480+8+2) AND (VC3<480+8+2+2)) THEN
VS1<='0';
ELSE VS1<='1';
END IF;
END PROCESS P4;



PROCESS(SK) ----------------------------------------------开始按键
BEGIN
IF SK='1' THEN START<='1';
ELSE START<='0';
END IF;
END PROCESS;



PROCESS(CLK50MHZ,START)
BEGIN
IF START='1' THEN

PS2CLK_R<="000";
ELSIF RISING_EDGE(CLK50MHZ) THEN
PS2CLK_R(2)<= PS2CLK_R(1);

PS2CLK_R(1)<= PS2CLK_R(0);
PS2CLK_R(0)<= PS2CLK;
END IF;
END PROCESS;
PS2CLKFALL<='1' WHEN PS2CLK_R="110" ELSE '0';
PROCESS(CLK50MHZ) THEN
IF MMD='1' THEN PS2REG<=( OTHERS=>'0');
ELSIF PS2CLKFALL='1' THEN
IF PS2REG(0)='0' THEN
PS2REG<=PS2DATA & "01111111111";
ELSE
PS2REG<=PS2DATA & PS2REG(11 DOWNTO 1);
END IF;
END IF;
END IF
END PROCESS;
PROCESS(PS2REG)
IF PS2REG(0)='0' THEN
PS2_DATA<=PS2REG(11 DOWNTO 1);
PS2DOUT<= NOT PS2_DATA(8 DOWNTO 1);
ELSE
PS2DOUT<="00000000";
END IF;
END PROCESS;




BEGIN
CASE( PS2DOUT) IS
--- WHEN "01011010"=>SK='1';----键enter
---- WHEN "00101001"=>SK='0';----键space

WHEN "00011010"=>toneindex<=1;CODE0<='1';----键Z----1 低1
WHEN "00100010"=>toneindex<=2;CODE1<='1';----键X----2
WHEN "00110100"=>toneindex<=3;CODE2<='1';----键C----3
WHEN "00101011"=>toneindex<=4;CODE3<='1';----键V----4
WHEN "00100100"=>toneindex<=5;CODE4<='1';----键B----5
WHEN "00110011"=>toneindex<=6;CODE5<='1';----键N----6
WHEN "00111011"=>toneindex<=7;CODE6<='1';----键M----7



WHEN "00011100"=>toneindex<=8;CODE7<='1';----键A----1 中 1
WHEN "00011011"=>toneindex<=9;CODE8<='1';----键S----2
WHEN "00100011"=>toneindex<=10;CODE9<='1';----键D----3
WHEN "00101011"=>toneindex<=11;CODE10<='1'----键F----4
WHEN "00100100"=>toneindex<=12;CODE11<='1';----键G----5
WHEN "00110011"=>toneindex<=13;CODE12<='1';----键H----6
WHEN "00111011"=>toneindex<=14;CODE13<='1';----键J----7


WHEN "00010101"=>toneindex<=15;CODE14<='1';----键Q----1 高1
WHEN "00101101"=>toneindex<=16;CODE15<='1';----键W----2
WHEN "00100100"=>toneindex<=17;CODE16<='1';----键E----3
WHEN "00101101"=>toneindex<=18;CODE17<='1';----键R----4
WHEN "00101100"=>toneindex<=19;CODE18<='1';----键T----5
WHEN "00110101"=>toneindex<=20;CODE19<='1';----键Y----6
WHEN "00111100"=>toneindex<=21;CODE20<='1';----键U----7
WHEN "00111100"=>toneindex<=22;CODE21<='1';----键K休




WHEN OTHERS=>TOO<=NULL
END CASE;

PROCESS(PS2DOUT)
BEGIN
IF PS2DOUT="01011010" THEN -----ENTER
SK='1';
ELSIF PS2DOUT="00101001" THEN ----SPACE
SK='0';
END IF;
ELSE SK='0';
END PROCESS;


PROCESS(CLK4HZ)


BEGIN
IF(CLK4HZ 'EVENT AND CLK4HZ ='1')THEN
IF(COUNT3=31)THEN --计数器值为31
COUNT3<=0; --计数器清0
ELSE
COUNT3<=COUNT3+1;
END IF;
END IF;
END PROCESS;

PROCESS(COUNT3,PS2DOUT)
BEGIN


IF PS2DOUT="00010110" THEN ---- 按键1有效

CASE COUNT3 IS --此CASE语句:存储自动演奏两只老虎
WHEN 0 => toneindex<=1; --1
WHEN 1 => toneindex<=2; --2
WHEN 2 => toneindex<=3; --3
WHEN 3 => toneindex<=1; --1
WHEN 4 => toneindex<=1; --1
WHEN 5 => toneindex<=2; --2
WHEN 6 => toneindex<=3; --3
WHEN 7 => toneindex<=1; --1
WHEN 8 => toneindex<=3; --3
WHEN 9 => toneindex<=4; --4
WHEN 10 => toneindex<=5; --5
WHEN 11 => toneindex<=3; --3
WHEN 12 => toneindex<=4; --4
WHEN 13 => toneindex<=5; --5
WHEN 14 => toneindex<=5; --5
WHEN 15 => toneindex<=6; --6
WHEN 16 => toneindex<=5; --5
WHEN 17 => toneindex<=4; --4
WHEN 18 => toneindex<=1; ---1
WHEN 20 => toneindex<=5; --5
WHEN 21 => toneindex<=6; --6
WHEN 22 => toneindex<=5; --5
WHEN 23 => toneindexO<=4; --4
WHEN 24 => toneindex<=3; --3
WHEN 25 => toneindex<=1; --1
WHEN 26 => toneindex<=3; --3
WHEN 27 => toneindex<=6; --DI6
WHEN 28 => toneindex<=1; --1
WHEN OTHERS => NULL;
END CASE;
END IF

END PROCESS ;



PROCESS(CLK4HZ)


BEGIN
IF(CLK4HZ 'EVENT AND CLK4HZ ='1')THEN
IF(COUNT1=138)THEN --计数器值为138
COUNT1<=0; --计数器清0
ELSE
COUNT1<=COUNT3+1;
END IF;
END IF;
END PROCESS;

PROCESS(COUNT1,PS2DOUT)
BEGIN


IF PS2DOUT="11111110" THEN ---- 按键2有效

CASE COUNT1 IS --此CASE语句:存储自动演奏梁祝

when 00 =>toneindex<=3; when 01 =>toneindex<=3; when 02 =>toneindex<=3;
when 03 =>toneindex<=3; when 04 =>toneindex<=5; when 05 =>toneindex<=5;
when 06 =>toneindex<=5; when 07 =>toneindex<=6; when 08 =>toneindex<=8;
when 09 =>toneindex<=8; when 10 =>toneindex<=8; when 11 =>toneindex<=9;
when 12 =>toneindex<=6; when 13 =>toneindex<=8; when 14 =>toneindex<=5;
when 15 =>toneindex<=5; when 16 =>toneindex<=12; when 17 =>toneindex<=12;
when 18 =>toneindex<=12; when 19 =>toneindex<=15; when 20 =>toneindex<=13;
when 21 =>toneindex<=12; when 22 =>toneindex<=10; when 23 =>toneindex<=12;
when 24 =>toneindex<=9;when 25 =>toneindex<=9;when 26 =>toneindex<=9;
when 27 =>toneindex<=9;when 28 =>toneindex<=9;when 29 =>toneindex<=9;
when 30 =>toneindex<=9;when 31 =>toneindex<=9;when 32 =>toneindex<=9;
when 33 =>toneindex<=9;when 34 =>toneindex<=9;when 35 =>toneindex<=10

;
when 36 =>toneindex<=7;when 37 =>toneindex<=7;when 38=>toneindex<=6;
when 39 =>toneindex<=6;when 40 =>toneindex<=5;when 41 =>toneindex<=5;
when 42 =>toneindex<=5; when 43 =>toneindex<=6;when 44 =>toneindex<=8;
when 45 =>toneindex<=8;when 46 =>toneindex<=9;when 47 =>toneindex<=9;
when 48 =>toneindex<=3;when 49 =>toneindex<=3;when 50 =>toneindex<=8;
when 51=>toneindex<=8;when 52 =>toneindex<=6;when 53=>toneindex<=5;
when 54=>toneindex<=6;when 55=>toneindex<=8;when 56 =>toneindex<=5;
when 57 =>toneindex<=5;when 58 =>toneindex<=5;when 59 =>toneindex<=5;
when 60 =>toneindex<=5;when 61 =>toneindex<=5;when 62 =>toneindex<=5;
when 63 =>toneindex<=5;when 64 =>toneindex<=10;when 65 =>toneindex<=10;
when 66 =>toneindex<=10;when 67 =>toneindex<=12;when 68 =>toneindex<=7;
when 69 =>toneindex<=7;when 70=>toneindex<=9; when 71 =>toneindex<=9;
when 72 =>toneindex<=6;when 73 =>toneindex<=8;when 74 =>toneindex<=5;
when 75 =>toneindex<=5;when 76 =>toneindex<=5;when 77 =>toneindex<=5;
when 78 =>toneindex<=5;when 79 =>toneindex<=5;when 80 =>toneindex<=3;
when 81 =>toneindex<=5;when 82 =>toneindex<=3;when 83 =>toneindex<=3;
when 84 =>toneindex<=5;when 85 =>toneindex<=6;when 86 =>toneindex<=7;
when 87 =>toneindex<=9;when 88=>toneindex<=6; when 89 =>toneindex<=6;
when 90=>toneindex<=6;when 91 =>toneindex<=6;when 92 =>toneindex<=6;
when 93 =>toneindex<=6;when 94 =>toneindex<=5;when 95 =>toneindex<=6;
when 96 =>toneindex<=8; when 97 =>toneindex<=8;when 98=>toneindex<=8;
when 99 =>toneindex<=9;when 100 =>toneindex<=12; when 101 =>toneindex<=12;
when 102 =>toneindex<=10; when 103 =>toneindex<=10;when 104 =>toneindex<=9;
when 105 =>toneindex<=9;when 106 =>toneindex<=10;when 107 =>toneindex<=9;
when 108 =>toneindex<=8; when 109 =>toneindex<=8;when 110 =>toneindex<=6;
when 111 =>toneindex<=5;when 112 =>toneindex<=3;when 113 =>toneindex<=3;
when 114 =>toneindex<=3;when 115 =>toneindex<=3;when 116 =>toneindex<=8;
when 117 =>toneindex<=8;when 118 =>toneindex<=8;when 119 =>toneindex<=8;
when 120 =>toneindex<=6;when 121 =>toneindex<=8;when 122 =>toneindex<=6;
when 123 =>toneindex<=5;when 124 =>toneindex<=3;when 125=>toneindex<=6;
when 126 =>toneindex<=8;when 127 =>toneindex<=5;when 128 =>toneindex<=5;
when 129 =>toneindex<=5;when 130=>toneindex<=5;when 131 =>toneindex<=5;
when 132 =>toneindex<=5; when 133 =>toneindex<=5;when 134 =>toneindex<=5;
when 135 =>toneindex<=5;when 136=>toneindex<=5;when 137 =>toneindex<=5;
when 138 =>toneindex<=5;
WHEN OTHERS=>NULL;
---TOO<=toneindex;
END CASE;
END IF;
END PROCESS;




PROCESS(toneindex)
BEGIN
CASE toneindex IS
WHEN 1=>TOO<=1911;HIGH1<="001";VGA_1='1';----键Z----1 低1
WHEN 2=>TOO<=1702;HIGH1<="001";VGA_1='1';----键X----2
WHEN 3=>TOO<=1517;HIGH1<="001";VGA_1='1';----键C----3
WHEN 4=>TOO<=1432;HIGH1<="001";;VGA_1='1';----键V----4
WHEN 5=>TOO<=1276;HIGH1<="001";VGA_1='1';----键B----5
WHEN 6=>TOO<=1136;HIGH1<="001";VGA_1='1';----键N--

--6
WHEN 7=>TOO<=1012;HIGH1<="001";VGA_1='1';----键M----7



WHEN 8=>TOO<=955;HIGH1<="010";VGA_2='1'; ----键A----1 中 1
WHEN 9=>TOO<=851;HIGH1<="010";VGA_2='1';----键S----2
WHEN 10=>TOO<=758;HIGH1<="010";VGA_2='1';----键D----3
WHEN 11=>TOO<=716;HIGH1<="010";VGA_2='1';----键F----4
WHEN 12=>TOO<=638;HIGH1<="010";VGA_2='1';----键G----5
WHEN 13=>TOO<=568;HIGH1<="010";VGA_2='1';----键H----6
WHEN 14"=>TOO<=506;HIGH1<="010";VGA_3='1';----键J----7


WHEN 15=>TOO<=478;HIGH1<="100";VGA_3='1';----键Q----1 高1
WHEN 16=>TOO<=425;HIGH1<="100";VGA_3='1';----键W----2
WHEN 17=>TOO<=379;HIGH1<="100";VGA_3='1';----键E----3
WHEN 18=>TOO<=358;HIGH1<="100";VGA_3='1';----键R----4
WHEN 19=>TOO<=319;HIGH1<="100";;VGA_3='1';----键T----5
WHEN 20=>TOO<=284;HIGH1<="100";VGA_3='1';----键Y----6
WHEN 21=>TOO<=253;HIGH1<="100";VGA_3='1';----键U----7
WHEN 22=>TOO<=2047; HIGH1="000";VGA_3='0' ----键K休止

WHEN OTHERS=>TOO<=NULL;
END CASE;
END PROCESS;

PROCESS(CLK50MHZ) --------------------50分频为1MHZ
VARIABLE COUNT6:INTEGER RANGE 0 TO 50;
BEGIN
IF CLK50MHZ'EVENT AND CLK50MHZ='1' THEN
COUNT6:= COUNT6+1;
IF COUNT6=25 THEN
C0 <='1';
ELSIF COUNT6=50 THEN
C0 <='0'; COUNT6:=0;
END IF;
END IF;
END PROCESS;
PROCESS(CLK50MHZ) --将50MHZ时钟100分频,=500KHZ;
VARIABLE COUNT7: INTEGER RANGE 0 TO 100;
BEGIN
IF(CLK50MHZ 'EVENT AND CLK50MHZ ='1')THEN
COUNT7:=COUNT7+1;
IF COUNT7=50 THEN
C1<='1';
ELSIF COUNT7=100 THEN
C1 <='0'; COUNT7:=0;
END IF;
END IF;
END PROCESS;


PROCESS(CLK500KHZ ,TOO)
VARIABLE COUNT4:INTEGER RANGE 0 TO 2047; --定义变量频率计数器2047Hz
BEGIN

IF(CLK500KHZ'EVENT AND CLK500KHZ='1')THEN ---CLK500KHZ脉冲上升沿触发
IF COUNT4COUNT4:=COUNT4+1;FULLCLK<='1'; --计数器加1,音频信号为1
ELSE
COUNT4:=0;FULLCLK<='0';
END IF;
END IF;
END PROCESS;



PROCESS(CLK1MHZ) --工作进程开始,将1MHZ时钟250000分频得4HZ;
VARIABLE COUNT8:INTEGER RANGE 0 TO 10;
BEGIN
IF(CLK1MHZ 'EVENT AND CLK1MHZ ='1')THEN
COUNT8:=count8+1;
IF COUNT8=125000 THEN
C2 <='1';
ELSIF COUNT8=250000 THEN
C2 <='0'; COUNT8:=0;
END IF;
END IF;
END PROCESS;
ROCESS(FULLCLK) --音频信号输出进程开始
VARIABLE COUNT5:STD_LOGIC:='0'; --定义变量计数器2,初值0
BEGIN
IF(FULLCLK'EVENT AND FULLCLK='1')THEN --音频信号输出上升沿有效时
COUNT5:=NO TCOUNT5;
IF COUNT5='1'THEN
SPKOUT<='1';
ELSE
SPKOUT<='0';
END IF;
END IF;
END PROCESS;







PROCESS(CLK) BEGIN -------------初始界面 五线

谱wxp
BEGIN
IF START='0' THEN
IF (RISING_EDGE(CLK)) THEN
IF ((VC3>=100 AND VC3<=130) AND ((HC3>=40 AND HC3<=600))
THEN WXP1<='1';
ELSE WXP1<='0';
END PROCESS;
PROCESS(CLK) BEGIN
BEGIN
IF START='0' THEN
IF (RISING_EDGE(CLK)) THEN
OR((VC3>=160 AND VC3<=190) AND ((HC3>=40 AND HC3<=600))
THEN WXP2<='1';
ELSE WXP2<='0';
END PROCESS;
PROCESS(CLK) BEGIN
BEGIN
IF START='0' THEN
IF (RISING_EDGE(CLK)) THEN
OR ((VC3>=220 AND VC3<=250) AND (HC3>=40 AND HC3<=600))
THEN WXP3<='1';
ELSE WXP3<='0';
END PROCESS;
PROCESS(CLK) BEGIN
BEGIN
IF START='0' THEN
IF (RISING_EDGE(CLK)) THEN
OR ((VC3>=280 AND VC3<=310) AND ((HC3>=40 AND HC3<=600))
THEN WXP4<='1';
ELSE WXP4<='0';
END PROCESS;
PROCESS(CLK) BEGIN
BEGIN
IF START='0' THEN
IF (RISING_EDGE(CLK)) THEN
OR ((VC3>=340 AND VC3<=370) AND ((HC3>=40 AND HC3<=600))
THEN WXP5<='1';
ELSE WXP5<='0';
END PROCESS;


PROCESS(CLK) BEGIN ---------小音箱
BEGIN
IF START='0' THEN
IF (RISING_EDGE(CLK)) THEN
IF ((VC3>=250 AND VC3<=255) AND ((HC3>=625 AND HC3<=630)) AND ((HC3>=630 AND HC3<=635))

OR ((VC3>=255 AND VC3<=260) AND ((HC3>=620 AND HC3<=625)) AND ((HC3>=630 AND HC3<=635))
OR ((VC3>=260 AND VC3<=265) AND ((HC3>=615 AND HC3<=620)) AND ((HC3>=630 AND HC3<=635))
OR ((VC3>=265 AND VC3<=270) AND ((HC3>=610 AND HC3<=615)) AND ((HC3>=630 AND HC3<=635))
OR ((VC3>=270 AND VC3<=275) AND ((HC3>=605 AND HC3<=610)) AND ((HC3>=630 AND HC3<=635))

OR ((VC3>=275 AND VC3<=280) AND ((HC3>=570 AND HC3<=605)) AND ((HC3>=605 AND HC3<=610)) AND ((HC3>=630 AND HC3<=635))
OR ((VC3>=280 AND VC3<=285) AND ((HC3>=570 AND HC3<=575)) AND ((HC3>=605 AND HC3<=610)) AND ((HC3>=630 AND HC3<=635))
OR ((VC3>=285 AND VC3<=290) AND ((HC3>=570 AND HC3<=575)) AND ((HC3>=605 AND HC3<=610)) AND ((HC3>=630 AND HC3<=635))
OR ((VC3>=290 AND VC3<=295) AND ((HC3>=570 AND HC3<=575)) AND ((HC3>=605 AND HC3<=610)) AND ((HC3>=630 AND HC3<=635))
OR ((VC3>=295 AND VC3<=300) AND ((HC3>=570 AND HC3<=575)) AND ((HC3>=605 AND HC3<=610)) AND ((HC3>=630 AND HC3<=635))
OR ((VC3>=300 AND VC3<=305) AND ((HC3>=570 AND HC3<=605)) AND ((HC3>=605 AND HC3<=610)) AND ((HC3>=630 AND HC3<=635))


OR ((VC3>=305 AND V

C3<=310) AND ((HC3>=610 AND HC3<=615)) AND ((HC3>=630 AND HC3<=635))

OR ((VC3>=310 AND VC3<=315) AND ((HC3>=615 AND HC3<=620)) AND ((HC3>=630 AND HC3<=635))
OR ((VC3>=315 AND VC3<=320) AND ((HC3>=620 AND HC3<=625)) AND ((HC3>=630 AND HC3<=635))
OR ((VC3>=320 AND VC3<=325) AND ((HC3>=630 AND HC3<=635)) AND ((HC3>=630 AND HC3<=635))
OR ((VC3>=325 AND VC3<=330) AND ((HC3>=630 AND HC3<=635)) AND ((HC3>=635 AND HC3<=640))
THEN CSJM<='1';
ELSE CSJM<='0';
END IF;
END IF;

END PROCESS;


PROCESS(CLK) BEGIN
BEGIN
IF START='1' THEN

IF (RISING_EDGE(CLK)) THEN
IF (CODE0 OR CODE7 OR CODE14 OR CODE21) ='1'THEN
A1=10 ;
ELSE A1='0' ;

END IF;
END IF;
END PROCESS;

PROCESS(CLK) BEGIN
BEGIN
IF START='1' THEN

IF (RISING_EDGE(CLK)) THEN
IF (CODE1 OR CODE8 OR CODE15) ='1'THEN
A2=10 ;
ELSE A2='0' ;

END IF;
END IF;
END PROCESS;

PROCESS(CLK) BEGIN
BEGIN
IF START='1' THEN

IF (RISING_EDGE(CLK)) THEN
IF (CODE2 OR CODE9 OR CODE16) ='1'THEN
A3=10 ;
ELSE A3='0' ;

END IF;
END IF;
END PROCESS;

PROCESS(CLK) BEGIN
BEGIN
IF START='1' THEN

IF (RISING_EDGE(CLK)) THEN
IF (CODE3 OR CODE10 OR CODE17) ='1'THEN
A4=10 ;
ELSE A4='0' ;

END IF;
END IF;
END PROCESS;

PROCESS(CLK) BEGIN
BEGIN
IF START='1' THEN

IF (RISING_EDGE(CLK)) THEN
IF (CODE4 OR CODE11 OR CODE18) ='1'THEN
A5=10 ;
ELSE A5='0' ;

END IF;
END IF;
END PROCESS;

PROCESS(CLK) BEGIN
BEGIN
IF START='1' THEN

IF (RISING_EDGE(CLK)) THEN
IF (CODE5 OR CODE12 OR CODE19) ='1'THEN
A6=10 ;
ELSE A6='0' ;

END IF;
END IF;
END PROCESS;

PROCESS(CLK) BEGIN
BEGIN
IF START='1' THEN

IF (RISING_EDGE(CLK)) THEN
IF (CODE6 OR CODE13 OR CODE20 ) ='1'THEN
A7=10 ;
ELSE A7='0' ;

END IF;
END IF;
END PROCESS;









PROCESS(CLK) BEGIN -------------电子琴界面
BEGIN
IF START='1' THEN

IF (RISING_EDGE(CLK)) THEN

IF ((VC3>=40 AND VC3<=90) AND ((HC3>=A1+400 AND HC3<=A1+600))
T HEN HEIS0<='1';-----黑色键高音
ELSE HEIS0<='0';
END IF;
END IF
END PROCESS;


PROCESS(CLK) BEGI

N -------------电子琴界面
BEGIN
IF START='1' THEN
IF (RISING_EDGE(CLK)) THEN

IF ((VC3>=140 AND VC3<=190) AND ((HC3>=A2+400 AND HC3<=A2+600))
THEN HEIS1<='1';-----黑色键高音
ELSE HEIS1<='0';
END IF;
END IF
END PROCESS;

PROCESS(CLK) BEGIN -------------电子琴界面
BEGIN
IF START='1' THEN
IF (RISING_EDGE(CLK)) THEN

IF ((VC3>=240 AND VC3<=290) AND ((HC3>=A3+400 AND HC3<=A3+600))

THEN HEIS2<='1';-----黑色键高音
ELSE HEIS2<='0';
END IF;
END IF
END PROCESS;



PROCESS(CLK) BEGIN -------------电子琴界面
BEGIN
IF START='1' THEN
IF (RISING_EDGE(CLK)) THEN


IF ((VC3>=340 AND VC3<=390) AND (HC3>=A4+400 AND HC3<=A4+600))
THEN HEIS3<='1';-----黑色键高音
ELSE HEIS3<='0';
END IF;
END IF
END PROCESS;

PROCESS(CLK) BEGIN -------------电子琴界面
BEGIN
IF START='1' THEN
IF (RISING_EDGE(CLK)) THEN

IF ((VC3>=90 AND VC3<140) AND (HC3>=A5+400 AND HC3
THEN BAIS4<='1';------白色键中音
ELSE BAIS4<='0';
END IF;
END IF;
END PROCESS;

PROCESS(CLK) BEGIN -------------电子琴界面
BEGIN
IF START='1' THEN
IF (RISING_EDGE(CLK)) THEN

IF ((VC3>=190 AND VC3<240) AND (HC3>=A6+400 AND HC3THER BAIS5<='1';------白色键中音
ELSE BAIS5<='0';
END IF;
END IF;
END PROCESS;

PROCESS(CLK) BEGIN -------------电子琴界面
BEGIN
IF START='1' THEN
IF (RISING_EDGE(CLK)) THEN

IF ((VC3>=290 AND VC3<340) AND (HC3>=A7+400 AND HC3THEN BAIS6<='1';------白色键中音
ELSE BAIS6<='0';
END IF;
END IF;
END PROCESS;
PROCESS(CLK) BEGIN -------------电子琴界面
BEGIN
IF (RISING_EDGE(CLK)) THEN
IF START='1' THEN
IF ((VC3>=390 AND VC3<440) AND (HC3>=A1+400 AND HC3THEN BAIS7<='1';------白色键中音
ELSE BAIS7<='0';
END IF;
END IF;
END PROCESS;























PROCESS(CLK) BEGIN ------- 初始模块颜色控制
IF CLK'EVENT AND CLK='1' THEN
IF (HC3<=640 AND VC3<=480) THEN
IF START='0' THEN
IF (WXP1 OR CSJM OR WXP2 OR WXP3 OR WXP4 OR WXP5)='1' THEN
R<=(NOT WXP1) OR (NOT CSJM) OR (NOT WXP2) OR WXP3 OR WXP4 OR (NO WXP5 ) AND HS1 AND VS1;
G<=(NOT WX

P1) OR (NOT CSJM) OR WXP2 OR (NOT WXP3 ) OR (NOT WXP4 ) OR WXP5 AND HS1 AND VS1;
B<=(NOT WXP1) OR (NOT CSJM) OR (NOT WXP2) OR (NOT WXP3 ) OR WXP4 OR (NOT WXP5 ) AND HS1 AND VS1;
ELSE
R<='0';G<='0';B<='1';
END IF;
END IF;
END IF;
END PROCESS;


PROCESS(CLK) BEGIN
IF CLK'EVENT AND CLK='1' THEN
IF (HC3<=640 AND VC3<=480) THEN
IF START='1' THEN --------------------------游戏界面

IF(HEIS0 OR HEIS1 OR HEIS2 OR HEIS3 OR BAIS4 OR BAIS5 OR BAIS6 OR BAIS7) ='1' THEN
R<=(NOT HEIS0) OR (NOT HEIS1) OR (NOT HEIS2) OR (NOT HEIS3) OR BSIS4 OR BSIS5 OR BSIS6 OR BSIS7 AND HS1 AND VS1;
G<=(NOT HEIS0) OR (NOT HEIS1) OR (NOT HEIS2) OR (NOT HEIS3) OR BSIS4 OR BSIS5 OR BSIS6 OR BSIS7 AND HS1 AND VS1;
G<=(NOT HEIS0) OR (NOT HEIS1) OR (NOT HEIS2) OR (NOT HEIS3) OR BSIS4 OR BSIS5 OR BSIS6 OR BSIS7 AND HS1 AND VS1;

ELSE R<='0';G<='0';B<='1';
END IF;
END IF;
END PROCESS;

HS<=HS1;VS<=VS1;
END ONE;


相关文档
最新文档