help with binary decoder

Discussion in 'VHDL' started by majmoat_ensan, Aug 6, 2011.

  1. hi all;

    i have this code for a 5-bits binary counter :


    LIBRARY ieee;
    USE ieee.std_logic_1164.all;
    USE ieee.numeric_std.all;
    ENTITY counter IS
    PORT ( count : OUT unsigned (4 DOWNTO 0);
    load : IN STD_LOGIC;
    pre :IN unsigned (4 DOWNTO 0);
    Clk : IN STD_LOGIC);
    END counter;
    ARCHITECTURE Behavioral OF counter IS
    SIGNAL c : unsigned(4 DOWNTO 0) := "00000";

    BEGIN
    count <= c;
    PROCESS(Clk)
    BEGIN
    IF( rising_edge(Clk) ) THEN
    IF(load = '1') THEN
    c <= pre;
    ELSE
    c <= c + 1;
    END IF;
    END IF;
    END PROCESS;
    END Behavioral;


    I want to connect the output to a binary decoder that shows the state
    of the counter
    how can i do that?

    can any one help me plz
     
    majmoat_ensan, Aug 6, 2011
    #1
    1. Advertising

  2. majmoat_ensan

    eliascm

    Joined:
    Jan 30, 2009
    Messages:
    42
    Binary Decoder

    Code:
    -----------------------------------------------------------------------------------------------------
    library IEEE;
    use IEEE.STD_LOGIC_1164.all;
    use IEEE.NUMERIC_STD.all;
    ------------------------------------------------------------------------------------------------------
    entity decode is
    
      generic (code_size       : positive := 5;                                       --Code input size
                output_asserted : std_logic := '1';                          --Sets output asserted value
    						out_size        : positive  := 32
    		 		 );
    port (word_in         : in  std_logic_vector(code_size - 1 downto 0);   --Input to be decoded
           decode_ena   : in  std_logic := '1';                                         --If LOW, no decoding
           oe_n              : in  std_logic := '0';                                    --If HIGH, outputs are Hi-Z
           decode_out   : out std_logic_vector(out_size - 1 downto 0));     --Decoder ouput
    
    end decode;
    ------------------------------------------------------------------------------------------------------
    architecture archdecode of decode is
    
    begin
    
    pdecode : process(word_in, oe_n, decode_ena)
      begin
        if oe_n = '1' then
          decode_out <= (others => 'Z');
        elsif decode_ena = '0' then
          decode_out <= (others => not output_asserted);
        else
          for i in decode_out'range loop
            if unsigned(word_in) = i then
              decode_out(i) <= output_asserted;
            else
              decode_out(i) <= not output_asserted;
            end if;
          end loop;
        end if;
      end process pdecode;
    
    end;
    
    
     
    eliascm, Aug 12, 2011
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jacobo
    Replies:
    4
    Views:
    1,216
    Marc Randolph
    May 19, 2004
  2. axelman

    Newbie, VIN Number decoder help

    axelman, Jun 5, 2007, in forum: ASP .Net
    Replies:
    7
    Views:
    517
    Cowboy \(Gregory A. Beamer\)
    Jul 14, 2007
  3. mitsui9999

    VHDL HELP!!!!! Kepad decoder code

    mitsui9999, Oct 17, 2008, in forum: VHDL
    Replies:
    0
    Views:
    763
    mitsui9999
    Oct 17, 2008
  4. majmoat_ensan

    help with binary decoder

    majmoat_ensan, Aug 6, 2011, in forum: VHDL
    Replies:
    1
    Views:
    1,033
    eliascm
    Aug 12, 2011
  5. Replies:
    2
    Views:
    151
    GaborSzakacs
    May 12, 2014
Loading...

Share This Page