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

Subversion Repositories xulalx25soc

[/] [xulalx25soc/] [trunk/] [rtl/] [busmaster.v] - Blame information for rev 54

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

Line No. Rev Author Line
1 46 dgisselq
`define XULA25
2 2 dgisselq
///////////////////////////////////////////////////////////////////////////
3
//
4
// Filename:    busmaster.v
5
//
6
// Project:     XuLA2 board
7
//
8
// Purpose:     This is the highest level, Verilator simulatable, portion of
9
//              the XuLA2 core.  You should be able to successfully Verilate 
10
//      this file, and then build a test bench that tests and proves the
11
//      capability of anything within here.
12
//
13
//      In general, this means the file is little more than a wishbone
14
//      interconnect that connects multiple devices together.  User-JTAG
15
//      commands come in via i_rx_stb and i_rx_data.  These are converted into
16
//      wishbone bus interactions, the results of which come back out via
17
//      o_tx_data and o_tx_stb.
18
//
19
//
20
// Creator:     Dan Gisselquist, Ph.D.
21
//              Gisselquist Technology, LLC
22
//
23
///////////////////////////////////////////////////////////////////////////
24
//
25
// Copyright (C) 2015, Gisselquist Technology, LLC
26
//
27
// This program is free software (firmware): you can redistribute it and/or
28
// modify it under the terms of  the GNU General Public License as published
29
// by the Free Software Foundation, either version 3 of the License, or (at
30
// your option) any later version.
31
//
32
// This program is distributed in the hope that it will be useful, but WITHOUT
33
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
34
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
35
// for more details.
36
//
37
// License:     GPL, v3, as defined and found on www.gnu.org,
38
//              http://www.gnu.org/licenses/gpl.html
39
//
40
//
41
///////////////////////////////////////////////////////////////////////////
42
//
43 31 dgisselq
 
44 46 dgisselq
//
45
// Configuration question #1
46
//
47
//      What innate capabilities are built into the board?
48
//
49 2 dgisselq
`define INCLUDE_ZIPCPU
50
// `define      NO_ZIP_WBU_DELAY
51
`define IMPLEMENT_ONCHIP_RAM
52 31 dgisselq
`ifndef VERILATOR
53
`ifndef XULA25
54 2 dgisselq
`define FANCY_ICAP_ACCESS
55 31 dgisselq
`endif
56
`endif
57 2 dgisselq
`define FLASH_ACCESS
58 18 dgisselq
// `define SDCARD_ACCESS        // Not built yet ...
59
//
60 46 dgisselq
 
61
 
62 18 dgisselq
//
63 46 dgisselq
// Configuration question #2
64
//
65
//      Are any scopes built in to the board?
66
//
67
 
