jdh_1984
Member level 2
I am planning to design a circuit which is calculating the linear movement to a wheel, with input from encoders. Sine I am new to VHDL I have designed a simplified circuit for testing the “code” at a Altera DE2-70 evaluation board.
I currently having a hard time to design this simple up/down counter (with push buttons as control to the up/down value). The problem is random view of number at the BCD when the buttons are activated. My code is as follows:
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity test is
port
(
a :IN STD_LOGIC;
b :IN STD_LOGIC;
result :OUT UNSIGNED(6 downto 0));
end entity;
Architecture rtl of test is
signal n6 : UNSIGNED (3 downto 0);
begin
PROCESS(a,b)
begin
IF (a = '1' AND n6<"1111" ) THEN
n6<=n6 + 1;
ELSIF (b='1' AND n6>"0000") THEN
n6<=n6 - 1;
END IF;
--Seven segment view
Case n6 IS
WHEN "0000"=>
result<="1000000" ;
:
:
:
result<="0001110";
END CASE;
END PROCESS;
END rtl;
Could it be the “bouncing” that occurs when the button is activated that cause the trouble?
Have I understood the PROCESS keyword right when I compare this to raising a event in other programming language? I.e when one of the variables in the sensitivity list changes value, the contents of the process is executed.
I currently having a hard time to design this simple up/down counter (with push buttons as control to the up/down value). The problem is random view of number at the BCD when the buttons are activated. My code is as follows:
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity test is
port
(
a :IN STD_LOGIC;
b :IN STD_LOGIC;
result :OUT UNSIGNED(6 downto 0));
end entity;
Architecture rtl of test is
signal n6 : UNSIGNED (3 downto 0);
begin
PROCESS(a,b)
begin
IF (a = '1' AND n6<"1111" ) THEN
n6<=n6 + 1;
ELSIF (b='1' AND n6>"0000") THEN
n6<=n6 - 1;
END IF;
--Seven segment view
Case n6 IS
WHEN "0000"=>
result<="1000000" ;
:
:
:
result<="0001110";
END CASE;
END PROCESS;
END rtl;
Could it be the “bouncing” that occurs when the button is activated that cause the trouble?
Have I understood the PROCESS keyword right when I compare this to raising a event in other programming language? I.e when one of the variables in the sensitivity list changes value, the contents of the process is executed.