Monday, 29 July 2013

Design of 8 to 3 Priority Encoder using When Else statements -Method 1 (VHDL Code)






Design of 8 to 3 Priority Encoder using When-Else Statement - Method 1 



Output Waveform 1 :  8 to 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 8 to 3 Priority Encoder using when else.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
   
dout <= "000" when din(7)='1' else
        "001" when din(6)='1'else
        "010" when din(5)='1' else
        "011" when din(4)='1' else
        "100" when din(3)='1' else
        "101" when din(2)='1' else
        "110" when din(1)='1' else
        "111" when din(0)='1';
   

end priority_enc_arc;

7 comments :

Thang Nguyen said...

i'm confused that if both din(6) and din(5) equal 1because when else is concurrent statement.what signal of output?? cant you explain for me>>

naresh.dobal said...

Hi Thang,

Don't be confused with concurrent statements and when else statements. Concurrent execution, execute statements at same simulation time. But if you see the code then we have only single when else statement in our code...

Regard//
Naresh Singh Dobal
nsdobal@gmail.com

Thang Nguyen said...

thank to your help, mr naresh .

Thang Nguyen said...

i still confuse that what value of dout is prior if input contain both din(0) and din(1) equalling 1. can you explain more detail for me??

Ahmed mousa said...

Can't I just " And " the 8 bits input with a 8 bits vector i know to check if it gets me one at the desired bit . example

Z<="0011" when (A and "00001000") = " 00001000" else.....

Bojan Matovski said...

Thang, this is a priority encoder. If din(0) and din(1) are zero, then dout will be equal to "110", because din(1) is the line with bigger priority.

Read about Encoders here:
http://www.electronics-tutorials.ws/combination/comb_4.html

Anonymous said...

in this program of priority encoder i guess the the inputs are active high and outputs active low... am i correct?

what does din(7)='1' means?
is it d7 input asserted or is it din ='00000001'?

plz clarify...

Post a Comment

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