Advertisement
Guest User

Untitled

a guest
Nov 6th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 3.45 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:     University of Alberta
  3. -- Engineer:    Raza Bhatti
  4. --
  5. -- Create Date: 05/18/2018 09:43:23 AM
  6. -- Design Name:
  7. -- Module Name: SevenSegments - Behavioral
  8. -- Project Name:
  9. -- Target Devices:
  10. -- Tool Versions:
  11. -- Description:
  12. --
  13. -- Dependencies:
  14. --
  15. -- Revision:
  16. -- Revision 0.01 - File Created
  17. -- Additional Comments:
  18. --
  19. ----------------------------------------------------------------------------------
  20.  
  21.  
  22. library IEEE;
  23. use IEEE.STD_LOGIC_1164.ALL;
  24. use IEEE.STD_LOGIC_UNSIGNED.ALL;
  25. use IEEE.NUMERIC_STD.ALL;
  26.  
  27. -- Uncomment the following library declaration if using
  28. -- arithmetic functions with Signed or Unsigned values
  29. --use IEEE.NUMERIC_STD.ALL;
  30.  
  31. -- Uncomment the following library declaration if instantiating
  32. -- any Xilinx leaf cells in this code.
  33. --library UNISIM;
  34. --use UNISIM.VComponents.all;
  35.  
  36. entity SevenSegments is
  37.     Port (
  38.             clk:        in STD_LOGIC;
  39.             CC :        out STD_LOGIC;      --Common cathode input to select respective 7-segment digit.
  40.             out_7seg :  out STD_LOGIC_VECTOR (6 downto 0));
  41. end SevenSegments;
  42.  
  43. architecture Behavioral of SevenSegments is
  44.  
  45. signal count: std_logic_vector(63 downto 0);
  46. signal clk_out: std_logic:='0';
  47. signal seg_select: std_logic:='0';
  48. signal SevenSeg_Count: std_logic_vector(3 downto 0):="0000";
  49. signal count1: std_logic_vector(63 downto 0);
  50. signal mycc: std_logic:= '0';
  51. begin
  52.     CLK_OneHz: process(clk)
  53.     begin
  54.         if rising_edge(clk) then
  55.             if (count1 < 1000) then
  56.                 count1 <= count1 + 1;
  57.             else
  58.                 count1<=(others=>'0');
  59.                 mycc <= (not mycc);
  60.                 CC <= mycc;
  61.             end if;
  62.            
  63.             if(count<125000000) then
  64.                 count<=count+'1';
  65.             else
  66.                 count<=(others=>'0');
  67.                 clk_out<=not clk_out;
  68.                 SevenSeg_Count<=SevenSeg_Count+'1';
  69.             end if;
  70.         end if;
  71.     end process;
  72.  
  73.    
  74. Decoder_4to7Segment: process (clk_out)
  75.    
  76.         begin
  77.             --Write your design lines here. Hint: use Case statement.
  78.              case SevenSeg_Count is
  79.                 when "0000" =>
  80.                 out_7seg <= "0111111";
  81.                 when "0001" =>
  82.                 out_7seg <= "0000110";
  83.                 when "0010" =>
  84.                 out_7seg <= "1011011";
  85.                 when "0011" =>
  86.                 out_7seg <= "1001111";
  87.                 when "0100" =>
  88.                 out_7seg <= "1100110";
  89.                 when "0101" =>
  90.                 out_7seg <= "1101101";
  91.                 when "0110" =>
  92.                 out_7seg <= "1111101";
  93.                 when "0111" =>
  94.                 out_7seg <= "0000111";
  95.                 when "1000" =>
  96.                 out_7seg <= "1111111";
  97.                 when "1001" =>
  98.                 out_7seg <= "1101111";
  99.                 when "1010" =>
  100.                 out_7seg <= "1101111";
  101.                 when "1011" =>
  102.                 out_7seg <= "1111100";
  103.                 when "1100" =>
  104.                 out_7seg <= "0111001";
  105.                 when "1101" =>
  106.                 out_7seg <= "1011110";
  107.                 when "1110" =>
  108.                 out_7seg <= "1111001";
  109.                 when "1111" =>
  110.                 out_7seg <= "1110001";
  111.              end case;
  112.  
  113.         end process;
  114.        
  115.        
  116.        
  117.  
  118. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement