Rev 668 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 668 | Rev 684 | ||
---|---|---|---|
Line 53... | Line 53... | ||
53 | 53 | ||
54 | // modes inputs |
54 | // modes inputs |
55 | input wire mode_atm_n_pent, |
55 | input wire mode_atm_n_pent, |
56 | input wire mode_a_text, |
56 | input wire mode_a_text, |
57 | 57 | ||
- | 58 | input wire [ 1:0] modes_raster, |
|
- | 59 | input wire mode_contend_type, |
|
58 | 60 | ||
59 | output reg hblank, |
61 | output reg hblank, |
60 | output reg hsync, |
62 | output reg hsync, |
61 | 63 | ||
62 | output reg line_start, // 1 video cycle prior to actual start of visible line |
64 | output reg line_start, // 1 video cycle prior to actual start of visible line |
Line 65... | Line 67... | ||
65 | 67 | ||
66 | output reg hint_start, // horizontal position of INT start, for fine tuning |
68 | output reg hint_start, // horizontal position of INT start, for fine tuning |
67 | 69 | ||
68 | output reg scanin_start, |
70 | output reg scanin_start, |
69 | 71 | ||
- | 72 | input wire vpix, |
|
70 | output reg hpix, // marks gate during which pixels are outting |
73 | output reg hpix, // marks gate during which pixels are outting |
71 | 74 | ||
- | 75 | output reg contend, // for 48k/128k CPU contention |
|
- | 76 | ||
- | 77 | output reg border_sync, // for 48k/128k 4t border emulation |
|
- | 78 | ||
72 | // these signals turn on and turn off 'go' signal |
79 | // these signals turn on and turn off 'go' signal |
73 | output reg fetch_start, // 18 cycles earlier than hpix, coincide with cend |
80 | output reg fetch_start, // 18 cycles earlier than hpix, coincide with cend |
74 | output reg fetch_end // --//-- |
81 | output reg fetch_end // --//-- |
75 | 82 | ||
76 | ); |
83 | ); |
Line 96... | Line 103... | ||
96 | // 16 cycles after 1st data bundle is fetched |
103 | // 16 cycles after 1st data bundle is fetched |
97 | 104 | ||
98 | 105 | ||
99 | localparam SCANIN_BEG = 9'd88; // when scan-doubler starts pixel storing |
106 | localparam SCANIN_BEG = 9'd88; // when scan-doubler starts pixel storing |
100 | 107 | ||
- | 108 | ||
101 | localparam HINT_BEG = 9'd2; |
109 | localparam HINT_BEG = 9'd2; |
- | 110 | localparam HINT_BEG_48K = 9'd126; |
|
- | 111 | localparam HINT_BEG_128K = 9'd130; |
|
- | 112 | ||
- | 113 | ||
- | 114 | localparam HPERIOD_224 = 9'd448; |
|
- | 115 | localparam HPERIOD_228 = 9'd456; |
|
- | 116 | ||
- | 117 | ||
- | 118 | localparam CONTEND_START = 9'd127; // fixed for correct contend phase: coincides with positive edge of z80 clock |
|
- | 119 | //localparam CONTEND_START_48K = 9'd132; |
|
- | 120 | //localparam CONTEND_START_128K = 9'd132; |
|
102 | 121 | ||
103 | 122 | ||
104 | localparam HPERIOD = 9'd448; |
123 | localparam BORDER_PHASE = 3'd4; |
105 | 124 | ||
106 | 125 | ||
107 | reg [8:0] hcount; |
126 | reg [8:0] hcount; |
108 | 127 | ||
- | 128 | reg [8:0] contend_ctr; |
|
109 | 129 | ||
110 | // for simulation only |
130 | // for simulation only |
111 | // |
131 | // |
112 | initial |
132 | initial |
113 | begin |
133 | begin |
Line 122... | Line 142... | ||
122 | 142 | ||
123 | 143 | ||
124 | 144 | ||
125 | always @(posedge clk) if( cend ) |
145 | always @(posedge clk) if( cend ) |
126 | begin |
146 | begin |
127 | if( init || (hcount==(HPERIOD-9'd1)) ) |
147 | if( init || hcount==( (modes_raster==2'b11) ? (HPERIOD_228-9'd1) : (HPERIOD_224-9'd1) ) ) |
128 | hcount <= 9'd0; |
148 | hcount <= 9'd0; |
129 | else |
149 | else |
130 | hcount <= hcount + 9'd1; |
150 | hcount <= hcount + 9'd1; |
131 | end |
151 | end |
132 | 152 | ||
Line 209... | Line 229... | ||
209 | 229 | ||
210 | 230 | ||
211 | 231 | ||
212 | always @(posedge clk) |
232 | always @(posedge clk) |
213 | begin |
233 | begin |
214 | if( pre_cend && (hcount==HINT_BEG) ) |
234 | if( pre_cend && hcount==( modes_raster[1] ? (modes_raster[0] ? HINT_BEG_128K : HINT_BEG_48K) : HINT_BEG ) ) |
215 | hint_start <= 1'b1; |
235 | hint_start <= 1'b1; |
216 | else |
236 | else |
217 | hint_start <= 1'b0; |
237 | hint_start <= 1'b0; |
218 | end |
238 | end |
219 | 239 | ||
Line 226... | Line 246... | ||
226 | hpix <= 1'b0; |
246 | hpix <= 1'b0; |
227 | end |
247 | end |
228 | 248 | ||
229 | 249 | ||
230 | 250 | ||
- | 251 | // contention generator |
|
- | 252 | initial |
|
- | 253 | contend_ctr <=9'h100; |
|
- | 254 | // |
|
- | 255 | always @(posedge clk) if( cend ) |
|
- | 256 | begin |
|
- | 257 | if( hcount == CONTEND_START ) |
|
- | 258 | contend_ctr <= 9'd0; |
|
- | 259 | else if( !contend_ctr[8] ) |
|
- | 260 | contend_ctr <= contend_ctr + 9'd1; |
|
- | 261 | end |
|
- | 262 | // |
|
- | 263 | // |
|
- | 264 | always @(posedge clk) if( cend ) |
|
- | 265 | begin |
|
- | 266 | if( contend_ctr[8] || !vpix ) |
|
- | 267 | contend <= 1'b0; |
|
- | 268 | else if( !mode_contend_type ) |
|
- | 269 | // 48k type contention |
|
- | 270 | case( contend_ctr[3:1] ) |
|
- | 271 | 3'd6, |
|
- | 272 | 3'd7: contend <= 1'b0; |
|
- | 273 | default: contend <= 1'b1; |
|
- | 274 | endcase |
|
- | 275 | else |
|
- | 276 | // +2a/+3 type contention |
|
- | 277 | case( contend_ctr[3:1] ) |
|
- | 278 | 3'd1: contend <= 1'b0; |
|
- | 279 | default: contend <= 1'b1; |
|
- | 280 | endcase |
|
- | 281 | // |
|
- | 282 | // warning! probably +2a/+3 contention pattern is incorrect, it begins with 1 cycle contention but probably should end |
|
- | 283 | // with one extra contention cycle. Anyway this is left as TODO. |
|
- | 284 | // |
|
- | 285 | end |
|
- | 286 | ||
- | 287 | ||
- | 288 | ||
- | 289 | // border sync signal gen |
|
- | 290 | always @(posedge clk) |
|
- | 291 | if( pre_cend && hcount[2:0]==BORDER_PHASE ) |
|
- | 292 | border_sync <= 1'b1; |
|
- | 293 | else |
|
- | 294 | border_sync <= 1'b0; |
|
- | 295 | ||
231 | 296 | ||
232 | 297 | ||
233 | endmodule |
298 | endmodule |
234 | 299 |