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

Subversion Repositories s6soc

[/] [s6soc/] [trunk/] [rtl/] [altbusmaster.v] - Blame information for rev 46

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

Line No. Rev Author Line
1 5 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    altbusmaster.v
4
//
5
// Project:     CMod S6 System on a Chip, ZipCPU demonstration project
6
//
7 46 dgisselq
// Purpose:     Because the S6 is *so* small logic-wise, the logic of setting up
8
//              a project/design was separated from the logic of the design
9
//      itself.  Hence, this is the "setup" design.  It allows us to test various
10
//      components from the command line interface, as well as erasing and 
11
//      programming the flash in order to set up the actual device interface.
12 5 dgisselq
//
13
// Creator:     Dan Gisselquist, Ph.D.
14
//              Gisselquist Technology, LLC
15
//
16
////////////////////////////////////////////////////////////////////////////////
17
//
18 46 dgisselq
// Copyright (C) 2015-2017, Gisselquist Technology, LLC
19 5 dgisselq
//
20
// This program is free software (firmware): you can redistribute it and/or
21
// modify it under the terms of  the GNU General Public License as published
22
// by the Free Software Foundation, either version 3 of the License, or (at
23
// your option) any later version.
24
//
25
// This program is distributed in the hope that it will be useful, but WITHOUT
26
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
27
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
28
// for more details.
29
//
30
// You should have received a copy of the GNU General Public License along
31
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
32
// target there if the PDF file isn't present.)  If not, see
33
// <http://www.gnu.org/licenses/> for a copy.
34
//
35
// License:     GPL, v3, as defined and found on www.gnu.org,
36
//              http://www.gnu.org/licenses/gpl.html
37
//
38
//
39
////////////////////////////////////////////////////////////////////////////////
40
//
41
//
42
`include "builddate.v"
43
//
44 11 dgisselq
// `define      IMPLEMENT_ONCHIP_RAM
45 5 dgisselq
`define FLASH_ACCESS
46 46 dgisselq
// `define      DBG_SCOPE       // About 204 LUTs, at 2^6 addresses
47 25 dgisselq
// `define      COMPRESSED_SCOPE
48 11 dgisselq
`define WBUBUS
49 5 dgisselq
module  altbusmaster(i_clk, i_rst,
50 8 dgisselq
                // DEPP I/O Control
51
                i_depp_astb_n, i_depp_dstb_n, i_depp_write_n,
52
                        i_depp_data, o_depp_data, o_depp_wait,
53
                // External UART interface
54 5 dgisselq
                i_rx_stb, i_rx_data, o_tx_stb, o_tx_data, i_tx_busy,
55 46 dgisselq
                        o_uart_rts_n,
56 5 dgisselq
                // The SPI Flash lines
57
                o_qspi_cs_n, o_qspi_sck, o_qspi_dat, i_qspi_dat, o_qspi_mod,
58
                // The board I/O
59
                i_btn, o_led, o_pwm, o_pwm_aux,
60
                // Keypad connections
61
                i_kp_row, o_kp_col,
62
                // UART control
63
                o_uart_setup,
64
                // GPIO lines
65
                i_gpio, o_gpio);
66 8 dgisselq
        parameter       BUS_ADDRESS_WIDTH=23,
67
                        BAW=BUS_ADDRESS_WIDTH; // 24bits->2,258,23b->2181
68 46 dgisselq
        // 2^14 bytes requires a LGMEMSZ of 14, and 12 address bits ranging from
69
        // 0 to 11.  As with many other devices, the wb_cyc line is more for
70
        // form than anything else--it is ignored by the memory itself.
71
        localparam      LGMEMSZ=14;     // Takes 8 BLKRAM16 elements for LGMEMSZ=14
72
        // As with the memory size, the flash size is also measured in log_2 of
73
        // the number of bytes.
74
        localparam      LGFLASHSZ = 24;
75 5 dgisselq
        input                   i_clk, i_rst;
76 8 dgisselq
        // The bus commander, via an external DEPP port
77
        input                   i_depp_astb_n, i_depp_dstb_n, i_depp_write_n;
78
        input   wire    [7:0]    i_depp_data;
79
        output  wire    [7:0]    o_depp_data;
80
        output  wire            o_depp_wait;
81
        // Serial inputs
82 5 dgisselq
        input                   i_rx_stb;
83
        input           [7:0]    i_rx_data;
84 8 dgisselq
        output  reg             o_tx_stb;
85
        output  reg     [7:0]    o_tx_data;
86 5 dgisselq
        input                   i_tx_busy;
87 46 dgisselq
        output  wire            o_uart_rts_n;
88 5 dgisselq
        // SPI flash control
89
        output  wire            o_qspi_cs_n, o_qspi_sck;
90
        output  wire    [3:0]    o_qspi_dat;
91
        input           [3:0]    i_qspi_dat;
92
        output  wire    [1:0]    o_qspi_mod;
93
        // Board I/O
94
        input           [1:0]    i_btn;
95
        output  wire    [3:0]    o_led;
96
        output  wire            o_pwm;
97
        output  wire    [1:0]    o_pwm_aux;
98
        // Keypad
99
        input           [3:0]    i_kp_row;
100
        output  wire    [3:0]    o_kp_col;
101
        // UART control
102 46 dgisselq
        output  wire    [30:0]   o_uart_setup;
103 5 dgisselq
        // GPIO liines
104
        input           [15:0]   i_gpio;
105
        output  wire    [15:0]   o_gpio;
106
 
107
 
108
        //
109
        //
110
        // Master wishbone wires
111
        //
112
        //
113
        wire            wb_cyc, wb_stb, wb_we, wb_stall, wb_ack, wb_err;
114 8 dgisselq
        wire    [31:0]   wb_data, wb_idata, w_wbu_addr;
115 5 dgisselq
        wire    [(BAW-1):0]      wb_addr;
116
 
117
        // Wires going to devices
118
        // And then headed back home
119
        wire    w_interrupt;
120 8 dgisselq
`ifdef  WBUBUS
121 5 dgisselq
        //
122
        //
123
        // The BUS master (source): The WB to UART conversion bus
124
        //
125
        //
126 11 dgisselq
        wire            dep_rx_stb, dep_tx_stb, dep_tx_busy;
127
        wire    [7:0]    dep_rx_data, dep_tx_data;
128
        deppbyte        deppdrive(i_clk,
129
                i_depp_astb_n, i_depp_dstb_n, i_depp_write_n,
130
                        i_depp_data, o_depp_data, o_depp_wait,
131
                dep_rx_stb, dep_rx_data,
132
                dep_tx_stb, dep_tx_data, dep_tx_busy);
133
 
134 46 dgisselq
        wire    bus_dbg;
135
        wbubus #(22) busbdriver(i_clk,
136 11 dgisselq
                        // i_rx_stb, i_rx_data,         // UART control
137
                        dep_rx_stb, dep_rx_data,        // DEPP control
138 5 dgisselq
                        // The wishbone interface
139
                        wb_cyc, wb_stb, wb_we, w_wbu_addr, wb_data,
140
                                wb_ack, wb_stall, wb_err, wb_idata,
141
                        w_interrupt,
142 11 dgisselq
                        // Provide feedback to the DEPP interface
143 46 dgisselq
                        dep_tx_stb, dep_tx_data, dep_tx_busy,
144
                        bus_dbg);
145 11 dgisselq
//                      // Provide feedback to the UART
146
//                      o_tx_stb, o_tx_data, i_tx_busy
147
        // assign       o_uart_rts = (~rx_rdy);
148 46 dgisselq
 
149
        wire    [30:0]   bus_debug;
150
        assign  bus_debug = {
151
                        wb_cyc, wb_stb, wb_ack, wb_stall,
152
                        wb_addr[7:0],
153
                        dep_rx_stb, (~dep_tx_busy)&&(dep_tx_stb), dep_tx_stb,
154
                        dep_rx_data, dep_tx_data };
155 8 dgisselq
`else
156
        //
157
        //
158
        // Another BUS master (source): A conversion from DEPP to busmaster
159
        //
160
        //
161
        wbdeppsimple    deppdrive(i_clk,
162
                i_depp_astb_n, i_depp_dstb_n, i_depp_write_n,
163
                        i_depp_data, o_depp_data, o_depp_wait,
164
                wb_cyc, wb_stb, wb_we, w_wbu_addr, wb_data,
165
                        wb_ack, wb_stall, wb_err, wb_idata,
166
                        w_interrupt);
167
`endif
168 5 dgisselq
 
169 46 dgisselq
        assign  wb_addr = w_wbu_addr[(BAW-1):0];
170 5 dgisselq
 
171 46 dgisselq
 
172
        // Signals to build/detect bus errors
173
        wire    none_sel, many_sel;
174
 
175
        wire    io_sel, flash_sel, flctl_sel, scop_sel, mem_sel;
176 25 dgisselq
        wire    flash_ack, scop_ack, cfg_ack, mem_ack, many_ack;
177 5 dgisselq
        wire    io_stall, flash_stall, scop_stall, cfg_stall, mem_stall;
178 8 dgisselq
        reg     io_ack;
179 5 dgisselq
 
180
        wire    [31:0]   flash_data, scop_data, cfg_data, mem_data, pwm_data,
181
                        spio_data, gpio_data, uart_data;
182
        reg     [31:0]   io_data;
183
        reg     [(BAW-1):0]      bus_err_addr;
184 46 dgisselq
        //
185
        // wb_ack
186
        //
187
        // The returning wishbone ack is equal to the OR of every component that
188
        // might possibly produce an acknowledgement, gated by the CYC line.  To
189
        // add new components, OR their acknowledgements in here.
190
        //
191
        // Note the reference to none_sel.  If nothing is selected, the result
192
        // is an error.  Here, we do nothing more than insure that the erroneous
193
        // request produces an ACK ... if it was ever made, rather than stalling
194
        // the bus.
195
        //
196 5 dgisselq
 
197 46 dgisselq
 
198
        assign  wb_ack = (wb_cyc)&&((io_ack)||(scop_ack)
199 5 dgisselq
                                ||(mem_ack)||(flash_ack)||((none_sel)&&(1'b1)));
200 46 dgisselq
 
201
        //
202
        // wb_stall
203
        //
204
        // The returning wishbone stall line really depends upon what device
205
        // is requested.  Thus, if a particular device is selected, we return
206
        // the stall line for that device.
207
        //
208
        // To add a new device, simply and that devices select and stall lines
209
        // together, and OR the result with the massive OR logic below.
210
        //
211 5 dgisselq
        assign  wb_stall = ((io_sel)&&(io_stall))
212
                        ||((scop_sel)&&(scop_stall))
213
                        ||((mem_sel)&&(mem_stall))
214
                        ||((flash_sel||flctl_sel)&&(flash_stall));
215
                        // (none_sel)&&(1'b0)
216
 
217 46 dgisselq
        //
218
        // wb_idata
219
        //
220
        // This is the data returned on the bus.  Here, we select between a
221
        // series of bus sources to select what data to return.  The basic
222
        // logic is simply this: the data we return is the data for which the
223
        // ACK line is high.
224
        //
225
        // The last item on the list is chosen by default if no other ACK's are
226
        // true.  Although we might choose to return zeros in that case, by
227
        // returning something we can skimp a touch on the logic.
228
        //
229
        // To add another device, add another ack check, and another closing
230
        // parenthesis.
231
        //
232 5 dgisselq
        assign  wb_idata =  (io_ack|scop_ack)?((io_ack )? io_data  : scop_data)
233 46 dgisselq
                        : ((mem_ack)?(mem_data)
234
                        : flash_data);
235 5 dgisselq
 
236 46 dgisselq
        //
237
        // wb_err
238
        //
239
        // This is the bus error signal.  It should never be true, but practice
240
        // teaches us otherwise.  Here, we allow for three basic errors:
241
        //
242
        // 1. STB is true, but no devices are selected
243
        //
244
        //      This is the null pointer reference bug.  If you try to access
245
        //      something on the bus, at an address with no mapping, the bus
246
        //      should produce an error--such as if you try to access something
247
        //      at zero.
248
        //
249
        // 2. STB is true, and more than one device is selected
250
        //
251
        //      (This can be turned off, if you design this file well.  For
252
        //      this line to be true means you have a design flaw.)
253
        //
254
        // 3. If more than one ACK is every true at any given time.
255
        //
256
        //      This is a bug of bus usage, combined with a subtle flaw in the
257
        //      WB pipeline definition.  You can issue bus requests, one per
258
        //      clock, and if you cross device boundaries with your requests,
259
        //      you may have things come back out of order (not detected here)
260
        //      or colliding on return (detected here).  The solution to this
261
        //      problem is to make certain that any burst request does not cross
262
        //      device boundaries.  This is a requirement of whoever (or
263
        //      whatever) drives the bus.
264
        //
265
        assign  wb_err = ((wb_stb)&&(none_sel || many_sel)) || many_ack;
266
 
267 5 dgisselq
        // Addresses ...
268 46 dgisselq
        //
269
        // dev_sel
270
        //
271
        // The device select lines
272
        //
273
        //
274 5 dgisselq
 
275
 
276 46 dgisselq
        //
277
        // The skipaddr bitfield below is our cheaters way of handling
278
        // device selection.  We grab particular wires from the bus to do
279
        // this, and ignore all others.  While this may lead to some
280
        // surprising results for the CPU when it tries to access an
281
        // inappropriate address, it also minimizes our logic while also
282
        // placing every address at the right address.  The only problem is
283
        // ... devices will also be at some unexpected addresses, but ... this
284
        // is still within our spec.
285
        //
286
        wire    [3:0]    skipaddr;
287
        assign  skipaddr = {
288
                        wb_addr[(LGFLASHSZ-2)], // Flash
289
                        wb_addr[(LGMEMSZ-2)],   // RAM
290
                        wb_addr[ 9],            // SCOPE
291
                        wb_addr[ 8] };          // I/O
292
        //
293
        // This might not be the most efficient way in hardware, but it will
294
        // work for our purposes here.  There are two phantom bits for each
295
        // of these ... bits that tell the CPU which byte within the word, and
296
        // another phantom bit because we allocated a minimum of two words to
297
        // every device.
298
        //
299
        wire    idle_n;
300
`ifdef  ZERO_ON_IDLE
301
        assign idle_n = wb_stb;
302
`else
303
        assign idle_n = 1'b1;
304 5 dgisselq
`endif
305 46 dgisselq
 
306
// `define ZERO_ON_IDLE
307
`ifdef  ZERO_ON_IDLE
308
        assign  idle_n = (wb_cyc)&&(wb_stb);
309 25 dgisselq
`else
310 46 dgisselq
        assign  idle_n = 1'b1;
311
`endif
312
        assign  io_sel   =((idle_n)&&(skipaddr[3:0]==4'h1));
313
        assign  scop_sel =((idle_n)&&(skipaddr[3:1]==3'h1)); // = 4'h2
314
        assign  flctl_sel= 1'b0; // ((wb_cyc)&&(skipaddr[3:0]==4'h3));
315
        assign  mem_sel  =((idle_n)&&(skipaddr[3:2]==2'h1));
316
        assign  flash_sel=((idle_n)&&(skipaddr[3]));
317
 
318
        //
319
        // none_sel
320
        //
321
        // This wire is true if wb_stb is true and no device is selected.  This
322
        // is an error condition, but here we present the logic to test for it.
323
        //
324
        //
325
        // If you add another device, add another OR into the select lines
326
        // associated with this term.
327
        //
328
        assign  none_sel =((wb_stb)&&(skipaddr==4'h0));
329
 
330
        //
331
        // many_sel
332
        //
333
        // This should *never* be true .... unless you mess up your address
334
        // decoding logic.  Since I've done that before, I test/check for it
335
        // here.
336
        //
337
        // To add a new device here, simply add it to the list.  Make certain
338
        // that the width of the add, however, is greater than the number
339
        // of devices below.  Hence, for 3 devices, you will need an add
340
        // at least 3 bits in width, for 7 devices you will need at least 4
341
        // bits, etc.
342
        //
343
        // Because this add uses the {} operator, the individual components to
344
        // it are by default unsigned ... just as we would like.
345
        //
346
        // There's probably another easier/better/faster/cheaper way to do this,
347
        // but I haven't found any such that are also easier to adjust with
348
        // new devices.  I'm open to options.
349
        //
350
        assign  many_sel = 1'b0;
351
 
352
        //
353
        // many_ack
354
        //
355
        // Normally this would capture the error when multiple things creates acks
356
        // at the same time.  The S6 is small, though, and doesn't have the logic
357
        // we need to do this right.  Hence we just declare (and hope) that this
358
        // will never be true and work with that.
359
        //
360 25 dgisselq
        assign  many_ack = 1'b0;
361 46 dgisselq
 
362 5 dgisselq
        wire            flash_interrupt, scop_interrupt, tmra_int, tmrb_int,
363 46 dgisselq
                        gpio_int, pwm_int, keypad_int,button_int;
364 5 dgisselq
 
365
 
366
        //
367 46 dgisselq
        // bus_err_addr
368 5 dgisselq
        //
369 46 dgisselq
        // We'd like to know, after the fact, what (if any) address caused a
370
        // bus error.  So ... if we get a bus error, let's record the address
371
        // on the bus for later analysis.
372 5 dgisselq
        //
373 46 dgisselq
        initial bus_err_addr = 0;
374
        always @(posedge i_clk)
375
                if (wb_err)
376
                        bus_err_addr <= wb_addr;
377
        //
378
        // Interrupt processing
379
        //
380
        // The interrupt controller will be used to tell us if any interrupts
381
        // take place.  
382
        //
383
        // To add more interrupts, you can just add more wires to this int_vector
384
        // for the new interrupts.
385
        // 
386 5 dgisselq
        reg             rx_rdy;
387 11 dgisselq
        wire    [11:0]   int_vector;
388 25 dgisselq
        assign  int_vector = {
389
                                flash_interrupt, gpio_int, pwm_int, keypad_int,
390 46 dgisselq
                                (!o_tx_stb), rx_rdy,
391 13 dgisselq
                                tmrb_int, tmra_int,
392 46 dgisselq
                                1'b0, scop_interrupt,
393 5 dgisselq
                                wb_err, button_int };
394
 
395
        wire    [31:0]   pic_data;
396 11 dgisselq
        icontrol #(12)  pic(i_clk, 1'b0, (wb_stb)&&(io_sel)
397 5 dgisselq
                                        &&(wb_addr[3:0]==4'h0)&&(wb_we),
398
                        wb_data, pic_data, int_vector, w_interrupt);
399
 
400 46 dgisselq
        wire    [31:0]   timer_data, timer_b;
401 5 dgisselq
        wire            zta_ack, zta_stall, ztb_ack, ztb_stall;
402 25 dgisselq
        ziptimer        #(32,31,1)
403 46 dgisselq
                thetimer(i_clk, 1'b0, 1'b1, wb_cyc,
404 5 dgisselq
                                (wb_stb)&&(io_sel)&&(wb_addr[3:0]==4'h2),
405 46 dgisselq
                                wb_we, wb_data, zta_ack, zta_stall, timer_data,
406 5 dgisselq
                                tmra_int);
407 25 dgisselq
        ziptimer        #(32,31,0)
408 8 dgisselq
                zipt_b(i_clk, 1'b0, 1'b1, wb_cyc,
409 5 dgisselq
                                (wb_stb)&&(io_sel)&&(wb_addr[3:0]==4'h3),
410
                                wb_we, wb_data, ztb_ack, ztb_stall, timer_b,
411
                                tmrb_int);
412
 
413
        always @(posedge i_clk)
414
                case(wb_addr[3:0])
415
                        4'h0: io_data <= pic_data;
416 46 dgisselq
                        4'h1: io_data <= { {(30-BAW){1'b0}}, bus_err_addr, 2'b00 };
417
                        4'h2: io_data <= timer_data;
418 5 dgisselq
                        4'h3: io_data <= timer_b;
419
                        4'h4: io_data <= pwm_data;
420
                        4'h5: io_data <= spio_data;
421
                        4'h6: io_data <= gpio_data;
422
                        4'h7: io_data <= uart_data;
423
                        default: io_data <= `DATESTAMP;
424
                        // 4'h8: io_data <= `DATESTAMP;
425
                endcase
426
        always @(posedge i_clk)
427 46 dgisselq
                io_ack <= (wb_stb)&&(io_sel);
428 5 dgisselq
        assign  io_stall = 1'b0;
429
 
430
        wire    pwm_ack, pwm_stall;
431 13 dgisselq
        wbpwmaudio      #(14'd10000,2,0,14)
432
                theaudio(i_clk, wb_cyc,
433
                                ((wb_stb)&&(io_sel)&&(wb_addr[3:0]==4'h4)),
434
                                        wb_we, 1'b0, wb_data,
435
                                pwm_ack, pwm_stall, pwm_data, o_pwm,
436
                                        o_pwm_aux, //={pwm_shutdown_n,pwm_gain}
437
                                        pwm_int);
438 5 dgisselq
 
439
        //
440
        // Special Purpose I/O: Keypad, button, LED status and control
441
        //
442 25 dgisselq
        wire    [3:0]    w_led;
443 46 dgisselq
        spio    thespio(i_clk, wb_cyc,(wb_stb)&&(io_sel)&&(wb_addr[3:0]==4'h5),
444
                                wb_we, wb_data, spio_data,
445
                        o_kp_col, i_kp_row, i_btn, w_led,
446 5 dgisselq
                        keypad_int, button_int);
447 32 dgisselq
        assign  o_led = { w_led[3]|w_interrupt,w_led[2],w_led[1:0] };
448 5 dgisselq
 
449
        //
450
        // General purpose (sort of) I/O:  (Bottom two bits robbed in each
451
        // direction for an I2C link at the toplevel.v design)
452
        //
453
        wbgpio  #(16,16,16'hffff) thegpio(i_clk, wb_cyc,
454
                        (wb_stb)&&(io_sel)&&(wb_addr[3:0]==4'h6), wb_we,
455
                        wb_data, gpio_data, i_gpio, o_gpio, gpio_int);
456
 
457
        //
458
        //
459
        //      Rudimentary serial port control
460
        //
461
        reg     [7:0]    r_rx_data;
462
        // Baud rate is set by clock rate / baud rate.
463
        // Thus, 80MHz / 115200MBau
464
        //      = 694.4, or about 0x2b6. 
465
        // although the CPU might struggle to keep up at this speed without a
466
        // hardware buffer.
467
        //
468
        // We'll add the flag for two stop bits.
469 8 dgisselq
        // assign       o_uart_setup = 30'h080002b6; // 115200 MBaud @ an 80MHz clock
470 46 dgisselq
        assign  o_uart_setup = 31'h4000208d; // 9600 MBaud, 8N1
471 5 dgisselq
 
472 8 dgisselq
        initial o_tx_stb = 1'b0;
473
        initial o_tx_data = 8'h00;
474
        always @(posedge i_clk)
475
                if ((wb_stb)&&(io_sel)&&(wb_addr[3:0]==4'h7)&&(wb_we))
476
                begin
477
                        o_tx_data <= wb_data[7:0];
478
                        o_tx_stb <= 1'b1;
479
                end
480
                else if ((o_tx_stb)&&(~i_tx_busy))
481
                        o_tx_stb <= 1'b0;
482
        initial rx_rdy = 1'b0;
483
        always @(posedge i_clk)
484
                if (i_rx_stb)
485
                        r_rx_data <= i_rx_data;
486
        always @(posedge i_clk)
487
        begin
488
                if((wb_stb)&&(io_sel)&&(wb_addr[3:0]==4'h7)&&(~wb_we))
489
                        rx_rdy <= i_rx_stb;
490
                else if (i_rx_stb)
491
                        rx_rdy <= (rx_rdy | i_rx_stb);
492
        end
493 46 dgisselq
        assign  o_uart_rts_n = (rx_rdy);
494 8 dgisselq
        assign  uart_data = { 23'h0, ~rx_rdy, r_rx_data };
495
        //
496
        // uart_ack gets returned as part of io_ack, since that happens when
497
        // io_sel and wb_stb are defined
498
        //
499
        // always @(posedge i_clk)
500
                // uart_ack<= ((wb_stb)&&(io_sel)&&(wb_addr[3:0]==4'h7));
501 5 dgisselq
 
502
 
503
 
504
        //
505
        //      FLASH MEMORY CONFIGURATION ACCESS
506
        //
507 46 dgisselq
`ifdef  FLASH_ACCESS
508
        wbqspiflash #(LGFLASHSZ)        flashmem(i_clk,
509 11 dgisselq
                wb_cyc,(wb_stb)&&(flash_sel),(wb_stb)&&(flctl_sel),wb_we,
510 46 dgisselq
                        wb_addr[(LGFLASHSZ-3):0], wb_data,
511 5 dgisselq
                flash_ack, flash_stall, flash_data,
512
                o_qspi_sck, o_qspi_cs_n, o_qspi_mod, o_qspi_dat, i_qspi_dat,
513
                flash_interrupt);
514
`else
515 46 dgisselq
        reg     r_flash_ack;
516
        initial r_flash_ack = 1'b0;
517 5 dgisselq
        always @(posedge i_clk)
518 46 dgisselq
                r_flash_ack <= (wb_stb)&&((flash_sel)||(flctl_sel));
519
 
520
        assign  flash_ack = r_flash_ack;
521
        assign  flash_stall = 1'b0;
522
        assign  flash_data = 32'h0000;
523
        assign  flash_interrupt = 1'b0;
524
 
525
        assign  o_qspi_sck   = 1'b1;
526
        assign  o_qspi_cs_n  = 1'b1;
527
        assign  o_qspi_mod   = 2'b01;
528
        assign  o_qspi_dat   = 4'b1111;
529 5 dgisselq
`endif
530
 
531
        //
532
        //      ON-CHIP RAM MEMORY ACCESS
533
        //
534 8 dgisselq
`ifdef  IMPLEMENT_ONCHIP_RAM
535 46 dgisselq
        memdev  #(.LGMEMSZ(LGMEMSZ))
536
                ram(i_clk, wb_cyc, (wb_stb)&&(mem_sel), wb_we,
537
                        wb_addr[(LGMEMSZ-3):0], wb_data, wb_sel,
538
                        mem_ack, mem_stall, mem_data);
539 8 dgisselq
`else
540
        assign  mem_data = 32'h00;
541
        assign  mem_stall = 1'b0;
542
        reg     r_mem_ack;
543
        always @(posedge i_clk)
544 46 dgisselq
                r_mem_ack <= (wb_stb)&&(mem_sel);
545 8 dgisselq
        assign  mem_ack = r_mem_ack;
546
`endif
547 5 dgisselq
 
548
        //
549
        //
550
        //      WISHBONE SCOPE
551
        //
552
        //
553
        //
554
        //
555
        wire    [31:0]   scop_cfg_data;
556
        wire            scop_cfg_ack, scop_cfg_stall, scop_cfg_interrupt;
557 8 dgisselq
`ifdef  DBG_SCOPE
558 5 dgisselq
        wire            scop_cfg_trigger;
559 46 dgisselq
        assign  scop_cfg_trigger = (wb_stb)&&(cfg_sel);
560
        wire    scop_trigger = bus_dbg;
561 25 dgisselq
`ifdef  COMPRESSED_SCOPE
562
        wbscopc #(5'ha)
563
`else
564
        wbscope #(5'ha)
565
`endif
566 46 dgisselq
        wbcfgscope(i_clk, 1'b1, scop_trigger, bus_debug,
567 5 dgisselq
                // Wishbone interface
568 8 dgisselq
                i_clk, wb_cyc, (wb_stb)&&(scop_sel),
569 5 dgisselq
                                wb_we, wb_addr[0], wb_data,
570
                        scop_cfg_ack, scop_cfg_stall, scop_cfg_data,
571
                scop_cfg_interrupt);
572 8 dgisselq
`else
573
        reg     r_scop_cfg_ack;
574
        always @(posedge i_clk)
575 46 dgisselq
                r_scop_cfg_ack <= (wb_stb)&&(scop_sel);
576 8 dgisselq
        assign  scop_cfg_ack = r_scop_cfg_ack;
577
        assign  scop_cfg_data = 32'h000;
578
        assign  scop_cfg_stall= 1'b0;
579 5 dgisselq
`endif
580
 
581
        assign  scop_interrupt = scop_cfg_interrupt;
582
        assign  scop_ack   = scop_cfg_ack;
583
        assign  scop_stall = scop_cfg_stall;
584
        assign  scop_data  = scop_cfg_data;
585
 
586
endmodule
587
 

powered by: WebSVN 2.1.0

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