68
//
69
// Position #1: The flash scope, or perhaps the wishbone bus/uart/jtag scope
70
//
71 2 dgisselq
// `define      FLASH_SCOPE
72 46 dgisselq
`ifndef FLASH_SCOPE
73
// `define      WBUS_SCOPE // Occupies the FLASH_SCOPE location, so both cannot be active
74
`endif
75
//
76
// Position #2: The ICAP configuration scope
77
//
78 18 dgisselq
`ifdef  FANCY_ICAP_ACCESS
79 46 dgisselq
`define CFG_SCOPE // Only defined if we have the access ...
80 18 dgisselq
`endif
81 46 dgisselq
//
82
// Position #3: The SDRAM scope
83
//
84
`define SDRAM_SCOPE
85
//
86
// Position #4: The Zip CPU scope
87
//
88 31 dgisselq
`ifdef  XULA25
89 46 dgisselq
// `define      ZIP_SCOPE
90 31 dgisselq
`endif
91
 
92 2 dgisselq
module  busmaster(i_clk, i_rst,
93
                i_rx_stb, i_rx_data, o_tx_stb, o_tx_data, i_tx_busy,
94
                // The SPI Flash lines
95
                o_sf_cs_n, o_sd_cs_n, o_spi_sck, o_spi_mosi, i_spi_miso,
96
                // The SDRAM lines
97
                o_ram_cs_n, o_ram_cke, o_ram_ras_n, o_ram_cas_n,
98
                        o_ram_we_n, o_ram_bs, o_ram_addr,
99
                        o_ram_drive_data, i_ram_data, o_ram_data,
100
                        o_ram_dqm,
101
                // Generic GPIO
102
                i_gpio, o_gpio, o_pwm,
103
                i_rx_uart, o_tx_uart);
104
        parameter       ZIP_ADDRESS_WIDTH=24, NGPO=15, NGPI=15,
105
                        ZA=ZIP_ADDRESS_WIDTH;
106
        input                   i_clk, i_rst;
107
        // The bus commander, via an external JTAG port
108
        input                   i_rx_stb;
109
        input           [7:0]    i_rx_data;
110
        output  wire            o_tx_stb;
111
        output  wire    [7:0]    o_tx_data;
112
        input                   i_tx_busy;
113
        // SPI flash control
114
        output  wire            o_sf_cs_n, o_sd_cs_n;
115
        output  wire            o_spi_sck, o_spi_mosi;
116
        input                   i_spi_miso;
117
        // SDRAM control
118
        output  wire            o_ram_cs_n, o_ram_cke;
119
        output  wire            o_ram_ras_n, o_ram_cas_n, o_ram_we_n;
120
        output  wire    [12:0]   o_ram_addr;
121
        output  wire    [1:0]    o_ram_bs;
122
        output  wire            o_ram_drive_data;
123
        input           [15:0]   i_ram_data;
124
        output  wire    [15:0]   o_ram_data;
125
        output  wire    [1:0]    o_ram_dqm;
126
        input   [(NGPI-1):0]     i_gpio;
127
        output wire [(NGPO-1):0] o_gpio;
128
        output  wire            o_pwm;
129
        input                   i_rx_uart;
130
        output  wire            o_tx_uart;
131
 
132
 
133
        //
134
        //
135
        // Master wishbone wires
136
        //
137
        //
138
        wire            wb_cyc, wb_stb, wb_we, wb_stall, wb_ack, wb_err;
139
        wire    [31:0]   wb_data, wb_idata, wb_addr;
140
 
141
        //
142
        //
143
        // First BUS master source: The JTAG
144
        //
145
        //
146
        wire    [31:0]   dwb_idata;
147
 
148
        // Wires going to devices
149
        wire            wbu_cyc, wbu_stb, wbu_we;
150
        wire    [31:0]   wbu_addr, wbu_data;
151
        // and then coming from devices
152
        wire            wbu_ack, wbu_stall, wbu_err;
153
        wire    [31:0]   wbu_idata;
154
        // And then headed back home
155
        wire    w_interrupt;
156
        // Oh, and the debug control for the ZIP CPU
157
        wire            wbu_zip_sel, zip_dbg_ack, zip_dbg_stall;
158 9 dgisselq
        assign  wbu_zip_sel =((wbu_cyc)&&(wbu_addr[24]));
159 2 dgisselq
        wire    [31:0]   zip_dbg_data;
160
        wbubus  genbus(i_clk, i_rx_stb, i_rx_data,
161
                        wbu_cyc, wbu_stb, wbu_we, wbu_addr, wbu_data,
162
`ifdef  INCLUDE_ZIPCPU
163
                        ((~wbu_zip_sel)&&(wbu_ack))
164
                                ||((wbu_zip_sel)&&(zip_dbg_ack)),
165
                        ((~wbu_zip_sel)&&(wbu_stall))
166
                                ||((wbu_zip_sel)&&(zip_dbg_stall)),
167
                                wbu_err, (wbu_zip_sel)?zip_dbg_data:dwb_idata,
168
`else
169
                        wbu_ack, wbu_stall,
170
                                wbu_err, dwb_idata,
171
`endif
172
                        w_interrupt,
173
                        o_tx_stb, o_tx_data, i_tx_busy);
174
 
175
 
176
        //
177
        //
178
        // Second BUS master source: The ZipCPU
179
        //
180
        //
181
        wire            zip_cyc, zip_stb, zip_we, zip_cpu_int;
182
        wire    [(ZA-1):0]       w_zip_addr;
183
        wire    [31:0]   zip_addr, zip_data;
184
        // and then coming from devices
185
        wire            zip_ack, zip_stall, zip_err;
186
        wire    dwb_we, dwb_stb, dwb_cyc, dwb_ack, dwb_stall, dwb_err;
187
        wire    [31:0]   dwb_addr, dwb_odata;
188
        wire    [7:0]    w_ints_to_zip_cpu;
189
`ifdef  INCLUDE_ZIPCPU
190 31 dgisselq
`ifdef  XULA25
191 2 dgisselq
        wire    [31:0]   zip_debug;
192
        zipsystem #(24'h2000,ZA,8,1,8)
193
                zippy(i_clk, 1'b0,
194
                        // Zippys wishbone interface
195
                        zip_cyc, zip_stb, zip_we, w_zip_addr, zip_data,
196
                                zip_ack, zip_stall, dwb_idata, zip_err,
197
                        w_ints_to_zip_cpu, zip_cpu_int,
198
                        // Debug wishbone interface
199
                        ((wbu_cyc)&&(wbu_zip_sel)),
200
                                ((wbu_stb)&&(wbu_zip_sel)),wbu_we, wbu_addr[0],
201
                                wbu_data,
202
                                zip_dbg_ack, zip_dbg_stall, zip_dbg_data,
203
                        zip_debug);
