Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

VHDL for CPLD Code for Button On Release Enable

Status
Not open for further replies.

JoK3r

Newbie level 1
Joined
Apr 20, 2009
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,289
enable vhdl

Hi ALL,

I am new to this forum and I am in need of a big hand of help here.

How do I make my VHDL Codes to execute ONLY when an 'enter' button is pressed and released i.e. not pressed all the time?

So the enter button would work 'like' a reset button, except that the button enables my codes to be executed.

I know I just can't simple write something like

if enter = '0' then
bla bla bla..
end if;

as then enter would change from 1 to 0 to 1 (Active Low Logic) when the button is pressed, thus disabling code execution at the next clock cycle.

Will somebody be able to help me with this?

Thanks in advance
 

cpld code

You have to detect a change of the key so we need a register which holds the old state of the key:

Code:
  signal PreviousKey: std_logic;

I assume there is also a signal which has the current state of the key (could be the direct 'hardware' key, or a debounced state of it):

Code:
  signal CurrentKey: std_logic;

And then in a process we check if the key has changed:
Code:
process (clk)
begin
  if rising_edge(clk) then
    -- Check if the key has changed
    if (CurrentKey != PreviousKey) then
      -- The key has changed; check for press or release
      if (CurrentKey = '0') then
        -- The key has been released ...
      else
        -- The key has been pressed ...
      end if;
    end if;
    -- Record the current state (so we can detect a change)
    PreviousKey <= CurrentKey;
  end if;
end process;


Note: This code has not been (syntax) checked by any means so keep that in mind.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top