我需要做一个基于FPGA的俄罗斯方块设计,需要FPGA的程序,用的液晶显示屏为12864希望各位大神帮帮忙啊。 10
2个回答
展开全部
我有用VGA显示的,你要不要?要的话给邮箱
ENTITY RUSSIA IS
PORT(CLK :IN STD_LOGIC; -------时钟频率,选用低频
RESET :IN STD_LOGIC; -------复位键
LEFT :IN STD_LOGIC; -------左移键
RIGHT :IN STD_LOGIC; -------右移键
SCORES :OUT INTEGER RANGE 0 TO 15; -------分数
STA0 : OUT STD_LOGIC_VECTOR(0 TO 3) ; -------以下为四行状态寄存
STA1 : OUT STD_LOGIC_VECTOR(0 TO 3) ;
STA2 : OUT STD_LOGIC_VECTOR(0 TO 3) ;
STA3 : OUT STD_LOGIC_VECTOR(0 TO 3) );
END RUSSIA;
ARCHITECTURE MOVING OF RUSSIA IS
SIGNAL STATU0 : STD_LOGIC_VECTOR(0 TO 3) ;
SIGNAL STATU1 : STD_LOGIC_VECTOR(0 TO 3) ;
SIGNAL STATU2 : STD_LOGIC_VECTOR(0 TO 3) ;
SIGNAL STATU3 : STD_LOGIC_VECTOR(0 TO 3) ;
SIGNAL FLAG : STD_LOGIC; -------game over 标志
SIGNAL FP :INTEGER RANGE 0 TO 499; -------1000分频
SIGNAL CLK1 :STD_LOGIC;
SIGNAL SCOR_TEMP :INTEGER RANGE 0 TO 15;
SIGNAL ROW4 :STD_LOGIC; -------消行标志
SIGNAL ROW,COL:INTEGER RANGE 0 TO 3; -------点的坐标控制
BEGIN
--------p1用来分频(字数限制,此处省略)--------
P2:PROCESS(CLK1,RESET)
BEGIN
IF RESET='1' THEN --------系统初始化(略)
ELSIF(CLK1'EVENT AND CLK1='1')THEN
--------此处是(game over 进入空循环、消行、加分、判断四列中是否有一列全为1,是则FLAG<='1'、消行)程序-----------
ELSIF RIGHT='1' AND COL<3 THEN --------右移判断(下面代码有错)
CASE ROW IS
WHEN 0=>IF STATU0(COL+1)='0' THEN COL<=COL+1;STATU0(COL+1)<='1';STATU0(COL)<='0'; END IF ;
WHEN 1=>IF STATU1(COL+1)='0' THEN COL<=COL+1;STATU1(COL+1)<='1';STATU1(COL)<='0'; END IF ;
WHEN 2=>IF STATU2(COL+1)='0' THEN COL<=COL+1;STATU2(COL+1)<='1';STATU2(COL)<='0'; END IF ;
WHEN OTHERS=>IF STATU3(COL+1)='0' THEN COL<=COL+1;STATU3(COL+1)<='1'; STATU3(COL)<='0'; END IF ;
END CASE;
ELSIF LEFT='1' AND COL>0 THEN ---------左移判断
CASE ROW IS
WHEN 0=>IF STATU0(COL-1)='0' THEN COL<=COL-1;STATU0(COL-1)<='1';STATU0(COL)<='0'; END IF ;
WHEN 1=>IF STATU1(COL-1)='0' THEN COL<=COL-1;STATU1(COL-1)<='1';STATU1(COL)<='0'; END IF ;
WHEN 2=>IF STATU2(COL-1)='0' THEN COL<=COL-1;STATU2(COL-1)<='1';STATU2(COL)<='0'; END IF ;
WHEN OTHERS=>IF STATU3(COL-1)='0' THEN COL<=COL-1;STATU3(COL-1)<='1'; STATU3(COL)<='0'; END IF ;
END CASE; --------以下elsif语句为点的下移处理
END IF;
END PROCESS;
SCORES<=SCOR_TEMP;
STA0<=STATU0;
STA1<=STATU1;
STA2<=STATU2;
STA3<=STATU3;
END;
ENTITY RUSSIA IS
PORT(CLK :IN STD_LOGIC; -------时钟频率,选用低频
RESET :IN STD_LOGIC; -------复位键
LEFT :IN STD_LOGIC; -------左移键
RIGHT :IN STD_LOGIC; -------右移键
SCORES :OUT INTEGER RANGE 0 TO 15; -------分数
STA0 : OUT STD_LOGIC_VECTOR(0 TO 3) ; -------以下为四行状态寄存
STA1 : OUT STD_LOGIC_VECTOR(0 TO 3) ;
STA2 : OUT STD_LOGIC_VECTOR(0 TO 3) ;
STA3 : OUT STD_LOGIC_VECTOR(0 TO 3) );
END RUSSIA;
ARCHITECTURE MOVING OF RUSSIA IS
SIGNAL STATU0 : STD_LOGIC_VECTOR(0 TO 3) ;
SIGNAL STATU1 : STD_LOGIC_VECTOR(0 TO 3) ;
SIGNAL STATU2 : STD_LOGIC_VECTOR(0 TO 3) ;
SIGNAL STATU3 : STD_LOGIC_VECTOR(0 TO 3) ;
SIGNAL FLAG : STD_LOGIC; -------game over 标志
SIGNAL FP :INTEGER RANGE 0 TO 499; -------1000分频
SIGNAL CLK1 :STD_LOGIC;
SIGNAL SCOR_TEMP :INTEGER RANGE 0 TO 15;
SIGNAL ROW4 :STD_LOGIC; -------消行标志
SIGNAL ROW,COL:INTEGER RANGE 0 TO 3; -------点的坐标控制
BEGIN
--------p1用来分频(字数限制,此处省略)--------
P2:PROCESS(CLK1,RESET)
BEGIN
IF RESET='1' THEN --------系统初始化(略)
ELSIF(CLK1'EVENT AND CLK1='1')THEN
--------此处是(game over 进入空循环、消行、加分、判断四列中是否有一列全为1,是则FLAG<='1'、消行)程序-----------
ELSIF RIGHT='1' AND COL<3 THEN --------右移判断(下面代码有错)
CASE ROW IS
WHEN 0=>IF STATU0(COL+1)='0' THEN COL<=COL+1;STATU0(COL+1)<='1';STATU0(COL)<='0'; END IF ;
WHEN 1=>IF STATU1(COL+1)='0' THEN COL<=COL+1;STATU1(COL+1)<='1';STATU1(COL)<='0'; END IF ;
WHEN 2=>IF STATU2(COL+1)='0' THEN COL<=COL+1;STATU2(COL+1)<='1';STATU2(COL)<='0'; END IF ;
WHEN OTHERS=>IF STATU3(COL+1)='0' THEN COL<=COL+1;STATU3(COL+1)<='1'; STATU3(COL)<='0'; END IF ;
END CASE;
ELSIF LEFT='1' AND COL>0 THEN ---------左移判断
CASE ROW IS
WHEN 0=>IF STATU0(COL-1)='0' THEN COL<=COL-1;STATU0(COL-1)<='1';STATU0(COL)<='0'; END IF ;
WHEN 1=>IF STATU1(COL-1)='0' THEN COL<=COL-1;STATU1(COL-1)<='1';STATU1(COL)<='0'; END IF ;
WHEN 2=>IF STATU2(COL-1)='0' THEN COL<=COL-1;STATU2(COL-1)<='1';STATU2(COL)<='0'; END IF ;
WHEN OTHERS=>IF STATU3(COL-1)='0' THEN COL<=COL-1;STATU3(COL-1)<='1'; STATU3(COL)<='0'; END IF ;
END CASE; --------以下elsif语句为点的下移处理
END IF;
END PROCESS;
SCORES<=SCOR_TEMP;
STA0<=STATU0;
STA1<=STATU1;
STA2<=STATU2;
STA3<=STATU3;
END;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询