⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ddrv.vhd

📁 Workshop vhdl code from Esperan
💻 VHD
字号:
-----------------------------------------------------------------------
-- 
-- Original Code Copyright (c) 1999 by Esperan. All rights reserved.
-- www.esperan.com
-- 
-- This source file may be used and distributed without restriction
-- provided that this copyright statement is not removed from the file
-- and that any derivative work contains this copyright notice. 
--
-- Esperan VHDL Alarm Clock Lab Exercise Design V5.0
--
-- Ddrv.vhd
-- Bit based display driver 
--
--------------------------------------------------------------- 

Library IEEE;
use IEEE.Std_Logic_1164.all; 

entity DDRV is
port ( ALARM_TIME, CURRENT_TIME  : in std_logic_vector (3 downto 0);
       SHOW_A                    : in std_logic;
       SOUND_ALARM               : out std_logic;
       DISPLAY                   : out std_logic_vector (6 downto 0)
     );
end DDRV;  

architecture RTL of DDRV is
   
-- constants for the segments to light for each digit 0 to 9
   constant ZERO_SEG  : std_logic_vector(6 downto 0):= "0111111";
   constant ONE_SEG   : std_logic_vector(6 downto 0):= "0000110";
   constant TWO_SEG   : std_logic_vector(6 downto 0):= "1011011";
   constant THREE_SEG : std_logic_vector(6 downto 0):= "1001111";
   constant FOUR_SEG  : std_logic_vector(6 downto 0):= "1100110";
   constant FIVE_SEG  : std_logic_vector(6 downto 0):= "1101101";
   constant SIX_SEG   : std_logic_vector(6 downto 0):= "1111101";
   constant SEVEN_SEG : std_logic_vector(6 downto 0):= "0000111";
   constant EIGHT_SEG : std_logic_vector(6 downto 0):= "1111111";
   constant NINE_SEG  : std_logic_vector(6 downto 0):= "1101111";
   constant ERROR_SEG : std_logic_vector(6 downto 0):= "1111100"; 
   
   signal DISPLAY_TIME : std_logic_vector (3 downto 0);

begin

-------------------------------------------
-- process to multiplex DISPLAY_TIME and 
-- to sound the alarm
-------------------------------------------  

  MUX_ALARM: process (ALARM_TIME, CURRENT_TIME, SHOW_A)
  begin
    if (SHOW_A = '1') then
      DISPLAY_TIME <= ALARM_TIME;
    else
      DISPLAY_TIME <= CURRENT_TIME;
    end if;

    if (ALARM_TIME = CURRENT_TIME) then
       SOUND_ALARM <= '1';
    else
       SOUND_ALARM <= '0';
    end if;

  end process MUX_ALARM;

-------------------------------------------
-- process to drive the 7 segment display
-------------------------------------------
   BCDTO7SEG :
   process (DISPLAY_TIME)
   begin
      case DISPLAY_TIME is
          when "0000" =>   
            DISPLAY <= ZERO_SEG;
          when "0001" =>   
            DISPLAY <= ONE_SEG;
          when "0010" =>   
            DISPLAY <= TWO_SEG;
          when "0011" =>   
            DISPLAY <= THREE_SEG;
          when "0100" =>   
            DISPLAY <= FOUR_SEG;
          when "0101" =>   
            DISPLAY <= FIVE_SEG;
          when "0110" =>   
            DISPLAY <= SIX_SEG;
          when "0111" =>   
            DISPLAY <= SEVEN_SEG;
          when "1000" =>   
            DISPLAY <= EIGHT_SEG;
          when "1001" =>   
            DISPLAY <= NINE_SEG;
          when others =>   
            DISPLAY <= ERROR_SEG;
      end case;
   end process BCDTO7SEG;

end RTL ;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -