最高优先级编码器.txt
上传用户:easylife05
上传日期:2013-03-21
资源大小:42k
文件大小:1k
源码类别:

VHDL/FPGA/Verilog

开发平台:

C/C++

  1. -- Highest Priority Encoder
  2. -- download from www.pld.com.cn & www.fpga.com.cn
  3. LIBRARY ieee;
  4. USE ieee.std_logic_1164.ALL;
  5. entity priority is
  6.         port(I : in bit_vector(7 downto 0); --inputs to be prioritised
  7.                 A : out bit_vector(2 downto 0); --encoded output
  8.                 GS : out bit);  --group signal output
  9. end priority;
  10. architecture v1 of priority is
  11. begin
  12.         process(I)
  13.         begin
  14.                 GS <= '1'; --set default outputs
  15.                 A <= "000";
  16.                 if I(7) = '1' then
  17.                         A <= "111";
  18.                 elsif I(6) = '1' then
  19.                         A <= "110";
  20.                 elsif I(5) = '1' then
  21.                         A <= "101";
  22.                 elsif I(4) = '1' then
  23.                         A <= "100";
  24.                 elsif I(3) = '1' then
  25.                         A <= "011";
  26.                 elsif I(2) = '1' then
  27.                         A <= "010";
  28.                 elsif I(1) = '1' then
  29.                         A <= "001";
  30.                 elsif I(0) = '1' then
  31.                         A <= "000";
  32.                 else
  33.                         GS <= '0';
  34.                 end if;
  35.         end process;    
  36. end v1;