Advertisement
milanmetal

[VHDL] RAM 64x16 // RESET, CE, EN

Apr 28th, 2017
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.80 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date:    03:21:39 04/29/2017
  6. -- Design Name:
  7. -- Module Name:    RAM64x16 - Behavioral
  8. ----Zadatak 1: Napisati VHDL model memorije sa sledećim karakteristikama:
  9. ----• kapacitet memorije, m = 64
  10. ----• širine magistrala podataka, n = 16
  11. ----• tip čitanja podataka iz registarske banke - sinhrono
  12. ----• mod čitanja - „Write-First"
  13. ----• sinhroni reset ulaz
  14. ----• sinhroni clock enable ulaz
  15. ----• sinhroni enable ulaz
  16. ----Za razvijeni VHDL model napisai odgovarajući testbenč pomoću kojega će biti moguće izvršiti funkcionalnu verifikaciju modela.
  17. ----------------------------------------------------------------------------------
  18. library IEEE;
  19. use IEEE.STD_LOGIC_1164.ALL;
  20. use IEEE.STD_LOGIC_UNSIGNED.ALL;
  21. use IEEE.STD_LOGIC_ARITH.ALL;
  22.  
  23.  
  24. entity RAM64x16 is
  25.     PORT(
  26.         CLK: in std_logic;
  27.         RESET: in std_logic;
  28.         CE: in std_logic;
  29.         EN: in std_logic;
  30.        
  31.         write : in std_logic;
  32.         wdata : in std_logic_vector(15 downto 0);
  33.        
  34.         address : in std_logic_vector(5 downto 0);
  35.        
  36.         rdata: out std_logic_vector(15 downto 0)
  37.        
  38.     );
  39. end RAM64x16;
  40.  
  41. architecture Behavioral of RAM64x16 is
  42. type MEM_FILE_t is array (0 to 63) of std_logic_vector(15 downto 0);
  43. signal MEM_FILE : MEM_FILE_t;
  44.  
  45. begin
  46.     RAM: process(CLK)
  47.     begin
  48.         if(CLK'event and CLK = '1') then
  49.             if(RESET = '1') then
  50.                 MEM_FILE <= (others => (others => '0'));
  51.             else
  52.                 if(EN = '1' and CE = '1') then
  53.                     if(write = '1') then
  54.                         -- Write-First
  55.                         MEM_FILE(conv_integer(address)) <= wdata;
  56.                         rdata <= MEM_FILE(conv_integer(address));
  57.                     else
  58.                         rdata <= MEM_FILE(conv_integer(address));
  59.                     end if;
  60.                 end if;
  61.             end if;
  62.         end if;
  63.     end process;
  64. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement