I am working with an DE2-70 board and I am trying to use some of it's buttons as inputs. The buttons are activated at 0, and I need to check if two buttons in particular are being pressend separatly, in order to increase/decrease a number.
I tried doing the following, where iKEY are the buttons and position is the number i am trying to modify:
reg [4:0] position;
position = 5'b0;
output wire enable = !(iKEY[3] && iKEY[2]);
always @(posedge enable) begin
if(iKEY[3] == 0)
position = position + 5'b00001;
if(iKEY[2] == 0)
position = position - 5'b00001;
end
I tried several differences of this implementation, such as tring to change the ifs conditions or changing the logic function when setting the enable signal, but I always get stuck in some problem. I am new to hardware logic, so maybe I am thinking in it in the wrong way
Edit: If both buttons are pressed at the same time I expect the hardware to neither increment nor decrement the number