EmbDev.net

Forum: FPGA, VHDL & Verilog VHDL calculator matrix input help.


von ed jones (Guest)


Rate this post
useful
not useful
code for matrix button input so far. getting signals from buttons but 
not sending signals to 4bit led output,
any help would be great.
1
Library IEEE;
2
Use IEEE.STD_LOGIC_1164.ALL;
3
Use IEEE.STD_LOGIC_ARITH.ALL;
4
Use IEEE.STD_LOGIC_UNSIGNED.ALL;
5
 
6
Entity keypad_input is
7
Port( clk                : in std_logic;
8
      col_line           : in  std_logic_vector(2 downto 0);
9
      row_line           : out std_logic_vector(3 downto 0);
10
      Number             : out std_logic_vector(3 downto 0));
11
End keypad_input;
12
 
13
14
Architecture Behavior of keypad_input is 
15
signal sig_c : std_logic_vector(2 downto 0):= "000";
16
signal sig_r : std_logic_vector(3 downto 0):= "0001" ;
17
signal num  : std_logic_VECTOR (3 DOWNTO 0);
18
Signal C0    : std_logic_vector (2 downto 0):= "000";
19
Signal C1    : std_logic_vector (2 downto 0):= "000";
20
Signal C2    : std_logic_vector (2 downto 0):= "000";
21
 
22
begin
23
  
24
-- send signal to rows of keypad --
25
process (clk) is
26
  Begin
27
    If (clk 'event and clk = '0') then
28
  sig_r <= sig_r(0) & sig_r(3 downto 1);        
29
end if;
30
end process;
31
 row_line <= sig_r;
32
 
33
debounce: process (clk,sig_c,col_line) is
34
  Begin
35
    If (Clk 'event and Clk = '1') then
36
       C0 <= C0(1 downto 0) & Col_line(0);
37
       C1 <= C1(1 downto 0) & Col_line(1); 
38
       C2 <= C2(1 downto 0) & Col_line(2);
39
    end if;
40
   
41
sig_c(0) <= C0(0) and C0(1) and (not C0(2));
42
sig_c(1) <= C1(0) and C1(1) and (not C1(2));
43
sig_c(2) <= C2(0) and C2(1) and (not C2(2));
44
 
45
 End process;
46
47
-- read debounces signals --
48
input: Process (num, sig_r, sig_c)  is
49
begin
50
if sig_r = "0001" then
51
  if sig_c(0) = '1' then 
52
    num <= "1110"; -- e
53
  elsif sig_c(1) = '1' then
54
    num <= "0000"; -- 0
55
  elsif sig_c (2) = '1' then 
56
    num <= "1010"; -- a
57
   else null;
58
  end if;
59
  
60
elsif sig_r = "0010" then
61
  if sig_c(0) = '1' then 
62
    num <= "0011"; -- 3
63
  elsif sig_c(1) = '1' then
64
    num <= "0010"; -- 2
65
  elsif sig_c (2) = '1' then  
66
    num <= "0001"; -- 1
67
  else null;
68
  end if;
69
70
elsif sig_r = "0100" then
71
  if sig_c(0) = '1' then 
72
    num <= "0110"; -- 6
73
  elsif sig_c(1) = '1' then
74
    num <= "0101"; -- 5
75
  elsif sig_c (2) = '1' then  
76
    num <= "0100"; -- 4
77
  else null;
78
  end if;
79
80
elsif sig_r = "1000" then
81
  if sig_c(0) = '1' then 
82
    num <= "1001"; -- 9
83
  elsif sig_c(1) = '1' then
84
    num <= "1000"; -- 8
85
  elsif sig_c (2) = '1' then 
86
    num <= "0111"; -- 7
87
  else null;
88
  end if;
89
 end if;  
90
end process;
91
number <= num;
92
93
end Behavior;

: Edited by Moderator
von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Attached files:

Rate this post
useful
not useful
ed jones wrote:
> getting signals from buttons but not sending signals to 4bit led output
How did you find that out? What do you expect? And what do you get 
instead?


BTW1: your "debounce" process suffers three big design flaws.
1. sig_c and col_line are not necessary in the sensitivity list.
2. at the moment C0, C1 and C2 are missing for a correct simualation!!
3. do NOT combine synchronous and combinatorial processes into one.
So finally: only clk must be in that sensitivity list. And after 
"end if" there must follow "end process":
1
  process (clk) begin
2
    If (Clk 'event and Clk = '1') then
3
       -- this is the synchronous process
4
    end if;
5
    -- nothing here!!!!!!!
6
  end process;


BTW2: please read that very short manual for the editbox here. Most 
important is that thing with those [vhdl] tags...

: Edited by Moderator
Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.