Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- `timescale 1ns / 1ps
- //////////////////////////////////////////////////////////////////////////////////
- // Company:
- // Engineer:
- //
- // Create Date: 31.03.2020 13:05:10
- // Design Name:
- // Module Name: draw_rect_ctl
- // Project Name:
- // Target Devices:
- // Tool Versions:
- // Description:
- //
- // Dependencies:
- //
- // Revision:
- // Revision 0.01 - File Created
- // Additional Comments:
- //
- //////////////////////////////////////////////////////////////////////////////////
- module draw_rect_ctl(
- input wire clk,
- input wire mouse_left,
- input wire [11:0] mouse_xpos,
- input wire [11:0] mouse_ypos,
- output reg [11:0] xpos,
- output reg [11:0] ypos
- );
- localparam
- licznik = 1000000,
- final_y = 535;
- reg [19:0] counter = 0;
- reg [19:0] counter_nxt = 0;
- reg [11:0] time_counter = 0;
- reg [11:0] time_counter_nxt = 0;
- reg [11:0] initial_x, initial_y;
- reg [11:0] current_y, current_x;
- reg movement = 0;
- always @(posedge mouse_left)
- begin
- initial_y = mouse_ypos;
- end
- always @*
- begin
- counter_nxt = counter;
- if ((counter == licznik) && (mouse_left == 1) && (movement == 1))
- begin
- counter_nxt = 0;
- time_counter_nxt = time_counter + 1;
- end
- if (mouse_left == 1)
- begin
- current_y = initial_y + time_counter;
- end
- if ((current_y >= final_y) && (mouse_left == 1))
- begin
- //position_counter_nxt = 12'b000000000000;
- movement = 0;
- current_y = final_y;
- end
- if (mouse_left == 1'b0)
- begin
- current_x = mouse_xpos;
- current_y = mouse_ypos;
- time_counter_nxt = 0;
- counter_nxt = 0;
- movement = 1;
- end
- end
- always @(posedge clk)
- begin
- counter <= counter_nxt + 1;
- time_counter <= time_counter_nxt;
- ypos <= current_y;
- xpos <= current_x;
- end
- endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement