Search This Blog

Monday, 5 August 2013

VHDL Code for 8x3 Encoder

Encoder is a combinational circuit which converts set of signal into equivalent code. Function is exactly opposite of Decoder. Find out Test Bench for 8x3 Encoder here.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
library ieee;
use ieee.std_logic_1164.all;


entity enco8x3_seq is
  
  port (
    i : in  std_logic_vector(7 downto 0);  -- inputs
    o : out std_logic_vector(2 downto 0));  -- outputs

end enco8x3_seq;


architecture beh of enco8x3_seq is

begin  -- beh

  enco : process (i)
  variable temp : std_logic_vector(2 downto 0);
  begin
    case i is
      when "00000001" => temp := "000";
      when "00000010" => temp := "001";
      when "00000100" => temp := "010";
      when "00001000" => temp := "011" ;
      when "00010000" => temp := "100";
      when "00100000" => temp := "101";
      when "01000000" => temp := "110";
      when "10000000" => temp := "111";
      when others => temp := "XXX";
    end case;
    o <= temp;
  end process enco;

end beh;

No comments:

Post a Comment