Advertisement
madegoff

ARM_Meminterface_almostdone

May 27th, 2024
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.86 KB | None | 0 0
  1. --------------------------------------------------------------------------------
  2. -- Schnittstelle zur Anbindung des RAM an die Busse des HWPR-Prozessors
  3. --------------------------------------------------------------------------------
  4. -- Datum: ??.??.2013
  5. -- Version: ?.?
  6. --------------------------------------------------------------------------------
  7. library ieee;
  8. use ieee.std_logic_1164.all;
  9. use ieee.numeric_std.all;
  10.  
  11. library work;
  12. use work.ArmConfiguration.all;
  13. use work.ArmTypes.all;
  14.  
  15. entity ArmMemInterface is
  16. generic(
  17. --------------------------------------------------------------------------------
  18. -- Beide Generics sind fuer das HWPR nicht relevant und koennen von
  19. -- Ihnen ignoriert werden.
  20. --------------------------------------------------------------------------------
  21. SELECT_LINES : natural range 0 to 2 := 1;
  22. EXTERNAL_ADDRESS_DECODING_INSTRUCTION : boolean := false);
  23. port ( RAM_CLK : in std_logic;
  24. -- Instruction-Interface
  25. IDE : in std_logic;
  26. IA : in std_logic_vector(31 downto 2);
  27. ID : out std_logic_vector(31 downto 0);
  28. IABORT : out std_logic;
  29. -- Data-Interface
  30. DDE : in std_logic;
  31. DnRW : in std_logic;
  32. DMAS : in std_logic_vector(1 downto 0);
  33. DA : in std_logic_vector(31 downto 0);
  34. DDIN : in std_logic_vector(31 downto 0);
  35. DDOUT : out std_logic_vector(31 downto 0);
  36. DABORT : out std_logic);
  37. end entity ArmMemInterface;
  38.  
  39. architecture behave of ArmMemInterface is
  40.  
  41. type ram_type is array(4095 downto 0) of std_logic_vector(31 downto 0);
  42. shared variable RAM : ram_type;
  43. signal WEB : std_logic_vector(3 downto 0);
  44. signal abort : std_logic := ('0') ;
  45.  
  46. begin
  47.  
  48. WEB <= "0011" when (DMAS = "01" and DA(1 downto 0) = "00") else
  49. "1100" when (DMAS = "01" and DA(1 downto 0) = "11") else
  50. "0001" when (DMAS = "00" and DA(1 downto 0) = "00") else
  51. "0010" when (DMAS = "00" and DA(1 downto 0) = "01") else
  52. "0100" when (DMAS = "00" and DA(1 downto 0) = "10") else
  53. "1000" when (DMAS = "00" and DA(1 downto 0) = "11") else
  54. "1111" when (DMAS = "10" and DA(1 downto 0) = "00");
  55.  
  56. ram_inst : entity work.ArmRAMB_4kx32(behavioral)
  57. port map(
  58. RAM_CLK => RAM_CLK,
  59. ENA => IDE,
  60. ADDRA => IA(13 downto 2),
  61. WEB => WEB,
  62. DOA => ID,
  63. DIB => DDIN,
  64. ENB => DDE,
  65. ADDRB => DA(13 downto 2)
  66. );
  67.  
  68. instruction_bus : process(IDE, IA)
  69. begin
  70. if ( IDE = '1' ) then
  71. if( IA >= INST_LOW_ADDR and IA <= INST_HIGH_ADDR) then
  72. IABORT <= '0';
  73. ID <= RAM(to_integer(unsigned(IA)));
  74. else
  75. IABORT <= '1';
  76. ID <= (others => 'Z');
  77. end if;
  78. else
  79. ID <= (others => 'Z');
  80. IABORT <= 'Z';
  81. end if;
  82. end process;
  83.  
  84. daten_bus : process(DDE, DA, DnRW, DMAS)
  85. begin
  86. if((DDE = '1') and (DnRW = '0')) then
  87. DDOUT <= RAM(to_integer(unsigned(DA(31 downto 2))));
  88. else
  89. DDOUT <= (others => 'Z');
  90. end if;
  91. if((DDE = '1') and (DnRW = '1')) then
  92. if (DMAS = "11") then
  93. abort <= '1';
  94. end if;
  95. end if;
  96. if((DDE = '1') and (DnRW = '1')) then
  97. if (DMAS = "11") then
  98. abort <= '1';
  99. elsif(DMAS = "01") then
  100. if(DA(1 downto 0) = "00" or DA(1 downto 0) = "10") then
  101. abort <= '0';
  102. else
  103. abort <= '1';
  104. end if;
  105. elsif(DMAS = "10") then
  106. if(DA(1 downto 0) = "00") then
  107. abort <= '0';
  108. else
  109. abort <= '1';
  110. end if;
  111. end if;
  112. if(abort = '0') then
  113. RAM(to_integer(unsigned(DA))) := DDIN;
  114. end if;
  115. end if;
  116. DABORT <= abort;
  117. end process;
  118. end architecture behave;
  119.  
  120.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement