Fsm ps2data
From HDLBits
fsm_ps2Previous
Nextfsm_serial
See also: PS/2 packet parser.
Now that you have a state machine that will identify three-byte messages in a PS/2 byte stream, add a datapath that will also output the 24-bit (3 byte) message whenever a packet is received (out_bytes[23:16] is the first byte, out_bytes[15:8] is the second byte, etc.).
out_bytes needs to be valid whenever the done signal is asserted. You may output anything at other times (i.e., don't-care).
For example:
Module Declaration
module top_module( input clk, input [7:0] in, input reset, // Synchronous reset output [23:0] out_bytes, output done);
fsm_ps2Previous
Nextfsm_serial