Advertisement
Guest User

Untitled

a guest
Jan 25th, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 0.74 KB | None | 0 0
  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use ieee.numeric_std.all;
  4.  
  5. entity part2 is
  6.  PORT( clk, rd, we: in std_logic;
  7.         addr: in std_logic_vector(1 downto 0);
  8.         data_in: in std_logic_vector(7 downto 0);
  9.         data_out: out std_logic_vector(7 downto 0));
  10.  end;
  11.  
  12. Architecture arch of part2 is
  13. Type my_array is array (0 to 3) of std_logic_vector(7 downto 0);
  14. signal ram: my_array;
  15. signal rw: std_logic_vector(1 downto 0);
  16. Begin
  17. rw<= rd & we;
  18.  
  19.     Process(clk)
  20.         Begin
  21.             if (clk 'event and clk ='1') then
  22.             case rw is
  23.             when "01" => ram(to_integer(unsigned(addr))) <= data_in;
  24.             when "10" => data_out <= ram (to_integer (unsigned (addr)));
  25.             when others => data_out <= "ZZZZZZZZ";
  26.             end case;
  27.             end if;
  28.             end process;
  29.             end arch;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement