OpenCores
URL https://opencores.org/ocsvn/vg_z80_sbc/vg_z80_sbc/trunk

Subversion Repositories vg_z80_sbc

[/] [vg_z80_sbc/] [trunk/] [rtl/] [top_vg_z80.v] - Blame information for rev 36

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 hharte
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3 30 hharte
////  $Id: top_vg_z80.v,v 1.4 2008-12-15 06:44:47 hharte Exp $    ////
4 3 hharte
////  top_sk_z80.v - Z80 SBC Based on Xilinx S3E Starter Kit      ////
5
////                 Top-Level                                    ////
6
////                                                              ////
7
////  This file is part of the Vector Graphic Z80 SBC Project     ////
8
////  http://www.opencores.org/projects/vg_z80_sbc/               ////
9
////                                                              ////
10
////  Author:                                                     ////
11
////      - Howard M. Harte (hharte@opencores.org)                ////
12
////                                                              ////
13
//////////////////////////////////////////////////////////////////////
14
////                                                              ////
15
//// Copyright (C) 2008 Howard M. Harte                           ////
16
////                                                              ////
17
//// This source file may be used and distributed without         ////
18
//// restriction provided that this copyright statement is not    ////
19
//// removed from the file and that any derivative work contains  ////
20
//// the original copyright notice and the associated disclaimer. ////
21
////                                                              ////
22
//// This source file is free software; you can redistribute it   ////
23
//// and/or modify it under the terms of the GNU Lesser General   ////
24
//// Public License as published by the Free Software Foundation; ////
25
//// either version 2.1 of the License, or (at your option) any   ////
26
//// later version.                                               ////
27
////                                                              ////
28
//// This source is distributed in the hope that it will be       ////
29
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
30
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
31
//// PURPOSE.  See the GNU Lesser General Public License for more ////
32
//// details.                                                     ////
33
////                                                              ////
34
//// You should have received a copy of the GNU Lesser General    ////
35
//// Public License along with this source; if not, download it   ////
36
//// from http://www.opencores.org/lgpl.shtml                     ////
37
////                                                              ////
38
//////////////////////////////////////////////////////////////////////
39
 
40
//+---------------------------------------------------------------------------+
41
//| 16 1MB Address Regions:
42
//| 
43
//| 0:00000 - Wishbone I/O
44
//| 1:00000 - SRAM (32k)
45 30 hharte
//| 2:00000 - FLASH (512K) (really 8K SRAM for now)
46 3 hharte
//| 6:00000 - VGA Controller
47 30 hharte
//| 8:00000 - DDR SDRAM    (really 4K SRAM for now)
48 3 hharte
//| 
49
//| 16 4K Entries:
50
//| 
51
//| 0:00xxx - Lower <xxx> 12 address bits are passed through unchanged.
52
//| 
53
//| Mapping register (MMR) is divided into two fields:
54
//| 
55
//| Upper 4-bits = MMR_H  <h>
56
//| Lower 8-bits = MMR_L  <ll>
57
//| 
58
//| forms the final 24-bit address as follows:
59
//| 
60
//| <h>:<llxxx>
61
//| 
62 13 hharte
//| This provides for 16MB of address space from 64K,
63
//|
64
//| In the Z80's 64K address space, the mapping is configured by default as
65
//| follows:
66
//|
67 4 hharte
//| 0000-0FFF - 4K SRAM containing shadow copy of Monitor, only used to jump to monitor at 0xE000.
68 13 hharte
//| 1000-1FFF - 4K SRAM
69
//| 2000-2FFF - 4K SRAM
70 30 hharte
//| 3000-3FFF - Shadow of 2000-2FFF
71
//| 4000-4FFF - Shadow of 2000-2FFF
72 13 hharte
//| 5000-5FFF - Shadow of 2000-2FFF
73 30 hharte
//| 6000-6FFF - Shadow of 2000-2FFF
74
//| 7000-7FFF - Shadow of 2000-2FFF
75
//| 8000-8FFF - Shadow of 2000-2FFF
76
//| 9000-9FFF - Shadow of 2000-2FFF
77
//| A000-AFFF - Shadow of 2000-2FFF
78
//| B000-BFFF - 4K SRAM
79
//| C000-CFFF - 4K SRAM
80
//| D000-DFFF - 4K SRAM
81
//| E000-EFFF - 4K SRAM Containing Vector Graphics Monitor 4.0C (serial) or 4.3 (flashwriter)
82 4 hharte
//| F000-FFFF - Flashwriter 2 Dual-port SRAM
83 30 hharte
//|
84
//| I/O Port Map
85
//| 00-01 - Keyboard
86
//| 02-03 - Console UART
87
//| 04-05 - AUX UART
88
//| 06-07 - Third UART (not bonded out)
89
//| 08-1F - Shadow of 00-07
90
//| 20-23 - MMU
91
//| 24-3F - Shadow of 20-23
92
//| 40-7F - CPU Ctrl (test registers for now.)
93
//| 60-63 - MMU
94
//| 80-BF - spiMaster
95
//| C0-C3 - HD/FD Disk Controller
96
//| C4-C7 - HD/FD Disk Controller Diagnostic Registers
97
//| C8-DF - Shadow of C0-C7
98
//| E0-FF - FPB - FF = Programmed Output (LEDs)
99 13 hharte
//| 
100
//| This design runs on the Xilinx Spartan-3E Starter Kit with XC3S500E FPGA.
101
//| There are issues with the SDRAM controller, but everything else seems to
102
//| work fine.
103
//|
104
//| There is slightly more than 2K of RAM
105
//| available above the display-visible area of the Flashwriter2, from
106
//| F780-FFFFh.  This can be used as general-purpose RAM, but be aware that
107
//| the monitor uses some of this RAM for its stack and some temporary
108
//| variables.
109 3 hharte
//+---------------------------------------------------------------------------+
110
 
111
`include "ddr_include.v"
112
 
113
`define USE_INTERNAL_RAM
114
 
