Advertisement
Guest User

Untitled

a guest
Nov 5th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 0.94 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3. use ieee.std_logic_arith.all;
  4. use ieee.std_logic_unsigned.all;
  5.  
  6. entity lr4 is
  7.     generic(aw:positive:=8; dw:positive:=128);   -- 2^8=256, 256x128
  8.     Port(
  9.         clk ,we ,en : in std_logic;
  10.         addr : in std_logic_vector(aw-1 downto 0);
  11.         di : in std_logic_vector(dw-1 downto 0);
  12.         do : out std_logic_vector(dw-1 downto 0)
  13.     );
  14. end lr4;
  15.  
  16. architecture Behavioral of lr4 is
  17.  
  18. type ram_type is array (0 to 2**aw-1 ) of std_logic_vector (dw-1 downto 0);
  19. signal RAM: ram_type := (0 to 2**aw-1 => X"11111111111111111111111111111111");
  20.  
  21. begin
  22.     process (clk)
  23.     begin
  24.         if rising_edge(clk) then
  25.             if en = '1' then
  26.                 if we = '1' then    --write
  27.                     RAM(conv_integer(addr)) <= di;
  28.                 end if;
  29.                 do <= RAM(conv_integer(addr));
  30.             end if;
  31.         end if;
  32.     end process;
  33. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement