Subversion Repositories pentevo

Rev

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

  1. // ZX-Evo Base Configuration (c) NedoPC 2014
  2. //
  3. // CMOS emulator: cmos is needed for zxevo.rom to function correctly
  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. module cmosemu
  25. (
  26.         input  wire       zclk,
  27.  
  28.         input  wire       cmos_req,
  29.         input  wire [7:0] cmos_addr,
  30.         input  wire       cmos_rnw,
  31.         output reg  [7:0] cmos_read,
  32.         input  wire [7:0] cmos_write
  33. );
  34.  
  35.         reg [7:0] mem [0:239];
  36.  
  37.         reg req_r;
  38.  
  39.         function [7:0] cmos_rd
  40.         (
  41.                 input [7:0] addr
  42.         );
  43.  
  44.                 if( addr<8'd240 )
  45.                         cmos_rd = mem[addr];
  46.                 else
  47.                         cmos_rd = 8'hFF;
  48.         endfunction
  49.  
  50.         task cmos_wr
  51.         (
  52.                 input [7:0] addr,
  53.                 input [7:0] data
  54.         );
  55.                 if( addr<8'd240 )
  56.                         mem[addr] <= data;
  57.         endtask
  58.  
  59.  
  60.  
  61.         initial
  62.         begin
  63.                 int i;
  64.                 for(i=0;i<256;i=i+1)
  65.                         mem[i] <= 8'd0;
  66.         end
  67.  
  68.  
  69.         always @(posedge zclk)
  70.                 req_r <= cmos_req;
  71.  
  72.         always @(posedge zclk)
  73.         begin
  74.                 cmos_read <= cmos_rd(cmos_addr);
  75.  
  76.                 if( req_r && !cmos_rnw )
  77.                         cmos_wr(cmos_addr,cmos_write);
  78.         end
  79.  
  80.  
  81.  
  82. endmodule
  83.  
  84.