-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathposition_mover.sv
46 lines (40 loc) · 1.26 KB
/
position_mover.sv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 11/17/2020 01:25:32 PM
// Design Name:
// Module Name: position_mover
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module position_mover( // module to detect and store movement of player (right or left)
input RBTN, // right button
input LBTN, // left button
input clock,
input rst,
output [2:0] columnPosition
);
logic [2:0] position = 3'b011;
always_ff @(posedge clock) begin
if (rst)
position <= 3'b011;
else begin
if(RBTN && !LBTN && position < 6) // right movement, if the right button is pressed but the left button not pressed (to account for both buttons being pressed at the same time)
position <= position + 1;
else if (LBTN && !RBTN && position > 0) // left movement
position <= position - 1;
end
end
assign columnPosition = position;
endmodule