Advertisement
rommik

dvb_s2x_RAM.vhd

Dec 14th, 2019
575
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.79 KB | None | 0 0
  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use std.textio.all;
  4. use ieee.numeric_std.all;
  5.  
  6. entity dvb_s2x_RAM is
  7.     Port(
  8.         clk       : in std_logic;                              
  9.         res       : in std_logic;    
  10.         WE        : in std_logic;                    -- Write enable              
  11.         address   : in integer range 0 to 64805;
  12.         in_data   : in std_logic_vector(0 downto 0);
  13.         out_data  : out std_logic_vector(0 downto 0));        
  14. end dvb_s2x_RAM;
  15.  
  16.  
  17. architecture Behavioral of dvb_s2x_RAM is
  18.  
  19. constant C_RAM_WIDTH : integer := 1;                                            -- Specify RAM data width
  20. constant C_RAM_DEPTH : integer := 64806;                                        -- Specify RAM depth (number of entries)
  21.  
  22. signal out_high : std_logic_vector(C_RAM_WIDTH-1 downto 0) := (others => '0');  -- RAM output data when RAM_PERFORMANCE = HIGH_PERFORMANCE                                      
  23. signal read_en  : std_logic := '1';                                             -- Output register enable
  24.  
  25. type ram_type is array (C_RAM_DEPTH-1 downto 0) of std_logic_vector(C_RAM_WIDTH-1 downto 0);   -- 2D Array Declaration for RAM signal
  26.      
  27. signal RAM_data : std_logic_vector(C_RAM_WIDTH-1 downto 0);
  28. signal RAM      : ram_type := (others => (others => '0'));
  29.  
  30. begin
  31.  
  32. process(clk)
  33. begin
  34.     if(rising_edge(clk)) then
  35.         if(WE = '1') then
  36.             RAM(address) <= in_data;
  37.         end if;
  38.         RAM_data <= RAM(address);
  39.     end if;
  40. end process;
  41.  
  42.  
  43. process(clk)
  44. begin
  45.     if(rising_edge(clk)) then
  46.         if(res = '1') then
  47.             out_high <= (others => '0');
  48.         elsif(read_en = '1') then
  49.             out_high <= RAM_data;
  50.         end if;
  51.     end if;
  52. end process;
  53. out_data <= out_high;
  54.  
  55. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement