Advertisement
Guest User

Untitled

a guest
Nov 4th, 2018
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.25 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3. USE ieee.std_logic_arith.all;
  4. entity lab81 is
  5.     Port (clk : in std_logic;
  6.         srst : in std_logic;
  7.         dout : out std_logic_vector(7 downto 0));
  8. end lab81;
  9.  
  10. architecture Behavioral of lab81 is
  11. type ROM is array( 0 to 15) of std_logic_vector(7 downto 0);
  12. signal cnts : ROM :=
  13.     ( 0 => "00000000",
  14.     1 => "00110000",
  15.     2 => "01011001",
  16.     3 => "01110101",
  17.     4 => "01111111",
  18.     5 => "01110101",
  19.     6 => "01011001",
  20.     7 => "00110000",
  21.     8 => "00000000",
  22.     9 => "11001111",
  23.     10 => "10100110",
  24.     11 => "10001010",
  25.     12 => "10000001",
  26.     13 => "10001010",
  27.     14 => "10100110",
  28.     15 => "11001111");
  29. signal cntr : std_logic_vector(26 downto 0):=(others => '0');
  30. signal s_dout : std_logic_vector(7 downto 0);
  31. signal add : std_logic_vector(3 downto 0):=(others => '0');
  32.  
  33. begin
  34. addres_proc : process(clk) begin
  35.     if rising_edge(clk) then
  36.         if srst = '1' then
  37.             add <= (others => '0');
  38.         else
  39.             add <= unsigned(add) + 1;
  40.         end if;
  41.     end if;
  42. end process;
  43. gen_sin : process(clk) begin
  44.     if rising_edge(clk) then
  45.         s_dout <= cnts(conv_integer(unsigned(add)));
  46.     end if;
  47. end process;
  48. dout <= s_dout;
  49. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement