I am programming a xilinx basys 3 board in behavioral VHDL. I am illuminating the individual segments of the 4x seven segment display to make it looks as though the display has two rotating "wheels". My overall project consists of many components such as a decoder, mux, debouncer, counter, clock divider for display refresh rate, etc. All of which have been cleared by my prof. I am currently working on the component that takes in a 250 Hz clk and an up and down button. The up and down buttons will allow for the incrementation of a counter that is mapped to 11 different prescalar values. These values will then vary a clock divider max step accordingly.
Currently my reset button works. However the up and down buttons just pause the rotation of the segments instead of increasing the rate at which they rotate. I believe this component is the issue but I cannot find out where, within the three processes.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.std_logic_unsigned.all;
entity wheelClkDiv is
Port ( btnUp, btnDown, clk, reset : in STD_LOGIC;
--up/down/rst buttons and 250Hz clk initialized as inputs
clkout : out STD_LOGIC
-- newly divided clock initialized as output
);
end wheelClkDiv;
architecture Behavioral of wheelClkDiv is
signal count : STD_LOGIC_VECTOR(19 downto 0) := x"00000"; --20 bit count value for clk divider
signal temp : STD_LOGIC := '0'; --temp store value for clk divider
signal countDiv : STD_LOGIC_VECTOR(19 downto 0) := x"00000"; --value given to choose prescalar
signal btn_counter : STD_LOGIC_VECTOR(3 downto 0) := "0110"; --button press counter
begin
buttonChoose : process(btnUp, btnDown, reset)
begin
if(btnUp = '1') then
btn_counter <= btn_counter + 1; --add one to count if up button pushed
elsif(btnDown = '1') then
btn_counter <= btn_counter - 1; --subtract one from count if down button pushed
elsif(reset = '1') then
btn_counter <="0110"; --set back to middle speed if reset is pushed
end if;
end process;
setDivideCase : process(btn_counter)
begin
case btn_counter is --case statement to choose prescalar based on btn_counter value
when "0000" =>
countDiv <= b"00000000000110010000"; --3.2s cycle
when "0001" =>
countDiv <= b"00000000000100101100"; --2.4s cycle
when "0010" =>
countDiv <= b"00000000000011001000"; --1.6s cycle
when "0011" =>
countDiv <= b"00000000000010010110"; --1.2s cycle
when "0100" =>
countDiv <= b"00000000000001100100"; --0.8s cycle
when "0101" =>
countDiv <= b"00000000000001001011"; --0.6s cycle
when "0110" =>
countDiv <= b"00000000000000110010"; --0.4s cycle
when "0111" =>
countDiv <= b"00000000000000100110"; --0.3s cycle
when "1000" =>
countDiv <= b"00000000000000011001"; --0.2s cycle
when "1001" =>
countDiv <= b"00000000000000010011"; --0.15s cycle
when "1010" =>
countDiv <= b"00000000000000001101"; --0.1s cycle
when others =>
countDiv <= b"00000000000000001101";--not correct
end case;
end process;
wheelDivider : process(clk, reset)
begin
if(reset = '1') then --reset clock count if reset pushed
count <= x"00000";
temp <= '0';
elsif(rising_edge(clk)) then
if(count = countDiv) then --set clk counter value to prescalar
count <= x"00000";
temp <= not temp;
else
count <= count + 1; --keep incrementing clk count until it matches PS
temp <= temp;
end if;
end if;
end process;
clkout <= temp; --give temp value to output clk
end Behavioral;