Advertisement
madegoff

HWPTI_2024_Blatt2_Aufgabe1

May 17th, 2024 (edited)
754
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 3.76 KB | None | 0 0
  1. ------------------------------------------------------------------------------
  2. --  Paket fuer die Funktionen zur die Abbildung von ARM-Registeradressen
  3. --  auf Adressen des physischen Registerspeichers (5-Bit-Adressen)
  4. ------------------------------------------------------------------------------
  5. --  Datum:      05.11.2013
  6. --  Version:    0.1
  7. ------------------------------------------------------------------------------
  8.  
  9. library ieee;
  10. use ieee.std_logic_1164.all;
  11. library work;
  12. use work.ArmTypes.all;
  13.  
  14. --------------------------------------------------------------------------------
  15. --  Bezeichner fuer die verschiedenen Registeradressen
  16. --------------------------------------------------------------------------------
  17.     subtype RegAddress is std_logic_vector(3 downto 0);
  18.     constant R0 : RegAddress := "0000";
  19.     constant R1 : RegAddress := "0001";
  20.     constant R2 : RegAddress := "0010";
  21.     constant R3 : RegAddress := "0011";
  22.     constant R4 : RegAddress := "0100";
  23.     constant R5 : RegAddress := "0101";
  24.     constant R6 : RegAddress := "0110";
  25.     constant R7 : RegAddress := "0111";
  26.     constant R8 : RegAddress := "1000";
  27.     constant R9 : RegAddress := "1001";
  28.     constant R10    : RegAddress := "1010";
  29.     constant R11    : RegAddress := "1011";
  30.     constant R12    : RegAddress := "1100";
  31.     constant R13    : RegAddress := "1101";
  32.     constant R14    : RegAddress := "1110";
  33.     constant R15    : RegAddress := "1111";
  34. --------------------------------------------------------------------------------
  35.  
  36. package ArmRegaddressTranslation is
  37.  
  38.     function get_internal_address(
  39.         EXT_ADDRESS: std_logic_vector(3 downto 0);
  40.         THIS_MODE: std_logic_vector(4 downto 0);
  41.         USER_BIT : std_logic)
  42.     return std_logic_vector;
  43.  
  44. end package ArmRegaddressTranslation;
  45.  
  46. package body ArmRegAddressTranslation is
  47.  
  48. function get_internal_address(
  49.     EXT_ADDRESS: std_logic_vector(3 downto 0);
  50.     THIS_MODE: std_logic_vector(4 downto 0);
  51.     USER_BIT : std_logic)
  52.     return std_logic_vector
  53. is
  54.     Signal res : std_logic_vector(4 downto 0) := (others => '0');
  55.     Signal d_out: integer;
  56. --------------------------------------------------------------------------------       
  57. --  Raum fuer lokale Variablen innerhalb der Funktion
  58. --------------------------------------------------------------------------------
  59.  
  60.     begin
  61. --------------------------------------------------------------------------------       
  62. --  Functionscode
  63. --------------------------------------------------------------------------------   
  64.  
  65.    process(EXT_ADDRESS, USER_BIT, THIS_MODE)
  66.    begin   
  67.     --fuer register R0-R7 unabhaengig vom modi einfach die gleiche adresse
  68.     if((unsigned(EXT_ADDRESS) >=R0 and unsigned(EXT_ADDRESS) <=R7 or unsigned(EXT_ADDRESS) == R15 or
  69.         USER_BIT = 1) then
  70.             res(3 downto 0) <= EXT_ADDRESS;
  71.            
  72.     --fuer register R8-R12 entweder normal die gleiche adresse ODER wenn Mode = FIQ inkrementieren
  73.     elsif (unsigned(EXT_ADDRESS) >= R8 and unsigned(EXT_ADDRESS) <= 12)) then
  74.         if(THIS_MODE = FIQ) then
  75.             d_out <= (to_integer(unsigned(EXT_ADRESS)) + 8);
  76.             res <= to_std_logic_vector(d_out);
  77.         else res(3 downto 0) <= EXT_ADDRESS;
  78.        
  79.      --fuer restlichen register je nach mode
  80.      else
  81.         if(THIS_MODE = IRQ) then
  82.             d__out <= (to_integer(unsigned(EXT_ADRESS)) + 10);
  83.             res <= to_std_logic_vector(d_out);
  84.         elsif(THIS_MODE = SUPERVISOR) then
  85.             d__out <= (to_integer(unsigned(EXT_ADRESS)) + 12);
  86.             res <= to_std_logic_vector(d_out);
  87.         elsif(THIS_MODE = UNDEFINED) then
  88.             d__out <= (to_integer(unsigned(EXT_ADRESS)) + 14);
  89.             res <= to_std_logic_vector(d_out);
  90.         end if;
  91.        
  92.     end process;
  93.    
  94.     return res;        
  95.  
  96. end function get_internal_address; 
  97.      
  98. end package body ArmRegAddressTranslation;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement