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.

rotary switch & buttons VHDL

Status
Not open for further replies.

tferguson

Newbie level 3
Joined
Dec 7, 2010
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,306
Hello - I am trying to create a counter that will increment and decrement based on the direction the switch is turned. The counter is easy, but how do I read the input?
 

something like this?

Code:
process(clk)
begin
  if rising_edge(clk) then
    
    --------------------
    --Increment
    --------------------
    if switch = '1' then
      counter <= counter + 1;
      
    else
      counter <= counter - 1;
    end if;
  end if;
end process;
 

something like this?

Code:
process(clk)
begin
  if rising_edge(clk) then
    
    --------------------
    --Increment
    --------------------
    if switch = '1' then
      counter <= counter + 1;
      
    else
      counter <= counter - 1;
    end if;
  end if;
end process;

Thank you for the post, but the logic of the counter isn't my issue...it's how do you obtain the input from a button or switch?

T
 

You need to route the switch to a pin on the FPGA on your circuit board.
 

That sort of makes sense. The switch isn't part of the FPGA, so I need to assign an input (button or switch) that is on the board, to an input on the FPGA?

This is what I'm trying to do:

A synchronous up/down counter in VHDL that:
-Counts from 0 to FFFF.
-Uses the rotary switch to increment (rotate right) and decrement counter (rotate left).
-2 Push Buttons (pick any 2 of 4 available): one for an asynchronous reset (starts @ 0) & an a “synchronous” (hold button & rotate left or right) preset (starts @ BEEF). Need to de-bounce these switches in software.
-Write the count value to an LCD

So far, I have a counter :)

I respect and hate this stuff all at the same time :O
 

That sort of makes sense. The switch isn't part of the FPGA, so I need to assign an input (button or switch) that is on the board, to an input on the FPGA?

Yes. If you have a development board, the switches will already be connected to FPGA pins. You just need to map a top level input in your code to that pin on the FPGA.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top