Advertisement
Guest User

Untitled

a guest
Nov 5th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 2.78 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 :=(
  20.     x"99",x"88",x"77",x"66",
  21.     x"55",x"44",x"33",x"22",
  22.     x"11",x"00",x"00",x"00",
  23.     x"00",x"00",x"00",x"00",
  24.     x"00",x"00",x"00",x"00",
  25.     x"00",x"00",x"00",x"00",
  26.     x"00",x"00",x"00",x"00",
  27.     x"00",x"00",x"00",x"00",
  28.     x"00",x"00",x"00",x"00",
  29.     x"00",x"00",x"00",x"00",
  30.     x"00",x"00",x"00",x"00",
  31.     x"00",x"00",x"00",x"00",
  32.     x"00",x"00",x"00",x"00",
  33.     x"00",x"00",x"00",x"00",
  34.     x"00",x"00",x"00",x"00",
  35.     x"00",x"00",x"00",x"00",
  36.     x"00",x"00",x"00",x"00",
  37.     x"00",x"00",x"00",x"00",
  38.     x"00",x"00",x"00",x"00",
  39.     x"00",x"00",x"00",x"00",
  40.     x"00",x"00",x"00",x"00",
  41.     x"00",x"00",x"00",x"00",
  42.     x"00",x"00",x"00",x"00",
  43.     x"00",x"00",x"00",x"00",
  44.     x"00",x"00",x"00",x"00",
  45.     x"00",x"00",x"00",x"00",
  46.     x"00",x"00",x"00",x"00",
  47.     x"00",x"00",x"00",x"00",
  48.     x"00",x"00",x"00",x"00",
  49.     x"00",x"00",x"00",x"00",
  50.     x"00",x"00",x"00",x"00",
  51.     x"00",x"00",x"00",x"00",
  52.     x"00",x"00",x"00",x"00",
  53.     x"00",x"00",x"00",x"00",
  54.     x"00",x"00",x"00",x"00",
  55.     x"00",x"00",x"00",x"00",
  56.     x"00",x"00",x"00",x"00",
  57.     x"00",x"00",x"00",x"00",
  58.     x"00",x"00",x"00",x"00",
  59.     x"00",x"00",x"00",x"00",
  60.     x"00",x"00",x"00",x"00",
  61.     x"00",x"00",x"00",x"00",
  62.     x"00",x"00",x"00",x"00",
  63.     x"00",x"00",x"00",x"00",
  64.     x"00",x"00",x"00",x"00",
  65.     x"00",x"00",x"00",x"00",
  66.     x"00",x"00",x"00",x"00",
  67.     x"00",x"00",x"00",x"00",
  68.     x"00",x"00",x"00",x"00",
  69.     x"00",x"00",x"00",x"00",
  70.     x"00",x"00",x"00",x"00",
  71.     x"00",x"00",x"00",x"00",
  72.     x"00",x"00",x"00",x"00",
  73.     x"00",x"00",x"00",x"00",
  74.     x"00",x"00",x"00",x"00",
  75.     x"00",x"00",x"00",x"00",
  76.     x"00",x"00",x"00",x"00",
  77.     x"00",x"00",x"00",x"00",
  78.     x"00",x"00",x"00",x"00",
  79.     x"00",x"00",x"00",x"00",
  80.     x"00",x"00",x"00",x"00",
  81.     x"00",x"00",x"00",x"00",
  82.     x"00",x"00",x"00",x"00",
  83.     x"00",x"00",x"00",x"00"
  84.     );
  85.  
  86. begin
  87.     process (clk)
  88.     begin
  89.         if rising_edge(clk) then
  90.             if en = '1' then
  91.                 if we = '1' then    --write
  92.                     RAM(conv_integer(addr)) <= di;
  93.                 end if;
  94.                 do <= RAM(conv_integer(addr));
  95.             end if;
  96.         end if;
  97.     end process;
  98. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement