Monday, 29 July 2013

Design of 8 : 3 Priority Encoder using if - else statements - Method 1 (VHDL Code).





Design of 8 : 3 Priority Encoder using IF-ELSE Statements -


Output Waveform : 8 : 3 Priority Encoder



Output Waveform : 8 to 3 Priority Encoder



VHDL Code -



-------------------------------------------------------------------------------
--
-- Title       : priority_encoder_8_3
-- Design      : vhdl_upload2
-- Author      : Naresh Singh Dobal
-- Company     : nsdobal@gmail.com
-- Verilog HDL Programs &  Exercise with Naresh Singh Dobal.
--
-------------------------------------------------------------------------------
--
-- File        : Design of Priority Encoder using if else statements.vhd

   

library IEEE;
use IEEE.STD_LOGIC_1164.all;     
use ieee.numeric_std.all;

entity priority_encoder_8_3 is
     port(
         din : in STD_LOGIC_VECTOR(7 downto 0);
         dout : out STD_LOGIC_VECTOR(2 downto 0)
         );
end priority_encoder_8_3;


architecture priority_enc_arc of priority_encoder_8_3 is
begin

    pri_enc : process (din) is
    begin
        if (din(7)='1') then
            dout <= "000";
        elsif (din(6)='1') then
            dout <= "001";
        elsif (din(5)='1') then
            dout <= "010";
        elsif (din(4)='1') then
            dout <= "011";
        elsif (din(3)='1') then
            dout <= "100";
        elsif (din(2)='1') then
            dout <= "101";
        elsif (din(1)='1') then
            dout <= "110";
        elsif (din(0)='1') then
            dout <= "111";
        end if;
    end process pri_enc;
   

end priority_enc_arc;

4 comments :

Anonymous said...

what happens if the input is suppose 00000011 then the output should be 001 but it is coming out 000 instead

Hemang Parikh said...

than the output will be 110

Unknown said...

it's returning 000 because:
0 - LSB ( in entity use "downto")
0 -
0 -
0 -
0 -
0 -
0 -
1 -
1 - MSB (same as LSB)

that way, the priority is given by the order of significant bytes. In this case, MSB is set to 1 then, no matter what, the output will be 000.

Unknown said...

Could you please send me the Truth Table

Post a Comment

 
Design by Wordpress Theme | Bloggerized by Free Blogger Templates | coupon codes