Rev 737 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 826 | lvd | 1 | // ZX-Evo Base Configuration (c) NedoPC 2008,2009,2010,2011,2012,2013,2014,2015,2016,2019 |
| 360 | lvd | 2 | // |
| 3 | // top-level |
||
| 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 | |||
| 24 | `include "../include/tune.v" |
||
| 25 | |||
| 4 | lvd | 26 | module top( |
| 27 | |||
| 28 | // clocks |
||
| 29 | input fclk, |
||
| 30 | output clkz_out, |
||
| 31 | input clkz_in, |
||
| 32 | |||
| 33 | // z80 |
||
| 34 | input iorq_n, |
||
| 35 | input mreq_n, |
||
| 36 | input rd_n, |
||
| 37 | input wr_n, |
||
| 38 | input m1_n, |
||
| 39 | input rfsh_n, |
||
| 40 | output int_n, |
||
| 41 | output nmi_n, |
||
| 42 | output wait_n, |
||
| 43 | output res, |
||
| 44 | |||
| 45 | inout [7:0] d, |
||
| 46 | input [15:0] a, |
||
| 47 | |||
| 48 | // zxbus and related |
||
| 49 | output csrom, |
||
| 50 | output romoe_n, |
||
| 51 | output romwe_n, |
||
| 52 | |||
| 53 | output rompg0_n, |
||
| 54 | output dos_n, // aka rompg1 |
||
| 55 | output rompg2, |
||
| 56 | output rompg3, |
||
| 57 | output rompg4, |
||
| 58 | |||
| 59 | input iorqge1, |
||
| 60 | input iorqge2, |
||
| 61 | output iorq1_n, |
||
| 62 | output iorq2_n, |
||
| 63 | |||
| 64 | // DRAM |
||
| 65 | inout [15:0] rd, |
||
| 66 | output [9:0] ra, |
||
| 67 | output rwe_n, |
||
| 68 | output rucas_n, |
||
| 69 | output rlcas_n, |
||
| 70 | output rras0_n, |
||
| 71 | output rras1_n, |
||
| 72 | |||
| 73 | // video |
||
| 74 | output [1:0] vred, |
||
| 75 | output [1:0] vgrn, |
||
| 76 | output [1:0] vblu, |
||
| 77 | |||
| 78 | output vhsync, |
||
| 79 | output vvsync, |
||
| 80 | output vcsync, |
||
| 81 | |||
| 82 | // AY control and audio/tape |
||
| 83 | output ay_clk, |
||
| 84 | output ay_bdir, |
||
| 85 | output ay_bc1, |
||
| 86 | |||
| 87 | output beep, |
||
| 88 | |||
| 89 | // IDE |
||
| 90 | output [2:0] ide_a, |
||
| 91 | inout [15:0] ide_d, |
||
| 92 | |||
| 93 | output ide_dir, |
||
| 94 | |||
| 95 | input ide_rdy, |
||
| 96 | |||
| 97 | output ide_cs0_n, |
||
| 98 | output ide_cs1_n, |
||
| 99 | output ide_rs_n, |
||
| 100 | output ide_rd_n, |
||
| 101 | output ide_wr_n, |
||
| 102 | |||
| 103 | // VG93 and diskdrive |
||
| 104 | output vg_clk, |
||
| 105 | |||
| 106 | output vg_cs_n, |
||
| 107 | output vg_res_n, |
||
| 108 | |||
| 109 | output vg_hrdy, |
||
| 110 | output vg_rclk, |
||
| 111 | output vg_rawr, |
||
| 112 | output [1:0] vg_a, // disk drive selection |
||
| 113 | output vg_wrd, |
||
| 114 | output vg_side, |
||
| 115 | |||
| 116 | input step, |
||
| 117 | input vg_sl, |
||
| 118 | input vg_sr, |
||
| 119 | input vg_tr43, |
||
| 120 | input rdat_b_n, |
||
| 121 | input vg_wf_de, |
||
| 122 | input vg_drq, |
||
| 123 | input vg_irq, |
||
| 124 | input vg_wd, |
||
| 125 | |||
| 126 | // serial links (atmega-fpga, sdcard) |
||
| 127 | output sdcs_n, |
||
| 128 | output sddo, |
||
| 129 | output sdclk, |
||
| 130 | input sddi, |
||
| 131 | |||
| 132 | input spics_n, |
||
| 133 | input spick, |
||
| 134 | input spido, |
||
| 135 | output spidi, |
||
| 136 | output spiint_n |
||
| 137 | ); |
||
| 138 | |||
| 139 | wire dos; |
||
| 140 | |||
| 141 | |||
| 142 | wire zclk; // z80 clock for short |
||
| 143 | |||
| 200 | lvd | 144 | wire zpos,zneg; |
| 145 | |||
| 4 | lvd | 146 | wire rst_n; // global reset |
| 147 | |||
| 148 | wire rrdy; |
||
| 149 | wire [15:0] rddata; |
||
| 150 | |||
| 151 | wire [4:0] rompg; |
||
| 152 | |||
| 153 | wire [7:0] zports_dout; |
||
| 154 | wire zports_dataout; |
||
| 155 | wire porthit; |
||
| 156 | |||
| 699 | lvd | 157 | wire csrom_int; |
| 67 | lvd | 158 | |
| 699 | lvd | 159 | |
| 67 | lvd | 160 | wire [39:0] kbd_data; |
| 161 | wire [ 7:0] mus_data; |
||
| 110 | lvd | 162 | wire kbd_stb,mus_xstb,mus_ystb,mus_btnstb,kj_stb; |
| 67 | lvd | 163 | |
| 164 | wire [ 4:0] kbd_port_data; |
||
| 110 | lvd | 165 | wire [ 4:0] kj_port_data; |
| 67 | lvd | 166 | wire [ 7:0] mus_port_data; |
| 167 | |||
| 168 | |||
| 88 | lvd | 169 | |
| 170 | |||
| 171 | wire [7:0] wait_read,wait_write; |
||
| 172 | wire wait_rnw; |
||
| 173 | wire wait_start_gluclock; |
||
| 228 | lvd | 174 | wire wait_start_comport; |
| 88 | lvd | 175 | wire wait_end; |
| 176 | wire [7:0] gluclock_addr; |
||
| 228 | lvd | 177 | wire [2:0] comport_addr; |
| 88 | lvd | 178 | wire [6:0] waits; |
| 179 | |||
| 180 | |||
| 181 | |||
| 182 | |||
| 98 | lvd | 183 | // config signals |
| 826 | lvd | 184 | wire [7:0] not_used0; |
| 185 | wire [7:0] not_used1; |
||
| 98 | lvd | 186 | wire cfg_vga_on; |
| 684 | lvd | 187 | // |
| 188 | wire [1:0] modes_raster; |
||
| 189 | wire mode_contend_type = 1'b0; // 48/128/+2 or +2a/+3 TODO: take these signals from somewhere |
||
| 190 | wire mode_contend_ena = 1'b1; // contention enable |
||
| 191 | wire contend; |
||
| 826 | lvd | 192 | // |
| 193 | wire [3:0] fdd_mask; |
||
| 88 | lvd | 194 | |
| 425 | lvd | 195 | // nmi signals |
| 196 | wire gen_nmi; |
||
| 197 | wire clr_nmi; |
||
| 198 | wire in_nmi; |
||
| 576 | lvd | 199 | wire [1:0] set_nmi; |
| 200 | wire imm_nmi; |
||
| 737 | lvd | 201 | wire nmi_buf_clr; |
| 98 | lvd | 202 | |
| 576 | lvd | 203 | // breakpoint signals |
| 204 | wire brk_ena; |
||
| 205 | wire [15:0] brk_addr; |
||
| 98 | lvd | 206 | |
| 207 | |||
| 4 | lvd | 208 | wire tape_in; |
| 209 | |||
| 210 | wire [15:0] ideout; |
||
| 211 | wire [15:0] idein; |
||
| 212 | wire idedataout; |
||
| 213 | |||
| 214 | |||
| 215 | wire [7:0] zmem_dout; |
||
| 216 | wire zmem_dataout; |
||
| 217 | |||
| 218 | |||
| 219 | |||
| 220 | reg [3:0] ayclk_gen; |
||
| 221 | |||
| 222 | |||
| 223 | wire [7:0] received; |
||
| 224 | wire [7:0] tobesent; |
||
| 225 | |||
| 226 | |||
| 227 | wire intrq,drq; |
||
| 228 | wire vg_wrFF; |
||
| 229 | |||
| 230 | |||
| 668 | lvd | 231 | wire up_ena; |
| 232 | wire [ 5:0] up_paladdr; |
||
| 233 | wire [ 7:0] up_paldata; |
||
| 234 | wire up_palwr; |
||
| 4 | lvd | 235 | |
| 236 | |||
| 237 | |||
| 668 | lvd | 238 | |
| 4 | lvd | 239 | assign zclk = clkz_in; |
| 240 | |||
| 241 | |||
| 242 | // RESETTER |
||
| 243 | wire genrst; |
||
| 244 | |||
| 245 | resetter myrst( .clk(fclk), |
||
| 134 | ddp | 246 | .rst_in_n(~genrst), |
| 247 | .rst_out_n(rst_n) ); |
||
| 4 | lvd | 248 | defparam myrst.RST_CNT_SIZE = 6; |
| 249 | |||
| 250 | |||
| 123 | lvd | 251 | |
| 425 | lvd | 252 | assign nmi_n=gen_nmi ? 1'b0 : 1'bZ; |
| 123 | lvd | 253 | |
| 4 | lvd | 254 | assign res= ~rst_n; |
| 255 | |||
| 256 | |||
| 257 | |||
| 258 | |||
| 259 | |||
| 284 | lvd | 260 | |
| 261 | |||
| 262 | |||
| 4 | lvd | 263 | assign ide_rs_n = rst_n; |
| 264 | |||
| 265 | assign ide_d = idedataout ? ideout : 16'hZZZZ; |
||
| 266 | assign idein = ide_d; |
||
| 267 | |||
| 268 | assign ide_dir = ~idedataout; |
||
| 269 | |||
| 270 | |||
| 271 | |||
| 272 | |||
| 30 | lvd | 273 | |
| 274 | wire [7:0] peff7; |
||
| 275 | wire [7:0] p7ffd; |
||
| 276 | |||
| 277 | |||
| 200 | lvd | 278 | wire romrw_en; |
| 279 | wire cpm_n; |
||
| 395 | lvd | 280 | wire fnt_wr; |
| 30 | lvd | 281 | |
| 200 | lvd | 282 | |
| 283 | |||
| 30 | lvd | 284 | wire cpu_req,cpu_rnw,cpu_wrbsel,cpu_strobe; |
| 285 | wire [20:0] cpu_addr; |
||
| 286 | wire [15:0] cpu_rddata; |
||
| 287 | wire [7:0] cpu_wrdata; |
||
| 288 | |||
| 340 | lvd | 289 | wire cbeg,post_cbeg,pre_cend,cend; |
| 30 | lvd | 290 | |
| 340 | lvd | 291 | wire go; |
| 30 | lvd | 292 | |
| 293 | |||
| 543 | lvd | 294 | // AVR SDcard control |
| 295 | wire avr_lock_claim, |
||
| 296 | avr_lock_grant, |
||
| 297 | avr_sdcs_n, |
||
| 298 | avr_sd_start; |
||
| 299 | wire [7:0] avr_sd_datain; |
||
| 300 | wire [7:0] avr_sd_dataout; |
||
| 30 | lvd | 301 | |
| 543 | lvd | 302 | // ZX SDcard control |
| 303 | wire zx_sdcs_n_val, |
||
| 304 | zx_sdcs_n_stb, |
||
| 305 | zx_sd_start; |
||
| 306 | wire [7:0] zx_sd_datain; |
||
| 307 | wire [7:0] zx_sd_dataout; |
||
| 30 | lvd | 308 | |
| 543 | lvd | 309 | |
| 284 | lvd | 310 | wire tape_read; // data for tapein |
| 30 | lvd | 311 | |
| 284 | lvd | 312 | wire beeper_mux; // what is mixed to FPGA beeper output - beeper (0) or tapeout (1) |
| 213 | lvd | 313 | |
| 340 | lvd | 314 | wire [2:0] atm_scr_mode; |
| 284 | lvd | 315 | |
| 471 | lvd | 316 | wire atm_turbo; |
| 340 | lvd | 317 | |
| 471 | lvd | 318 | |
| 360 | lvd | 319 | wire beeper_wr, covox_wr; |
| 340 | lvd | 320 | |
| 321 | |||
| 284 | lvd | 322 | |
| 425 | lvd | 323 | wire [5:0] palcolor; // palette readback |
| 284 | lvd | 324 | |
| 325 | |||
| 326 | |||
| 425 | lvd | 327 | |
| 467 | lvd | 328 | wire [1:0] int_turbo; |
| 329 | wire cpu_next; |
||
| 330 | wire cpu_stall; |
||
| 331 | |||
| 332 | wire external_port; |
||
| 333 | |||
| 334 | |||
| 335 | |||
| 4 | lvd | 336 | //AY control |
| 337 | always @(posedge fclk) |
||
| 338 | begin |
||
| 339 | ayclk_gen <= ayclk_gen + 4'd1; |
||
| 340 | end |
||
| 341 | |||
| 342 | assign ay_clk = ayclk_gen[3]; |
||
| 343 | |||
| 344 | |||
| 345 | |||
| 346 | |||
| 347 | |||
| 200 | lvd | 348 | // fix ATM2-style ROM addressing for PENT-like ROM layout. |
| 349 | // this causes compications when writing to the flashROM from Z80 |
||
| 350 | // and need to split and re-build old ATM romfiles before burning in |
||
| 351 | // flash |
||
| 256 | lvd | 352 | // wire [1:0] adr_fix; |
| 353 | // assign adr_fix = ~{ rompg[0], rompg[1] }; |
||
| 354 | // assign rompg0_n = ~adr_fix[0]; |
||
| 355 | // assign dos_n = adr_fix[1]; |
||
| 356 | // assign rompg2 = 1'b0;//rompg[2]; |
||
| 357 | // assign rompg3 = 1'b0;//rompg[3]; |
||
| 358 | // assign rompg4 = 1'b0;//rompg[4]; |
||
| 4 | lvd | 359 | |
| 256 | lvd | 360 | assign rompg0_n = ~rompg[0]; |
| 361 | assign dos_n = rompg[1]; |
||
| 362 | assign rompg2 = rompg[2]; |
||
| 363 | assign rompg3 = rompg[3]; |
||
| 364 | assign rompg4 = rompg[4]; |
||
| 4 | lvd | 365 | |
| 200 | lvd | 366 | wire [3:0] zclk_stall; |
| 4 | lvd | 367 | |
| 467 | lvd | 368 | zclock zclock |
| 369 | ( |
||
| 684 | lvd | 370 | .fclk (fclk ), |
| 371 | .zclk (zclk ), |
||
| 372 | .rst_n(rst_n), |
||
| 373 | |||
| 374 | .a(a), |
||
| 375 | |||
| 376 | .mreq_n(mreq_n), |
||
| 377 | .iorq_n(iorq_n), |
||
| 378 | .m1_n (m1_n ), |
||
| 379 | .rfsh_n(rfsh_n), |
||
| 380 | |||
| 381 | .modes_raster (modes_raster ), |
||
| 382 | .mode_contend_type(mode_contend_type), |
||
| 383 | .mode_contend_ena (mode_contend_ena ), |
||
| 384 | .mode_7ffd_bits (p7ffd[2:0] ), |
||
| 385 | .contend (contend ), |
||
| 386 | |||
| 387 | .zclk_out(clkz_out), |
||
| 388 | |||
| 389 | .zpos(zpos), |
||
| 390 | .zneg(zneg), |
||
| 391 | |||
| 392 | |||
| 393 | .pre_cend(pre_cend), |
||
| 394 | .cbeg (cbeg ), |
||
| 395 | |||
| 396 | .zclk_stall( cpu_stall | (|zclk_stall) ), |
||
| 397 | .turbo ( {atm_turbo,~(peff7[4])} ), |
||
| 398 | .int_turbo (int_turbo ), |
||
| 399 | |||
| 400 | .external_port(external_port) |
||
| 467 | lvd | 401 | ); |
| 4 | lvd | 402 | |
| 403 | |||
| 404 | |||
| 405 | wire [7:0] dout_ram; |
||
| 406 | wire ena_ram; |
||
| 407 | wire [7:0] dout_ports; |
||
| 408 | wire ena_ports; |
||
| 409 | |||
| 410 | |||
| 287 | ddp | 411 | wire [3:0] border; |
| 30 | lvd | 412 | |
| 413 | wire drive_ff; |
||
| 699 | lvd | 414 | wire drive_00; |
| 30 | lvd | 415 | |
| 200 | lvd | 416 | |
| 340 | lvd | 417 | wire atm_palwr; |
| 418 | wire [5:0] atm_paldata; |
||
| 200 | lvd | 419 | |
| 543 | lvd | 420 | wire [7:0] fontrom_readback; |
| 421 | |||
| 422 | |||
| 423 | |||
| 424 | |||
| 340 | lvd | 425 | wire int_start; |
| 200 | lvd | 426 | |
| 427 | |||
| 699 | lvd | 428 | |
| 4 | lvd | 429 | // data bus out: either RAM data or internal ports data or 0xFF with unused ports |
| 722 | lvd | 430 | // assign d = ena_ram ? dout_ram : ( ena_ports ? dout_ports : ( (drive_ff|drive_00) ? {8{drive_ff}} : 8'bZZZZZZZZ ) ); |
| 4 | lvd | 431 | |
| 722 | lvd | 432 | wire [7:0] d_pre_out; |
| 433 | wire d_ena; |
||
| 434 | |||
| 435 | assign d_pre_out = ({8{ena_ram&(~drive_00)}} & dout_ram) | ({8{ena_ports}} & dout_ports) | {8{drive_ff}} ; |
||
| 436 | assign d_ena = (ena_ram|ena_ports|drive_ff|drive_00); |
||
| 437 | // |
||
| 438 | assign d = d_ena ? d_pre_out : 8'bZZZZ_ZZZZ; |
||
| 439 | // |
||
| 699 | lvd | 440 | assign csrom = csrom_int && !drive_00; |
| 4 | lvd | 441 | |
| 442 | |||
| 443 | zbus zxbus( .iorq_n(iorq_n), .rd_n(rd_n), .wr_n(wr_n), .m1_n(m1_n), |
||
| 134 | ddp | 444 | .iorq1_n(iorq1_n), .iorq2_n(iorq2_n), .iorqge1(iorqge1), .iorqge2(iorqge2), |
| 445 | .porthit(porthit), .drive_ff(drive_ff) ); |
||
| 4 | lvd | 446 | |
| 447 | |||
| 448 | |||
| 200 | lvd | 449 | |
| 450 | ///////////////////////////////////// |
||
| 451 | // ATM memory pagers instantiation // |
||
| 452 | ///////////////////////////////////// |
||
| 453 | |||
| 454 | wire pager_off; |
||
| 455 | |||
| 456 | wire pent1m_ROM; |
||
| 457 | wire [ 5:0] pent1m_page; |
||
| 458 | wire pent1m_ram0_0; |
||
| 459 | wire pent1m_1m_on; |
||
| 460 | |||
| 461 | wire atmF7_wr_fclk; |
||
| 462 | |||
| 463 | wire [3:0] dos_turn_off, |
||
| 464 | dos_turn_on; |
||
| 465 | |||
| 466 | wire [ 7:0] page [0:3]; |
||
| 467 | wire [ 3:0] romnram; |
||
| 674 | lvd | 468 | wire [ 3:0] wrdisable; |
| 200 | lvd | 469 | |
| 425 | lvd | 470 | // for reading back data via xxBE port |
| 471 | wire [ 7:0] rd_pages [0:7]; |
||
| 472 | wire [ 7:0] rd_ramnrom; |
||
| 473 | wire [ 7:0] rd_dos7ffd; |
||
| 674 | lvd | 474 | wire [ 7:0] rd_wrdisables; |
| 425 | lvd | 475 | |
| 200 | lvd | 476 | generate |
| 477 | |||
| 478 | genvar i; |
||
| 479 | |||
| 480 | for(i=0;i<4;i=i+1) |
||
| 481 | begin : instantiate_atm_pagers |
||
| 674 | lvd | 482 | atm_pager #( .ADDR(i) ) atm_pager |
| 483 | ( |
||
| 484 | .rst_n(rst_n), |
||
| 485 | .fclk (fclk), |
||
| 486 | .zpos (zpos), |
||
| 487 | .zneg (zneg), |
||
| 488 | |||
| 489 | .za(a), |
||
| 490 | .zd(d), |
||
| 491 | .mreq_n(mreq_n), |
||
| 492 | .rd_n (rd_n), |
||
| 493 | .m1_n (m1_n), |
||
| 494 | |||
| 495 | .pager_off(pager_off), |
||
| 496 | |||
| 497 | .pent1m_ROM (pent1m_ROM), |
||
| 498 | .pent1m_page (pent1m_page), |
||
| 499 | .pent1m_ram0_0(pent1m_ram0_0), |
||
| 500 | .pent1m_1m_on (pent1m_1m_on), |
||
| 501 | |||
| 502 | |||
| 503 | .in_nmi(in_nmi), |
||
| 504 | |||
| 505 | .atmF7_wr(atmF7_wr_fclk), |
||
| 506 | |||
| 507 | .dos(dos), |
||
| 508 | |||
| 509 | .dos_turn_on (dos_turn_on[i]), |
||
| 510 | .dos_turn_off(dos_turn_off[i]), |
||
| 511 | |||
| 512 | .zclk_stall(zclk_stall[i]), |
||
| 513 | |||
| 514 | .page (page[i] ), |
||
| 515 | .romnram (romnram[i] ), |
||
| 684 | lvd | 516 | .wrdisable(wrdisable[i]), |
| 674 | lvd | 517 | |
| 518 | .rd_page0 (rd_pages[i ]), |
||
| 519 | .rd_page1 (rd_pages[i+4]), |
||
| 520 | |||
| 521 | .rd_ramnrom ( {rd_ramnrom [i+4], rd_ramnrom [i]} ), |
||
| 522 | .rd_dos7ffd ( {rd_dos7ffd [i+4], rd_dos7ffd [i]} ), |
||
| 523 | .rd_wrdisables( {rd_wrdisables[i+4], rd_wrdisables[i]} ) |
||
| 524 | ); |
||
| 684 | lvd | 525 | |
| 200 | lvd | 526 | end |
| 527 | |||
| 528 | endgenerate |
||
| 529 | |||
| 530 | |||
| 531 | /////////////////////////// |
||
| 532 | // DOS signal controller // |
||
| 533 | /////////////////////////// |
||
| 534 | |||
| 535 | zdos zdos( .rst_n(rst_n), |
||
| 536 | |||
| 537 | .fclk(fclk), |
||
| 538 | |||
| 539 | .dos_turn_on ( |dos_turn_on ), |
||
| 540 | .dos_turn_off( |dos_turn_off ), |
||
| 541 | |||
| 542 | .cpm_n(cpm_n), |
||
| 543 | |||
| 544 | .dos(dos) |
||
| 545 | ); |
||
| 546 | |||
| 547 | |||
| 548 | |||
| 549 | |||
| 550 | /////////////////////////// |
||
| 551 | // Z80 memory controller // |
||
| 552 | /////////////////////////// |
||
| 553 | |||
| 467 | lvd | 554 | zmem z80mem |
| 555 | ( |
||
| 556 | .fclk (fclk ), |
||
| 557 | .rst_n(rst_n), |
||
| 558 | |||
| 559 | .zpos(zpos), |
||
| 560 | .zneg(zneg), |
||
| 4 | lvd | 561 | |
| 467 | lvd | 562 | .cbeg (cbeg ), |
| 563 | .post_cbeg(post_cbeg), |
||
| 564 | .pre_cend (pre_cend ), |
||
| 565 | .cend (cend ), |
||
| 566 | |||
| 567 | .za (a ), |
||
| 568 | .zd_in (d ), |
||
| 569 | .zd_out(dout_ram), |
||
| 570 | .zd_ena(ena_ram ), |
||
| 571 | .m1_n (m1_n ), |
||
| 572 | .rfsh_n(rfsh_n ), |
||
| 573 | .iorq_n(iorq_n ), |
||
| 574 | .mreq_n(mreq_n ), |
||
| 575 | .rd_n (rd_n ), |
||
| 576 | .wr_n (wr_n ), |
||
| 4 | lvd | 577 | |
| 467 | lvd | 578 | .win0_romnram(romnram[0]), |
| 579 | .win1_romnram(romnram[1]), |
||
| 580 | .win2_romnram(romnram[2]), |
||
| 581 | .win3_romnram(romnram[3]), |
||
| 4 | lvd | 582 | |
| 467 | lvd | 583 | .win0_page(page[0]), |
| 584 | .win1_page(page[1]), |
||
| 585 | .win2_page(page[2]), |
||
| 586 | .win3_page(page[3]), |
||
| 4 | lvd | 587 | |
| 674 | lvd | 588 | .win0_wrdisable(wrdisable[0]), |
| 589 | .win1_wrdisable(wrdisable[1]), |
||
| 590 | .win2_wrdisable(wrdisable[2]), |
||
| 591 | .win3_wrdisable(wrdisable[3]), |
||
| 592 | |||
| 467 | lvd | 593 | .romrw_en(romrw_en), |
| 4 | lvd | 594 | |
| 467 | lvd | 595 | .rompg (rompg ), |
| 596 | .romoe_n(romoe_n), |
||
| 597 | .romwe_n(romwe_n), |
||
| 699 | lvd | 598 | .csrom (csrom_int), |
| 4 | lvd | 599 | |
| 467 | lvd | 600 | .cpu_req (cpu_req ), |
| 601 | .cpu_rnw (cpu_rnw ), |
||
| 602 | .cpu_wrbsel(cpu_wrbsel), |
||
| 603 | .cpu_strobe(cpu_strobe), |
||
| 604 | .cpu_addr (cpu_addr ), |
||
| 605 | .cpu_wrdata(cpu_wrdata), |
||
| 606 | .cpu_rddata(cpu_rddata), |
||
| 607 | .cpu_stall (cpu_stall ), |
||
| 608 | .cpu_next (cpu_next ), |
||
| 4 | lvd | 609 | |
| 737 | lvd | 610 | .int_turbo(int_turbo), |
| 611 | .nmi_buf_clr(nmi_buf_clr) |
||
| 467 | lvd | 612 | ); |
| 4 | lvd | 613 | |
| 614 | |||
| 467 | lvd | 615 | |
| 616 | |||
| 4 | lvd | 617 | wire [20:0] daddr; |
| 618 | wire dreq; |
||
| 619 | wire drnw; |
||
| 620 | wire [15:0] drddata; |
||
| 621 | wire [15:0] dwrdata; |
||
| 622 | wire [1:0] dbsel; |
||
| 623 | |||
| 30 | lvd | 624 | |
| 625 | |||
| 626 | |||
| 200 | lvd | 627 | dram dram( .clk(fclk), |
| 628 | .rst_n(rst_n), |
||
| 4 | lvd | 629 | |
| 200 | lvd | 630 | .addr(daddr), |
| 631 | .req(dreq), |
||
| 632 | .rnw(drnw), |
||
| 633 | .cbeg(cbeg), |
||
| 634 | .rrdy(drrdy), |
||
| 635 | .rddata(drddata), |
||
| 636 | .wrdata(dwrdata), |
||
| 637 | .bsel(dbsel), |
||
| 4 | lvd | 638 | |
| 200 | lvd | 639 | .ra(ra), |
| 640 | .rd(rd), |
||
| 641 | .rwe_n(rwe_n), |
||
| 642 | .rucas_n(rucas_n), |
||
| 643 | .rlcas_n(rlcas_n), |
||
| 644 | .rras0_n(rras0_n), |
||
| 645 | .rras1_n(rras1_n) |
||
| 646 | ); |
||
| 4 | lvd | 647 | |
| 648 | |||
| 649 | wire [1:0] bw; |
||
| 650 | |||
| 651 | wire [20:0] video_addr; |
||
| 652 | wire [15:0] video_data; |
||
| 653 | wire video_strobe; |
||
| 654 | wire video_next; |
||
| 655 | |||
| 656 | arbiter dramarb( .clk(fclk), |
||
| 134 | ddp | 657 | .rst_n(rst_n), |
| 4 | lvd | 658 | |
| 134 | ddp | 659 | .dram_addr(daddr), |
| 660 | .dram_req(dreq), |
||
| 661 | .dram_rnw(drnw), |
||
| 662 | .dram_cbeg(cbeg), |
||
| 663 | .dram_rrdy(drrdy), |
||
| 664 | .dram_bsel(dbsel), |
||
| 665 | .dram_rddata(drddata), |
||
| 666 | .dram_wrdata(dwrdata), |
||
| 4 | lvd | 667 | |
| 340 | lvd | 668 | .post_cbeg(post_cbeg), |
| 669 | .pre_cend (pre_cend ), |
||
| 670 | .cend (cend ), |
||
| 4 | lvd | 671 | |
| 134 | ddp | 672 | .go(go), |
| 673 | .bw(bw), |
||
| 4 | lvd | 674 | |
| 134 | ddp | 675 | .video_addr(video_addr), |
| 676 | .video_data(video_data), |
||
| 677 | .video_strobe(video_strobe), |
||
| 678 | .video_next(video_next), |
||
| 4 | lvd | 679 | |
| 134 | ddp | 680 | //.cpu_waitcyc(cpu_waitcyc), |
| 467 | lvd | 681 | .cpu_next (cpu_next), |
| 134 | ddp | 682 | .cpu_req(cpu_req), |
| 683 | .cpu_rnw(cpu_rnw), |
||
| 684 | .cpu_addr(cpu_addr), |
||
| 685 | .cpu_wrbsel(cpu_wrbsel), |
||
| 686 | .cpu_wrdata(cpu_wrdata), |
||
| 687 | .cpu_rddata(cpu_rddata), |
||
| 688 | .cpu_strobe(cpu_strobe) ); |
||
| 4 | lvd | 689 | |
| 684 | lvd | 690 | video_top video_top |
| 691 | ( |
||
| 340 | lvd | 692 | .clk(fclk), |
| 134 | ddp | 693 | |
| 340 | lvd | 694 | .vred(vred), |
| 695 | .vgrn(vgrn), |
||
| 696 | .vblu(vblu), |
||
| 697 | .vhsync(vhsync), |
||
| 698 | .vvsync(vvsync), |
||
| 699 | .vcsync(vcsync), |
||
| 134 | ddp | 700 | |
| 340 | lvd | 701 | .zxborder(border), |
| 134 | ddp | 702 | |
| 340 | lvd | 703 | .pent_vmode( {peff7[0],peff7[5]} ), |
| 704 | .atm_vmode (atm_scr_mode), |
||
| 705 | |||
| 706 | .scr_page(p7ffd[3]), |
||
| 707 | |||
| 708 | .vga_on(cfg_vga_on), |
||
| 709 | |||
| 684 | lvd | 710 | .modes_raster (modes_raster ), |
| 711 | .mode_contend_type(mode_contend_type), |
||
| 712 | |||
| 713 | .contend(contend), |
||
| 714 | |||
| 340 | lvd | 715 | .cbeg (cbeg ), |
| 716 | .post_cbeg(post_cbeg), |
||
| 717 | .pre_cend (pre_cend ), |
||
| 718 | .cend (cend ), |
||
| 719 | |||
| 720 | .video_go (go ), |
||
| 721 | .video_bw (bw ), |
||
| 722 | .video_addr (video_addr ), |
||
| 723 | .video_data (video_data ), |
||
| 724 | .video_strobe(video_strobe), |
||
| 725 | .video_next (video_next ), |
||
| 726 | |||
| 727 | .atm_palwr (atm_palwr ), |
||
| 728 | .atm_paldata(atm_paldata), |
||
| 668 | lvd | 729 | |
| 730 | .up_ena (up_ena ), |
||
| 731 | .up_paladdr(up_paladdr), |
||
| 732 | .up_paldata(up_paldata), |
||
| 733 | .up_palwr (up_palwr ), |
||
| 340 | lvd | 734 | |
| 394 | tsl | 735 | .int_start(int_start), |
| 736 | |||
| 395 | lvd | 737 | .fnt_a (a[10:0]), |
| 738 | .fnt_d (d ), |
||
| 425 | lvd | 739 | .fnt_wr(fnt_wr ), |
| 740 | |||
| 543 | lvd | 741 | .palcolor(palcolor), |
| 742 | |||
| 743 | .fontrom_readback(fontrom_readback) |
||
| 340 | lvd | 744 | ); |
| 745 | |||
| 746 | |||
| 284 | lvd | 747 | slavespi slavespi( |
| 748 | .fclk(fclk), .rst_n(rst_n), |
||
| 4 | lvd | 749 | |
| 284 | lvd | 750 | .spics_n(spics_n), .spidi(spidi), |
| 751 | .spido(spido), .spick(spick), |
||
| 372 | lvd | 752 | .status_in({/* wait_rnw */ wr_n, waits[6:0]}), .genrst(genrst), |
| 543 | lvd | 753 | .kbd_out(kbd_data), |
| 284 | lvd | 754 | .kbd_stb(kbd_stb), .mus_out(mus_data), |
| 755 | .mus_xstb(mus_xstb), .mus_ystb(mus_ystb), |
||
| 756 | .mus_btnstb(mus_btnstb), .kj_stb(kj_stb), |
||
| 757 | .gluclock_addr(gluclock_addr), |
||
| 758 | .comport_addr (comport_addr), |
||
| 759 | .wait_write(wait_write), |
||
| 760 | .wait_read(wait_read), |
||
| 761 | .wait_rnw(wait_rnw), |
||
| 762 | .wait_end(wait_end), |
||
| 826 | lvd | 763 | .config0( {not_used0[7:6], modes_raster, beeper_mux, tape_read, set_nmi[0], cfg_vga_on} ), |
| 764 | .config1( {not_used0[7:4], fdd_mask} ), |
||
| 543 | lvd | 765 | |
| 766 | .sd_lock_out(avr_lock_claim), |
||
| 767 | .sd_lock_in (avr_lock_grant), |
||
| 768 | .sd_cs_n (avr_sdcs_n ), |
||
| 769 | .sd_start (avr_sd_start ), |
||
| 770 | .sd_datain (avr_sd_datain ), |
||
| 771 | .sd_dataout (avr_sd_dataout) |
||
| 284 | lvd | 772 | ); |
| 773 | |||
| 67 | lvd | 774 | zkbdmus zkbdmus( .fclk(fclk), .rst_n(rst_n), |
| 134 | ddp | 775 | .kbd_in(kbd_data), .kbd_stb(kbd_stb), |
| 776 | .mus_in(mus_data), .mus_xstb(mus_xstb), |
||
| 777 | .mus_ystb(mus_ystb), .mus_btnstb(mus_btnstb), |
||
| 778 | .kj_stb(kj_stb), .kj_data(kj_port_data), |
||
| 779 | .zah(a[15:8]), .kbd_data(kbd_port_data), |
||
| 780 | .mus_data(mus_port_data) |
||
| 781 | ); |
||
| 4 | lvd | 782 | |
| 783 | |||
| 200 | lvd | 784 | zports zports( .zclk(zclk), .fclk(fclk), .rst_n(rst_n), .zpos(zpos), .zneg(zneg), |
| 785 | .din(d), .dout(dout_ports), .dataout(ena_ports), |
||
| 786 | .a(a), .iorq_n(iorq_n), .rd_n(rd_n), .wr_n(wr_n), .porthit(porthit), |
||
| 360 | lvd | 787 | .ay_bdir(ay_bdir), .ay_bc1(ay_bc1), .border(border), |
| 200 | lvd | 788 | .p7ffd(p7ffd), .peff7(peff7), .mreq_n(mreq_n), .m1_n(m1_n), .dos(dos), |
| 543 | lvd | 789 | .vg_intrq(intrq), .vg_drq(drq), .vg_wrFF(vg_wrFF), .vg_cs_n(vg_cs_n), |
| 200 | lvd | 790 | .idein(idein), .ideout(ideout), .idedataout(idedataout), |
| 791 | .ide_a(ide_a), .ide_cs0_n(ide_cs0_n), .ide_cs1_n(ide_cs1_n), |
||
| 792 | .ide_wr_n(ide_wr_n), .ide_rd_n(ide_rd_n), |
||
| 67 | lvd | 793 | |
| 543 | lvd | 794 | .sd_cs_n_val(zx_sdcs_n_val), |
| 795 | .sd_cs_n_stb(zx_sdcs_n_stb), |
||
| 796 | .sd_start (zx_sd_start ), |
||
| 797 | .sd_datain (zx_sd_datain ), |
||
| 798 | .sd_dataout (zx_sd_dataout), |
||
| 799 | |||
| 200 | lvd | 800 | .keys_in(kbd_port_data), |
| 340 | lvd | 801 | .mus_in (mus_port_data), |
| 802 | .kj_in (kj_port_data ), |
||
| 88 | lvd | 803 | |
| 213 | lvd | 804 | .tape_read(tape_read), |
| 805 | |||
| 200 | lvd | 806 | .gluclock_addr(gluclock_addr), |
| 340 | lvd | 807 | .comport_addr (comport_addr ), |
| 200 | lvd | 808 | .wait_start_gluclock(wait_start_gluclock), |
| 340 | lvd | 809 | .wait_start_comport (wait_start_comport ), |
| 810 | .wait_rnw (wait_rnw ), |
||
| 200 | lvd | 811 | .wait_write(wait_write), |
| 340 | lvd | 812 | .wait_read (wait_read ), |
| 684 | lvd | 813 | |
| 476 | lvd | 814 | .atmF7_wr_fclk(atmF7_wr_fclk), |
| 4 | lvd | 815 | |
| 476 | lvd | 816 | .atm_scr_mode(atm_scr_mode), |
| 817 | .atm_turbo (atm_turbo), |
||
| 818 | .atm_pen (pager_off), |
||
| 819 | .atm_cpm_n (cpm_n), |
||
| 820 | .atm_pen2 (atm_pen2), |
||
| 200 | lvd | 821 | |
| 476 | lvd | 822 | .romrw_en(romrw_en), |
| 200 | lvd | 823 | |
| 476 | lvd | 824 | .pent1m_ram0_0(pent1m_ram0_0), |
| 825 | .pent1m_1m_on (pent1m_1m_on), |
||
| 826 | .pent1m_page (pent1m_page), |
||
| 827 | .pent1m_ROM (pent1m_ROM), |
||
| 200 | lvd | 828 | |
| 476 | lvd | 829 | .atm_palwr (atm_palwr ), |
| 830 | .atm_paldata(atm_paldata), |
||
| 340 | lvd | 831 | |
| 476 | lvd | 832 | .beeper_wr(beeper_wr), |
| 833 | .covox_wr (covox_wr ), |
||
| 360 | lvd | 834 | |
| 467 | lvd | 835 | .fnt_wr(fnt_wr), |
| 836 | .clr_nmi(clr_nmi), |
||
| 425 | lvd | 837 | |
| 838 | |||
| 467 | lvd | 839 | .pages(~{ rd_pages[7], rd_pages[6], |
| 840 | rd_pages[5], rd_pages[4], |
||
| 841 | rd_pages[3], rd_pages[2], |
||
| 842 | rd_pages[1], rd_pages[0] }), |
||
| 425 | lvd | 843 | |
| 674 | lvd | 844 | .ramnroms ( rd_ramnrom ), |
| 845 | .dos7ffds ( rd_dos7ffd ), |
||
| 846 | .wrdisables( rd_wrdisables ), |
||
| 425 | lvd | 847 | |
| 467 | lvd | 848 | .palcolor(palcolor), |
| 543 | lvd | 849 | .fontrom_readback(fontrom_readback), |
| 668 | lvd | 850 | |
| 851 | .up_ena (up_ena ), |
||
| 852 | .up_paladdr(up_paladdr), |
||
| 853 | .up_paldata(up_paldata), |
||
| 854 | .up_palwr (up_palwr ), |
||
| 425 | lvd | 855 | |
| 476 | lvd | 856 | .external_port(external_port), |
| 200 | lvd | 857 | |
| 576 | lvd | 858 | .set_nmi(set_nmi[1]), |
| 476 | lvd | 859 | |
| 576 | lvd | 860 | .brk_ena (brk_ena ), |
| 861 | .brk_addr(brk_addr) |
||
| 467 | lvd | 862 | ); |
| 200 | lvd | 863 | |
| 467 | lvd | 864 | |
| 425 | lvd | 865 | zint zint( |
| 866 | .fclk(fclk), |
||
| 867 | .zpos(zpos), |
||
| 868 | .zneg(zneg), |
||
| 4 | lvd | 869 | |
| 425 | lvd | 870 | .int_start(int_start), |
| 4 | lvd | 871 | |
| 425 | lvd | 872 | .iorq_n(iorq_n), |
| 873 | .m1_n (m1_n ), |
||
| 4 | lvd | 874 | |
| 651 | lvd | 875 | .wait_n(spiint_n), // spiint_n is 1-0 signal, wait_n is Z-0 |
| 876 | |||
| 425 | lvd | 877 | .int_n(int_n) |
| 878 | ); |
||
| 879 | |||
| 880 | znmi znmi |
||
| 881 | ( |
||
| 882 | .rst_n(rst_n), |
||
| 883 | .fclk(fclk), |
||
| 884 | .zpos(zpos), |
||
| 885 | .zneg(zneg), |
||
| 886 | |||
| 887 | .rfsh_n(rfsh_n), |
||
| 518 | lvd | 888 | .m1_n (m1_n ), |
| 889 | .mreq_n(mreq_n), |
||
| 890 | .csrom (csrom ), |
||
| 891 | .a (a ), |
||
| 425 | lvd | 892 | |
| 893 | .int_start(int_start), |
||
| 894 | |||
| 895 | .set_nmi(set_nmi), |
||
| 576 | lvd | 896 | .imm_nmi(imm_nmi), |
| 425 | lvd | 897 | .clr_nmi(clr_nmi), |
| 898 | |||
| 699 | lvd | 899 | .drive_00(drive_00), |
| 900 | |||
| 425 | lvd | 901 | .in_nmi (in_nmi ), |
| 737 | lvd | 902 | .gen_nmi(gen_nmi), |
| 903 | .nmi_buf_clr(nmi_buf_clr) |
||
| 425 | lvd | 904 | ); |
| 905 | |||
| 906 | |||
| 576 | lvd | 907 | zbreak zbreak |
| 908 | ( |
||
| 909 | .rst_n(rst_n), |
||
| 910 | .fclk(fclk), |
||
| 911 | .zpos(zpos), |
||
| 912 | .zneg(zneg), |
||
| 425 | lvd | 913 | |
| 576 | lvd | 914 | .m1_n (m1_n ), |
| 915 | .mreq_n(mreq_n), |
||
| 916 | .a (a ), |
||
| 425 | lvd | 917 | |
| 576 | lvd | 918 | .imm_nmi(imm_nmi), |
| 919 | |||
| 920 | .brk_ena (brk_ena ), |
||
| 921 | .brk_addr(brk_addr) |
||
| 922 | ); |
||
| 923 | |||
| 924 | |||
| 925 | |||
| 926 | |||
| 927 | |||
| 928 | |||
| 88 | lvd | 929 | zwait zwait( .wait_start_gluclock(wait_start_gluclock), |
| 228 | lvd | 930 | .wait_start_comport (wait_start_comport), |
| 134 | ddp | 931 | .wait_end(wait_end), |
| 932 | .rst_n(rst_n), |
||
| 933 | .wait_n(wait_n), |
||
| 934 | .waits(waits), |
||
| 935 | .spiint_n(spiint_n) ); |
||
| 88 | lvd | 936 | |
| 937 | |||
| 938 | |||
| 939 | |||
| 4 | lvd | 940 | wire [1:0] vg_ddrv; |
| 941 | assign vg_a[0] = vg_ddrv[0] ? 1'b1 : 1'b0; // possibly open drain? |
||
| 942 | assign vg_a[1] = vg_ddrv[1] ? 1'b1 : 1'b0; |
||
| 943 | |||
| 944 | vg93 vgshka( .zclk(zclk), .rst_n(rst_n), .fclk(fclk), .vg_clk(vg_clk), |
||
| 134 | ddp | 945 | .vg_res_n(vg_res_n), .din(d), .intrq(intrq), .drq(drq), .vg_wrFF(vg_wrFF), |
| 946 | .vg_hrdy(vg_hrdy), .vg_rclk(vg_rclk), .vg_rawr(vg_rawr), .vg_a(vg_ddrv), |
||
| 947 | .vg_wrd(vg_wrd), .vg_side(vg_side), .step(step), .vg_sl(vg_sl), .vg_sr(vg_sr), |
||
| 948 | .vg_tr43(vg_tr43), .rdat_n(rdat_b_n), .vg_wf_de(vg_wf_de), .vg_drq(vg_drq), |
||
| 949 | .vg_irq(vg_irq), .vg_wd(vg_wd) ); |
||
| 4 | lvd | 950 | |
| 951 | |||
| 952 | |||
| 953 | |||
| 543 | lvd | 954 | // spi2 zspi( .clock(fclk), .sck(sdclk), .sdo(sddo), .sdi(sddi), .start(sd_start), |
| 955 | // .speed(2'b00), .din(sd_datain), .dout(sd_dataout) ); |
||
| 956 | spihub spihub( |
||
| 4 | lvd | 957 | |
| 543 | lvd | 958 | .fclk (fclk ), |
| 959 | .rst_n(rst_n), |
||
| 360 | lvd | 960 | |
| 543 | lvd | 961 | .sdcs_n(sdcs_n), |
| 962 | .sdclk (sdclk ), |
||
| 963 | .sddo (sddo ), |
||
| 964 | .sddi (sddi ), |
||
| 360 | lvd | 965 | |
| 543 | lvd | 966 | .zx_sdcs_n_val(zx_sdcs_n_val), |
| 967 | .zx_sdcs_n_stb(zx_sdcs_n_stb), |
||
| 968 | .zx_sd_start (zx_sd_start ), |
||
| 969 | .zx_sd_datain (zx_sd_datain ), |
||
| 970 | .zx_sd_dataout(zx_sd_dataout), |
||
| 360 | lvd | 971 | |
| 543 | lvd | 972 | .avr_lock_in (avr_lock_claim), |
| 973 | .avr_lock_out (avr_lock_grant), |
||
| 974 | .avr_sdcs_n (avr_sdcs_n ), |
||
| 975 | .avr_sd_start (avr_sd_start ), |
||
| 976 | .avr_sd_datain (avr_sd_datain ), |
||
| 977 | .avr_sd_dataout(avr_sd_dataout) |
||
| 360 | lvd | 978 | |
| 543 | lvd | 979 | |
| 980 | ); |
||
| 981 | |||
| 982 | |||
| 983 | |||
| 984 | |||
| 985 | |||
| 360 | lvd | 986 | ////////////////////////////////////// |
| 987 | // sound: beeper, tapeout and covox // |
||
| 988 | ////////////////////////////////////// |
||
| 989 | |||
| 990 | sound sound( |
||
| 991 | |||
| 992 | .clk(fclk), |
||
| 993 | |||
| 994 | .din(d), |
||
| 995 | |||
| 996 | .beeper_wr(beeper_wr), |
||
| 997 | .covox_wr (covox_wr ), |
||
| 998 | |||
| 999 | .beeper_mux(beeper_mux), |
||
| 1000 | |||
| 1001 | .sound_bit(beep) |
||
| 1002 | ); |
||
| 1003 | |||
| 1004 | |||
| 4 | lvd | 1005 | endmodule |
| 1006 |