204 31 dgisselq
`else
205
        zipbones #(24'h2000,ZA,8,1)
206
                zippy(i_clk, 1'b0,
207
                        // Zippys wishbone interface
208
                        zip_cyc, zip_stb, zip_we, w_zip_addr, zip_data,
209
                                zip_ack, zip_stall, dwb_idata, zip_err,
210
                        w_interrupt, zip_cpu_int,
211
                        // Debug wishbone interface
212
                        ((wbu_cyc)&&(wbu_zip_sel)),
213
                                ((wbu_stb)&&(wbu_zip_sel)),wbu_we, wbu_addr[0],
214
                                wbu_data,
215
                                zip_dbg_ack, zip_dbg_stall, zip_dbg_data);
216
`endif
217 2 dgisselq
        generate
218
        if (ZA < 32)
219
                assign  zip_addr = { {(32-ZA){1'b0}}, w_zip_addr };
220
        else
221
                assign  zip_addr = w_zip_addr;
222
        endgenerate
223
 
224
 
225
        //
226
        //
227
        // And an arbiter to decide who gets to access the bus
228
        //
229
        //
230
        /*
231
        wbarbiter #(32,32) wbu_zip_arbiter(i_clk, i_rst,
232
                // The UART interface Master
233
                wbu_addr, wbu_data, wbu_we, (wbu_stb)&&(~wbu_zip_sel),
234
                        (wbu_cyc)&&(~wbu_zip_sel), wbu_ack, wbu_stall, wbu_err,
235
                // The ZIP CPU Master
236
                zip_addr, zip_data, zip_we, zip_stb,
237
                        zip_cyc, zip_ack, zip_stall, zip_err,
238
                // Common bus returns
239
                dwb_addr,dwb_odata,dwb_we,dwb_stb, dwb_cyc, dwb_ack, dwb_stall, dwb_err);
240
        */
241
        wbpriarbiter #(32,32) wbu_zip_arbiter(i_clk,
242
                // The ZIP CPU Master -- gets priority in the arbiter
243
                zip_cyc, zip_stb, zip_we, zip_addr, zip_data,
244
                        zip_ack, zip_stall, zip_err,
245
                // The JTAG interface Master, secondary priority,
246
                // will suffer a 1clk delay in arbitration
247
                (wbu_cyc)&&(~wbu_zip_sel), (wbu_stb)&&(~wbu_zip_sel), wbu_we,
248
                        wbu_addr, wbu_data,
249
                        wbu_ack, wbu_stall, wbu_err,
250
                // Common bus returns
251
                dwb_cyc, dwb_stb, dwb_we, dwb_addr, dwb_odata,
252
                        dwb_ack, dwb_stall, dwb_err);
253
 
254
`else
255
        assign  zip_cyc = 1'b0;
256
        assign  zip_stb = 1'b0;
257
        assign  zip_we  = 1'b0;
258
        assign  zip_cpu_int = 1'b0;
259
        assign  zip_addr = 32'h000;
260
        assign  zip_data = 32'h000;
261
 
262
        reg     r_zip_dbg_ack;
263
        initial r_zip_dbg_ack = 1'b0;
264
        always @(posedge i_clk)
265
                r_zip_dbg_ack <= ((wbu_cyc)&&(wbu_zip_sel)&(wbu_stb));
266
        assign  zip_dbg_ack = r_zip_dbg_ack;
267
        assign  zip_dbg_stall = 1'b0;
268
        assign  zip_dbg_data = 32'h000;
269
 
270
        assign  dwb_addr = wbu_addr;
271
        assign  dwb_odata = wbu_data;
272
        assign  dwb_we = wbu_we;
273
        assign  dwb_stb = (wbu_stb);
274
        assign  dwb_cyc = (wbu_cyc);
275
        assign  wbu_ack = dwb_ack;
276
        assign  wbu_stall = dwb_stall;
277
        assign  dwb_idata = wb_idata;
278
        assign  wbu_err = dwb_err;
279
`endif
280
 
281
 
282
        // 
283
        // 
284
        // And because the ZIP CPU and the Arbiter create an unacceptable
285
        // delay, we fail timing.  So we add in a delay cycle ...
286
        // 
287
        // 
288
`ifdef  NO_ZIP_WBU_DELAY
289
        assign  wb_cyc    = dwb_cyc;
290
        assign  wb_stb    = dwb_stb;
291
        assign  wb_we     = dwb_we;
292
        assign  wb_addr   = dwb_addr;
293
        assign  wb_data   = dwb_odata;
294
        assign  dwb_idata = wb_idata;
295
        assign  dwb_ack   = wb_ack;
296
        assign  dwb_stall = wb_stall;
297
        assign  dwb_err   = wb_err;
298
`else
299
        busdelay        wbu_zip_delay(i_clk,
300
                        dwb_cyc, dwb_stb, dwb_we, dwb_addr, dwb_odata,
301
                                dwb_ack, dwb_stall, dwb_idata, dwb_err,
302
                        wb_cyc, wb_stb, wb_we, wb_addr, wb_data,
303
                                wb_ack, wb_stall, wb_idata, wb_err);
304
`endif
305
 
306
 
307
 
308
        wire    io_sel, pwm_sel, uart_sel, flash_sel, flctl_sel, scop_sel,
309
                        cfg_sel, mem_sel, sdram_sel, sdcard_sel,
310
                        none_sel, many_sel, io_bank;
311
        wire    io_ack, flash_ack, scop_ack, cfg_ack, mem_ack,
312
                        sdram_ack, sdcard_ack, uart_ack, pwm_ack;
313
        wire    io_stall, flash_stall, scop_stall, cfg_stall, mem_stall,
314
                        sdram_stall, sdcard_stall, uart_stall, pwm_stall;
315
 
316
        wire    [31:0]   io_data, flash_data, scop_data, cfg_data, mem_data,
317
                        sdram_data, sdcard_data, uart_data, pwm_data;
318
        reg     [31:0]   bus_err_addr;
319
 
320
        assign  wb_ack = (wb_cyc)&&((io_ack)||(uart_ack)||(pwm_ack)
321
                                ||(scop_ack)||(cfg_ack)
322
                                ||(mem_ack)||(flash_ack)||(sdram_ack)
323
                                ||(sdcard_ack)
324
                                ||((none_sel)&&(1'b1)));
325
        assign  wb_stall = ((io_sel)&&(io_stall))
326
                        ||((uart_sel)&&(uart_stall))
327
                        ||((pwm_sel)&&(pwm_stall))
328
                        ||((scop_sel)&&(scop_stall))
329
                        ||((cfg_sel)&&(cfg_stall))
330
                        ||((mem_sel)&&(mem_stall))
331
                        ||((sdram_sel)&&(sdram_stall))
332
                        ||((sdcard_sel)&&(sdcard_stall))
333
                        ||((flash_sel||flctl_sel)&&(flash_stall));
334
                        // (none_sel)&&(1'b0)
335
 
336
        /*
337
        assign  wb_idata = (io_ack)?io_data
338
                        : ((scop_ack)?scop_data
339
                        : ((cfg_ack)?cfg_data
340
                        : ((mem_ack)?mem_data
341
                        : ((flash_ack)?flash_data
342
                        : 32'h00))));
343
        */
344
        assign  wb_idata =  (io_ack|scop_ack)?((io_ack )? io_data  : scop_data)
345
                        : ((uart_ack|pwm_ack)?((uart_ack)?uart_data: pwm_data)
346
                        : ((cfg_ack) ? cfg_data
347
                        : ((sdram_ack|sdcard_ack)
348
                                        ?((sdram_ack)? sdram_data : sdcard_data)
349
                        : ((mem_ack)?mem_data:flash_data)))); // if (flash_ack)
350
        assign  wb_err = ((wb_cyc)&&(wb_stb)&&(none_sel || many_sel)) || many_ack;
351
 
352
        // Addresses ...
353
        //      0000 xxxx       configuration/control registers
354
        //      001x xxxx       Down-sampler taps       (64 taps, 2 at a time)
355
        //      1xxx xxxx       Up-sampler taps
356
        //      1 xxxx xxxx xxxx xxxx xxxx      Up-sampler taps
357 31 dgisselq
 
358
        wire    pre_io, pre_pwm, pre_uart, pre_flctl, pre_scop;
359 2 dgisselq
        assign  io_bank  = (wb_cyc)&&(wb_addr[31:5] == 27'h8);
360 31 dgisselq
        assign  pre_io   = (~pre_flctl)&&(~pre_pwm)&&(~pre_uart)&&(~pre_scop);
361
        assign  io_sel   = (io_bank)&&(pre_io);
362
        assign  pre_pwm  = (wb_addr[4: 1]== 4'h4);
363
        assign  pwm_sel  = (io_bank)&&(pre_pwm);
364
        assign  pre_uart = (wb_addr[4: 1]== 4'h5)||(wb_addr[4:0]==5'h7);
365
        assign  uart_sel = (io_bank)&&(pre_uart);
366
        assign  pre_flctl= (wb_addr[4: 2]== 3'h3);
367
        assign  flctl_sel= (io_bank)&&(pre_flctl);
368
        assign  pre_scop = (wb_addr[4: 3]== 2'h3);
369
        assign  scop_sel = (io_bank)&&(pre_scop);
370 2 dgisselq
        assign  cfg_sel  =((wb_cyc)&&(wb_addr[31: 6]== 26'h05));
371
        // zip_sel is not on the bus at this point
372
        assign  mem_sel  =((wb_cyc)&&(wb_addr[31:13]== 19'h01));
373
        assign  flash_sel=((wb_cyc)&&(wb_addr[31:18]== 14'h01));
374
        assign  sdcard_sel=1'b0;
375
        assign  sdram_sel=((wb_cyc)&&(wb_addr[31:23]== 9'h01));
376 31 dgisselq
 
377
        assign  none_sel =((wb_cyc)&&(wb_stb)&&(~
378
                        (io_sel
379
                        ||uart_sel
380
                        ||pwm_sel
381
                        ||flctl_sel
382
                        ||scop_sel
383
                        ||cfg_sel
384
                        ||mem_sel
385
                        ||sdram_sel
386
                        ||sdcard_sel
387
                        ||flash_sel)));
388 2 dgisselq
        assign  many_sel =((wb_cyc)&&(wb_stb)&&(
389
                         {3'h0, io_sel}
390
                        +{3'h0, uart_sel}
391
                        +{3'h0, pwm_sel}
392
                        +{3'h0, flctl_sel}
393
                        +{3'h0, scop_sel}
394
                        +{3'h0, cfg_sel}
395
                        +{3'h0, mem_sel}
396
                        +{3'h0, sdram_sel}
397
                        +{3'h0, sdcard_sel}
398
                        +{3'h0, flash_sel} > 1));
399
 
400
        wire    many_ack;
401
        assign  many_ack =((wb_cyc)&&(
402
                         {3'h0, io_ack}
403
                        +{3'h0, uart_ack}
404
                        +{3'h0, pwm_ack}
405 31 dgisselq
                        // FLCTL acks through the flash, so one less check here
406 2 dgisselq
                        +{3'h0, scop_ack}
407
                        +{3'h0, cfg_ack}
408
                        +{3'h0, mem_ack}
409
                        +{3'h0, sdram_ack}
410
                        +{3'h0, sdcard_ack}
411
                        +{3'h0, flash_ack} > 1));
412
 
413
        always @(posedge i_clk)
414
                if (wb_err)
415
                        bus_err_addr <= wb_addr;
416
 
417
        wire            flash_interrupt, scop_interrupt,
418
                        uart_rx_int, uart_tx_int, pwm_int;
419
        // The I/O processor, herein called an ioslave
420
        ioslave #(NGPO, NGPI) runio(i_clk,
421
                        wb_cyc, (io_sel)&&(wb_stb), wb_we, wb_addr[4:0],
422
                                wb_data, io_ack, io_stall, io_data,
423
                        i_gpio, o_gpio,
424
                        bus_err_addr,
425
                        { uart_tx_int, uart_rx_int, pwm_int, scop_interrupt,
426 31 dgisselq
                                flash_interrupt,
427
`ifdef  XULA25
428
                                zip_cpu_int
429
`else
430
                                1'b0
431
`endif
432
                                },
433 2 dgisselq
                        w_ints_to_zip_cpu,
434
                        w_interrupt);
