Advertisement
alex1232222

Untitled

Dec 12th, 2020
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.96 KB | None | 0 0
  1. LIBRARY ieee;
  2. use ieee.std_logic_1164.all;
  3. use ieee.numeric_std.all;
  4.  
  5. entity RAM is
  6. port (
  7.     r_reset             :in std_logic;
  8.     r_ready             :in std_logic;
  9.     clk             : in std_logic;
  10.     r_CPU_cs            : in std_logic;
  11.     r_CPU_data_in           : in std_logic_vector (0 to 63);
  12.     r_CPU_address           : in std_logic_vector (0 to 15);
  13.     r_DMA_cs            : in std_logic;
  14.     r_DMA_data_in           : in std_logic_vector (0 to 63);
  15.     r_DMA_command           : in std_logic_vector (0 to 1);
  16.     r_DMA_address           : in std_logic_vector (0 to 15);
  17.     r_DMA_data_out          : out std_logic_vector (0 to 63));
  18. end RAM;
  19.  
  20. architecture behave of RAM is
  21. type ram_64k_x64 is array (0 to 65536) of std_logic_vector(0 to 63);
  22. signal r_memory_Ram : ram_64k_x64 := (
  23. 15  => x"000000000000001A",
  24. 16  => x"C000000000000014",
  25. 17  => x"000000000000001A",
  26. 18  => x"A000000C0000000A",
  27. 19  => x"0000000000001213",
  28. 20  => x"C000000000000000",
  29. 21  => x"0AAAAAAAAAAA0001",
  30. 300     => x"D000000000003456",
  31. 301 => x"000000000000001A",
  32. 302 => x"C0000000000000A0",
  33. 303 => x"0000000000000001",
  34. 304 => x"C0000000000000DD",
  35. others  => x"0000000000000000"
  36. );
  37. -- pragma sythesis_off             
  38. -- pragma sythesis_on
  39. begin
  40.  
  41. process(clk) -- cs - выборка кристала, если cs = 1 - zzzz
  42. begin  
  43.     If r_reset = '1' then
  44.         r_DMA_data_out <= x"0000000000000000";
  45.     elsif (rising_edge(clk)) then
  46.         IF (r_CPU_cs = '0') then
  47.             r_memory_Ram(to_integer (unsigned(r_CPU_address))) <= r_CPU_data_in;
  48.                 r_DMA_data_out <= x"0000000000000000";
  49.         elsif (r_DMA_cs = '1' ) then -- спящий режим
  50.             r_DMA_data_out <= x"0000000000000000";
  51.         elsif (r_ready ='0') then
  52.             if (r_DMA_command = "01") then -- команда чтения
  53.                 r_DMA_data_out <= r_memory_Ram(to_integer (unsigned(r_DMA_address)));
  54.             elsif (r_DMA_command = "10") then -- команда записи
  55.                 r_memory_Ram(to_integer (unsigned(r_DMA_address))) <= r_DMA_data_in;
  56.                 r_DMA_data_out <= x"0000000000000000";
  57.             end if;
  58.         end if;
  59.     end if;
  60. end process;
  61. end behave;
  62.    
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement