Design of 4 to 2 Encoder using IF-ELSE Statements (Behavior Modeling Style).
Output Waveform : 4 to 2 Encoder |
VHDL Code -
-------------------------------------------------------------------------------
--
-- Title : encoder4_2
-- Design : vhdl_upload 1
-- Author : Naresh Singh Dobal
-- Company : nsdobal@gmail.com
-- VHDL Tutorials & exercise by Naresh Singh Dobal
-------------------------------------------------------------------------------
--
-- File : 4 to 2 Encoder using if else.vhd
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity encoder4_2 is
port(
din : in STD_LOGIC_VECTOR(3 downto 0);
dout : out STD_LOGIC_VECTOR(1 downto 0)
);
end encoder4_2;
architecture encoder4_2_arc of encoder4_2 is
begin
encoder : process (din) is
begin
if (din="1000") then
dout <= "00";
elsif (din="0100") then
dout <= "01";
elsif (din="0010") then
dout <= "10";
elsif (din="0001") then
dout <= "11";
else
dout <= "ZZ";
end if;
end process encoder;
end encoder4_2_arc;
Thanx for the programs sir..these are really helpful! Can you plz guide me as to where and when do we use "zz", "u" , "x" etc..
ReplyDeleteAlso, in the architecture for s-r flip flop,which one would be suitable for the toggle case ?
Plz reply asap... thnx !
:P
ReplyDelete