435
                // 8684
436
                // 1'bx, 4'h0, scop_sel, scop_ack, ~scop_stall, 
437
                //      wb_err, ~vga_interrupt, 2'b00, flash_interrupt
438
        //
439
 
440
        //
441
        //      UART device
442
        //
443
        uartdev serialport(i_clk, i_rx_uart, o_tx_uart,
444
                        wb_cyc, (wb_stb)&&(uart_sel), wb_we,
445 9 dgisselq
                                        { ~wb_addr[2], wb_addr[0]}, wb_data,
446
                        uart_ack, uart_stall, uart_data,
447 2 dgisselq
                        uart_rx_int, uart_tx_int);
448
 
449
        //
450
        //      PWM (audio) device
451
        //
452 46 dgisselq
        // The audio rate is given by the number of clock ticks between
453
        // samples.  If we are running at 80 MHz, then divide that by the
454
        // sample rate to get the first parameter for the PWM device.  The
455
        // second parameter is zero or one, indicating whether or not the
456
        // audio rate can be adjusted (1), or whether it is fixed within the
457
        // build (0).
458
`ifdef  XULA25
459
        wbpwmaudio      #(32'd1814,1)   // 44.1 kHz, user adjustable
460
`else
461
        wbpwmaudio      #(32'h10000,0)   //  8   kHz, fixed audio rate
462
`endif
463
                pwmdev(i_clk,
464 2 dgisselq
                        wb_cyc, (wb_stb)&&(pwm_sel), wb_we, wb_addr[0],
465
                        wb_data, pwm_ack, pwm_stall, pwm_data, o_pwm, pwm_int);
466 46 dgisselq
 
467 2 dgisselq
 
468
 
469
        //
470
        //      FLASH MEMORY CONFIGURATION ACCESS
471
        //
472
        wire    flash_cs_n, flash_sck, flash_mosi;
473
`ifdef  FLASH_ACCESS
474
        wbspiflash      flashmem(i_clk,
475
                wb_cyc,(wb_stb&&flash_sel),(wb_stb)&&(flctl_sel),wb_we,
476
                        wb_addr[17:0], wb_data,
477
                flash_ack, flash_stall, flash_data,
478
                flash_sck, flash_cs_n, o_sf_cs_n, flash_mosi, i_spi_miso,
479
                flash_interrupt);
480
`else
481
        reg     r_flash_ack;
482
        initial r_flash_ack = 1'b0;
483
        always @(posedge i_clk)
484
                r_flash_ack <= (wb_cyc)&&(wb_stb)&&((flash_sel)||(flctl_sel));
485
 
486
        assign  flash_ack = r_flash_ack;
487
        assign  flash_stall = 1'b0;
488
        assign  flash_data = 32'h0000;
489
        assign  flash_interrupt = 1'b0;
490
 
491
        assign  flash_cs_n = 1'b1;
492
        assign  flash_sck  = 1'b1;
493
        assign  flash_mosi = 1'b1;
494
 
495
        This is an error
496
`endif
497
 
498
`ifdef  FLASH_ACCESS
499
`ifdef  SDCARD_ACCESS
500
        spiarbiter      spichk(i_clk,
501
                flash_cs_n, flash_sck, flash_mosi,
502
                sdcard_cs_n, sdcard_sck, sdcard_mosi,
503
                o_sf_cs_n, o_sd_cs_n, o_spi_sck, o_spi_mosi);
504
        This is an error
505
`else
506
        // Flash access, but no SD card access
507
        assign  o_sf_cs_n  = flash_cs_n;
508
        assign  o_sd_cs_n  = 1'b1;
509
        assign  o_spi_sck  = flash_sck;
510
        assign  o_spi_mosi = flash_mosi;
511
`endif // SDCARD_ACCESS && FLASH_ACCESS
512
`else // FLASH_ACCESS
513
`ifdef  SDCARD_ACCESS
514
        // SDCard access, but no flash access
515
        assign  o_sf_cs_n  = 1'b1;
516
        assign  o_sd_cs_n  = sdcard_cs_n;
517
        assign  o_spi_sck  = sdcard_sck;
518
        assign  o_spi_mosi = sdcard_mosi;
519
`else
520
        // No SPI access ...
521
        assign  o_sf_cs_n  = 1'b1;
522
        assign  o_sd_cs_n  = 1'b1;
523
        assign  o_spi_sck  = 1'b1;
524
        assign  o_spi_mosi = 1'b1;
525
`endif // SDCARD_ACCESS, w/o FLASH_ACCESS
526
`endif // !FLASH_ACCESS
527
 
528
 
529
        //
530
        //      MULTIBOOT/ICAPE2 CONFIGURATION ACCESS
531
        //
532
        wire    [31:0]   cfg_scope;
533
`ifdef  FANCY_ICAP_ACCESS
534
        wbicape6        fpga_cfg(i_clk, wb_cyc,(cfg_sel)&&(wb_stb), wb_we,
535
                                wb_addr[5:0], wb_data,
536
                                cfg_ack, cfg_stall, cfg_data,
537
                                cfg_scope);
538
`else
539
        assign  cfg_scope = 32'h0000;
540
        reg     r_cfg_ack;
541
        initial r_cfg_ack = 1'b0;
542
        always @(posedge i_clk)
543
                r_cfg_ack <= ((wb_cyc)&&(cfg_sel)&&(wb_stb)&&(~cfg_stall));
544
        assign  cfg_ack = r_cfg_ack;
545
        assign  cfg_stall = 1'b0;
546
        assign  cfg_data = 32'h0000;
547
`endif
548
 
549
 
550
        //
551
        //      RAM MEMORY ACCESS
552
        //
553
`ifdef  IMPLEMENT_ONCHIP_RAM
554
        memdev  #(13) ram(i_clk, wb_cyc, (wb_stb)&&(mem_sel), wb_we,
555
                        wb_addr[12:0], wb_data, mem_ack, mem_stall, mem_data);
556
`else
557
        reg     r_mem_ack;
558
        always @(posedge i_clk)
559
                r_mem_ack = (wb_cyc)&&(wb_stb)&&(mem_sel);
560
        assign  mem_data = 32'h000;
561
        assign  mem_stall = 1'b0;
562
        assign  mem_ack = r_mem_ack;
563
`endif
564
 
565
 
566
        //
567
        //      SDRAM Memory Access
568
        //
569
        wire    [31:0]   sdram_debug;
570
`ifndef BYPASS_SDRAM_ACCESS
571
        wbsdram sdram(i_clk,
572
                wb_cyc, (wb_stb)&&(sdram_sel),
573
                        wb_we, wb_addr[22:0], wb_data,
574
                        sdram_ack, sdram_stall, sdram_data,
575
                o_ram_cs_n, o_ram_cke, o_ram_ras_n, o_ram_cas_n, o_ram_we_n,
576
                        o_ram_bs, o_ram_addr,
577
                        o_ram_drive_data, i_ram_data, o_ram_data, o_ram_dqm,
578
                sdram_debug);
579
`else
580
        reg     r_sdram_ack;
581
        initial r_sdram_ack = 1'b0;
582
        always @(posedge i_clk)
583
                r_sdram_ack <= (wb_cyc)&&(wb_stb)&&(sdram_sel);
584
        assign  sdram_ack = r_sdram_ack;
585
        assign  sdram_stall = 1'b0;
586
        assign  sdram_data = 32'h0000;
587
 
588
        assign  o_ram_ce_n  = 1'b1;
589
        assign  o_ram_ras_n = 1'b1;
590
        assign  o_ram_cas_n = 1'b1;
591
        assign  o_ram_we_n  = 1'b1;
592
 
593
        assign  sdram_debug = 32'h0000;
594
`endif
595
 
596
        //
597
        //
598
        //      WISHBONE SCOPES
599
        //
600
        //
601
        //
602
        //
603 46 dgisselq
        wire    [31:0]   scop_flash_data;
604
        wire    scop_flash_ack, scop_flash_stall, scop_flash_interrupt;
605
 
606
`ifndef FLASH_ACCESS
607 2 dgisselq
`ifdef  FLASH_SCOPE
608 46 dgisselq
`undef  FLASH_SCOPE // FLASH_SCOPE only makes sense if you have flash access
609
`endif
610
`endif
611
 
612
`ifdef  FLASH_SCOPE
613 2 dgisselq
        reg     [31:0]   r_flash_debug, last_flash_debug;
614
        always @(posedge i_clk)
615
                r_flash_debug <= flash_debug;
616
        always @(posedge i_clk)
617
                last_flash_debug <= r_flash_debug;
618
        wbscope spiscope(i_clk, 1'b1, (~o_spi_cs_n), r_flash_debug,
619
                // Wishbone interface
620
                i_clk, wb_cyc, ((wb_stb)&&(scop_sel)&&(wb_addr[2:1]==2'b00)), wb_we, wb_addr[0],
621
                        wb_data,
622
                        scop_flash_ack, scop_flash_stall, scop_flash_data,
623
                scop_flash_interrupt);
624
`else
625 46 dgisselq
`ifdef  WBUS_SCOPE
626
        wbscopc #(5'ha) wbuscope(i_clk, 1'b1, wbus_debug[31], wbus_debug[30:0],
627
                // Wishbone interface
628
                i_clk, wb_cyc, ((wb_stb)&&(scop_sel)&&(wb_addr[2:1]==2'b00)), wb_we, wb_addr[0],
629
                        wb_data,
630
                        scop_flash_ack, scop_flash_stall, scop_flash_data,
631
                scop_flash_interrupt);
632
`else
633 2 dgisselq
        assign  scop_flash_data = 32'h00;
634
        assign  scop_flash_ack  = (wb_stb)&&(scop_sel)&&(wb_addr[2:1]==2'b00);
635
        assign scop_flash_stall = 1'b0;
636
        assign scop_flash_interrupt = 1'b0;
637
`endif
638 46 dgisselq
`endif
639 2 dgisselq
 
640
 
641
        wire    [31:0]   scop_cfg_data;
642
        wire            scop_cfg_ack, scop_cfg_stall, scop_cfg_interrupt;
643
`ifdef  CFG_SCOPE
644
        wire            scop_cfg_trigger;
645
        assign  scop_cfg_trigger = (wb_cyc)&&(wb_stb)&&(cfg_sel);
646 18 dgisselq
        wbscope #(5'h7) wbcfgscope(i_clk, 1'b1, scop_cfg_trigger, cfg_scope,
647 2 dgisselq
                // Wishbone interface
648
                i_clk, wb_cyc, ((wb_stb)&&(scop_sel)&&(wb_addr[2:1]==2'b01)),
649
                                wb_we, wb_addr[0], wb_data,
650
                        scop_cfg_ack, scop_cfg_stall, scop_cfg_data,
651
                scop_cfg_interrupt);
652
`else
653
        assign  scop_cfg_data = 32'h00;
654
        assign  scop_cfg_ack  = (wb_stb)&&(scop_sel)&&(wb_addr[2:1]==2'b01);
655
        assign  scop_cfg_stall = 1'b0;
656
        assign  scop_cfg_interrupt = 1'b0;
657
`endif
658
 
659
        wire    [31:0]   scop_ram_data;
660
        wire            scop_ram_ack, scop_ram_stall, scop_ram_interrupt;
661
`ifdef  SDRAM_SCOPE
662
        wire            sdram_trigger;
663 46 dgisselq
        assign  sdram_trigger = sdram_debug[18]; // sdram_sel;
664 2 dgisselq
 
665 46 dgisselq
        wbscope #(5'hb) sdramscope(i_clk, 1'b1, sdram_trigger,
666 2 dgisselq
                        sdram_debug,
667 46 dgisselq
                        //{ sdram_trigger, wb_data[30:0] },
668 2 dgisselq
                // Wishbone interface
669
                i_clk, wb_cyc, ((wb_stb)&&(scop_sel)&&(wb_addr[2:1]==2'b10)), wb_we, wb_addr[0],
670
                        wb_data,
671
                        scop_ram_ack, scop_ram_stall, scop_ram_data,
672
                scop_ram_interrupt);
673
`else
674
        assign  scop_ram_data = 32'h00;
675
        assign  scop_ram_ack  = (wb_stb)&&(scop_sel)&&(wb_addr[2:1]==2'b10);
676
        assign  scop_ram_stall = 1'b0;
677
        assign  scop_ram_interrupt = 1'b0;
678
`endif
679
 
680
        wire    [31:0]   scop_zip_data;
681
        wire            scop_zip_ack, scop_zip_stall, scop_zip_interrupt;
682
`ifdef  ZIP_SCOPE
683
        wire            zip_trigger;
684
        assign  zip_trigger=(wbu_zip_sel)&&(wbu_we)&&(wbu_stb)&&(~wbu_addr[0]);
685 9 dgisselq
        wbscope #(5'ha) zipscope(i_clk, 1'b1, zip_trigger,
686 2 dgisselq
                        zip_debug,
687
                // Wishbone interface
688
                i_clk, wb_cyc, ((wb_stb)&&(scop_sel)&&(wb_addr[2:1]==2'b11)), wb_we, wb_addr[0],
689
                        wb_data,
690
                        scop_zip_ack, scop_zip_stall, scop_zip_data,
691
                scop_zip_interrupt);
692
`else
693
        assign  scop_zip_data = 32'h00;
694
        assign  scop_zip_ack  = (wb_stb)&&(scop_sel)&&(wb_addr[2:1]==2'b11);
695
        assign  scop_zip_stall = 1'b0;
696
        assign  scop_zip_interrupt = 1'b0;
697
`endif
698
 
699
 
700
        assign  scop_interrupt = scop_flash_interrupt || scop_cfg_interrupt
701
                                || scop_ram_interrupt || scop_zip_interrupt;
702
        assign  scop_ack   = scop_cfg_ack | scop_flash_ack | scop_ram_ack | scop_zip_ack;
703
        assign  scop_stall = ((~wb_addr[2])?
704
                                ((wb_addr[1])?scop_flash_stall:scop_cfg_stall)
705
                                : ((wb_addr[1])?scop_ram_stall:scop_zip_stall));
706
        assign  scop_data  = ((scop_cfg_ack)?scop_cfg_data
707
                                : ((scop_flash_ack) ? scop_flash_data
708
                                : ((scop_ram_ack) ? scop_ram_data
709
                                : scop_zip_data)));
710
 
711
 
712
        reg     r_sdcard_ack;
713
        initial r_sdcard_ack = 1'b0;
714
        always @(posedge i_clk)
715
                r_sdcard_ack <= (wb_cyc)&&(wb_stb)&&(sdcard_sel);
716
        assign  sdcard_stall = 1'b0;
717
        assign  sdcard_ack = r_sdcard_ack;
718
        assign  sdcard_data = 32'h0000;
719
endmodule
720
 
721
// 0x8684 interrupts ...???

powered by: WebSVN 2.1.0

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