Advertisement
madegoff

ARM_RAMB_4kx32

May 24th, 2024
422
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 2.89 KB | None | 0 0
  1. --------------------------------------------------------------------------------
  2. --  Wrapper um Basys3-Blockram fuer den RAM des HWPR-Prozessors.
  3. --------------------------------------------------------------------------------
  4. --  Datum:      23.05.2022
  5. --  Version:    1.1
  6. --------------------------------------------------------------------------------
  7.  
  8. library ieee;
  9. use ieee.std_logic_1164.all;
  10. use ieee.numeric_std.all;
  11.  
  12. entity ArmRAMB_4kx32 is
  13.     generic(
  14. --------------------------------------------------------------------------------
  15. --  SELECT_LINES ist fuer das HWPR irrelevant, wird aber in einer
  16. --  komplexeren Variante dieses Speichers zur Groessenauswahl
  17. --  benoetigt. Im Hardwarepraktikum bitte ignorieren und nicht aendern.
  18. --------------------------------------------------------------------------------
  19.         SELECT_LINES : natural range 0 to 2 := 1);
  20.     port(
  21.         RAM_CLK : in  std_logic;
  22.         ENA     : in  std_logic;
  23.         ADDRA   : in  std_logic_vector(11 downto 0);
  24.         WEB     : in  std_logic_vector(3 downto 0);
  25.         ENB     : in  std_logic;
  26.         ADDRB   : in  std_logic_vector(11 downto 0);
  27.         DIB     : in  std_logic_vector(31 downto 0);
  28.         DOA     : out  std_logic_vector(31 downto 0);
  29.         DOB     : out  std_logic_vector(31 downto 0));
  30. end entity ArmRAMB_4kx32;
  31.  
  32.  
  33. architecture behavioral of ArmRAMB_4kx32 is
  34.    
  35.     type ram_type is array (4095 downto 0) of std_logic_vector(31 downto 0);
  36.     signal RAM : ram_type;
  37.     begin
  38.     WRITE_AND_READ: process(RAM_CLK)
  39.     begin
  40.         if(rising_edge(RAM_CLK)) then
  41.             if (ENA = '1') then --wenn enable A, lesen aus dem RAM anstelle (int) der entsprechenden Register Adresse
  42.                 DOA <= RAM(to_integer(unsigned(ADDRA)));
  43.             end if;
  44.        
  45.             -- DIB hat die Form: |++++|++++|++++|++++| besteht aus 32 Bit - 4 Bloecken
  46.        
  47.             if (ENB = '1') then --wenn enable B, kann man aus B lesen oder auf B schreiben, je nach WEB
  48.                 if (WEB = "0000") then --lesezugriff auf port B
  49.                     DOB <= RAM(to_integer(unsigned(ADDRB)));
  50.                 end if;
  51.            
  52.                 if (WEB(0) = '1') then --erstes block (die letzten 8Bit) schreiben
  53.                     RAM(to_integer(unsigned(ADDRB)))(7 downto 0) <= DIB(7 downto 0);
  54.                 end if;
  55.                 if (WEB(1) = '1') then -- zweites block
  56.                     RAM(to_integer(unsigned(ADDRB)))(15 downto 8) <= DIB(15 downto 8);
  57.                 end if;
  58.                 if (WEB(2) = '1') then --drittes block
  59.                     RAM(to_integer(unsigned(ADDRB)))(23 downto 16) <= DIB(23 downto 16);
  60.                 end if;
  61.                 if (WEB(3) = '1') then --viertes block
  62.                     RAM(to_integer(unsigned(ADDRB)))(31 downto 24) <= DIB(31 downto 24);
  63.                 end if;
  64.             end if;
  65.         end if;
  66.                        
  67.     end process;
  68. end architecture behavioral;
  69.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement