- Joined
- Dec 1, 2008
- Messages
- 2
- Reaction score
- 0
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
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:
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: