aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/synth/int01/prio02.vhdl
blob: d6b164d199471ae832edb0802f3e15b811e62042 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity prio02 is
  port (dat : std_logic_vector(15 downto 0);
        prio : out natural);
end;

architecture behav of prio02 is
  function prioritize(b : std_logic_vector(15 downto 0)) return natural
  is
    variable level : integer range 0 to 15;
  begin
    level := 0;
    for i in 15 downto 0 loop
      level := i;
      if b(i) = '1' then exit; end if;
    end loop;
    return level;
  end;
begin
  prio <= prioritize (dat);
end;