Advertisement
madegoff

ArmPriorityVectorFilter

Jun 18th, 2023 (edited)
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.75 KB | None | 0 0
  1. --------------------------------------------------------------------------------
  2. --  Prioritaetsencoder fuer das Finden des niederwertigsten
  3. --  gesetzten Bits in einem 16-Bit-Vektor.
  4. --------------------------------------------------------------------------------
  5. --  Datum:      ??.??.2013
  6. --  Version:    ?.??
  7. --------------------------------------------------------------------------------
  8. library ieee;
  9. use ieee.std_logic_1164.all;
  10.  
  11. entity ArmPriorityVectorFilter is
  12.     port(
  13.         PVF_VECTOR_UNFILTERED   : in std_logic_vector(15 downto 0);
  14.         PVF_VECTOR_FILTERED : out std_logic_vector(15 downto 0)
  15.         );
  16. end entity ArmPriorityVectorFilter;
  17.  
  18. architecture structure of ArmPriorityVectorFilter is
  19.  
  20.     component ArmRegisterBitAdd
  21.         port(
  22.             RBA_REGLIST : in std_logic_vector(15 downto 0);
  23.             RBA_NR_OF_REGS  : out std_logic_vector(4 downto 0)
  24.         );
  25.     end component ArmRegisterBitAdd;
  26.    
  27.     signal nummer_of_regs: std_logic_vector(4 downto 0);
  28.     signal pos: integer;
  29.  
  30.     begin
  31.  
  32.     CURRENT_NR_OF_REGS : ArmRegisterBitAdd
  33.         port map(
  34.             RBA_REGLIST => PVF_VECTOR_UNFILTERED;
  35.             RBA_NR_OF_REGS  => nummer_of_regs;
  36.         );
  37.  
  38.  
  39.     process(PVF_VECTOR_UNFILTERED, nummer_of_regs)
  40.         variable i: integer;
  41.     begin
  42.         for i in 15 downto 0 loop -- das niederwertigste bit = 1 finden
  43.             if (PVF_VECTOR_UNFILTERED(i) = '1') then
  44.                 pos = i;
  45.                 exit;
  46.             end if;
  47.         end loop;
  48.  
  49.         case nummer_of_reg
  50.             when "0001" => PVF_VECTOR_FILTERED <= PVF_VECTOR_UNFILTERED; --wenn ein Bit gesetzt, bleibt er gesetzt
  51.             when "0000" => PVF_VECTOR_FILTERED <= others => '0'; --wenn kein Bit gesetzt, so gilt es auch fuer den ausgang
  52.             when others =>
  53.                             PVF_VECTOR_FILTERED <= others => '0';
  54.                             PVF_VECTOR_FILTERED(pos) <= '1';
  55.         end case;
  56.     end process;
  57.  
  58. end architecture structure;
  59.  
  60.  
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement