Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > help with binary decoder

Reply
Thread Tools

help with binary decoder

 
 
majmoat_ensan
Guest
Posts: n/a
 
      08-06-2011
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
 
Reply With Quote
 
 
 
 
eliascm eliascm is offline
Member
Join Date: Jan 2009
Posts: 42
 
      08-12-2011
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;
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
help with binary decoder majmoat_ensan VHDL 1 08-12-2011 10:49 AM
Newbie, VIN Number decoder help axelman ASP .Net 7 07-14-2007 08:02 PM
Creative DDTS-100 decoder hiss, help wanted pls Joshua Wood NZ Computing 2 11-26-2005 12:56 PM
Decoder Logo Help =?Utf-8?B?SlA=?= Windows 64bit 1 05-23-2005 11:56 PM
Please, I need help with a mpeg layer 1 decoder in vhdl jacobo VHDL 4 05-19-2004 02:19 AM



Advertisments