Rev 1062 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1062 | lvd | 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, |
||
| 1064 | lvd | 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 | |||
| 1062 | lvd | 52 | ); |
| 53 | |||
| 54 | localparam CHAR_ADDR_INIT = 12'h000; |
||
| 1064 | lvd | 55 | localparam CHAR_LINE_ADD = 12'd60; |
| 56 | |||
| 1062 | lvd | 57 | localparam ATTR_ADDR_INIT = 12'h9C0; |
| 1064 | lvd | 58 | localparam ATTR_LINE_ADD = 12'd40; |
| 1062 | lvd | 59 | |
| 1064 | lvd | 60 | reg [11:0] char_line_addr; |
| 1062 | lvd | 61 | reg [11:0] attr_line_addr; |
| 62 | |||
| 1064 | lvd | 63 | reg [11:0] char_addr; |
| 1062 | lvd | 64 | |
| 1064 | lvd | 65 | reg [11:0] attr_addr; |
| 66 | reg [2:0] attr_phase; |
||
| 1062 | lvd | 67 | |
| 68 | |||
| 69 | |||
| 1064 | lvd | 70 | |
| 1062 | lvd | 71 | always @(posedge clk) |
| 72 | if( pix_stb ) |
||
| 73 | begin |
||
| 1064 | lvd | 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; |
||
| 1062 | lvd | 78 | end |
| 1064 | lvd | 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 |
||
| 1062 | lvd | 88 | |
| 1064 | lvd | 89 | |
| 1062 | lvd | 90 | always @(posedge clk) |
| 91 | if( pix_stb ) |
||
| 92 | begin |
||
| 1064 | lvd | 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; |
||
| 1062 | lvd | 97 | end |
| 98 | |||
| 99 | |||
| 1064 | lvd | 100 | |
| 101 | |||
| 1062 | lvd | 102 | endmodule |
| 103 |