VHDL实现智能药盒
文章目录
一、简介
来继续实现智能药盒,这里只不过是换了一个板子,换了一种语言而已。
二、代码
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
use ieee.std_logic_unsigned.all;
ENTITY yaohe_jichu IS
PORT(BTN0,BTN1,BTN2:IN STD_LOGIC;
BTN3:IN STD_LOGIC;
CLK:IN STD_LOGIC;
ROW_OUT : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
RED_OUT : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
GRN_OUT : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
LED_OUT : OUT STD_LOGIC_VECTOR(5 DOWNTO 0);
FMQ : OUT STD_LOGIC;
btn_row:out std_logic_vector(3 downto 0);
row0:in std_logic_vector(3 downto 0);
disp_seg:out std_logic_vector(6 downto 0);
disp_cat:out std_logic_vector(7 downto 0);
switch1:in std_logic
);
END yaohe_jichu;
ARCHITECTURE ACT OF yaohe_jichu IS
SIGNAL CONT,CONT_1:INTEGER RANGE 0 TO 3;
signal BTN1_I,BTN0_I,BTN2_I,BTN3_I,resetmp3,resetmp4,resetmp5,resetmp6,resetmp7,resetmp8,resetmp9,resetmp10,CLK_10,CLK_60,CLK_5:STD_LOGIC;
SIGNAL NUM_2 : INTEGER RANGE 0 TO 59;SIGNAL NUM_3 : INTEGER RANGE 0 TO 7;
SIGNAL NUM_4,OC,COD,COC,change : INTEGER RANGE 0 TO 1;
SIGNAL TMP_1:INTEGER RANGE 0 TO 49999;
SIGNAL TMP_2:INTEGER RANGE 0 TO 24999999;
SIGNAL TMP_3:INTEGER RANGE 0 TO 12499999;
signal scan: std_logic_vector(1 downto 0);
signal tmp: integer range 0 to 49999;
signal deshake1: integer range 0 to 99;
signal deshake2: integer range 0 to 99;
signal deshake3: integer range 0 to 99;
signal clktmp,OP: std_logic;
signal clk_out: std_logic;
signal number: std_logic_vector(3 downto 0);
signal number1: std_logic_vector(3 downto 0);
signal number1_IN_1: std_logic_vector(3 downto 0);
signal number1_IN_2: std_logic_vector(3 downto 0);
signal number2: std_logic_vector(3 downto 0);
signal number2_IN_1: std_logic_vector(3 downto 0);
signal number2_IN_2: std_logic_vector(3 downto 0);
signal number3: std_logic_vector(3 downto 0);
signal number3_IN_1: std_logic_vector(3 downto 0);
signal number3_IN_2: std_logic_vector(3 downto 0);
signal number1_OUT: std_logic_vector(3 downto 0);
signal number2_OUT: std_logic_vector(3 downto 0);
signal number1_OUT_O: std_logic_vector(3 downto 0);
signal number2_OUT_O: std_logic_vector(3 downto 0);
signal number4: std_logic_vector(3 downto 0);
signal number5: std_logic_vector(3 downto 0);
signal number6: std_logic_vector(3 downto 0);
signal COMB_1: std_logic_vector(3 downto 0);
signal COMB_2: std_logic_vector(3 downto 0);
signal col0: std_logic_vector(3 downto 0);
--button3--
signal feeding_medicine: STD_LOGIC:='0';
signal feeding_medicine0: STD_LOGIC:='0';
signal position:INTEGER RANGE 0 TO 3;--position.
--判断是否吃药了--
--initial is 0
--if needed to take medicine, then set the number to 1
--if taken the medicine, then set the number to 0 again.
BEGIN
PROCESS(CLK)
BEGIN
IF CLK'EVENT AND CLK = '1'THEN
IF TMP_2 = 24999999 THEN TMP_2 <= 0;
CLK_60 <= NOT CLK_60;
ELSE TMP_2 <= TMP_2 + 1;
END IF;
END IF;
END PROCESS;
PROCESS(CLK) --button0--
BEGIN
IF BTN0_I'EVENT AND BTN0_I='1'THEN
OP<=NOT OP;
END IF;
END PROCESS;
PROCESS(CLK_5) --数码管输出值总设定--
BEGIN
IF OP ='1'THEN
IF CONT = 0 THEN number1_OUT_O<=number1_OUT;number2_OUT_O<=number2_OUT;
ELSE
IF CLK_5='1'THEN
number1_OUT_O<=number1_OUT;number2_OUT_O<=number2_OUT;
ELSE number1_OUT_O<="1111";number2_OUT_O<="1111";
END IF;
END IF;
IF OC=1 THEN
number1_OUT_O<=COMB_2;
number2_OUT_O<=COMB_1;
ELSE NULL;
END IF;
ELSE number1_OUT_O<="0000";number2_OUT_O<="0000";
END IF;
END PROCESS;
PROCESS(CLK_10) --button1设定时数码管显示--
BEGIN
IF OP = '1'THEN
IF CONT = 0 THEN number1_OUT<="1111";number2_OUT<="1111";
ELSIF CONT = 1 THEN number1_OUT<=number1_IN_1;number2_OUT<=number1_IN_2;
ELSIF CONT = 2 THEN number1_OUT<=number2_IN_1;number2_OUT<=number2_IN_2;
ELSIF CONT = 3 THEN number1_OUT<=number3_IN_1;number2_OUT<=number3_IN_2;
END IF;
ELSE number1_OUT<="0000";number2_OUT<="0000";
END IF;
END PROCESS;
PROCESS(CLK_10) --3*2个数码管输出值赋值--
BEGIN
IF OP ='1'THEN
IF CONT = 1 THEN
number1_IN_1<=number1;number1_IN_2<=number2;
END IF;
ELSE number1_IN_1<="0000";number1_IN_2<="0000";
END IF;
END PROCESS;
PROCESS(CLK_10)
BEGIN
IF OP ='1'THEN
IF CONT = 2 THEN
number2_IN_1<=number3;number2_IN_2<=number4;
END IF;
ELSE number2_IN_1<="0000";number2_IN_2<="0000";
END IF;
END PROCESS;
PROCESS(CLK_10)
BEGIN
IF OP ='1'THEN
IF CONT = 3 THEN
number3_IN_1<=number5;number3_IN_2<=number6;
END IF;
ELSE number3_IN_1<="0000";number3_IN_2<="0000";
END IF;
END PROCESS;
p1: PROCESS(CLK)--三个分频器--
BEGIN
IF CLK'EVENT AND CLK = '1'THEN
IF TMP_3 = 12499999 THEN TMP_3 <= 0;
CLK_5 <= NOT CLK_5;
ELSE TMP_3 <= TMP_3 + 1;
END IF;
END IF;
END PROCESS p1;
p2:process(clk)
begin
if clk'event and clk='1'then
if tmp=24999 then
tmp<=0;clktmp<=not clktmp;
else
tmp<=tmp + 1;
end if;
else
null;
end if;
end process p2;
clk_out<=clktmp;
p3: PROCESS(CLK_10)
BEGIN
IF CLK_10'event and CLK_10 = '1' THEN
IF NUM_3 = 7 THEN
NUM_3 <= 0;
ELSE NUM_3 <= NUM_3 + 1;
END IF;
END IF;
END PROCESS p3;
PROCESS(CLK_10) --2个数码管的显示扫描--
BEGIN
IF CLK_10'event and CLK_10 = '1' THEN
IF NUM_4 = 1 THEN
NUM_4 <= 0;
ELSE NUM_4 <= NUM_4 + 1;
END IF;
END IF;
END PROCESS;
PROCESS(CLK)
BEGIN
IF CLK'EVENT AND CLK = '1'THEN
IF TMP_1 = 49999 THEN TMP_1 <= 0;
CLK_10 <= NOT CLK_10;
ELSE TMP_1 <= TMP_1 + 1;
END IF;
END IF;
END PROCESS;
p00:process(CLK_10)--4个button的消抖--
begin
if(CLK_10'event and CLK_10 = '0') then
resetmp10 <= resetmp9;
resetmp9 <= BTN0;
end if;
end process p00;
BTN0_I <= CLK_10 AND resetmp9 AND (NOT resetmp10);
p01: process(CLK_10)
begin
if(CLK_10'event and CLK_10 = '0') then
resetmp8 <= resetmp7;
resetmp7 <= BTN1;
end if;
end process p01;
BTN1_I <= CLK_10 AND resetmp7 AND (NOT resetmp8);
p02:process(CLK_10)
begin
if(CLK_10'event and CLK_10 = '0') then
resetmp6 <= resetmp5;
resetmp5 <= BTN2;
end if;
end process p02;
BTN2_I <= CLK_10 AND resetmp5 AND (NOT resetmp6);
p03:process(CLK_10)
begin
if(CLK_10'event and CLK_10 = '0') then
resetmp4 <= resetmp3;
resetmp3 <= BTN3;
end if;
end process p03;
BTN3_I <= CLK_10 AND resetmp3 AND (NOT resetmp4);
process(clk) --设定键button1--
begin
IF OP = '1'THEN
IF BTN1_I'EVENT AND BTN1_I='1'THEN
IF CONT= 3 THEN CONT<=0;
ELSE CONT<=CONT+1;
END IF;
END IF;
ELSIF OP = '0'THEN CONT<=0;
END IF;
END PROCESS;
-- button3 --
process(clk)
begin
if OC=1 and feeding_medicine='1' then
IF BTN3_I'EVENT AND BTN3_I='1'THEN
feeding_medicine0<='1';
END IF;
else
feeding_medicine0<='0';
end if;
end process;
PROCESS(clk) --工作时时间判断--
BEGIN
--IF OP ='1'THEN
IF COC = 1 THEN
CONT_1<=0;
ELSE
IF OC=0 THEN
CONT_1<=CONT;
ELSE
if OC=1 then
if number1_IN_1=comb_2 and number1_IN_2=comb_1 then
FMQ<=clk_10;
cont_1<=1;
position<=1;
feeding_medicine<='1';
elsif number2_IN_1=comb_2 and number2_IN_2=comb_1 then
FMQ<=clk_10;
cont_1<=2;
position<=2;
feeding_medicine<='1';
elsif number3_IN_1=comb_2 and number3_IN_2=comb_1 then
FMQ<=clk_10;
cont_1<=3;
position<=3;
feeding_medicine<='1';
-- else null;
else
--position<=position;
IF BTN3_I'EVENT AND BTN3_I='1'THEN
feeding_medicine<='0';
END IF;
if feeding_medicine='1' then
if position=1 then
cont_1<=1;
FMQ<=clk_10;
elsif position=2 then
cont_1<=2;
FMQ<=clk_10;
elsif position=3 then
cont_1<=3;
FMQ<=clk_10;
else cont_1<=0;
end if;
else
cont_1<=0;
end if;
end if;
ELSE NULL;
end if;
END IF;
END IF;
--ELSE CONT_1<=0;
--END IF;
end process;
process(clk)
begin
IF OP = '1'THEN
IF BTN2_I'EVENT AND BTN2_I='1'THEN
IF OC=1 THEN OC<=0;
ELSE OC<=OC+1;
END IF;
END IF;
ELSE OC<=0;
END IF;
end process;
PROCESS(CLK_10) --点阵闪烁--
BEGIN
IF OP = '1'THEN
CASE CONT_1 IS
WHEN 0 =>
CASE NUM_3 IS
WHEN 0 => ROW_OUT <= "01111111";RED_OUT <= "00000000";GRN_OUT<="00000000";
WHEN 1 => ROW_OUT <= "10111111";RED_OUT <= "00000000";GRN_OUT<="00000000";
WHEN 2 => ROW_OUT <= "11011111";RED_OUT <= "00000000";GRN_OUT<="00000000";
WHEN 3 => ROW_OUT <= "11101111";RED_OUT <= "11000011";GRN_OUT<="00011011";
WHEN 4 => ROW_OUT <= "11110111";RED_OUT <= "11000011";GRN_OUT<="00011011";
WHEN 5 => ROW_OUT <= "11111011";RED_OUT <= "00000000";GRN_OUT<="00000000";
WHEN 6 => ROW_OUT <= "11111101";RED_OUT <= "00000000";GRN_OUT<="00000000";
WHEN 7 => ROW_OUT <= "11111110";RED_OUT <= "00000000";GRN_OUT<="00000000";
END CASE;
WHEN 1 =>
IF CLK_5='1'THEN
CASE NUM_3 IS
WHEN 0 => ROW_OUT <= "01111111";RED_OUT <= "00000000";GRN_OUT<="00000000";
WHEN 1 => ROW_OUT <= "10111111";RED_OUT <= "00000000";GRN_OUT<="00000000";
WHEN 2 => ROW_OUT <= "11011111";RED_OUT <= "00000000";GRN_OUT<="00000000";
WHEN 3 => ROW_OUT <= "11101111";RED_OUT <= "11000011";GRN_OUT<="00011011";
WHEN 4 => ROW_OUT <= "11110111";RED_OUT <= "11000011";GRN_OUT<="00011011";
WHEN 5 => ROW_OUT <= "11111011";RED_OUT <= "00000000";GRN_OUT<="00000000";
WHEN 6 => ROW_OUT <= "11111101";RED_OUT <= "00000000";GRN_OUT<="00000000";
WHEN 7 => ROW_OUT <= "11111110";RED_OUT <= "00000000";GRN_OUT<="00000000";
END CASE;
ELSE
CASE NUM_3 IS
WHEN 0 => ROW_OUT <= "01111111";RED_OUT <= "00000000";GRN_OUT<="00000000";
WHEN 1 => ROW_OUT <= "10111111";RED_OUT <= "00000000";GRN_OUT<="00000000";
WHEN 2 => ROW_OUT <= "11011111";RED_OUT <= "00000000";GRN_OUT<="00000000";
WHEN 3 => ROW_OUT <= "11101111";RED_OUT <= "00000011";GRN_OUT<="00011011";
WHEN 4 => ROW_OUT <= "11110111";RED_OUT <= "00000011";GRN_OUT<="00011011";
WHEN 5 => ROW_OUT <= "11111011";RED_OUT <= "00000000";GRN_OUT<="00000000";
WHEN 6 => ROW_OUT <= "11111101";RED_OUT <= "00000000";GRN_OUT<="00000000";
WHEN 7 => ROW_OUT <= "11111110";RED_OUT <= "00000000";GRN_OUT<="00000000";
END CASE;
END IF;
WHEN 2 =>
IF CLK_5='1'THEN
CASE NUM_3 IS
WHEN 0 => ROW_OUT <= "01111111";RED_OUT <= "00000000";GRN_OUT<="00000000";
WHEN 1 => ROW_OUT <= "10111111";RED_OUT <= "00000000";GRN_OUT<="00000000";
WHEN 2 => ROW_OUT <= "11011111";RED_OUT <= "00000000";GRN_OUT<="00000000";
WHEN 3 => ROW_OUT <= "11101111";RED_OUT <= "11000011";GRN_OUT<="00011011";
WHEN 4 => ROW_OUT <= "11110111";RED_OUT <= "11000011";GRN_OUT<="00011011";
WHEN 5 => ROW_OUT <= "11111011";RED_OUT <= "00000000";GRN_OUT<="00000000";
WHEN 6 => ROW_OUT <= "11111101";RED_OUT <= "00000000";GRN_OUT<="00000000";
WHEN 7 => ROW_OUT <= "11111110";RED_OUT <= "00000000";GRN_OUT<="00000000";
END CASE;
ELSE
CASE NUM_3 IS
WHEN 0 => ROW_OUT <= "01111111";RED_OUT <= "00000000";GRN_OUT<="00000000";
WHEN 1 => ROW_OUT <= "10111111";RED_OUT <= "00000000";GRN_OUT<="00000000";
WHEN 2 => ROW_OUT <= "11011111";RED_OUT <= "00000000";GRN_OUT<="00000000";
WHEN 3 => ROW_OUT <= "11101111";RED_OUT <= "11000011";GRN_OUT<="00000011";
WHEN 4 => ROW_OUT <= "11110111";RED_OUT <= "11000011";GRN_OUT<="00000011";
WHEN 5 => ROW_OUT <= "11111011";RED_OUT <= "00000000";GRN_OUT<="00000000";
WHEN 6 => ROW_OUT <= "11111101";RED_OUT <= "00000000";GRN_OUT<="00000000";
WHEN 7 => ROW_OUT <= "11111110";RED_OUT <= "00000000";GRN_OUT<="00000000";
END CASE;
END IF;
WHEN 3 =>
IF CLK_5='1'THEN
CASE NUM_3 IS
WHEN 0 => ROW_OUT <= "01111111";RED_OUT <= "00000000";GRN_OUT<="00000000";
WHEN 1 => ROW_OUT <= "10111111";RED_OUT <= "00000000";GRN_OUT<="00000000";
WHEN 2 => ROW_OUT <= "11011111";RED_OUT <= "00000000";GRN_OUT<="00000000";
WHEN 3 => ROW_OUT <= "11101111";RED_OUT <= "11000011";GRN_OUT<="00011011";
WHEN 4 => ROW_OUT <= "11110111";RED_OUT <= "11000011";GRN_OUT<="00011011";
WHEN 5 => ROW_OUT <= "11111011";RED_OUT <= "00000000";GRN_OUT<="00000000";
WHEN 6 => ROW_OUT <= "11111101";RED_OUT <= "00000000";GRN_OUT<="00000000";
WHEN 7 => ROW_OUT <= "11111110";RED_OUT <= "00000000";GRN_OUT<="00000000";
END CASE;
ELSE
CASE NUM_3 IS
WHEN 0 => ROW_OUT <= "01111111";RED_OUT <= "00000000";GRN_OUT<="00000000";
WHEN 1 => ROW_OUT <= "10111111";RED_OUT <= "00000000";GRN_OUT<="00000000";
WHEN 2 => ROW_OUT <= "11011111";RED_OUT <= "00000000";GRN_OUT<="00000000";
WHEN 3 => ROW_OUT <= "11101111";RED_OUT <= "11000000";GRN_OUT<="00011000";
WHEN 4 => ROW_OUT <= "11110111";RED_OUT <= "11000000";GRN_OUT<="00011000";
WHEN 5 => ROW_OUT <= "11111011";RED_OUT <= "00000000";GRN_OUT<="00000000";
WHEN 6 => ROW_OUT <= "11111101";RED_OUT <= "00000000";GRN_OUT<="00000000";
WHEN 7 => ROW_OUT <= "11111110";RED_OUT <= "00000000";GRN_OUT<="00000000";
END CASE;
END IF;
END CASE;
ELSE ROW_OUT <= "11111111";RED_OUT <= "00000000";GRN_OUT<="00000000";
END IF;
END PROCESS;
process(clk_out) --键盘扫描--
begin
if (clk_out'event and clk_out='1')then
if scan="11" then scan<="00";
else scan<=scan+1;
end if;
else
null;
end if;
case scan(1 downto 0) is
when "00"=>col0<="0111";
when "01"=>col0<="1011";
when "10"=>col0<="1101";
when "11"=>col0<="1110";
end case;
end process;
btn_row<=col0;
process(clk_out,row0,col0) --小键盘输入和消抖--
begin
if (clk_out'event and clk_out='1')then
case col0 is
when "1110"=>
case row0 is
when "0111"=>
if deshake1=99 then deshake1<=99;
else
deshake1<=deshake1+1;
end if;
if deshake1>66 then number<="0001";deshake1<=0;change<=1;--1
else null;
end if;
when "1011"=>
if deshake1=99 then deshake1<=99;
else
deshake1<=deshake1+1;
end if;
if deshake1>66 then number<="0100";deshake1<=0;change<=1;--4
else null;
end if;
when "1101"=>
if deshake1=99 then deshake1<=99;
else
deshake1<=deshake1+1;
end if;
if deshake1>66 then number<="0111";deshake1<=0;change<=1;--7
else null;
end if;
when others=> null;
end case;
when "1101"=>
case row0 is
when "0111"=>
if deshake1=99 then deshake1<=99;
else
deshake1<=deshake1+1;
end if;
if deshake1>66 then number<="0010";deshake1<=0;change<=1;--2
else null;
end if;
when "1011"=>
if deshake1=99 then deshake1<=99;
else
deshake1<=deshake1+1;
end if;
if deshake1>66 then number<="0101";deshake1<=0;change<=1;--5
else null;
end if;
when "1101"=>
if deshake1=99 then deshake1<=99;
else
deshake1<=deshake1+1;
end if;
if deshake1>66 then number<="1000";deshake1<=0;change<=1;--8
else null;
end if;
when "1110"=>
if deshake1=99 then deshake1<=99;
else
deshake1<=deshake1+1;
end if;
if deshake1>66 then number<="0000";deshake1<=0;change<=1;--0
else null;
end if;
when others=> null;
end case;
when "1011"=>
case row0 is
when "0111"=>
if deshake1=99 then deshake1<=99;
else
deshake1<=deshake1+1;
end if;
if deshake1>66 then number<="0011";deshake1<=0;change<=1;--3
else null;
end if;
when "1011"=>
if deshake1=99 then deshake1<=99;
else
deshake1<=deshake1+1;
end if;
if deshake1>66 then number<="0110";deshake1<=0;change<=1;--6
else null;
end if;
when "1101"=>
if deshake1=99 then deshake1<=99;
else
deshake1<=deshake1+1;
end if;
if deshake1>66 then number<="1001";deshake1<=0;change<=1;--9
else null;
end if;
when others=> null;
end case;
when others=> null;
end case;
else null;
end if;
if cont=1 and oc=0 and op='1' and switch1='1' and change=1 then number1<=number;change<=0;
elsif cont=1 and oc=0 and op='1' and switch1='0' and change=1 then number2<=number;change<=0;
elsif cont=2 and oc=0 and op='1' and switch1='1' and change=1 then number3<=number;change<=0;
elsif cont=2 and oc=0 and op='1' and switch1='0' and change=1 then number4<=number;change<=0;
elsif cont=3 and oc=0 and op='1' and switch1='1' and change=1 then number5<=number;change<=0;
elsif cont=3 and oc=0 and op='1' and switch1='0' and change=1 then number6<=number;change<=0;
--elsif op = '0'then number1<="0000";number2<="0000";number3<="0000";number4<="0000";number5<="0000";number6<="0000";
end if;
IF OP = '0'THEN
number1<="0000";number2<="0000";number3<="0000";number4<="0000";number5<="0000";number6<="0000";
END IF;
end process;
process(CLK_10) --数码管显示--
begin
IF OP='1'THEN
IF CLK_10'EVENT AND CLK_10='1'THEN
case NUM_4 is
when 0 =>
case number1_OUT_O is
when "0000" =>disp_seg<="1111110";disp_cat<="11111101";--abcdefg
when "0001" =>disp_seg<="0110000";disp_cat<="11111101";
when "0010" =>disp_seg<="1101101";disp_cat<="11111101";
when "0011" =>disp_seg<="1111001";disp_cat<="11111101";
when "0100" =>disp_seg<="0110011";disp_cat<="11111101";
when "0101" =>disp_seg<="1011011";disp_cat<="11111101";
when "0110" =>disp_seg<="1011111";disp_cat<="11111101";
when "0111" =>disp_seg<="1110000";disp_cat<="11111101";
when "1000" =>disp_seg<="1111111";disp_cat<="11111101";
when "1001" =>disp_seg<="1111011";disp_cat<="11111101";
when others=>disp_seg<="0000000";disp_cat<="11111111";
end case;
when 1 =>
case number2_OUT_O is
when "0000" =>disp_seg<="1111110";disp_cat<="11111110";--abcdefg
when "0001" =>disp_seg<="0110000";disp_cat<="11111110";
when "0010" =>disp_seg<="1101101";disp_cat<="11111110";
when "0011" =>disp_seg<="1111001";disp_cat<="11111110";
when "0100" =>disp_seg<="0110011";disp_cat<="11111110";
when "0101" =>disp_seg<="1011011";disp_cat<="11111110";
when "0110" =>disp_seg<="1011111";disp_cat<="11111110";
when "0111" =>disp_seg<="1110000";disp_cat<="11111110";
when "1000" =>disp_seg<="1111111";disp_cat<="11111110";
when "1001" =>disp_seg<="1111011";disp_cat<="11111110";
when others=>disp_seg<="0000000";disp_cat<="11111111";--debug
end case;
when others=>disp_seg<="0000000";disp_cat<="11111111";
end case;
END IF;
ELSE disp_seg<="0000000";disp_cat<="11111111";
END IF;
end process;
PROCESS(CLK_60) --60秒计时分频--
BEGIN
IF OP = '1'THEN
IF OC=1 THEN
IF CLK_60'event and CLK_60 = '1' THEN
IF NUM_2 = 59 THEN
NUM_2 <= 0;
ELSE NUM_2 <= NUM_2 + 1;
END IF;
END IF;
ELSIF OC=0 THEN NUM_2<=0;
END IF;
ELSE NUM_2<=0;
END IF;
END PROCESS;
PROCESS(CLK_60,NUM_2) --60秒计时显示转换--
BEGIN
IF CLK_60'EVENT AND CLK_60 = '1'THEN
CASE NUM_2 IS
WHEN 0=> COMB_1 <= "0000";COMB_2 <= "0000";
WHEN 1=> COMB_1 <= "0001";COMB_2 <= "0000";
WHEN 2=> COMB_1 <= "0010";COMB_2 <= "0000";
WHEN 3=> COMB_1 <= "0011";COMB_2 <= "0000";
WHEN 4=> COMB_1 <= "0100";COMB_2 <= "0000";
WHEN 5=> COMB_1 <= "0101";COMB_2 <= "0000";
WHEN 6=> COMB_1 <= "0110";COMB_2 <= "0000";
WHEN 7=> COMB_1 <= "0111";COMB_2 <= "0000";
WHEN 8=> COMB_1 <= "1000";COMB_2 <= "0000";
WHEN 9=> COMB_1 <= "1001";COMB_2 <= "0000";
WHEN 10=> COMB_1 <= "0000";COMB_2 <= "0001";
WHEN 11=> COMB_1 <= "0001";COMB_2 <= "0001";
WHEN 12=> COMB_1 <= "0010";COMB_2 <= "0001";
WHEN 13=> COMB_1 <= "0011";COMB_2 <= "0001";
WHEN 14=> COMB_1 <= "0100";COMB_2 <= "0001";
WHEN 15=> COMB_1 <= "0101";COMB_2 <= "0001";
WHEN 16=> COMB_1 <= "0110";COMB_2 <= "0001";
WHEN 17=> COMB_1 <= "0111";COMB_2 <= "0001";
WHEN 18=> COMB_1 <= "1000";COMB_2 <= "0001";
WHEN 19=> COMB_1 <= "1001";COMB_2 <= "0001";
WHEN 20=> COMB_1 <= "0000";COMB_2 <= "0010";
WHEN 21=> COMB_1 <= "0001";COMB_2 <= "0010";
WHEN 22=> COMB_1 <= "0010";COMB_2 <= "0010";
WHEN 23=> COMB_1 <= "0011";COMB_2 <= "0010";
WHEN 24=> COMB_1 <= "0100";COMB_2 <= "0010";
WHEN 25=> COMB_1 <= "0101";COMB_2 <= "0010";
WHEN 26=> COMB_1 <= "0110";COMB_2 <= "0010";
WHEN 27=> COMB_1 <= "0111";COMB_2 <= "0010";
WHEN 28=> COMB_1 <= "1000";COMB_2 <= "0010";
WHEN 29=> COMB_1 <= "1001";COMB_2 <= "0010";
WHEN 30=> COMB_1 <= "0000";COMB_2 <= "0011";
WHEN 31=> COMB_1 <= "0001";COMB_2 <= "0011";
WHEN 32=> COMB_1 <= "0010";COMB_2 <= "0011";
WHEN 33=> COMB_1 <= "0011";COMB_2 <= "0011";
WHEN 34=> COMB_1 <= "0100";COMB_2 <= "0011";
WHEN 35=> COMB_1 <= "0101";COMB_2 <= "0011";
WHEN 36=> COMB_1 <= "0110";COMB_2 <= "0011";
WHEN 37=> COMB_1 <= "0111";COMB_2 <= "0011";
WHEN 38=> COMB_1 <= "1000";COMB_2 <= "0011";
WHEN 39=> COMB_1 <= "1001";COMB_2 <= "0011";
WHEN 40=> COMB_1 <= "0000";COMB_2 <= "0100";
WHEN 41=> COMB_1 <= "0001";COMB_2 <= "0100";
WHEN 42=> COMB_1 <= "0010";COMB_2 <= "0100";
WHEN 43=> COMB_1 <= "0011";COMB_2 <= "0100";
WHEN 44=> COMB_1 <= "0100";COMB_2 <= "0100";
WHEN 45=> COMB_1 <= "0101";COMB_2 <= "0100";
WHEN 46=> COMB_1 <= "0110";COMB_2 <= "0100";
WHEN 47=> COMB_1 <= "0111";COMB_2 <= "0100";
WHEN 48=> COMB_1 <= "1000";COMB_2 <= "0100";
WHEN 49=> COMB_1 <= "1001";COMB_2 <= "0100";
WHEN 50=> COMB_1 <= "0000";COMB_2 <= "0101";
WHEN 51=> COMB_1 <= "0001";COMB_2 <= "0101";
WHEN 52=> COMB_1 <= "0010";COMB_2 <= "0101";
WHEN 53=> COMB_1 <= "0011";COMB_2 <= "0101";
WHEN 54=> COMB_1 <= "0100";COMB_2 <= "0101";
WHEN 55=> COMB_1 <= "0101";COMB_2 <= "0101";
WHEN 56=> COMB_1 <= "0110";COMB_2 <= "0101";
WHEN 57=> COMB_1 <= "0111";COMB_2 <= "0101";
WHEN 58=> COMB_1 <= "1000";COMB_2 <= "0101";
WHEN 59=> COMB_1 <= "1001";COMB_2 <= "0101";
END CASE;
END IF;
END PROCESS;
END;
三、其他操作
在写入代码以后还需要进行引脚分配以及烧录等操作,这些就不必赘述了,大家一定可以自行完成的啦。
四、总结
最后,谢谢大家的阅读与支持了啦,谢谢大家的支持。