Rev 340 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 668 | lvd | 1 | // ZX-Evo Base Configuration (c) NedoPC 2008,2009,2010,2011,2012,2013,2014 |
| 323 | lvd | 2 | // |
| 3 | // VGA scandoubler |
||
| 4 | |||
| 668 | lvd | 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 | |||
| 323 | lvd | 24 | module video_vga_double( |
| 25 | |||
| 668 | lvd | 26 | `include "../include/tune.v" |
| 27 | |||
| 323 | lvd | 28 | input wire clk, |
| 29 | |||
| 30 | input wire hsync_start, |
||
| 31 | |||
| 32 | input wire scanin_start, |
||
| 33 | input wire [ 5:0] pix_in, |
||
| 34 | |||
| 35 | input wire scanout_start, |
||
| 36 | output reg [ 5:0] pix_out |
||
| 37 | ); |
||
| 38 | /* |
||
| 39 | addressing of non-overlapping pages: |
||
| 40 | |||
| 41 | pg0 pg1 |
||
| 42 | 0xx 1xx |
||
| 43 | 2xx 3xx |
||
| 44 | 4xx 5xx |
||
| 45 | */ |
||
| 46 | |||
| 47 | reg [9:0] ptr_in; // count up to 720 |
||
| 48 | reg [9:0] ptr_out; // |
||
| 49 | |||
| 50 | reg pages; // swapping of pages |
||
| 51 | |||
| 52 | reg wr_stb; |
||
| 53 | |||
| 54 | wire [ 7:0] data_out; |
||
| 55 | |||
| 56 | |||
| 57 | always @(posedge clk) if( hsync_start ) |
||
| 58 | pages <= ~pages; |
||
| 59 | |||
| 60 | |||
| 61 | // write ptr and strobe |
||
| 62 | always @(posedge clk) |
||
| 63 | begin |
||
| 64 | if( scanin_start ) |
||
| 65 | begin |
||
| 66 | ptr_in[9:8] <= 2'b00; |
||
| 67 | ptr_in[5:4] <= 2'b11; |
||
| 68 | end |
||
| 69 | else |
||
| 70 | begin |
||
| 71 | if( ptr_in[9:8]!=2'b11 ) // 768-720=48 |
||
| 72 | begin |
||
| 73 | wr_stb <= ~wr_stb; |
||
| 74 | if( wr_stb ) |
||
| 75 | begin |
||
| 76 | ptr_in <= ptr_in + 10'd1; |
||
| 77 | end |
||
| 78 | end |
||
| 79 | end |
||
| 80 | end |
||
| 81 | |||
| 82 | |||
| 83 | // read ptr |
||
| 84 | always @(posedge clk) |
||
| 85 | begin |
||
| 86 | if( scanout_start ) |
||
| 87 | begin |
||
| 88 | ptr_out[9:8] <= 2'b00; |
||
| 89 | ptr_out[5:4] <= 2'b11; |
||
| 90 | end |
||
| 91 | else |
||
| 92 | begin |
||
| 93 | if( ptr_out[9:8]!=2'b11 ) |
||
| 94 | begin |
||
| 95 | ptr_out <= ptr_out + 10'd1; |
||
| 96 | end |
||
| 97 | end |
||
| 98 | end |
||
| 99 | |||
| 100 | //read data |
||
| 101 | always @(posedge clk) |
||
| 102 | begin |
||
| 103 | if( ptr_out[9:8]!=2'b11 ) |
||
| 104 | pix_out <= data_out[5:0]; |
||
| 105 | else |
||
| 106 | pix_out <= 6'd0; |
||
| 107 | end |
||
| 108 | |||
| 109 | |||
| 110 | |||
| 111 | |||
| 112 | |||
| 113 | mem1536 line_buf( .clk(clk), |
||
| 114 | |||
| 115 | .wraddr({ptr_in[9:8], pages, ptr_in[7:0]}), |
||
| 116 | .wrdata({2'b00,pix_in}), |
||
| 117 | .wr_stb(wr_stb), |
||
| 118 | |||
| 119 | .rdaddr({ptr_out[9:8], (~pages), ptr_out[7:0]}), |
||
| 120 | .rddata(data_out) |
||
| 121 | ); |
||
| 122 | |||
| 123 | |||
| 124 | endmodule |
||
| 125 | |||
| 126 | |||
| 127 | |||
| 128 | |||
| 129 | // 3x512b memory |
||
| 130 | module mem1536( |
||
| 131 | |||
| 132 | input wire clk, |
||
| 133 | |||
| 134 | input wire [10:0] wraddr, |
||
| 135 | input wire [ 7:0] wrdata, |
||
| 136 | input wire wr_stb, |
||
| 137 | |||
| 138 | input wire [10:0] rdaddr, |
||
| 139 | output reg [ 7:0] rddata |
||
| 140 | ); |
||
| 141 | |||
| 142 | reg [7:0] mem [0:1535]; |
||
| 143 | |||
| 144 | always @(posedge clk) |
||
| 145 | begin |
||
| 146 | if( wr_stb ) |
||
| 147 | begin |
||
| 148 | mem[wraddr] <= wrdata; |
||
| 149 | end |
||
| 150 | |||
| 151 | rddata <= mem[rdaddr]; |
||
| 152 | end |
||
| 153 | |||
| 154 | endmodule |
||
| 155 | |||
| 156 |