-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpipe.v
73 lines (64 loc) · 1.96 KB
/
pipe.v
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 11/18/2023 11:05:03 AM
// Design Name:
// Module Name: pipe
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module pipe #(parameter Initial_pipe_X = 500, Initial_pipe_Y = 400, PIPE_VEL = 10000)
(input clk, input initalize,
// input PIPE_VEL,
// input Initial_pipe_X,
// input Initial_pipe_Y,
output [10:0] pipe_x,
output [9:0] pipe_y);
//////Pipes
// Define initial values for pipe
//parameter initial_pipe_x = 500;
//parameter initial_pipe_y = 400;
//reg enable = 1;
reg [10:0] pipe_X = Initial_pipe_X;
reg [9:0] pipe_Y = Initial_pipe_Y;
// Velocity logic
reg [9:0] pipe_counter = 0;
reg [2:0] pipe_veloc = 0;
// wire [10:0] pipe_x1;
// wire [9:0] pipe_x2;
always @(posedge clk) begin
if (initalize)begin
pipe_X <= Initial_pipe_X;
pipe_Y <= Initial_pipe_Y;
pipe_veloc = 0;
pipe_counter = 0;
end
else if(pipe_counter < PIPE_VEL) begin
pipe_counter <= pipe_counter + 1;
if(pipe_counter % (PIPE_VEL) == 0) ///5000) == 0)// && counter < MAX_COUNTER_VALUE)
pipe_veloc <= pipe_counter / 100;
// Update pipe_x and pipe_y based on velocity
pipe_X <= pipe_X - 4 ; //pipe_veloc;
pipe_Y <= pipe_Y - pipe_veloc ; // 2;
end
else begin
pipe_veloc <= 0;
pipe_counter <= 0;
pipe_X <= Initial_pipe_X;
pipe_Y <= Initial_pipe_Y;
end
end
assign pipe_x = pipe_X;
assign pipe_y = pipe_Y;
endmodule