From d71b817e4989105aaa291dc00ec0636b41a7c3af Mon Sep 17 00:00:00 2001 From: Eugene Lozovoy Date: Fri, 4 Oct 2024 12:55:22 +0300 Subject: [PATCH] optimize ps/2 keyboard scancodes fifo --- rtl/periph/keyboard.v | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/rtl/periph/keyboard.v b/rtl/periph/keyboard.v index fee079d..ac3058f 100644 --- a/rtl/periph/keyboard.v +++ b/rtl/periph/keyboard.v @@ -329,7 +329,7 @@ always @(posedge clk) begin 2'd0: begin if (!fifo_empty) begin fifo_rdreq <= 1'b1; - step <= step + 1'b1; + step <= 2'd1; end end @@ -341,23 +341,22 @@ always @(posedge clk) begin else scancode <= fifo_q[7:0]; if (scancode_ack) - step <= step + 1'b1; + step <= (fifo_q[8] || fifo_q[9])? 2'd2 : 2'd0; end 2'd2: begin if (fifo_q[9] && fifo_q[8]) scancode <= 8'hF0; - else if (fifo_q[8] || fifo_q[9]) + else scancode <= fifo_q[7:0]; if (scancode_ack) - step <= step + 1'b1; + step <= (fifo_q[8] && fifo_q[9])? 2'd3 : 2'd0; end 2'd3: begin - if (fifo_q[9] && fifo_q[8]) - scancode <= fifo_q[7:0]; + scancode <= fifo_q[7:0]; if (scancode_ack) - step <= step + 1'b1; + step <= 0; end endcase