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

📄 p_disp4.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
--
-- P_disp4.vhd
-- Package containing procedure that visualises all 4
-- seven segment display digits, used for the 4 digit 
-- display driver.
--------------------------------------------------------------- 

Library IEEE;
use IEEE.Std_Logic_1164.all; 

package P_DISP4 is
   procedure DISP4(signal DISPLAY_MS_HR, DISPLAY_LS_HR,
		       DISPLAY_MS_MIN, DISPLAY_LS_MIN : std_logic_vector(6 downto 0));
end P_DISP4;


use std.textio.all;
package body P_DISP4 is

----------------------------------------------------------------
-- This is the procedure that outputs a seven segment display
-- to a text file.
--
-- Display (6 downto 0) looks like this:
--
--             111111111122222222223333333333
--   0123456789012345678901234567890123456789
--  1   #0##     ####     ####     ####
--  2  #    #   #    #   #    #   #    #
--  3  5    1   #    #   #    #   #    #
--  4  #    #   #    #   #    #   #    #
--  5  #    #   #    #   #    #   #    #
--  6   #6##     ####     ####     ####
--  7  #    #   #    #   #    #   #    #
--  8  4    2   #    #   #    #   #    #
--  9  #    #   #    #   #    #   #    #
-- 10  #    #   #    #   #    #   #    #
-- 11   #3##     ####     ####     ####
--
--     <-- 9 -->
----------------------------------------------------------------


procedure DISP4(signal DISPLAY_MS_HR, DISPLAY_LS_HR,
		       DISPLAY_MS_MIN, DISPLAY_LS_MIN: 
                       std_logic_vector(6 downto 0)) is
   file OUTFILE : text is out "clock.txt";
   variable L : line;
   constant SEG_CHAR : character := '#';
   constant SEG : string(4 downto 1) := (others => SEG_CHAR);
   type T_DIGIT_ARRAY is array (1 to 11) of string (1 to 36);
   -- DIGIT ARRAY (Y)(X)
   variable DIGIT_ARRAY : T_DIGIT_ARRAY := (others=>(others=> ' '));
   type T_CLOCK_TIME is array (3 downto 0) of std_logic_vector (6 downto 0);
   variable DISPLAY: T_CLOCK_TIME:= (DISPLAY_MS_HR, DISPLAY_LS_HR,
		       		     DISPLAY_MS_MIN, DISPLAY_LS_MIN);
   variable XOFF : integer;
begin

   DIGIT_ARRAY := (others=>(others=> ' '));


   for I in DISPLAY'low to DISPLAY'high loop -- this should be 4!

      XOFF := (DISPLAY'high - I - DISPLAY'low) * 9;

      -- Bit 0 
      if DISPLAY(I)(DISPLAY(I)'LOW + 0) = '1' then
         DIGIT_ARRAY(1)(XOFF+3 to XOFF+6) := SEG;
      end if;
   

      -- Bit 1 
      if DISPLAY(I)(DISPLAY(I)'LOW + 1) = '1' then
         -- DIGIT_ARRAY(2 to 5)(7):= SEG;
         DIGIT_ARRAY(2)(XOFF+7):= SEG_CHAR;
         DIGIT_ARRAY(3)(XOFF+7):= SEG_CHAR;
         DIGIT_ARRAY(4)(XOFF+7):= SEG_CHAR;
         DIGIT_ARRAY(5)(XOFF+7):= SEG_CHAR;
      end if;
   
      -- Bit 2 
      if DISPLAY(I)(DISPLAY(I)'LOW + 2) = '1' then
         -- DIGIT_ARRAY(7 to 10)(7) := SEG;
         DIGIT_ARRAY(7)(XOFF+7) := SEG_CHAR;
         DIGIT_ARRAY(8)(XOFF+7) := SEG_CHAR;
         DIGIT_ARRAY(9)(XOFF+7) := SEG_CHAR;
         DIGIT_ARRAY(10)(XOFF+7) := SEG_CHAR;
      end if;
   
      -- Bit 3 
      if DISPLAY(I)(DISPLAY(I)'LOW + 3) = '1' then
         DIGIT_ARRAY(11)(XOFF+3 to XOFF+6) := SEG;
      end if;
   
      -- Bit 4 
      if DISPLAY(I)(DISPLAY(I)'LOW + 4) = '1' then
         -- DIGIT_ARRAY(7 to 10)(2) := SEG;
         DIGIT_ARRAY(7)(XOFF+2) := SEG_CHAR;
         DIGIT_ARRAY(8)(XOFF+2) := SEG_CHAR;
         DIGIT_ARRAY(9)(XOFF+2) := SEG_CHAR;
         DIGIT_ARRAY(10)(XOFF+2) := SEG_CHAR;
      end if;
   
      -- Bit 5 
      if DISPLAY(I)(DISPLAY(I)'LOW + 5) = '1' then
         -- DIGIT_ARRAY(2 to 5)(2):= SEG;
         DIGIT_ARRAY(2)(XOFF+2):= SEG_CHAR;
         DIGIT_ARRAY(3)(XOFF+2):= SEG_CHAR;
         DIGIT_ARRAY(4)(XOFF+2):= SEG_CHAR;
         DIGIT_ARRAY(5)(XOFF+2):= SEG_CHAR;
      end if;
   
-- Bit 6 
      if DISPLAY(I)(DISPLAY(I)'LOW + 6) = '1' then
         DIGIT_ARRAY(6)(XOFF+3 to XOFF+6) := SEG;
      end if;

   end loop;
   
      -- now write it out to the file...
  for I in DIGIT_ARRAY'range loop
     write(L, DIGIT_ARRAY(I));
     writeline(OUTFILE, L);
  end loop; 
   
end DISP4;
   
end P_DISP4;

⌨️ 快捷键说明

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