OpenCores
URL https://opencores.org/ocsvn/a-z80/a-z80/trunk

Subversion Repositories a-z80

[/] [a-z80/] [trunk/] [host/] [zxspectrum_de1/] [ula/] [zx_kbd.sv] - Diff between revs 8 and 10

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 8 Rev 10
Line 1... Line 1...
//============================================================================
//============================================================================
// Implementation of the ZX Spectrum keyboard input generator
// ZX Spectrum keyboard input
// This module takes scan-codes from the PS/2 keyboard input and sets
//
// corresponding ZX key bitfields which are read by IN (FE) instructions.
// This module takes scan-codes from the attached PS/2 keyboard and sets
 
// corresponding ZX key bitfields which are read by the 'IN' instructions.
//
//
// PS/2      |  ZX Spectrum
// PS/2      |  ZX Spectrum
// ----------+-----------------
// ----------+-----------------
// CTRL      |  CAPS SHIFT
// CTRL      |  CAPS SHIFT
// ALT       |  SYMBOL SHIFT
// ALT       |  SYMBOL SHIFT
//
//
// In addition to regular alpha-numeric keys, this code simulates many standard
// For convenience, in addition to regular alpha-numeric keys, this code
// symbols on the PS/2 keyboard for convenience.
// simulates several other standard symbols on the PS/2 keyboard.
//
//
// PS/2      |  ZX Spectrum
// PS/2      |  ZX Spectrum
// ----------+-----------------
// ----------+-----------------
// BACKSPACE |  DELETE
// BACKSPACE |  DELETE
// Arrows Left, Right, Up, Down
// Arrows Left, Right, Up, Down
// ESC       |  BREAK (CAPS+SPACE)
// ESC       |  BREAK (CAPS+SPACE)
// SHIFT => PS/2 shift for these separate additional keys: -_ += ;: "' <, >. ?/
// SHIFT => PS/2 shift for additional keys: -_ += ;: "' <, >. ?/
//
//
//  Copyright (C) 2014-2016  Goran Devic
//  Copyright (C) 2014-2016  Goran Devic
//
//
//  This program is free software; you can redistribute it and/or modify it
//  This program is free software; you can redistribute it and/or modify it
//  under the terms of the GNU General Public License as published by the Free
//  under the terms of the GNU General Public License as published by the Free
Line 35... Line 36...
//  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//============================================================================
//============================================================================
module zx_keyboard
module zx_keyboard
(
(
    input wire clk,
    input wire clk,
    input wire reset,           // Reset (negative logic)
    input wire nreset,          // Active low reset
 
 
    // Output ZX-specific keyboard codes when requested by the ULA access
    // Output ZX-specific keyboard codes when requested by the ULA access
    input wire [15:0] A,        // Address bus
    input wire [15:0] A,        // Address bus
    output wire [4:0] key_row,  // Output the state of a requested row of keys
    output wire [4:0] key_row,  // Output the state of a requested row of keys
 
 
Line 61... Line 62...
 
 
// Calculate a "key is pressed" signal
// Calculate a "key is pressed" signal
assign pressed = ~(&keys[7] & &keys[6] & &keys[5] & &keys[4] & &keys[3] & &keys[2] & &keys[1] & &keys[0]);
assign pressed = ~(&keys[7] & &keys[6] & &keys[5] & &keys[4] & &keys[3] & &keys[2] & &keys[1] & &keys[0]);
 
 
// Output requested row of keys continously
// Output requested row of keys continously
always @(*) // always_comb
assign key_row =
begin
    (~A[8]  ? keys[0] : 5'b11111) &
    case (A[15:8])
    (~A[9]  ? keys[1] : 5'b11111) &
        8'b11111110: key_row = keys[0];
    (~A[10] ? keys[2] : 5'b11111) &
        8'b11111101: key_row = keys[1];
    (~A[11] ? keys[3] : 5'b11111) &
        8'b11111011: key_row = keys[2];
    (~A[12] ? keys[4] : 5'b11111) &
        8'b11110111: key_row = keys[3];
    (~A[13] ? keys[5] : 5'b11111) &
        8'b11101111: key_row = keys[4];
    (~A[14] ? keys[6] : 5'b11111) &
        8'b11011111: key_row = keys[5];
    (~A[15] ? keys[7] : 5'b11111);
        8'b10111111: key_row = keys[6];
 
        8'b01111111: key_row = keys[7];
 
    default:
 
        key_row = 5'b11111;
 
    endcase
 
end
 
 
 
always @(posedge clk or negedge reset)
always @(posedge clk or negedge nreset)
begin
begin
    if (!reset) begin
    if (!nreset) begin
        released <= 0;
        released <= 0;
        extended <= 0;
        extended <= 0;
        shifted  <= 0;
        shifted  <= 0;
 
 
        keys[0] <= '1;
        keys[0] <= '1;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.