这个学期刚刚学完EDA,想毕设用EDA技术做
试着做了一个计数器
功能是一个按键+1,一个按键可以-1,还有一个清零复位键
麻烦大神看一下有没有问题
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY C1 IS
PORT(rst,clk,A,B: IN STD_LOGIC;
count: OUT STD_LOGIC_VECTOR(7 DOWNTO 0)
END ENTITY CI;
ARCHITECTURE behaviour OF C1 IS
SIGNAL:Q STD_LOGIC_VECTOR(7 DOWNTO 0);
BEGIN
PROCESS(clk,rst,A,B)
VARIABLE S:STD_LOGIC_VECTOR(1 DOWNTO 0);
BEGIN
S:=A&B;
IF rst=‘1’ THEN Q:=(OTHERS=>‘0’);
ELSIF CLK'EVENT AND CLK=‘1’ THEN
CASE(S) IS
WHEN“01”=> Q<=Q+1;
WHEN“10”=> Q<=Q-1;
WHEN OTHERS =>NULL;
END CASE;
END IF;
END PROCESS;
count<=Q;
END ARCHITECTURE behaviour; |