Subversion Repositories pentevo

Rev

Rev 668 | 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. // 'PFD' design based on ZEK code
  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.  
  25. module fapch_zek
  26. (
  27.         input  wire fclk,
  28.  
  29.         input  wire rdat_n,
  30.  
  31.         output reg  vg_rclk,
  32.         output reg  vg_rawr
  33. );
  34.  
  35.         reg [3:0] rdat_sr;
  36.         reg       rawr_sync;
  37.  
  38.         reg rdat_n_r;
  39.  
  40.         always @ (posedge fclk)
  41.         begin
  42.                 rdat_n_r <= rdat_n;
  43.  
  44.  
  45.             rdat_sr <= { rdat_sr[2:0], rdat_n_r };
  46.             if (rdat_sr == 4'hF || rdat_sr == 4'h0)
  47.                 rawr_sync <= rdat_sr[3];
  48.         end
  49.  
  50.         // rawr
  51.         reg [4:0] rawr_sr;
  52.  
  53.         always @ (posedge fclk)
  54.         begin
  55.             rawr_sr <= { rawr_sr[3:0], rawr_sync };
  56.             vg_rawr <= !(rawr_sr[4] && !rawr_sr[0] ); // rawr 140ns
  57.         end
  58.  
  59.         // rclk
  60.         reg [5:0] counter = 0;
  61.         wire[5:0] delta = 27 - counter;
  62.         wire[5:0] shift = { delta[5], delta[5], delta[4:1] }; // sign div
  63.         wire[5:0] inc   = rawr_sr[1:0] == 2'b10 ? shift : 1;
  64.  
  65.         always @ (posedge fclk)
  66.         begin
  67.             if (counter < 55)
  68.                 counter <= counter + inc;
  69.             else
  70.             begin
  71.                 counter <= 0;
  72.                 vg_rclk = ~vg_rclk;
  73.             end
  74.  
  75.         end
  76.  
  77.         initial
  78.             vg_rclk = 0;
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86. endmodule
  87.  
  88.