115
module vg_z80_sbc
116
(
117
    CLK,
118
    RST, // Active Low
119
 
120 30 hharte
    PS2_KBD_CLK,
121
    PS2_KBD_DAT,
122
    CONS_UART_TXD,
123
    CONS_UART_RXD,
124
    AUX_UART_TXD,
125
    AUX_UART_RXD,
126 3 hharte
 
127
    FLASH_A,
128
    FLASH_D,
129
    FLASH_CE,
130
    FLASH_OE,
131
    FLASH_WE,
132
    FLASH_BYTE,
133
 
134
    SD_A,
135
    SD_DQ,
136
    SD_BA,
137
    SD_CAS,
138
    SD_CK_N,
139
    SD_CK_P,
140
    SD_CKE,
141
    SD_CS,
142
 
143
    SD_DM,
144
    SD_DQS,
145
    SD_RAS,
146
    SD_WE,
147
    SD_CK_FB,
148
 
149 13 hharte
    rot,
150 30 hharte
 
151
    hsync,
152
    vsync,
153
    R,
154
    G,
155
    B,
156 13 hharte
 
157
    SD_SPI_CLK,
158
    SD_SPI_MISO,
159
    SD_SPI_MOSI,
160 30 hharte
    SD_SPI_CS_N,
161
 
162
    LED,
163
    SW,
164
    LCD_E,
165
    LCD_RS,
166
    LCD_RW,
167
    LCD_D
168 13 hharte
 
169 3 hharte
);
170
 
171
input         CLK ;
172
input         RST ;
173
 
174 30 hharte
// UARTs
175
output        CONS_UART_TXD;
176
input         CONS_UART_RXD;
177
output        AUX_UART_TXD;
178
input         AUX_UART_RXD;
179 3 hharte
 
180
// FLASH Memory Interface
181
output [23:0] FLASH_A;
182
inout   [7:0] FLASH_D;
183
output        FLASH_CE;
184
output        FLASH_OE;
185
output        FLASH_WE;
186
output        FLASH_BYTE;
187
 
188
// VGA
189
output             hsync, vsync, R, G, B;
190
 
191
// PS/2
192
inout              PS2_KBD_CLK;
193
inout              PS2_KBD_DAT;
194 30 hharte
 
195
// The DDR interface has problems.  Seems like the caching has trouble.  It is commented out for now,
196 13 hharte
// and 8K of SRAM is in its place.
197 3 hharte
// DDR Interface
198
output             SD_CAS;
199
output             SD_CK_N;
200
output             SD_CK_P;
201
output             SD_CKE;
202
output             SD_CS;
203
 
204
output             SD_RAS;
205
output             SD_WE;
206
input              SD_CK_FB;
207
 
208
output [  `A_RNG]  SD_A;
209
output [ `BA_RNG]  SD_BA;
210
inout  [ `DQ_RNG]  SD_DQ;
211
inout  [`DQS_RNG]  SD_DQS;
212
output [ `DM_RNG]  SD_DM;
213
 
214
input  [2:0]       rot;
215
 
216 13 hharte
output    SD_SPI_CLK;
217
input     SD_SPI_MISO;
218
output    SD_SPI_MOSI;
219
output    SD_SPI_CS_N;
220
 
221 30 hharte
output       [7:0] LED;
222
input        [3:0] SW;
223
 
224
output             LCD_E;
225
output             LCD_RS;
226
output             LCD_RW;
227
output       [3:0] LCD_D;
228
 
229
 
230 3 hharte
wire    NRST = !RST;
231
 
232
wire  [7:0] flash_dat_i;
233
wire  [7:0] flash_dat_o;
234 13 hharte
wire [23:0] flash_adr_o;
235 3 hharte
wire        flash_ce_o, flash_oe_o, flash_we_o;
236
 
237
reg clk25mhz;
238
 
239
// Generate 25MHz Clock from 50MHz clock input
240
always @(posedge CLK or posedge RST)
241
    if (RST)
242
        begin
243
            clk25mhz <= 1'b0;
244
        end else begin
245
            clk25mhz <= !clk25mhz;
246
        end
247
 
248 13 hharte
assign FLASH_A = flash_adr_o; //{5'b0,flash_adr_o};
249 3 hharte
assign FLASH_D = (!flash_we_o) ? flash_dat_o : 8'bZZZZZZZZ;
250
assign flash_dat_i = FLASH_D;
251
assign FLASH_CE = flash_ce_o;
252
assign FLASH_OE = flash_oe_o;
253
assign FLASH_WE = flash_we_o;
254
assign FLASH_BYTE = 1'b0;
255
 
256
wire [15:0] rgb_int ;
257
// WISHBONE slave interface
258
wire    [31:0]  ADR_I = 32'h00000000;
259
wire    [31:0]  SDAT_I = 32'hffffffff;
260
wire    [31:0]  SDAT_O ;
261
wire    [3:0]   SEL_I = 1'b0;
262
wire            CYC_I = 1'b0;
263
wire            STB_I = 1'b0;
264
wire            WE_I  = 1'b0;
265
wire            CAB_I = 1'b0;
266
wire            ACK_O ;
267
wire            RTY_O ;
268
wire            ERR_O ;
269
 
270
// WISHBONE master interface
271
wire [31:0]  ADR_O ;
272
wire [31:0]  MDAT_I;
273
wire [31:0]  MDAT_O = 32'h00000000;
274
wire [3:0]   SEL_O = 4'b0000;
275
wire         CYC_O = 1'b0;
276
wire         STB_O = 1'b0;
277
wire         WE_O  = 1'b0;
278
wire         CAB_O = 1'b0;
279
wire         ACK_I;
280
wire         RTY_I;
281
wire         ERR_I;
282
 
283
wire         PCI_CLK = clk25mhz;
284
 
285
wire [31:0] wb_z80_dat_o;
286
wire        wb_z80_stb_o;
287
wire        wb_z80_cyc_o;
288
wire        wb_z80_we_o;
289
wire [15:0] wb_z80_adr_o;
290
wire [1:0]  wb_z80_tga_o;
291
wire        wb_z80_ack_i;
292
wire [31:0] wb_z80_dat_i;
293 30 hharte
wire        z80_int_req_i = 1'b0;
294 3 hharte
wire        wb_z80_err_i;
295
wire [3:0]  wb_z80_sel_o;
296
 
297
wire [7:0]  wb_z80_be_dat_i;    // dat moved to correct byte lane depending on sel lines.
298
wire [7:0]  wb_z80_final_dat_i;
299
 
300
wire        z80_mem_hit;
301
assign z80_mem_hit = wb_z80_tga_o == 2'b00;
302
 
303
assign wb_z80_sel_o = wb_z80_adr_o[1:0] == 2'b00 ? 4'b0001 :
304
                      wb_z80_adr_o[1:0] == 2'b01 ? 4'b0010 :
305
                      wb_z80_adr_o[1:0] == 2'b10 ? 4'b0100 : 4'b1000;
306
 
307
assign wb_z80_dat_o[15:8]  = wb_z80_dat_o[7:0];
308
assign wb_z80_dat_o[23:16] = wb_z80_dat_o[7:0];
309
assign wb_z80_dat_o[31:24] = wb_z80_dat_o[7:0];
310
 
311
assign wb_z80_be_dat_i = wb_z80_adr_o[1:0] == 2'b00 ? wb_z80_dat_i[7:0] :
312
                         wb_z80_adr_o[1:0] == 2'b01 ? wb_z80_dat_i[15:8] :
313
                         wb_z80_adr_o[1:0] == 2'b10 ? wb_z80_dat_i[23:16] : wb_z80_dat_i[31:24];
314
 
315
assign wb_z80_final_dat_i = z80_mem_hit ? wb_z80_be_dat_i : wb_z80_dat_i[7:0];
316
 
317 30 hharte
`define USE_WB_Z80      // Select wb_z80 CPU core instead of TV80 CPU Core.
318
`ifdef USE_WB_Z80
319 3 hharte
// Instantiate the Wishbone Z80 Core
320
z80_core_top z80cpu (
321 30 hharte
    .wb_clk_i(PCI_CLK),
322
    .wb_rst_i(RST),
323
    .wb_adr_o(wb_z80_adr_o),
324
    .wb_tga_o(wb_z80_tga_o),
325
    .wb_dat_i(wb_z80_final_dat_i),
326 3 hharte
    .wb_dat_o(wb_z80_dat_o[7:0]),
327 30 hharte
    .wb_cyc_o(wb_z80_cyc_o),
328 3 hharte
    .wb_stb_o(wb_z80_stb_o),
329
    .wb_we_o(wb_z80_we_o),
330
    .wb_ack_i(wb_z80_ack_i),
331
    .int_req_i(z80_int_req_i)
332
    );
333 30 hharte
`else
334
wire z80_nmi_req_i = 1'b0;
335
wire z80_busrq_i = 1'b0;
336
 
337
wire z80_busak_o;
338 3 hharte
 
339 30 hharte
// Instantiate Wishbone tv80 Z80 CPU Core
340
wb_tv80 z80_cpu (
341
    .clk_i(PCI_CLK),
342
    .nrst_i(NRST),
343
    .wbm_adr_o(wb_z80_adr_o),
344
    .wbm_tga_o(wb_z80_tga_o),
345
    .wbm_dat_i(wb_z80_final_dat_i),
346
    .wbm_dat_o(wb_z80_dat_o[7:0]),
347
    .wbm_cyc_o(wb_z80_cyc_o),
348
    .wbm_stb_o(wb_z80_stb_o),
349
    .wbm_we_o(wb_z80_we_o),
350
    .wbm_ack_i(wb_z80_ack_i),
351
    .nmi_req_i(z80_nmi_req_i),
352
    .int_req_i(z80_int_req_i),
353
    .busrq_i(z80_busrq_i),
354
    .busak_o(z80_busak_o)
355
    );
356
`endif // USE_WB_Z80
357
 
358 3 hharte
// Instantiate the CPU Controller
359
wire [31:0] wb_cpu_ctrl_dat_o;
360
wire [31:0] wb_cpu_ctrl_dat_i;
361
wire  [3:0] wb_cpu_ctrl_sel_i;
362
wire        wb_cpu_ctrl_we_i;
363
wire        wb_cpu_ctrl_stb_i;
364
wire        wb_cpu_ctrl_cyc_i;
365
wire        wb_cpu_ctrl_ack_o;
366 13 hharte
wire  [2:0] wb_cpu_ctrl_adr_i;
367 3 hharte
wire [31:0] cpu_ctrl_reg0;
368
wire [31:0] cpu_ctrl_reg1;
369
 
370
wb_cpu_ctrl cpu_ctrl0 (
371
    .clk_i(PCI_CLK),
372
    .nrst_i(NRST),
373
    .wb_adr_i(wb_cpu_ctrl_adr_i[2:0]),
374
    .wb_dat_o(wb_cpu_ctrl_dat_o),
375
    .wb_dat_i(wb_cpu_ctrl_dat_i),
376
    .wb_sel_i(wb_cpu_ctrl_sel_i),
377
    .wb_we_i(wb_cpu_ctrl_we_i),
378
    .wb_stb_i(wb_cpu_ctrl_stb_i),
379
    .wb_cyc_i(wb_cpu_ctrl_cyc_i),
380
    .wb_ack_o(wb_cpu_ctrl_ack_o),
381
    .datareg0(cpu_ctrl_reg0),
382
    .datareg1(cpu_ctrl_reg1)
383
    );
384
 
385
`ifdef USE_INTERNAL_RAM
386
// Instantiate the SRAM
387 30 hharte
wire [31:0] wbs_sram_dat_o;
388
wire [31:0] wbs_sram_dat_i;
389
wire [3:0]  wbs_sram_sel_i;
390
wire        wbs_sram_we_i;
391
wire        wbs_sram_stb_i;
392
wire        wbs_sram_cyc_i;
393
wire        wbs_sram_ack_o;
394
wire [14:0] wbs_sram_adr_i;
395
 
396 13 hharte
// Instantiate 16K SRAM initialized with Vector Monitor 4.3 ROM
397
wb_sram #(
398 30 hharte
    .mem_file_name("../mon43/MON4043.mem"),
399 13 hharte
    .adr_width(14),
400
    .dat_width(8)
401 30 hharte
) sram0 (
402 3 hharte
    .clk_i(PCI_CLK),
403
    .nrst_i(NRST),
404 30 hharte
    .wb_adr_i(wbs_sram_adr_i),
405
    .wb_dat_o(wbs_sram_dat_o),
406
    .wb_dat_i(wbs_sram_dat_i),
407
    .wb_sel_i(wbs_sram_sel_i),
408
    .wb_we_i(wbs_sram_we_i),
409
    .wb_stb_i(wbs_sram_stb_i),
410
    .wb_cyc_i(wbs_sram_cyc_i),
411
    .wb_ack_o(wbs_sram_ack_o)
412 3 hharte
    );
413
`endif // USE_INTERNAL_RAM
414
 
415
wire [31:0] wbs_vga_dat_o;
416
wire        wbs_vga_ack_o;
417
wire [31:0] wbs_vga_dat_i;
418
wire        wbs_vga_we_i;
419
wire  [3:0] wbs_vga_sel_i;
420
wire [13:0] wbs_vga_adr_i;
421
wire        wbs_vga_cyc_i;
422
wire        wbs_vga_stb_i;
423
 
424
// Instantiate the VGA Controller (Emulating Vector Graphic FlashWriter2)
425
wb_vga #(
426
    .font_height(10),
427
    .text_height(2))
428
vga0 (
429
    .clk_i(PCI_CLK),
430
    .clk_50mhz_i(CLK),
431
    .nrst_i(NRST),
432
    .wb_adr_i(wbs_vga_adr_i),
433
    .wb_dat_o(wbs_vga_dat_o),
434
    .wb_dat_i(wbs_vga_dat_i),
435
    .wb_sel_i(wbs_vga_sel_i),
436
    .wb_we_i(wbs_vga_we_i),
437
    .wb_stb_i(wbs_vga_stb_i),
438
    .wb_cyc_i(wbs_vga_cyc_i),
439
    .wb_ack_o(wbs_vga_ack_o),
440
    .vga_hsync_o(hsync),
441
    .vga_vsync_o(vsync),
442
    .vga_r_o(R),
443
    .vga_g_o(G),
444
    .vga_b_o(B)
445
    );
446
 
447 30 hharte
wire  [2:0] wbs_kbd_adr_i;
448
wire [31:0] wbs_kbd_dat_i;
449
wire [31:0] wbs_kbd_dat_o;
450
wire        wbs_kbd_we_i;
451
wire  [3:0] wbs_kbd_sel_i;
452
wire        wbs_kbd_cyc_i;
453
wire        wbs_kbd_stb_i;
454
wire        wbs_kbd_ack_o;
455
wire        uart3_rxd = 1'b0;
456
wire        uart3_txd;
457 3 hharte
 
458 30 hharte
// Instantiate the PS/2 Keyboard, and three Bitstreamer UARTs (third one not connected.)
459 3 hharte
wb_uart #(
460 30 hharte
        .clk_freq(25000000),
461
        .baud(115200)
462
) bitstreamer0 (
463 3 hharte
    .clk(PCI_CLK),
464
    .reset(RST),
465 30 hharte
    .wb_stb_i(wbs_kbd_stb_i),
466
    .wb_cyc_i(wbs_kbd_cyc_i),
467
    .wb_ack_o(wbs_kbd_ack_o),
468
    .wb_we_i(wbs_kbd_we_i),
469
    .wb_adr_i(wbs_kbd_adr_i),
470
    .wb_sel_i(wbs_kbd_sel_i),
471
    .wb_dat_i(wbs_kbd_dat_i),
472
    .wb_dat_o(wbs_kbd_dat_o),
473 3 hharte
    .ps2_clk(PS2_KBD_CLK),
474
    .ps2_data(PS2_KBD_DAT),
475 30 hharte
        .uart1_rxd(CONS_UART_RXD),
476
        .uart1_txd(CONS_UART_TXD),
477
        .uart2_rxd(AUX_UART_RXD),
478
        .uart2_txd(AUX_UART_TXD),
479
        .uart3_rxd(uart3_rxd),
480
        .uart3_txd(uart3_txd)
481 3 hharte
    );
482
 
483
wire [31:0] wbs_flash_dat_o;
484
wire        wbs_flash_ack_o;
485
wire [31:0] wbs_flash_dat_i;
486 13 hharte
wire        wbs_flash_we_i;
487 3 hharte
wire  [3:0] wbs_flash_sel_i;
488
wire [18:0] wbs_flash_adr_i;
489
wire        wbs_flash_cyc_i;
490
wire        wbs_flash_stb_i;
491 30 hharte
 
492
// Instantiate 8K of SRAM instead of FLASH controller.  FLASH is used for VHDFD Storage
493 13 hharte
wb_sram #(
494 30 hharte
    .adr_width(13),
495 13 hharte
    .dat_width(8)
496
) sram2 (
497 3 hharte
    .clk_i(PCI_CLK),
498
    .nrst_i(NRST),
499
    .wb_adr_i(wbs_flash_adr_i),
500
    .wb_dat_o(wbs_flash_dat_o),
501
    .wb_dat_i(wbs_flash_dat_i),
502
    .wb_sel_i(wbs_flash_sel_i),
503
    .wb_we_i(wbs_flash_we_i),
504
    .wb_stb_i(wbs_flash_stb_i),
505
    .wb_cyc_i(wbs_flash_cyc_i),
506 13 hharte
    .wb_ack_o(wbs_flash_ack_o)
507 3 hharte
    );
508
 
509 13 hharte
// Instantiate the FLASH Memory Interface
510
//wb_flash flash0 (
511
//    .clk_i(PCI_CLK), 
512
//    .nrst_i(NRST), 
513
//    .wb_adr_i(wbs_flash_adr_i), 
514
//    .wb_dat_o(wbs_flash_dat_o), 
515
//    .wb_dat_i(wbs_flash_dat_i), 
516
//    .wb_sel_i(wbs_flash_sel_i), 
517
//    .wb_we_i(wbs_flash_we_i), 
518
//    .wb_stb_i(wbs_flash_stb_i), 
519
//    .wb_cyc_i(wbs_flash_cyc_i), 
520
//    .wb_ack_o(wbs_flash_ack_o), 
521
//    .flash_adr_o(flash_adr_o), 
522
//    .flash_dat_o(flash_dat_o), 
523
//    .flash_dat_i(flash_dat_i), 
524
//    .flash_oe(flash_oe_o), 
525
//    .flash_ce(flash_ce_o), 
526
//    .flash_we(flash_we_o)
527
//    );
528
 
529 3 hharte
wire [31:0] wbs_ddr_dat_o;
530
wire        wbs_ddr_ack_o;
531
wire [31:0] wbs_ddr_dat_i;
532
wire        wbs_ddr_we_i;
533
wire  [3:0] wbs_ddr_sel_i;
534
wire [19:0] wbs_ddr_adr_i;
535
wire        wbs_ddr_cyc_i;
536
wire        wbs_ddr_stb_i;
537 30 hharte
 
538
// Instantiate 8K SRAM instead of DDR Controller
539 13 hharte
wb_sram #(
540
    .mem_file_name("none"),
541 30 hharte
    .adr_width(12),
542 13 hharte
    .dat_width(8)
543
) sram1 (
544
    .clk_i(PCI_CLK),
545
    .nrst_i(NRST),
546
    .wb_adr_i(wbs_ddr_adr_i[13:0]),
547
    .wb_dat_o(wbs_ddr_dat_o),
548 3 hharte
    .wb_dat_i(wbs_ddr_dat_i),
549
    .wb_sel_i(wbs_ddr_sel_i),
550 13 hharte
    .wb_we_i(wbs_ddr_we_i),
551
    .wb_stb_i(wbs_ddr_stb_i),
552 3 hharte
    .wb_cyc_i(wbs_ddr_cyc_i),
553 13 hharte
    .wb_ack_o(wbs_ddr_ack_o)
554 3 hharte
    );
555 30 hharte
 
556
 
557 13 hharte
//// Instantiate the DDR SDRAM Controller
558
//// (This is not working properly at the moment... not sure why.)
559 30 hharte
//      wire                   ddr_ps_ready;
560
//      wire                   ddr_ps_up = 1'b0;
561
//      wire                   ddr_ps_down = 1'b0;
562
//      wire                   ddr_probe_clk;
563
//      wire             [7:0] ddr_probe_sel = 8'h00;
564
//      wire             [7:0] ddr_probe;
565
//
566 13 hharte
//wb_ddr #(
567
//    .phase_shift(0),
568
//    .clk_multiply(12), //15), //13),
569
//    .clk_divide(3),
570
//    .wait200_init(26)
571
//) ddr0 (
572
//    .clk(PCI_CLK), 
573
//    .reset(RST), 
574 30 hharte
////    .rot(rot), 
575 13 hharte
//    .ddr_clk(SD_CK_P), 
576
//    .ddr_clk_n(SD_CK_N), 
577
//    .ddr_clk_fb(SD_CK_FB), 
578
//    .ddr_ras_n(SD_RAS), 
579
//    .ddr_cas_n(SD_CAS), 
580
//    .ddr_we_n(SD_WE), 
581
//    .ddr_cke(SD_CKE), 
582
//    .ddr_cs_n(SD_CS), 
583
//    .ddr_a(SD_A), 
584
//    .ddr_ba(SD_BA), 
585
//    .ddr_dq(SD_DQ), 
586
//    .ddr_dqs(SD_DQS), 
587
//    .ddr_dm(SD_DM), 
588 30 hharte
//    .wb_adr_i({10'b0, wbs_ddr_adr_i, 2'b00 }), 
589 13 hharte
//    .wb_dat_i(wbs_ddr_dat_i), 
590
//    .wb_dat_o(wbs_ddr_dat_o), 
591 30 hharte
//    .wb_sel_i(4'b1111), //wbs_ddr_sel_i), 
592 13 hharte
//    .wb_cyc_i(wbs_ddr_cyc_i), 
593
//    .wb_stb_i(wbs_ddr_stb_i), 
594
//    .wb_we_i(wbs_ddr_we_i), 
595 30 hharte
//    .wb_ack_o(wbs_ddr_ack_o), 
596
//    .ps_ready(ddr_ps_ready),
597
//    .ps_up(ddr_ps_up),
598
//    .ps_down(ddr_ps_down),
599
//    .probe_clk(ddr_probe_clk),
600
//    .probe_sel(ddr_probe_sel),
601
//    .probe(ddr_probe)
602 13 hharte
//    );
603 3 hharte
 
604
wire [31:0] wbs_mmu_dat_o;
605
wire        wbs_mmu_ack_o;
606
wire [31:0] wbs_mmu_dat_i;
607
wire        wbs_mmu_we_i;
608
wire  [3:0] wbs_mmu_sel_i;
609 13 hharte
wire  [1:0] wbs_mmu_adr_i;
610 3 hharte
wire        wbs_mmu_cyc_i;
611
wire        wbs_mmu_stb_i;
612
 
613
wire [15:0] mmu_adr_i = wb_z80_adr_o[15:0];
614
wire [23:0] mmu_adr_o;
615
 
616 13 hharte
wire  [1:0] mmu_slave_adr_low;
617
wire  [7:0] mmu_dat_i;
618
 
619
assign mmu_dat_i = wbs_mmu_sel_i == 4'b0001 ? wbs_mmu_dat_i[7:0] :
620
                     wbs_mmu_sel_i == 4'b0010 ? wbs_mmu_dat_i[15:8] :
621
                     wbs_mmu_sel_i == 4'b0100 ? wbs_mmu_dat_i[23:16] :
622
                     wbs_mmu_dat_i[31:24];
623
 
624
assign mmu_slave_adr_low = wbs_mmu_sel_i == 4'b0001 ? 2'b00 :
625
                       wbs_mmu_sel_i == 4'b0010 ? 2'b01 :
626
                       wbs_mmu_sel_i == 4'b0100 ? 2'b10 : 2'b11;
627
 
628 3 hharte
// Instantiate the Memory Management Unit
629
wb_mmu mmu0 (
630
    .clk_i(PCI_CLK),
631
    .nrst_i(NRST),
632 13 hharte
    .wbs_adr_i(mmu_slave_adr_low),
633 3 hharte
    .wbs_dat_o(wbs_mmu_dat_o),
634 13 hharte
    .wbs_dat_i(mmu_dat_i),
635 3 hharte
    .wbs_sel_i(wbs_mmu_sel_i),
636
    .wbs_we_i(wbs_mmu_we_i),
637
    .wbs_stb_i(wbs_mmu_stb_i),
638
    .wbs_cyc_i(wbs_mmu_cyc_i),
639
    .wbs_ack_o(wbs_mmu_ack_o),
640
    .mmu_adr_i(mmu_adr_i),
641 30 hharte
    .mmu_adr_o(mmu_adr_o),
642
    .rom_sel_i(SW[0])
643 3 hharte
    );
644
 
645 13 hharte
// Instantiate the Vector HD-FD Disk Controller
646
wire [31:0] wbs_vhdfd_dat_o;
647
wire [31:0] wbs_vhdfd_dat_i;
648
wire  [3:0] wbs_vhdfd_sel_i;
649
wire        wbs_vhdfd_we_i;
650
wire        wbs_vhdfd_stb_i;
651
wire        wbs_vhdfd_cyc_i;
652
wire        wbs_vhdfd_ack_o;
653
wire  [2:0] wbs_vhdfd_adr_i;
654
wire  [2:0] vhdfd_adr_i;
655
wire  [1:0] vhdfd_adr_low;
656
wire  [7:0] vhdfd_dat_i;
657
 
658
assign vhdfd_dat_i = wbs_vhdfd_sel_i == 4'b0001 ? wbs_vhdfd_dat_i[7:0] :
659
                     wbs_vhdfd_sel_i == 4'b0010 ? wbs_vhdfd_dat_i[15:8] :
660
                     wbs_vhdfd_sel_i == 4'b0100 ? wbs_vhdfd_dat_i[23:16] :
661
                     wbs_vhdfd_dat_i[31:24];
662
 
663
assign vhdfd_adr_low = wbs_vhdfd_sel_i == 4'b0001 ? 2'b00 :
664
                       wbs_vhdfd_sel_i == 4'b0010 ? 2'b01 :
665
                       wbs_vhdfd_sel_i == 4'b0100 ? 2'b10 : 2'b11;
666
 
667
assign vhdfd_adr_i = {wbs_vhdfd_adr_i[2], vhdfd_adr_low};
668
 
669
 
670
wb_vhdfd vfdhd0 (
671
    .clk_i(PCI_CLK),
672
    .nrst_i(NRST),
673
    .wbs_adr_i(vhdfd_adr_i[2:0]),
674
    .wbs_dat_o(wbs_vhdfd_dat_o),
675
    .wbs_dat_i(vhdfd_dat_i),
676
    .wbs_sel_i(wbs_vhdfd_sel_i),
677
    .wbs_we_i(wbs_vhdfd_we_i),
678
    .wbs_stb_i(wbs_vhdfd_stb_i),
679
    .wbs_cyc_i(wbs_vhdfd_cyc_i),
680
    .wbs_ack_o(wbs_vhdfd_ack_o),
681
    .flash_adr_o(flash_adr_o),
682
    .flash_dat_o(flash_dat_o),
683
    .flash_dat_i(flash_dat_i),
684
    .flash_oe(flash_oe_o),
685
    .flash_ce(flash_ce_o),
686
    .flash_we(flash_we_o)
687
    );
688
 
689
// Instantiate the spimaster Controller
690
wire [31:0] wbs_spimaster_dat_o;
691
wire [31:0] wbs_spimaster_dat_i;
692
wire  [3:0] wbs_spimaster_sel_i;
693
wire        wbs_spimaster_we_i;
694
wire        wbs_spimaster_stb_i;
695
wire        wbs_spimaster_cyc_i;
696
wire        wbs_spimaster_ack_o;
697
wire  [5:0] wbs_spimaster_adr_i;
698
wire  [7:0] spimaster_dat_i;
699
wire  [7:0] spimaster_adr_i;
700
wire  [1:0] spimaster_adr_low;
701
 
702
assign spimaster_dat_i = wbs_spimaster_sel_i == 4'b0001 ? wbs_spimaster_dat_i[7:0] :
703
                         wbs_spimaster_sel_i == 4'b0010 ? wbs_spimaster_dat_i[15:8] :
704
                         wbs_spimaster_sel_i == 4'b0100 ? wbs_spimaster_dat_i[23:16] :
705
                         wbs_spimaster_dat_i[31:24];
706
 
707
assign spimaster_adr_low = wbs_spimaster_sel_i == 4'b0001 ? 2'b00 :
708
                           wbs_spimaster_sel_i == 4'b0010 ? 2'b01 :
709
                           wbs_spimaster_sel_i == 4'b0100 ? 2'b10 : 2'b11;
710
 
711
assign spimaster_adr_i = {2'b00, wbs_spimaster_adr_i[5:2], spimaster_adr_low};
712 30 hharte
 
713 13 hharte
wire [31:0] cpu_ctrl1_reg0;
714
wire [31:0] cpu_ctrl1_reg1;
715
 
716
wb_cpu_ctrl cpu_ctrl1 (
717
    .clk_i(PCI_CLK),
718
    .nrst_i(NRST),
719
    .wb_adr_i(wbs_spimaster_adr_i[2:0]),
720
    .wb_dat_o(wbs_spimaster_dat_o),
721
    .wb_dat_i(wbs_spimaster_dat_i),
722
    .wb_sel_i(wbs_spimaster_sel_i),
723
    .wb_we_i(wbs_spimaster_we_i),
724
    .wb_stb_i(wbs_spimaster_stb_i),
725
    .wb_cyc_i(wbs_spimaster_cyc_i),
726
    .wb_ack_o(wbs_spimaster_ack_o),
727
    .datareg0(cpu_ctrl1_reg0),
728
    .datareg1(cpu_ctrl1_reg1)
729
    );
730 30 hharte
 
731 13 hharte
//spiMaster spimaster0 (
732
//    .clk_i(PCI_CLK), 
733
//    .rst_i(RST), 
734
//    .address_i(spimaster_adr_i), 
735
//    .data_o(wbs_spimaster_dat_o), 
736
//    .data_i(spimaster_dat_i), 
737
//    .we_i(wbs_spimaster_we_i), 
738
//    .strobe_i(wbs_spimaster_stb_i), 
739
//    .ack_o(wbs_spimaster_ack_o),
740
//    .spiSysClk(PCI_CLK), 
741
//    .spiClkOut(SD_SPI_CLK), 
742
//    .spiDataIn(SD_SPI_MISO), 
743
//    .spiDataOut(SD_SPI_MOSI), 
744
//    .spiCS_n(SD_SPI_CS_N)    
745
//    );
746
 
747
assign SD_SPI_CLK = PCI_CLK;
748
assign SD_SPI_MOSI = 1'b1;
749
assign SD_SPI_CS_N = 1'b1;
750
 
751
// Instantiate the fpb Controller
752
wire [31:0] wbs_fpb_dat_o;
753
wire [31:0] wbs_fpb_dat_i;
754
wire  [3:0] wbs_fpb_sel_i;
755
wire        wbs_fpb_we_i;
756
wire        wbs_fpb_stb_i;
757
wire        wbs_fpb_cyc_i;
758
wire        wbs_fpb_ack_o;
759
wire  [4:0] wbs_fpb_adr_i;
760
wire  [7:0] fpb_dat_i;
761
wire  [7:0] fpb_adr_i;
762
wire  [1:0] fpb_adr_low;
763
 
764 30 hharte
wb_fpb fpb0 (
765 13 hharte
    .clk_i(PCI_CLK),
766
    .nrst_i(NRST),
767 30 hharte
    .wbs_adr_i(wbs_fpb_adr_i[4:0]),
768
    .wbs_dat_o(wbs_fpb_dat_o),
769
    .wbs_dat_i(wbs_fpb_dat_i),
770
    .wbs_sel_i(wbs_fpb_sel_i),
771
    .wbs_we_i(wbs_fpb_we_i),
772
    .wbs_stb_i(wbs_fpb_stb_i),
773
    .wbs_cyc_i(wbs_fpb_cyc_i),
774
    .wbs_ack_o(wbs_fpb_ack_o),
775
    .prog_out_port(LED),
776
    .sense_sw_i({ 4'h0, SW }),
777
    .lcd_e(LCD_E),
778
    .lcd_rs(LCD_RS),
779
    .lcd_rw(LCD_RW),
780
    .lcd_dat(LCD_D)
781 13 hharte
    );
782
 
783
 
784 3 hharte
// Instantiate the Wishbone Backplane
785
intercon wb_intercon (
786
    .wb32_pci_master_dat_i(MDAT_I),
787
    .wb32_pci_master_ack_i(ACK_I),
788
    .wb32_pci_master_err_i(ERR_I),
789
    .wb32_pci_master_dat_o(MDAT_O),
790
    .wb32_pci_master_we_o(WE_O),
791
    .wb32_pci_master_sel_o(SEL_O),
792
    .wb32_pci_master_adr_o(ADR_O[23:0]),
793
    .wb32_pci_master_cyc_o(CYC_O),
794
    .wb32_pci_master_stb_o(STB_O),
795
    .wbm_z80_dat_i(wb_z80_dat_i),
796
    .wbm_z80_ack_i(wb_z80_ack_i),
797
    .wbm_z80_dat_o(wb_z80_dat_o),
798
    .wbm_z80_we_o(wb_z80_we_o),
799
    .wbm_z80_sel_o(wb_z80_sel_o),
800 13 hharte
    .wbm_z80_adr_o((wb_z80_tga_o & 2'b01) ? {16'h0000,wb_z80_adr_o[7:0]} : mmu_adr_o),
801 3 hharte
    .wbm_z80_cyc_o(wb_z80_cyc_o),
802
    .wbm_z80_stb_o(wb_z80_stb_o),
803
    .wb_cpu_ctrl_dat_o(wb_cpu_ctrl_dat_o),
804
    .wb_cpu_ctrl_ack_o(wb_cpu_ctrl_ack_o),
805
    .wb_cpu_ctrl_dat_i(wb_cpu_ctrl_dat_i),
806
    .wb_cpu_ctrl_we_i(wb_cpu_ctrl_we_i),
807
    .wb_cpu_ctrl_sel_i(wb_cpu_ctrl_sel_i),
808
    .wb_cpu_ctrl_adr_i(wb_cpu_ctrl_adr_i),
809
    .wb_cpu_ctrl_cyc_i(wb_cpu_ctrl_cyc_i),
810
    .wb_cpu_ctrl_stb_i(wb_cpu_ctrl_stb_i),
811
`ifdef USE_INTERNAL_RAM
812 30 hharte
    .wbs_sram_dat_o(wbs_sram_dat_o),
