Subversion Repositories pentevo

Rev

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

  1. // ZX-Evo SDLoad Configuration (c) NedoPC 2023
  2. //
  3. // fetch/display data from internal EABs
  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 video_fetch
  25. (
  26.         input  wire clk,
  27.         input  wire rst_n,
  28.  
  29.         input  wire pix_stb,
  30.  
  31.         input  wire i_hsync,
  32.         input  wire i_vsync,
  33.         input  wire i_hpix,
  34.         input  wire i_vpix,
  35.  
  36.         input  wire v_init,
  37.         input  wire h_init,
  38.         input  wire h_step,
  39.         input  wire h_char,
  40.  
  41.  
  42.  
  43.         // char/attr memory read
  44.         output wire        char_r_rdena, // marks valid char_r_addr
  45.         output wire [11:0] char_r_addr,
  46.         input  wire [ 7:0] char_r_data, // 1 cycle latency
  47.  
  48.         // font memory read
  49.         output wire [ 9:0] font_r_addr,
  50.         input  wire [ 7:0] font_r_data, // 1 cycle latency
  51.  
  52. );
  53.  
  54.         localparam CHAR_ADDR_INIT = 12'h000;
  55.         localparam CHAR_LINE_ADD  = 12'd60;
  56.  
  57.         localparam ATTR_ADDR_INIT = 12'h9C0;
  58.         localparam ATTR_LINE_ADD  = 12'd40;
  59.  
  60.         reg [11:0] char_line_addr;
  61.         reg [11:0] attr_line_addr;
  62.  
  63.         reg [11:0] char_addr;
  64.  
  65.         reg [11:0] attr_addr;
  66.         reg [2:0] attr_phase;
  67.  
  68.  
  69.  
  70.  
  71.         always @(posedge clk)
  72.         if( pix_stb )
  73.         begin
  74.                 if( v_init )
  75.                         char_line_addr <= CHAR_ADDR_INIT;
  76.                 else if( h_step )
  77.                         char_line_addr <= char_line_addr + CHAR_LINE_ADD;
  78.         end
  79.         //
  80.         always @(posedge clk)
  81.         if( pix_stb )
  82.         begin
  83.                 if( h_init )
  84.                         char_addr <= char_line_addr;
  85.                 else if( h_char )
  86.                         char_addr <= char_addr + 12'd1;
  87.         end
  88.  
  89.  
  90.         always @(posedge clk)
  91.         if( pix_stb )
  92.         begin
  93.                 if( v_init )
  94.                         attr_line_addr <= ATTR_ADDR_INIT;
  95.                 else if( h_step )
  96.                         attr_line_addr <= attr_line_addr + ATTR_LINE_ADD;
  97.         end
  98.  
  99.  
  100.  
  101.  
  102. endmodule
  103.  
  104.