daily pastebin goal
41%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 38 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use ieee.std_logic_unsigned.all;
  4.  
  5. entity pamiec is
  6.     port(
  7.         key : in std_logic;
  8.         clk : in std_logic;
  9.         sw  :in std_logic_vector (7 downto 0);
  10.         wr: in std_logic;
  11.         HEX0 : out std_logic_vector(0 to 6);
  12.         HEX1: out std_logic_vector(0 to 6)
  13.         );
  14. end pamiec;
  15.  
  16.  
  17. architecture rtl of pamiec is
  18. component RAM
  19.     port(
  20.         address : in std_logic_vector (4 downto 0);
  21.         clock : in std_logic := '1';
  22.         data : in std_logic_vector (7 downto 0);
  23.         wren : in std_logic;
  24.         q : out std_logic_vector (7 downto 0)
  25.         );
  26. end component;
  27.  
  28. component hex7seg
  29.     port(
  30.         hex : in std_logic_vector(3 downo 0);
  31.         display : out std_logic_vector(0 to 6)
  32.         );
  33. end component;
  34.  
  35. signal currentCount : std_logic_vector (4 downto 0);
  36. signal output : std_logic_vector (7 downto 0);
  37. alias bit3_0 : std_logic_vector (3 downto 0) is output(3 downto 0);
  38. alias bit7_4 : std_logic_vector (3 downto 0) is output(7 downto 4);
  39.  
  40. signal HEXTMP0 : std_logic_vector(0 to 6);
  41. signal HEXTMP1 : std_logic_vector(0 to 6);
  42.  
  43. begin
  44.  
  45.     MEM : RAM port map (address=>currentCount, clock=>clk, data=>sw, wren=>wr, q=>output);
  46.     SEG0 : hex7seg port map (hex=>bit3_0, display=>HEXTMP0);
  47.     SEG1 : hex7seg port map (hex=>bit7_4, display=>HEXTMP1);
  48.    
  49.     process(key)
  50.     begin
  51.         if(key = '0' and key'event) then
  52.             if(currentCount = "11111") then
  53.             currentCount <= "00000";
  54.             else
  55.             currentCount <= currentCount + '1';
  56.             end if;
  57.         end if;
  58.     end process;
  59.    
  60.     process(output)
  61.     begin
  62.     HEX0 <= HEXTMP0;
  63.     HEX1 <= HEXTMP1;
  64.     end process;
  65.    
  66. end rtl;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top