5 Write the VHDL code for the 8to3 priority encoder shown be
5. Write the VHDL code for the 8-to-3 priority encoder shown below using the withselect construct: outputs inputs
Solution
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY encoder IS
PORT( x : in STD_LOGIC_VECTOR(7 DOWNTO 0);
y : out STD_LOGIC_VECTOR(2 DOWNTO 0) );
END encoder;
ARCHITECTURE arc OF priorityencoder8to3 IS
BEGIN
WITH a SELECT y <=
\"000\" WHEN \"10000000\",
\"001\" WHEN \"01000000\",
\"010\" WHEN \"00100000\",
\"011\" WHEN \"00010000\",
\"100\" WHEN \"00001000\",
\"101\" WHEN \"00000100\",
\"110\" WHEN \"00000010\",
\"111\" WHEN \"00000001\",
\"zzz\" WHEN \"others\";
END arc;
