OpenCores
URL https://opencores.org/ocsvn/keyboardcontroller/keyboardcontroller/trunk

Subversion Repositories keyboardcontroller

[/] [keyboardcontroller/] [trunk/] [FSM.vhd] - Blame information for rev 6

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 wouterw
library ieee;
2
use ieee.std_logic_1164.all;
3
use ieee.numeric_std.all;
4
use work.Constants.all;
5
 
6
entity FSM is
7
    port (reset, clk : in  std_logic;
8
                strobe : out std_logic;
9
                sample : out std_logic;
10
                analyse : out std_logic;
11
                store : out std_logic;
12
                produce : out std_logic;
13
                release : out std_logic;
14
                debounced : in std_logic;
15
                keychanged : in std_logic; --keychange found
16
                keyreleased : in std_logic
17
        );
18
end FSM;
19
 
20
architecture FSM_arc of FSM is
21
    signal nState, cState : states;
22
begin
23
 
24
    process
25
    begin
26
    wait until rising_edge(clk);
27
           if( reset = '1' ) then
28
            cState <= idle;
29
           else
30
            cState <= nState;
31
           end if;
32
    end process;
33
 
34
    process(cState, debounced, keychanged, keyreleased)
35
 
36
    begin
37
                case cState is
38
 
39
                when idle =>                                            nState <= strobing;
40
 
41
                when strobing =>                                        nState <= sampling;
42
 
43
                when sampling =>                                        nState <= analysing;
44
 
45
                when analysing =>                                       if (debounced='1') then
46
                                                                                                        nState <= storing;
47
                                                                                                else
48
                                                                                                        nState <= analysing;
49
                                                                                                end if;
50
 
51
                when storing =>                          nState <= storing_stage2;
52
 
53
                when storing_stage2 => if (keychanged='1' and keyreleased='0') then
54
                                                                                                        nState <= producenormal;
55
                                                                                                elsif(keychanged='1' and keyreleased='1') then
56
                                                                                                        nState <= producerelease;
57
                                                                                                elsif (keychanged='0') then
58
                                                                                                        nState <= strobing;
59
                                                                                                end if;
60
 
61
                when producenormal =>                   nState <= strobing;
62
 
63
                when producerelease =>                  nState <= strobing;
64
 
65
                when others =>                                  nState <= idle;
66
 
67
      end case;
68
 
69
        end process;
70
 
71
        strobe <= cState(6);
72
        sample <= cState(5);
73
        analyse <= cState(4);
74
        store <= cState(3);
75
        produce <= cState(2);
76
        release <= cState(1);
77
 
78
        end FSM_arc;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.