基于vhdl语言的简易电子钟课程设计说明书内容摘要:
( 3)数据锁存器: library IEEE。 use。 18 Unment the following library declaration if using arithmetic functions with Signed or Unsigned values use。 Unment the following library declaration if instantiating any Xilinx primitives in this code. library UNISIM。 use。 entity latch is Port ( t_0 : in STD_LOGIC_VECTOR (3 downto 0)。 t_1 : in STD_LOGIC_VECTOR (3 downto 0)。 t_2 : in STD_LOGIC_VECTOR (3 downto 0)。 t_3 : in STD_LOGIC_VECTOR (3 downto 0)。 t_4 : in STD_LOGIC_VECTOR (3 downto 0)。 t_5 : in STD_LOGIC_VECTOR (3 downto 0)。 display_in : in STD_LOGIC。 t0 : out STD_LOGIC_VECTOR (3 downto 0)。 t1 : out STD_LOGIC_VECTOR (3 downto 0)。 t2 : out STD_LOGIC_VECTOR (3 downto 0)。 t3 : out STD_LOGIC_VECTOR (3 downto 0)。 t4 : out STD_LOGIC_VECTOR (3 downto 0)。 t5 : out STD_LOGIC_VECTOR (3 downto 0))。 end latch。 architecture Behavioral of latch is begin process(t_0,t_1,t_2,t_3,t_4,t_5,display_in) begin if display_in=39。 139。 then t0=t_0。 t1=t_1。 t2=t_2。 t3=t_3。 t4=t_4。 t5=t_5。 end if。 end process。 end Behavioral。 ( 4)显示译码模块: 19 library IEEE。 use。 use。 Unment the following library declaration if using arithmetic functions with Signed or Unsigned values use。 Unment the following library declaration if instantiating any Xilinx primitives in this code. library UNISIM。 use。 entity display is Port ( clk_1k : in STD_LOGIC。 t0 : in STD_LOGIC_VECTOR (3 downto 0)。 t1 : in STD_LOGIC_VECTOR (3 downto 0)。 t2 : in STD_LOGIC_VECTOR (3 downto 0)。 t3 : in STD_LOGIC_VECTOR (3 downto 0)。 t4 : in STD_LOGIC_VECTOR (3 downto 0)。 t5 : in STD_LOGIC_VECTOR (3 downto 0)。 dig_out : out STD_LOGIC_VECTOR (7 downto 0)。 seg_out : out STD_LOGIC_VECTOR (6 downto 0)。 dig_in : out std_logic_vector (2 downto 0) )。 end display。 architecture Behavioral of display is signal bcd: std_logic_vector(3 downto 0):=1000。 signal seg: std_logic_vector(6 downto 0):=1111110。 signal dig: std_logic_vector(2 downto 0):=000。 begin process(clk_1k) begin if clk_1k39。 event and clk_1k=39。 139。 then if dig=7 then dig=000。 else dig=dig+1。 end if。 end if。 20 end process。 process(dig) begin case dig is when 000=dig_out=11111110。 when 001=dig_out=11111101。 when 010=dig_out=11111011。 when 011=dig_out=11110111。 when 100=dig_out=11101111。 when 101=dig_out=11011111。 when 110=dig_out=10111111。 when others=dig_out=01111111。 end case。 end process。 process(dig) begin case dig is when 000=bcd=t0。 when 001=bcd=t1。 when 010=bcd=1010。 when 011=bcd=t2。 when 100=bcd=t3。 when 101=bcd=1010。 when 110=bcd=t4。 when 111=bcd=t5。 when others=bcd=1010。 end case。 end process。 process(bcd) begin case bcd is when 0000=seg=0000001。 when 0001=seg=1001111。 when 0010=seg=0010010。 when 0011=seg=0000110。 when 0100=seg=1001100。 when 0101=seg=0100100。 when 0110=seg=0100000。 when 0111=seg=0001111。 when 1000=seg=0000000。 when 1001=seg=0000100。 21 when others=seg=1111110。 end case。 end process。 seg_out=seg。 end Behavioral。 ( 5) 控制模块: library IEEE。 use。 use。 Unment the following library declaration if using arithmetic functions with Signed or Unsigned values use。 Unment the following library declaration if instantiating any Xilinx primitives in this code. library UNISIM。 use。 entity control is Port ( clk : in STD_LOGIC。 p : in STD_LOGIC。 q : in STD_LOGIC。 clr : out STD_LOGIC。 enc : out STD_LOGIC。 enl : out STD_LOGIC)。 end control。 architecture Behavioral of control is signal state:std_logic_vector(1 downto 0):=00。 signal n_state:std_logic_vector(1 downto 0):=00。 signal key:std_logic_vector(1 downto 0)。 begin key=p amp。 q。 process(state,key) begin case state is when 00= if key=10 then 22 n_state=01。 else n_state=state。 end if。 when 01= case key is when 10=n_state=11。 when 01=n_state=10。 when others=n_state=state。 end case。 when 10= if key=01 then n_state=01。 else n_state=state。 end if。 when others= case key is when 10=n_state=01。 when 01=n_state=00。 when others=n_state=state。 end case。 end case。 end process。 process(clk) begin if falling_edge(clk) then state=n_state。 end if。 end process。 process(state) begin case state is when 00= clr=39。 139。 enc=39。 139。 enl=39。 139。 when 01= clr=39。 039。 enc=39。 139。 enl=39。 139。 when 10= clr=39。 039。 enc=39。 139。 enl=39。 039。 when others= clr=39。 039。 enc=39。 039。 enl=39。 139。 23 end case。 end process。 end Behavioral。 ( 6)按键消抖模块: 消抖 : library IEEE。 use。 use。 Unment the following library declaration if using arithmetic functions with Signed or Unsigned values use。 Unment the following library declaration if instantiating any Xilinx primitives in this code. library UNISIM。 use。 entity xiaodou is Port ( clk : in STD_LOGIC。 key_in : in STD_LOGIC。 key_out : out STD_LOGIC)。 end xiaodou。 architecture Behavioral of xiaodou is signal k1,k2: STD_LOGIC。 signal t : STD_LOGIC_VECTOR (1 downto 0)。 begin process(clk,key_in) begin if clk39。 event and clk =39。 039。 then if t =3 then k1=39。 139。 else k1=39。 039。 t=t+1。 end if。 k2=k1。 end if。 if key_in =39。 039。 then t =00。 24 end if。 end process。 key_out = not k1 and k2。 end Behavioral。 开关消抖组合: libr。基于vhdl语言的简易电子钟课程设计说明书
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。
用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。