1、1实验二十四 多功能数字钟的设计钟太绵(2012213696)一、设计框图如下:二、程序代码如下LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL; USE IEEE.STD_LOGIC_UNSIGNED.ALL;USE IEEE.std_logic_arith.all;entity CLOCK28 is port( Clk : in std_logic; -时钟输入 1KHZRst : in std_logic; -复位输入 S1,S2 : in std_logic; - SPK : out std_logic; - LED: out std_logic_VEC
2、TOR(3 DOWNTO 0); DISPLAY : out std_logic_vector(6 downto 0); SEG_SEL : OUT std_logic_vector(2 downto 0) ); end CLOCK28; architecture behave of CLOCK28 is TYPE STATES IS(T0,T1,T2,T3);SIGNAL CT,NT:STATES;SIGNAL CLK1HZ,CLK5HZ:STD_LOGIC;SIGNAL QM,QS:INTEGER RANGE 59 DOWNTO 0;SIGNAL QH:INTEGER RANGE 23 D
3、OWNTO 0;SIGNAL DE:INTEGER RANGE 7 DOWNTO 0;SIGNAL M0,M1,M3,M4,M6,M7,MT,MD:std_logic_vector(3 downto 0); -VARIABLE M0,M1:STD_LOGIC_VECTOR(3 DOWNTO 0 );SIGNAL FULL,FULL2:STD_LOGIC;SIGNAL BEE,FG:STD_LOGIC;BEGINPROCESS(CLK,FULL)VARIABLE CNT:integer range 4999 downto 0;-10kHZ CHANGE TO 1HZVARIABLE CNT1:S
4、TD_LOGIC;BEGINIF CLKEVENT AND CLK=1 THENIF CNT=4999 THENCNT:=0;FULLNTIF(QS=50 and QM=59)THEN NTIF(QS=55 and QM=59)THEN NTIF(QS=0 and QM=0)THEN NTNT59) THEN- OR S2=0 OR S1=0;S:=S REM 60;M:=M+1;END IF;IF(M59) THENM:=M REM 60;H:=H+1;END IF;IF(H23)THENH:=H REM 24;4END IF;END IF;IF CLK5HZEVENT AND CLK5HZ=1 THENIF(S2=0) THENF2:=1;ELSEF2:=0;END IF;IF(S1=0) THENF1:=1;ELSEF1:=0;END IF;END IF;QSSPKSPKSPKSPKSPKMDMDMDMDMDMDMDMDMDDisplayDisplayDisplayDisplayDisplayDisplayDisplayDisplayDisplayDisplayDisplayNULL;END CASE;END PROCESS;END BEHAVE;三、modelsim 波形仿真如图