Yes, you're right. I must remember that is it HDL not language programming.
Now so fall edge I detect in this way ...
process(clk20khz, rst)
begin
if rst = '0' then
clk_r <= '0';
elsif (rising_edge(clk20khz)) then
clk_r <= '1';
clk_r <= not clk_r;
end if;
end process;
fall_edge <= clk_r and (not clk20khz);
I get warning that
"code_choice" "code_temp" "Next_State" "start_ps2" "done", which holds its previous value in one or more paths through the process.
How do I remove this warnings?
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.std_logic_signed.all;
entity klaw is
port(
but1, but2, but3 : in std_logic;
clk, rst : in std_logic;
DATA_PS_OUT, CLOCK_PS_OUT : inout std_logic
);
end klaw;
architecture klaw_arch of klaw is
component ps2
port(
rst, clk20khz : in std_logic;
start : in std_logic;
done : out std_logic;
DATA_PS_OUT, CLOCK_PS_OUT : inout std_logic;
dane_we : in std_logic_vector(7 downto 0)
);
end component;
component dzielnik_f
generic(
NBit : integer := 19; --4 --19 - 10Hz
Div : integer := 250000 --2 --250000 - 10Hz
);
port(
clk, rst : in std_logic; --50MHz
clk_out : out std_logic --1MHz
);
end component;
component debounce
port(
clk_in : in std_logic;
D_in : in std_logic;
Q_out : buffer std_logic := '0'
);
end component;
type State is (Read_but, Push, Break, Release);
signal Present_State, Next_State : State;
signal clk10Hz, clk20khz: std_logic;
signal key1, key2, key3 : std_logic;
signal code : std_logic_vector(7 downto 0);
constant PushF5 : std_logic_vector(7 downto 0) := "00111111";
constant PushESC : std_logic_vector(7 downto 0) := "00000001";
constant PushRight : std_logic_vector(7 downto 0) := "01001101";
constant PushLeft : std_logic_vector(7 downto 0) := "01001011";
constant ReleaseKey : std_logic_vector(7 downto 0) := "11110000";
signal start_ps2, done_ps2, done : std_logic;
signal code_temp : std_logic_vector(7 downto 0);
signal code_choice : std_logic_vector(1 downto 0);
begin
deb_clk: dzielnik_f generic map(NBit => 8, div => 16)
port map(clk => clk, rst => rst, clk_out => clk10Hz);
key_1: debounce port map(clk_in => clk10Hz, D_in => but1, Q_out => key1);
key_2: debounce port map(clk_in => clk10Hz, D_in => but2, Q_out => key2);
key_3: debounce port map(clk_in => clk10Hz, D_in => but3, Q_out => key3);
ps2_clk: dzielnik_f generic map(NBit => 9, div => 125)
port map(clk => clk, rst => rst, clk_out => clk20kHz);
ps2_port: ps2 port map(rst => rst, clk20khz => clk20khz, start => start_ps2, done => done_ps2,
DATA_PS_OUT => DATA_PS_OUT, CLOCK_PS_OUT => CLOCK_PS_OUT, dane_we => code);
process(done_ps2, rst)
begin
if( rst = '0') then
done <= '0';
elsif( rising_edge(done_ps2) ) then
done <= '1';
end if;
end process;
process(clk, rst)
begin
if( rst = '0') then
Present_State <= Read_but;
elsif( rising_edge(clk) ) then
Present_State <= Next_State;
end if;
end process;
process(Present_State, key1, key2, key3, done)
begin
-- start_ps2 <= '0';
-- code_temp <= (others => '0');
-- code_choice <= "00";
-- Next_State <= Read_but;
case Present_State is
when Read_but =>
code_choice <= "01";
if(key1 = '1') then
code_temp <= PushF5;
Next_State <= Push;
elsif(key2 = '1') then
code_temp <= PushLeft;
Next_State <= Push;
elsif(key3 = '1') then
code_temp <= PushRight;
Next_State <= Push;
else
Next_State <= Read_but;
end if;
when Push =>
start_ps2 <= '1';
if (done = '1') then
start_ps2 <= '0';
Next_State <= Break;
code_choice <= "10";
end if;
when Break =>
start_ps2 <= '1';
if (done = '1') then
start_ps2 <= '0';
Next_State <= Release;
code_choice <= "01";
end if;
when Release =>
start_ps2 <= '1';
if (done = '1') then
start_ps2 <= '0';
Next_State <= Read_but;
end if;
end case;
end process;
code <= code_temp when code_choice = "01" else
ReleaseKey when code_choice = "10" else (others => 'Z');
end klaw_arch;
Quartus throows warning in line 92 and 96.