Write a complete VHDL module for a 4-bit priority encoder. See FLD tor a descrip
ID: 1716942 • Letter: W
Question
Write a complete VHDL module for a 4-bit priority encoder. See FLD tor a description of a priority encoder. There are sixteen inputs: O encodes the highest priority input asserted in a (our bit binary code. E.g. "0000000000000001" outputs "0000" and input "1000000000000000" outputs "1111" V is true if at least one of the inputs is asserted (Multiple inputs can be true at the same time), else it is a false. Use vector notation for D and O. Use a conditional signal assignment to extract portions of the D bit vector for comparison with a constant vector and to ignore those bits which don't apply to each term. This allows your logic to ignore (don't-care) other lower priority bits (inputs). Simulate your design in directVHDL. Include the VHDL code and the simulation in your report. (directVHDL does not support don't-care terms, so the above notation is essential. In coming labs you will discover that Galaxy/Warp supports don't-care terms.)Explanation / Answer
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use ieee.numeric_std.all;
entity priority_encoder_16_4 is
port(
din : in STD_LOGIC_VECTOR(15 downto 0);
dout : out STD_LOGIC_VECTOR(3 downto 0)
);
end priority_encoder_16_4;
architecture priority_enc_arc of priority_encoder_16_4 is
begin
pri_enc : process (din) is
begin
if (std_match(din,"1------------------")) then
dout <= "0000";
elsif (std_match(din,"01--------------")) then
dout <= "0001";
elsif (std_match(din,"001-------------")) then
dout <= "0010";
elsif (std_match(din,"0001------------")) then
dout <= "0011";
elsif (std_match(din,"00001-----------")) then
dout <= "0100";
elsif (std_match(din,"000001----------")) then
dout <= "0101";
elsif (std_match(din,"0000001---------")) then
dout <= "0110";
elsif (std_match(din,"00000001--------")) then
dout <= "0111";
elsif (std_match(din,"00000001-------")) then
dout <= "1000";
elsif (std_match(din,"0000000001------")) then
dout <= "1001";
elsif (std_match(din,"00000000001-----")) then
dout <= "1010";
elsif (std_match(din,"000000000001----")) then
dout <= "1011";
elsif (std_match(din,"0000000000001---")) then
dout <= "1100";
elsif (std_match(din,"00000000000001--")) then
dout <= "1101";
elsif (std_match(din,"000000000000001-")) then
dout <= "1110";
elsif (std_match(din,"0000000000000001")) then
dout <= "1111";
end if;
end process pri_enc;
end priority_enc_arc;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.