Need to time outputs

Discussion in 'VHDL' started by RRamsey118, Dec 1, 2008.

  1. RRamsey118

    RRamsey118

    Joined:
    Dec 1, 2008
    Messages:
    2
    Hey I'm supposed to be making a digital pattern generator for class, but I can't figure out how to slow down the outputs. When I use the logic analyzer it only goes gets the last output. I tried using wait statements but I can only have one per process. My book is pretty crappy and I can't seem to really find anything on the internet, can someone help me out?

    Edit: forgot to mention some of the inptus, scancode_in is a command from a ps2 keyboard, with F0 saying released key and 5A signifying return. Choice is controlled by scan code in a different part of the system. Clock_48MHZ is a 48mhz clock on the board we're using. Custom input is just a custom input std_logic vector, don't really care about timing on that one.

    My code
    Code (Text):
    LIBRARY IEEE;
    USE IEEE.STD_LOGIC_1164.ALL;
    USE IEEE.STD_LOGIC_ARITH.ALL;
    USE IEEE.STD_LOGIC_UNSIGNED.ALL;

    ENTITY PRESETS IS
        PORT(   current_choice      :IN     STD_LOGIC_VECTOR(3 DOWNTO 0);
                custom_input        :IN     STD_LOGIC_VECTOR(17 DOWNTO 0);
                preset_output       :OUT    STD_LOGIC_VECTOR(17 DOWNTO 0);
                scancode_in         :IN     STD_LOGIC_VECTOR(7 DOWNTO 0);
                clk_48mhz           :IN     STD_LOGIC);
    END PRESETS;
       
    ARCHITECTURE a OF PRESETS IS
        SIGNAL SCANLAST                 :STD_LOGIC_VECTOR(7 DOWNTO 0);
        SIGNAL preset_last              :STD_LOGIC_VECTOR(17 DOWNTO 0);

    BEGIN
        PROCESS(scancode_in, current_choice, clk_48mhz)
            BEGIN
                IF ((scancode_in = x"5A") AND (SCANLAST = x"F0")) THEN
                    CASE current_choice(3 DOWNTO 0) IS
                        WHEN "0000" =>  -- Count up
                            preset_last(17 downto 0) <= "000000000000000000";
                            preset_output <= preset_last;
                           
                           
                        WHEN "0001" => -- count down
                            preset_last(17 downto 0) <= "111111111111111111";
                            preset_output <= preset_last;
                           

                           
                        WHEN "0010" => --BIT SHIFT L to R
                           
                            preset_last(17 downto 0) <= "000000000000000000";
                            preset_output <= preset_last;
                           
                            preset_last(17 downto 0) <= "100000000000000000";
                            preset_output <= preset_last;                  
                                   
                            for i in 0 to 16 loop
                            preset_output(17-i downto 16-i) <= "01";
                            end loop;
                           
                        WHEN "0011" =>  -- bit shift R to L
                           
                            preset_output(17 downto 0) <= "000000000000000000";
                            preset_output(17 downto 0) <= "000000000000000001";            
                            preset_output(17 downto 0) <= "000000000000000010";            
                            preset_output(17 downto 0) <= "000000000000000100";                    
                            preset_output(17 downto 0) <= "000000000000001000";                    
                            preset_output(17 downto 0) <= "000000000000010000";
                            preset_output(17 downto 0) <= "000000000000100000";
                            preset_output(17 downto 0) <= "000000000001000000";
                            preset_output(17 downto 0) <= "000000000010000000";
                            preset_output(17 downto 0) <= "000000000100000000";
                            preset_output(17 downto 0) <= "000000001000000000";
                            preset_output(17 downto 0) <= "000000010000000000";
                            preset_output(17 downto 0) <= "000000100000000000";
                            preset_output(17 downto 0) <= "000001000000000000";
                            preset_output(17 downto 0) <= "000010000000000000";
                            preset_output(17 downto 0) <= "000100000000000000";
                            preset_output(17 downto 0) <= "001000000000000000";
                            preset_output(17 downto 0) <= "010000000000000000";
                            preset_output(17 downto 0) <= "100000000000000000";
                       
                        WHEN "0100" => -- all bits on from L to R              
                           
                            preset_output <= "000000000000000000";
                            preset_output <= "100000000000000000";
                            preset_output <= "110000000000000000";
                            preset_output <= "111000000000000000";
                            preset_output <= "111100000000000000";
                            preset_output <= "111110000000000000";
                            preset_output <= "111111000000000000";
                            preset_output <= "111111100000000000";
                            preset_output <= "111111110000000000";
                            preset_output <= "111111111000000000";
                            preset_output <= "111111111100000000";
                            preset_output <= "111111111110000000";
                            preset_output <= "111111111111000000";
                            preset_output <= "111111111111100000";
                            preset_output <= "111111111111110000";
                            preset_output <= "111111111111111000";
                            preset_output <= "111111111111111100";
                            preset_output <= "111111111111111110";
                            preset_output <= "111111111111111111";
                       
                       
                        WHEN "0110" => --OR all bits off from L to R
                            preset_output <= NOT "000000000000000000";
                            preset_output <= NOT "110000000000000000";
                            preset_output <= NOT "111000000000000000";
                            preset_output <= NOT "111100000000000000";
                            preset_output <= NOT "111110000000000000";
                            preset_output <= NOT "111111000000000000";
                            preset_output <= NOT "111111100000000000";
                            preset_output <= NOT "111111110000000000";
                            preset_output <= NOT "111111111000000000";
                            preset_output <= NOT "111111111100000000";
                            preset_output <= NOT "111111111110000000";
                            preset_output <= NOT "111111111111000000";
                            preset_output <= NOT "111111111111100000";
                            preset_output <= NOT "111111111111110000";
                            preset_output <= NOT "111111111111111000";
                            preset_output <= NOT "111111111111111100";
                            preset_output <= NOT "111111111111111110";
                            preset_output <= NOT "111111111111111111";

                        WHEN "0101" => -- all bits on from R to L
                            preset_output <= "000000000000000001";
                            preset_output <= "000000000000000011";
                            preset_output <= "000000000000000111";
                            preset_output <= "000000000000001111";
                            preset_output <= "000000000000011111";
                            preset_output <= "000000000000111111";
                            preset_output <= "000000000001111111";
                            preset_output <= "000000000011111111";
                            preset_output <= "000000000111111111";
                            preset_output <= "000000001111111111";
                            preset_output <= "000000011111111111";
                            preset_output <= "000000111111111111";
                            preset_output <= "000001111111111111";
                            preset_output <= "000011111111111111";
                            preset_output <= "000111111111111111";
                            preset_output <= "001111111111111111";
                            preset_output <= "011111111111111111";
                            preset_output <= "111111111111111111";
                       
                       
                        WHEN "0111" => -- all bits off from R to L
                            preset_output <= NOT "000000000000000001";
                            preset_output <= NOT "000000000000000011";
                            preset_output <= NOT "000000000000000111";
                            preset_output <= NOT "000000000000001111";
                            preset_output <= NOT "000000000000011111";
                            preset_output <= NOT "000000000000111111";
                            preset_output <= NOT "000000000001111111";
                            preset_output <= NOT "000000000011111111";
                            preset_output <= NOT "000000000111111111";
                            preset_output <= NOT "000000001111111111";
                            preset_output <= NOT "000000011111111111";
                            preset_output <= NOT "000000111111111111";
                            preset_output <= NOT "000001111111111111";
                            preset_output <= NOT "000011111111111111";
                            preset_output <= NOT "000111111111111111";
                            preset_output <= NOT "001111111111111111";
                            preset_output <= NOT "011111111111111111";
                            preset_output <= NOT "111111111111111111";
                       
                        WHEN ("1000" OR "1001")=> -- Zeros with collapsing ones
                            preset_last <= "000000000000000000";
                            IF current_choice="1001" THEN
                            preset_output <= preset_last(17 downto 0); --for collapsing ones
                            ELSE
                            preset_output <= NOT preset_last;       -- for collapsing zeros
                            end if;
                            preset_last <= "100000000000000001";
                            IF current_choice="1001" THEN
                            preset_output <= preset_last(17 downto 0); --for collapsing ones
                            ELSE
                            preset_output <= NOT preset_last;       -- for collapsing zeros
                            end if;
                            preset_last <= "110000000000000011";
                            IF current_choice="1001" THEN
                            preset_output <= preset_last(17 downto 0); --for collapsing ones
                            ELSE
                            preset_output <= NOT preset_last;       -- for collapsing zeros
                            end if;
                            preset_last <= "111000000000000111";
                            IF current_choice="1001" THEN
                            preset_output <= preset_last(17 downto 0); --for collapsing ones
                            ELSE
                            preset_output <= NOT preset_last;       -- for collapsing zeros
                            end if;
                            preset_last <= "111100000000001111";
                            IF current_choice="1001" THEN
                            preset_output <= preset_last(17 downto 0); --for collapsing ones
                            ELSE
                            preset_output <= NOT preset_last;       -- for collapsing zeros
                            end if;
                            preset_last <= "111110000000011111";
                            IF current_choice="1001" THEN
                            preset_output <= preset_last(17 downto 0); --for collapsing ones
                            ELSE
                            preset_output <= NOT preset_last;       -- for collapsing zeros
                            end if;
                            preset_last <= "111111000000111111";
                            IF current_choice="1001" THEN
                            preset_output <= preset_last(17 downto 0); --for collapsing ones
                            ELSE
                            preset_output <= NOT preset_last;       -- for collapsing zeros
                            end if;
                            preset_last <= "111111100001111111";
                            IF current_choice="1001" THEN
                            preset_output <= preset_last(17 downto 0); --for collapsing ones
                            ELSE
                            preset_output <= NOT preset_last;       -- for collapsing zeros
                            end if;
                            preset_last <= "111111110011111111";
                            IF current_choice="1001" THEN
                            preset_output <= preset_last(17 downto 0); --for collapsing ones
                            ELSE
                            preset_output <= NOT preset_last;       -- for collapsing zeros
                            end if;
                            preset_last <= "111111111111111111";
                            IF current_choice="1001" THEN
                            preset_output <= preset_last(17 downto 0); --for collapsing ones
                            ELSE
                            preset_output <= NOT preset_last;       -- for collapsing zeros
                            end if;
                       
                        WHEN OTHERS =>
                            -- do nothing
                       
                    end case;
               
                end if;
               
                IF current_choice = "1010" THEN
                    preset_output(17 downto 0) <= custom_input(17 downto 0);
                END IF;
                   
                SCANLAST <= SCANCODE_IN;
       
    END PROCESS;



    END a;
     
    Last edited: Dec 1, 2008
    RRamsey118, Dec 1, 2008
    #1
    1. Advertisements

  2. RRamsey118

    jeppe

    Joined:
    Mar 10, 2008
    Messages:
    348
    Location:
    Denmark
    Well you must realize - when a signal assigned inside a process will it always be the last assignment that "wins". All the previous "forgotten".

    Please search for the intactive book at VHDL - Evita to learn more - speciallly chapter 6.

    My surgestion will be:

    1) Put wait for xx ns (but Im not sure this will work together with the sensitivitylist)
    2) put after xx ns statements like xx<"00" after 1 ns (same problem as above)
    3) make a more complex statemachine driven by the 48 MHz clock (complicated :-(

    Hope this made sense
    Jeppe
     
    jeppe, Dec 1, 2008
    #2
    1. Advertisements

  3. RRamsey118

    RRamsey118

    Joined:
    Dec 1, 2008
    Messages:
    2
    I tried using "wait for XX ns;" and the thing yelled at me saying I needed "until" which seems wrong to me. Either way I don't think it'll let me have multiple wait statements will it?

    Either way, I guess I'll start working on a different design then. Thanks.
    (unless someone has a magic fix, which would be awesome)
     
    RRamsey118, Dec 1, 2008
    #3
  4. RRamsey118

    jeppe

    Joined:
    Mar 10, 2008
    Messages:
    348
    Location:
    Denmark
    Well indeed: The only way your allowed to generate this kind waveform will be some kind of state machine, counter or shiftregister which controlled by the 48MHz clock.
    I forgot to mention - The wait for statement not for synthesizing.
    Jeppe
     
    jeppe, Dec 2, 2008
    #4
    1. Advertisements

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. E. Backhus
    Replies:
    2
    Views:
    7,192
    Alain
    Jul 25, 2003
  2. talgry@yahoo.com
    Replies:
    1
    Views:
    630
    mike_treseler
    Nov 29, 2004
  3. Martijn van Pottelberghe

    outputs are in conflict most of the time

    Martijn van Pottelberghe, Sep 27, 2006, in forum: VHDL
    Replies:
    8
    Views:
    656
  4. john sun
    Replies:
    2
    Views:
    428
    Tim Mackey
    Jan 23, 2007
  5. flamesrock
    Replies:
    8
    Views:
    615
    Hendrik van Rooyen
    Nov 24, 2006
Loading...

Share This Page