HOME       UP       PREV       FURTHER NOTES       NEXT (Counters and Timers)  

Keyboard Controller (scan multiplexed type).

  output [3:0] scankey;
  input pressed;
  reg int_enable, pending;
  reg [3:0] scankey, pkey;

always @(posedge clk) begin if (!pressed) pkey <= scankey; else scankey <= scankey + 1; if (hwen) int_enable <= wdata[0] pressed1 <= pressed; if (!pressed1 && pressed) pending <= 1; if (hren) pending <= 0; end assign interrupt = pending && int_enable; assign rdata = { 28'b0, pkey };

In practice, scan more slowly and use extra register on asynchronous input pressed. Also, have more than one input wire (use a close to square array).

Could use a separate microcontroller to scan keyboard.

This keyboard scanner generates an interrupt on each key press.

Standard PC keyboard generates an output byte on press and release and implements a short FIFO.


27: (C) 2008-11, DJ Greaves, University of Cambridge, Computer Laboratory.