data/full_repos/permissive/174323821/hdl/keyboard/jtframe_paddle.v
data/verilator_xmls/882bdc5c-aeae-4efe-b0a2-9d025534be8e.xml
module jtframe_paddle(
    input              rst,
    input              clk,
    input signed [8:0] mouse_dx,
    input              mouse_st,
    output reg   [7:0] paddle
);

`ifdef JTFRAME_PADDLE
    localparam [7:0] PADDLE_MAX = `JTFRAME_PADDLE;
`else
    localparam [7:0] PADDLE_MAX = 0;
`endif

`ifdef JTFRAME_PADDLE_SENS
    localparam PADDLE_SENS = `JTFRAME_PADDLE_SENS;
`else
    localparam PADDLE_SENS = 0;
`endif

reg  [8:0] nx_x;

always @* begin
    nx_x = paddle + mouse_dx;

    if( nx_x[8] ) begin
        nx_x = mouse_dx[8] ? 9'd0 : {1'b0,PADDLE_MAX};
    end
end

always @(posedge clk, posedge rst) begin
    if( rst ) begin
        paddle <= 0;
    end else begin
        if( mouse_st ) paddle <= nx_x[7:0] > PADDLE_MAX ? PADDLE_MAX : nx_x[7:0];
    end
end

endmodule
module jtframe_paddle(
    input              rst,
    input              clk,
    input signed [8:0] mouse_dx,
    input              mouse_st,
    output reg   [7:0] paddle
);


`ifdef JTFRAME_PADDLE
    localparam [7:0] PADDLE_MAX = `JTFRAME_PADDLE;
`else
    localparam [7:0] PADDLE_MAX = 0;
`endif

`ifdef JTFRAME_PADDLE_SENS
    localparam PADDLE_SENS = `JTFRAME_PADDLE_SENS;
`else
    localparam PADDLE_SENS = 0;
`endif

reg  [8:0] nx_x;

always @* begin
    nx_x = paddle + mouse_dx;

    if( nx_x[8] ) begin
        nx_x = mouse_dx[8] ? 9'd0 : {1'b0,PADDLE_MAX};
    end
end

always @(posedge clk, posedge rst) begin
    if( rst ) begin
        paddle <= 0;
    end else begin
        if( mouse_st ) paddle <= nx_x[7:0] > PADDLE_MAX ? PADDLE_MAX : nx_x[7:0];
    end
end

endmodule