Gray Code

Discussion in 'VHDL' started by sarovarc, Mar 2, 2011.

  1. sarovarc

    sarovarc

    Joined:
    Mar 2, 2011
    Messages:
    2
    Hi,

    I am a student, and my assignment is to create a gray code to bargraph design in VHDL using select signal assignment.

    I have been toying around with the following code, but it just doesnt seem to work.
    Code:
    library IEEE;
    use IEEE.STD_LOGIC_1164.all; 
    
    entity gray_2_bar is
        port( gray : in std_logic_vector (3 downto 0);
        bar_graph : out std_logic_vector (9 downto 0));
        
        attribute loc : string;
        attribute loc of gray: signal is "P2,P3,P4,P5";
        attribute loc of bar_graph: signal is "P27,P26,P25,P24,P23,P21,P20,P19,P18,P17"; 
    
    end gray_2_bar;
    
    --}} End of automatically maintained section  
    
    architecture gray2bar1 of gray_2_bar is
        signal temp: std_logic_vector (3 downto 0);
    begin
        temp <= gray;
        with temp select 
        bar_graph <= "1111111110" when "0000",
        <= "1111111100" when "0001", -- ERROR ON THIS LINE.
        <= "1111111000" when "0011",
        <= "1111110000" when "0010",
        <= "1111100000" when "0110",
        <= "1111000000" when "0111",
        <= "1110000000" when "0101",
        <= "1100000000" when "0100",
        <= "1000000000" when "1100",
        <= "0000000000" when "1101",
        <= "0000000000" when others;
    end gray2bar1;
    Here is the error:
    # Error: COMP96_0015: gray_2_bar.vhd : (46, 3): ';' expected.
    # Error: COMP96_0019: gray_2_bar.vhd : (46, 3): Keyword "end" expected.
    # Error: COMP96_0016: gray_2_bar.vhd : (46, 6): Design unit declaration expected.

    Also I am trying to write the same code using Conditional Statement, but I am not sure how to do it if my variables involve std_logic_vectors. If someone can point me in the right direction, that would be great. Also any help with this code too would be greatly appreciated.

    Thanks
    sarovarc, Mar 2, 2011
    #1
    1. Advertising

  2. sarovarc

    sarovarc

    Joined:
    Mar 2, 2011
    Messages:
    2
    Just wanted to post that I figured both out. Stupid error really.
    sarovarc, Mar 2, 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. Maka Sili
    Replies:
    0
    Views:
    500
    Maka Sili
    Aug 25, 2004
  2. Maka Sili
    Replies:
    0
    Views:
    395
    Maka Sili
    Aug 25, 2004
  3. Leo Duran
    Replies:
    0
    Views:
    894
    Leo Duran
    Aug 6, 2003
  4. Srinivas Rao \(Rbin/eds2\)

    gray code

    Srinivas Rao \(Rbin/eds2\), Oct 22, 2003, in forum: C Programming
    Replies:
    6
    Views:
    2,694
    Dave Von Pless
    Oct 24, 2003
  5. baigsku
    Replies:
    1
    Views:
    1,496
    joris
    Dec 14, 2009
Loading...

Share This Page