Ripple chain logic in VHDL

Discussion in 'VHDL' started by Govinda, May 6, 2008.

  1. Govinda

    Govinda

    Joined:
    Aug 2, 2007
    Messages:
    7
    Hi,

    What is the best way to write a vhdl code for the following encoded logic?

    If there is a 4 bit register and you only need to select the first '1' in that register starting from LSB and set all others to zero, how can that be written up in VHDL? I need to do this for a 32 bit register and I cant believe writing up the whole logic (one huge concurrent statement for each bit, especially the MSBs) is the best way to do it. Can anyone here suggest any alternatives?

    eg: 1011 needs to be 0001
    1100 needs to be 0100
    1110 needs to be 0010 etc.


    Thanks a lot- any help would be greatly appreciated.

    Govinda
    Govinda, May 6, 2008
    #1
    1. Advertising

  2. Govinda

    jeppe

    Joined:
    Mar 10, 2008
    Messages:
    348
    Location:
    Denmark
    jeppe, May 6, 2008
    #2
    1. Advertising

  3. Govinda

    jeppe

    Joined:
    Mar 10, 2008
    Messages:
    348
    Location:
    Denmark
    Ok try this

    PHP:
    library IEEE;
    use 
    IEEE.STD_LOGIC_1164.ALL;
    use 
    IEEE.STD_LOGIC_ARITH.ALL;
    use 
    IEEE.STD_LOGIC_UNSIGNED.ALL;

    entity logic_test1 is
        Port 
    in  std_logic_vector(5 downto 0);
               
    out std_logic_vector(5 downto 0));
    end logic_test1;

    architecture Behavioral of logic_test1 is

    begin
       process
    A)
           
    variable i,jinteger;
       
    begin
           Y 
    <= (others => '0'); 
           
    := 1;
            
    := 0;
           while 
    2**5 loop
                 
    if A(j)='1' then
                   Y 
    <= Conv_std_logic_vector(i,6);
                    exit;
             
    end if;
                
    := 2;
                
    := 1;
            
    end loop
        
    end process;

    end Behavioral;
    jeppe, May 6, 2008
    #3
  4. Govinda

    Govinda

    Joined:
    Aug 2, 2007
    Messages:
    7
    Thanks a lot Jeppe
    Govinda, May 7, 2008
    #4
    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. ALuPin

    Ripple clock warning

    ALuPin, Oct 5, 2004, in forum: VHDL
    Replies:
    2
    Views:
    3,006
    ALuPin
    Oct 6, 2004
  2. Patrick

    Ripple Clock : Quartus 4.1

    Patrick, Dec 3, 2004, in forum: VHDL
    Replies:
    1
    Views:
    622
    MikeTreseler
    Dec 3, 2004
  3. vizziee@gmail.com

    Ripple Clock for a counter

    vizziee@gmail.com, Aug 31, 2005, in forum: VHDL
    Replies:
    7
    Views:
    3,423
  4. afd
    Replies:
    1
    Views:
    8,273
    Colin Paul Gloster
    Mar 23, 2007
  5. spike
    Replies:
    8
    Views:
    1,440
    Steve Holden
    Feb 9, 2010
Loading...

Share This Page