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

Subversion Repositories a-z80

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

Show entire file | Details | Blame | View Log

Rev 8 Rev 10
Line 1... Line 1...
//============================================================================
//============================================================================
// Implementation of the PS/2 keyboard scan-code reader
// PS/2 keyboard scan-code reader
//
//
//  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 18... Line 18...
//  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//============================================================================
//============================================================================
module ps2_keyboard
module ps2_keyboard
(
(
    input wire clk,
    input wire clk,
    input wire reset,           // Reset (negative logic)
    input wire nreset,          // Active low reset
    input wire PS2_CLK,         // PS/2 keyboard clock line
    input wire PS2_CLK,         // PS/2 keyboard clock line
    input wire PS2_DAT,         // PS/2 keyboard data line
    input wire PS2_DAT,         // PS/2 keyboard data line
 
 
    output wire [7:0] scan_code,// Completed keyboard scan code
    output wire [7:0] scan_code,// Completed keyboard scan code
    output reg scan_code_ready, // Active for 1 clock: scan code is ready
    output reg scan_code_ready, // Active for 1 clock: scan code is ready
Line 45... Line 45...
assign parity = ^shiftreg[8:0];
assign parity = ^shiftreg[8:0];
 
 
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Filter the PS/2 clock signal since it might have a noise (false '1')
// Filter the PS/2 clock signal since it might have a noise (false '1')
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
always @(posedge clk or negedge reset)
always @(posedge clk or negedge nreset)
begin
begin
    if (!reset) begin
    if (!nreset) begin
        ps2_clk_in <= 1;
        ps2_clk_in <= 1;
        clk_filter <= 8'b1;
        clk_filter <= 8'b1;
        clk_edge <= 0;
        clk_edge <= 0;
        end
        end
    else begin
    else begin
Line 71... Line 71...
end
end
 
 
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// State machine to process bits of PS/2 data
// State machine to process bits of PS/2 data
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
always @(posedge clk or negedge reset)
always @(posedge clk or negedge nreset)
begin
begin
    if (!reset) begin
    if (!nreset) begin
        bit_count <= '0;
        bit_count <= '0;
        shiftreg <= '0;
        shiftreg <= '0;
        scan_code_ready <= 0;
        scan_code_ready <= 0;
        scan_code_error <= 0;
        scan_code_error <= 0;
        end
        end

powered by: WebSVN 2.1.0

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