813
    .wbs_sram_ack_o(wbs_sram_ack_o),
814
    .wbs_sram_dat_i(wbs_sram_dat_i),
815
    .wbs_sram_we_i(wbs_sram_we_i),
816
    .wbs_sram_sel_i(wbs_sram_sel_i),
817
    .wbs_sram_adr_i(wbs_sram_adr_i),
818
    .wbs_sram_cyc_i(wbs_sram_cyc_i),
819
    .wbs_sram_stb_i(wbs_sram_stb_i),
820 3 hharte
`endif // USE_INTERNAL_RAM
821
 
822 30 hharte
    .wbs_kbd_dat_o(wbs_kbd_dat_o),          // 0x00-0x01
823
    .wbs_kbd_ack_o(wbs_kbd_ack_o),
824
    .wbs_kbd_dat_i(wbs_kbd_dat_i),
825
    .wbs_kbd_we_i(wbs_kbd_we_i),
826
    .wbs_kbd_sel_i(wbs_kbd_sel_i),
827
    .wbs_kbd_adr_i(wbs_kbd_adr_i),
828
    .wbs_kbd_cyc_i(wbs_kbd_cyc_i),
829
    .wbs_kbd_stb_i(wbs_kbd_stb_i),
830 3 hharte
 
831
    .wbs_flash_dat_o(wbs_flash_dat_o),
832
    .wbs_flash_ack_o(wbs_flash_ack_o),
833
    .wbs_flash_dat_i(wbs_flash_dat_i),
834
    .wbs_flash_we_i (wbs_flash_we_i),
835
    .wbs_flash_sel_i(wbs_flash_sel_i),
836
    .wbs_flash_adr_i(wbs_flash_adr_i),
837
    .wbs_flash_cyc_i(wbs_flash_cyc_i),
838
    .wbs_flash_stb_i(wbs_flash_stb_i),
839
 
840
    .wbs_ddr_dat_o(wbs_ddr_dat_o),
841
    .wbs_ddr_ack_o(wbs_ddr_ack_o),
842
    .wbs_ddr_dat_i(wbs_ddr_dat_i),
843
    .wbs_ddr_we_i (wbs_ddr_we_i),
844
    .wbs_ddr_sel_i(wbs_ddr_sel_i),
845
    .wbs_ddr_adr_i(wbs_ddr_adr_i),
846
    .wbs_ddr_cyc_i(wbs_ddr_cyc_i),
847
    .wbs_ddr_stb_i(wbs_ddr_stb_i),
848 30 hharte
 
849
    .wbs_mmu_dat_o(wbs_mmu_dat_o),  // 0x20-0x23 
850 3 hharte
    .wbs_mmu_ack_o(wbs_mmu_ack_o),
851
    .wbs_mmu_dat_i(wbs_mmu_dat_i),
852
    .wbs_mmu_we_i (wbs_mmu_we_i),
853
    .wbs_mmu_sel_i(wbs_mmu_sel_i),
854
    .wbs_mmu_adr_i(wbs_mmu_adr_i),
855
    .wbs_mmu_cyc_i(wbs_mmu_cyc_i),
856
    .wbs_mmu_stb_i(wbs_mmu_stb_i),
857
 
858 13 hharte
    .wbs_vhdfd_dat_o(wbs_vhdfd_dat_o), // 0xC0
859
    .wbs_vhdfd_ack_o(wbs_vhdfd_ack_o),
860
    .wbs_vhdfd_dat_i(wbs_vhdfd_dat_i),
861
    .wbs_vhdfd_we_i (wbs_vhdfd_we_i),
862
    .wbs_vhdfd_sel_i(wbs_vhdfd_sel_i),
863
    .wbs_vhdfd_adr_i(wbs_vhdfd_adr_i),
864
    .wbs_vhdfd_cyc_i(wbs_vhdfd_cyc_i),
865
    .wbs_vhdfd_stb_i(wbs_vhdfd_stb_i),
866
 
867
    .wbs_spimaster_dat_o(wbs_spimaster_dat_o), // 0x80-0xBF
868
    .wbs_spimaster_ack_o(wbs_spimaster_ack_o),
869
    .wbs_spimaster_dat_i(wbs_spimaster_dat_i),
870
    .wbs_spimaster_we_i (wbs_spimaster_we_i),
871
    .wbs_spimaster_sel_i(wbs_spimaster_sel_i),
872
    .wbs_spimaster_adr_i(wbs_spimaster_adr_i),
873
    .wbs_spimaster_cyc_i(wbs_spimaster_cyc_i),
874
    .wbs_spimaster_stb_i(wbs_spimaster_stb_i),
875 30 hharte
 
876 13 hharte
    .wbs_fpb_dat_o(wbs_fpb_dat_o), // 0xE0-0xFF
877
    .wbs_fpb_ack_o(wbs_fpb_ack_o),
878
    .wbs_fpb_dat_i(wbs_fpb_dat_i),
879
    .wbs_fpb_we_i (wbs_fpb_we_i),
880
    .wbs_fpb_sel_i(wbs_fpb_sel_i),
881
    .wbs_fpb_adr_i(wbs_fpb_adr_i),
882
    .wbs_fpb_cyc_i(wbs_fpb_cyc_i),
883
    .wbs_fpb_stb_i(wbs_fpb_stb_i),
884
 
885 3 hharte
    .wbs_vga_dat_o(wbs_vga_dat_o),
886
    .wbs_vga_ack_o(wbs_vga_ack_o),
887
    .wbs_vga_dat_i(wbs_vga_dat_i),
888
    .wbs_vga_we_i (wbs_vga_we_i),
889
    .wbs_vga_sel_i(wbs_vga_sel_i),
890
    .wbs_vga_adr_i(wbs_vga_adr_i),
891
    .wbs_vga_cyc_i(wbs_vga_cyc_i),
892
    .wbs_vga_stb_i(wbs_vga_stb_i),
893
 
894
    .clk(PCI_CLK),
895
    .reset(RST)
896
    );
897
 
898
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.