Subversion Repositories pentevo

Rev

Rev 896 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed | ?url?

  1. // ZX-Evo Base Configuration (c) NedoPC 2008,2009,2010,2011,2012,2013,2014
  2. //
  3. // MUXes mouse and kbd data in two single databusses for zports
  4.  
  5. /*
  6.     This file is part of ZX-Evo Base Configuration firmware.
  7.  
  8.     ZX-Evo Base Configuration firmware is free software:
  9.     you can redistribute it and/or modify it under the terms of
  10.     the GNU General Public License as published by
  11.     the Free Software Foundation, either version 3 of the License, or
  12.     (at your option) any later version.
  13.  
  14.     ZX-Evo Base Configuration firmware is distributed in the hope that
  15.     it will be useful, but WITHOUT ANY WARRANTY; without even
  16.     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  17.     See the GNU General Public License for more details.
  18.  
  19.     You should have received a copy of the GNU General Public License
  20.     along with ZX-Evo Base Configuration firmware.
  21.     If not, see <http://www.gnu.org/licenses/>.
  22. */
  23.  
  24. `include "../include/tune.v"
  25.  
  26. module zkbdmus(
  27.  
  28.         input  wire        fclk,
  29.         input  wire        rst_n,
  30.  
  31.  
  32.         input  wire [39:0] kbd_in,  // key bits
  33.         input  wire        kbd_stb, // and strobe
  34.  
  35.         input  wire [ 7:0] mus_in,
  36.         input  wire        mus_xstb,
  37.         input  wire        mus_ystb,
  38.         input  wire        mus_btnstb,
  39.         input  wire        kj_stb,
  40.  
  41.  
  42.         input  wire [7:0] zah,
  43.  
  44.         output wire [ 4:0] kbd_data,
  45.         output wire [ 7:0] mus_data,
  46.         output reg  [ 4:0] kj_data
  47. );
  48.  
  49.         reg [39:0] kbd;
  50.         reg [ 7:0] musx,musy,musbtn;
  51.  
  52.         wire [4:0] keys [0:7]; // key matrix
  53.  
  54.         reg [4:0] kout; // wire AND
  55.  
  56.  
  57. `ifdef SIMULATE
  58.         initial
  59.         begin
  60. //              force kbd_data = 5'b11111;
  61.                 force mus_data = 8'hFF;
  62.                 force kj_data  = 5'b00000;
  63.  
  64.                 kbd = 40'd0;
  65.         end
  66. `endif
  67.  
  68.  
  69.         // store data from slavespi
  70.         //
  71.     always @(posedge fclk)
  72.     begin
  73.                 if( kbd_stb )
  74.                         kbd <= kbd_in;
  75.  
  76.                 if( mus_xstb )
  77.                         musx <= mus_in;
  78.  
  79.                 if( mus_ystb )
  80.                         musy <= mus_in;
  81.  
  82.                 if( mus_btnstb )
  83.                         musbtn <= mus_in;
  84.  
  85.                 if( kj_stb )
  86.                         kj_data <= mus_in[4:0];
  87.     end
  88.  
  89.  
  90.         // make keys
  91.         //
  92.         assign keys[0]={kbd[00],kbd[08],kbd[16],kbd[24],kbd[32]};// v  c  x  z  CS
  93.         assign keys[1]={kbd[01],kbd[09],kbd[17],kbd[25],kbd[33]};// g  f  d  s  a
  94.         assign keys[2]={kbd[02],kbd[10],kbd[18],kbd[26],kbd[34]};// t  r  e  w  q
  95.         assign keys[3]={kbd[03],kbd[11],kbd[19],kbd[27],kbd[35]};// 5  4  3  2  1
  96.         assign keys[4]={kbd[04],kbd[12],kbd[20],kbd[28],kbd[36]};// 6  7  8  9  0
  97.         assign keys[5]={kbd[05],kbd[13],kbd[21],kbd[29],kbd[37]};// y  u  i  o  p
  98.         assign keys[6]={kbd[06],kbd[14],kbd[22],kbd[30],kbd[38]};// h  j  k  l  EN
  99.         assign keys[7]={kbd[07],kbd[15],kbd[23],kbd[31],kbd[39]};// b  n  m  SS SP
  100.         //
  101.         always @*
  102.         begin
  103.                 kout = 5'b11111;
  104.  
  105.                 kout = kout & ({5{zah[0]}} | (~keys[0]));
  106.                 kout = kout & ({5{zah[1]}} | (~keys[1]));
  107.                 kout = kout & ({5{zah[2]}} | (~keys[2]));
  108.                 kout = kout & ({5{zah[3]}} | (~keys[3]));
  109.                 kout = kout & ({5{zah[4]}} | (~keys[4]));
  110.                 kout = kout & ({5{zah[5]}} | (~keys[5]));
  111.                 kout = kout & ({5{zah[6]}} | (~keys[6]));
  112.                 kout = kout & ({5{zah[7]}} | (~keys[7]));
  113.         end
  114.         //
  115.         assign kbd_data = kout;
  116.  
  117.         // make mouse
  118.         // FADF - buttons, FBDF - x, FFDF - y
  119.         //
  120.         assign mus_data = zah[0] ? ( zah[2] ? musy : musx ) : musbtn;
  121.  
  122.  
  123.  
  124. endmodule
  125.  
  126.