Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module specialfunc(
- input [3:0] p1_bounce, p2_bounce, p1_score, p2_score, // Bounce signals and scores
- input [10:0] x_paddle1, x_paddle2, x_ball, // X-coordinates of paddles and ball
- input [9:0] y_paddle1, y_paddle2, // Y-coordinates of paddles
- input p1_touch, p2_touch, clk, specialfunc_call, // Touch signals, clock, and special function call
- output reg [1:0] paddlesize_switcher // Output for paddle size switcher
- );
- reg p1_touch_init, p2_touch_init; // Initial touch signals for debounce
- reg [3:0] p1_score_init, p2_score_init; // Initial scores for debounce
- reg flag_1 = 1'd0; // Flag for paddle 1
- reg fl_2 = 1'd0; // Flag for paddle 2
- localparam H_active = 11'd1279; // Horizontal active area
- localparam BoundLR_offset = 10'd265; // Left and right bounds offset
- localparam ballwidth = 11'd20; // Width of the ball
- always @(posedge clk) begin
- // Check if player 2 bounces and the special function is called on the right side
- if (p2_bounce == 4'd3 && specialfunc_call && x_paddle2 > 841) begin
- p1_touch_init <= p1_touch; // Store initial touch signals
- p2_touch_init <= p2_touch;
- // Check for touch changes to avoid debounce
- if (p1_touch_init != p1_touch || p2_touch_init != p2_touch)
- paddlesize_switcher[0] <= 0; // Set switcher based on touch changes
- else
- paddlesize_switcher[0] <= 1; // Reset switcher if no touch changes
- end
- // Check if player 1 bounces and the special function is called on the left side
- else if (p1_bounce == 4'd3 && specialfunc_call && x_paddle1 < 438) begin
- p1_touch_init <= p1_touch; // Store initial touch signals
- p2_touch_init <= p2_touch;
- // Check for touch changes to avoid debounce
- if (p1_touch_init != p1_touch || p2_touch_init != p2_touch)
- paddlesize_switcher[1] <= 0; // Set switcher based on touch changes
- else
- paddlesize_switcher[1] <= 1; // Reset switcher if no touch changes
- end
- else begin
- paddlesize_switcher <= 2'b00; // Reset switcher if no special function
- end
- end
- endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement