-- EE 552 Project -- Dustin Demontigny -- March 10, 2003 -- preset_counter.vhd -- toggles between preset values for user interface library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; use work.smart_eq_pack.all; entity preset_counter is port(clock : in std_logic; reset : in std_logic; incr : in std_logic; decr : in std_logic; preset_value : out std_logic_vector(bits-1 downto 0)); end preset_counter; architecture mixed of preset_counter is signal hold : std_logic_vector(bits-1 downto 0); begin toggle_presets : process(clock) -- push button flags variable incr_pressed : integer := 0; variable decr_pressed : integer := 0; begin if clock'event and clock = '1' then -- reset to preset 0 if reset = '0' then hold <= "0000"; -- if either pushbutton is pressed, set the flag elsif incr = '0' then incr_pressed := 1; elsif decr = '0' then decr_pressed := 1; -- if pushbuttons are not pressed check for flag -- and increment or decrement preset value accordingly elsif incr_pressed = 1 then hold <= hold + "0001"; incr_pressed := 0; elsif decr_pressed = 1 then hold <= hold - "0001"; decr_pressed := 0; end if; -- send the hold value to the output every rising clock edge preset_value <= hold; end if; end process; end mixed;