Stepper-Motor-Control  v3.0.0
System on a Chip 2014 - Group 04
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
key_detect_tut.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 --! @file key_detect_tut.vhd
3 --! @author Prof. Dr.-Ing. Ferdinand Englberger
4 --! @version V3.0.2
5 --! @date 14.12.2012
6 --!
7 --! @brief Key-Detector
8 --! @details The component detects a press of key and
9 --! gererates a detection signal for one clock period
10 --!
11 --! @par History:
12 --! @details V3.0.2 Ferdinand Englberger
13 --! - english comments
14 --! @details V3.0.1 13.12.2011 Ferdinand Englberger
15 --! - Umlaut in comments
16 --! @details V3.0.0 25.12.2010 Ferdinand Englberger
17 --! - start of development for this component
18 -------------------------------------------------------------------------------
19 
20 --! Use Standard Library
21 LIBRARY ieee;
22 --! Use Logic Elements
23 USE ieee.std_logic_1164.all;
24 --! Use Conversion Functions
25 USE ieee.std_logic_arith.all;
26 --! Use Conversion Functions
27 USE ieee.std_logic_signed.all;
28 
29 --! @brief Tutorial-Component Key-Detector
30 entity key_detect_tut is
31  port
32  (
33  clock : in STD_LOGIC; --! Component Clock
34  reset_n : in STD_LOGIC; --! Component Reset
35  key_input : in STD_LOGIC; --! Siggnal vom Taster
36  key_detect : out STD_LOGIC --! Detect-Signal for key
37  );
38 end key_detect_tut;
39 
40 --! @brief Architecture of Key-Detector
41 --! @details a key is debounced and a detect signal
42 --! is generated (1 clock period)
43 architecture mykeydetect of key_detect_tut is
44 
45  --! Statedefinition for key detector
46  TYPE STATE_TYPE IS (start, newpress, pressed);
47  --! State signal for key detector
48  SIGNAL STkey: STATE_TYPE;
49 
50 begin
51  --! @brief detect and debounce the press of a key
52  --! at key-input-line. Generate a press detect
53  --! signal (1 clock period))
54  debounce : process (clock, reset_n, key_input)
55  begin
56  if (reset_n = '0') THEN
57  STkey <= start;
58  elsif (rising_edge(clock)) THEN
59  case STkey IS
60  when start =>
61  if(key_input = '0') THEN
62  STkey <= newpress;
63  else
64  STkey <= STkey;
65  end if;
66  when newpress =>
67  STkey <= pressed;
68  when pressed =>
69  if(key_input = '1') THEN
70  STkey <= start;
71  else
72  STkey <= STkey;
73  end if;
74  when others => STkey <= start;
75  end case;
76  end if;
77  end process;
78 
79  key_detect <= '1' WHEN STkey = newpress ELSE
80  '0';
81 end mykeydetect;
_library_ ieeeieee
Use Standard Library.
in reset_nSTD_LOGIC
Component Reset.
in key_inputSTD_LOGIC
Siggnal vom Taster.
Tutorial-Component Key-Detector.
in clockSTD_LOGIC
Component Clock.
out key_detectSTD_LOGIC
Detect-Signal for key.