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

Subversion Repositories pci

[/] [pci/] [trunk/] [rtl/] [verilog/] [pci_wb_slave.v] - Blame information for rev 154

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 77 mihad
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  File name "wb_slave.v"                                      ////
4
////                                                              ////
5
////  This file is part of the "PCI bridge" project               ////
6
////  http://www.opencores.org/cores/pci/                         ////
7
////                                                              ////
8
////  Author(s):                                                  ////
9
////      - Miha Dolenc (mihad@opencores.org)                     ////
10
////                                                              ////
11
////  All additional information is avaliable in the README       ////
12
////  file.                                                       ////
13
////                                                              ////
14
////                                                              ////
15
//////////////////////////////////////////////////////////////////////
16
////                                                              ////
17
//// Copyright (C) 2001 Miha Dolenc, mihad@opencores.org          ////
18
////                                                              ////
19
//// This source file may be used and distributed without         ////
20
//// restriction provided that this copyright statement is not    ////
21
//// removed from the file and that any derivative work contains  ////
22
//// the original copyright notice and the associated disclaimer. ////
23
////                                                              ////
24
//// This source file is free software; you can redistribute it   ////
25
//// and/or modify it under the terms of the GNU Lesser General   ////
26
//// Public License as published by the Free Software Foundation; ////
27
//// either version 2.1 of the License, or (at your option) any   ////
28
//// later version.                                               ////
29
////                                                              ////
30
//// This source is distributed in the hope that it will be       ////
31
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
32
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
33
//// PURPOSE.  See the GNU Lesser General Public License for more ////
34
//// details.                                                     ////
35
////                                                              ////
36
//// You should have received a copy of the GNU Lesser General    ////
37
//// Public License along with this source; if not, download it   ////
38
//// from http://www.opencores.org/lgpl.shtml                     ////
39
////                                                              ////
40
//////////////////////////////////////////////////////////////////////
41
//
42
// CVS Revision History
43
//
44
// $Log: not supported by cvs2svn $
45 153 mihad
// Revision 1.5  2004/01/24 11:54:18  mihad
46
// Update! SPOCI Implemented!
47
//
48 140 mihad
// Revision 1.4  2003/12/19 11:11:30  mihad
49
// Compact PCI Hot Swap support added.
50
// New testcases added.
51
// Specification updated.
52
// Test application changed to support WB B3 cycles.
53
//
54 132 mihad
// Revision 1.3  2003/08/14 18:01:53  simons
55
// ifdefs moved to thier own lines, this confuses some of the tools.
56
//
57 113 simons
// Revision 1.2  2003/08/03 18:05:06  mihad
58
// Added limited WISHBONE B3 support for WISHBONE Slave Unit.
59
// Doesn't support full speed bursts yet.
60
//
61 106 mihad
// Revision 1.1  2003/01/27 16:49:31  mihad
62
// Changed module and file names. Updated scripts accordingly. FIFO synchronizations changed.
63
//
64 77 mihad
// Revision 1.4  2002/08/19 16:54:25  mihad
65
// Got rid of undef directives
66
//
67
// Revision 1.3  2002/02/01 15:25:13  mihad
68
// Repaired a few bugs, updated specification, added test bench files and design document
69
//
70
// Revision 1.2  2001/10/05 08:14:30  mihad
71
// Updated all files with inclusion of timescale file for simulation purposes.
72
//
73
// Revision 1.1.1.1  2001/10/02 15:33:47  mihad
74
// New project directory structure
75
//
76
//
77
 
78
`include "bus_commands.v"
79
`include "pci_constants.v"
80
 
81
// synopsys translate_off
82
`include "timescale.v"
83
// synopsys translate_on
84
 
85 153 mihad
 
86
 
87 77 mihad
module pci_wb_slave
88
               (    wb_clock_in,
89
                    reset_in,
90
                    wb_hit_in,
91
                    wb_conf_hit_in,
92
                    wb_map_in,
93
                    wb_pref_en_in,
94
                    wb_mrl_en_in,
95
                    wb_addr_in,
96
                    del_bc_in,
97
                    wb_del_req_pending_in,
98
                    wb_del_comp_pending_in,
99
                    pci_drcomp_pending_in,
100
                    del_bc_out,
101
                    del_req_out,
102
                    del_done_out,
103
                    del_burst_out,
104
                    del_write_out,
105
                    del_write_in,
106
                    del_error_in,
107
                    del_in_progress_out,
108
                    ccyc_addr_in,
109
                    wb_del_addr_in,
110
                    wb_del_be_in,
111
                    wb_conf_offset_out,
112
                    wb_conf_renable_out,
113
                    wb_conf_wenable_out,
114
                    wb_conf_be_out,
115
                    wb_conf_data_in,
116
                    wb_conf_data_out,
117
                    wb_data_out,
118
                    wb_cbe_out,
119
                    wbw_fifo_wenable_out,
120
                    wbw_fifo_control_out,
121
                    wbw_fifo_almost_full_in,
122
                    wbw_fifo_full_in,
123 153 mihad
                                        wbw_fifo_half_full_in, //Robert, burst issue
124 77 mihad
                    wbr_fifo_renable_out,
125
                    wbr_fifo_be_in,
126
                    wbr_fifo_data_in,
127
                    wbr_fifo_control_in,
128
                    wbr_fifo_flush_out,
129
                    wbr_fifo_empty_in,
130
                    pciw_fifo_empty_in,
131
                    wbs_lock_in,
132 140 mihad
                    init_complete_in,
133 77 mihad
                    cache_line_size_not_zero,
134
                    sample_address_out,
135
                    CYC_I,
136
                    STB_I,
137
                    WE_I,
138
                    SEL_I,
139
                    SDATA_I,
140
                    SDATA_O,
141
                    ACK_O,
142
                    RTY_O,
143
                    ERR_O,
144
                    CAB_I
145
                );
146
 
147
/*----------------------------------------------------------------------------------------------------------------------
148
Various parameters needed for state machine and other stuff
149
----------------------------------------------------------------------------------------------------------------------*/
150
parameter WBR_SEL  = 1'b0 ;
151
parameter CONF_SEL = 1'b1 ;
152
 
153
`define FSM_BITS 3
154
parameter S_IDLE         = `FSM_BITS'h0 ;
155
parameter S_DEC1         = `FSM_BITS'h1 ;
156
parameter S_DEC2         = `FSM_BITS'h2 ;
157
parameter S_START        = `FSM_BITS'h3 ;
158
parameter S_W_ADDR_DATA  = `FSM_BITS'h4 ;
159
parameter S_READ         = `FSM_BITS'h5 ;
160
parameter S_CONF_WRITE   = `FSM_BITS'h6 ;
161
parameter S_CONF_READ    = `FSM_BITS'h7 ;
162
 
163
/*----------------------------------------------------------------------------------------------------------------------
164
System signals inputs
165
wb_clock_in - WISHBONE bus clock input
166
reset_in    - system reset input controlled by bridge's reset logic
167
----------------------------------------------------------------------------------------------------------------------*/
168
input wb_clock_in, reset_in ;
169
 
170
/*----------------------------------------------------------------------------------------------------------------------
171
Inputs from address decoding logic
172
wb_hit_in - Decoder logic indicates if address is in a range of one of images
173
wb_conf_hit_in - Decoder logic indicates that address is in configuration space range
174
wb_map_in   - Decoder logic provides information about image mapping - memory mapped image   - wb_map_in = 0
175
                                                                       IO space mapped image - wb_map_in = 1
176
wb_pref_en_in - Prefetch enable signal from currently selected image - used for PCI bus command usage
177
wb_addr_in - Address already transalted from WB bus to PCI bus input
178
wb_mrl_en_in - Memory read line enable input for each image
179
----------------------------------------------------------------------------------------------------------------------*/
180
input [4:0]     wb_hit_in ;         // hit indicators
181
input           wb_conf_hit_in ;    // configuration hit indicator
182
input [4:0]     wb_pref_en_in ;     // prefetch enable from all images
183
input [4:0]     wb_mrl_en_in ;      // Memory Read line command enable from images
184
input [4:0]     wb_map_in ;         // address space mapping indicators - 1 memory space mapping, 0-IO space mapping
185
input [31:0]    wb_addr_in ;        // Translated address input
186
 
187
/*----------------------------------------------------------------------------------------------------------------------
188
Delayed transaction control inputs and outputs:
189
Used for locking particular accesses when delayed transactions are in progress:
190
wb_del_addr_in - delayed transaction address input - when completion is ready it's used for transaction decoding
191
wb_del_be_in   - delayed transaction byte enable input - when completion is ready it's used for transaction decoding
192
----------------------------------------------------------------------------------------------------------------------*/
193
input  [31:0] wb_del_addr_in ;
194
input  [3:0]  wb_del_be_in ;
195
 
196
input [3:0] del_bc_in ;           // delayed request bus command used
197
input       wb_del_req_pending_in ;   // delayed request pending indicator
198
input       wb_del_comp_pending_in ;  // delayed completion pending indicator
199
input       pci_drcomp_pending_in ; // PCI initiated delayed read completion pending
200
 
201
output [3:0] del_bc_out ; // delayed transaction bus command output
202
 
203
output del_req_out ; // output for issuing delayed transaction requests
204
 
205
output del_done_out ; // output indicating current delayed completion finished on WISHBONE bus
206
 
207
output del_burst_out ; // delayed burst transaction indicator
208
 
209
output del_in_progress_out ; // delayed in progress indicator - since delayed transaction can be a burst transaction, progress indicator must be used for proper operation
210
 
211
output del_write_out ;   // write enable for delayed transaction - used for indicating that transaction is a write
212
 
213
input  del_write_in ;    // indicates that current delayed completion is from a write request
214
input  del_error_in ;    // indicate that delayed request terminated with an error - used for write requests
215
 
216
input  [31:0] ccyc_addr_in ; // configuration cycle address input - it's separate from other addresses, since it is stored separately and decoded for type 0 configuration access
217
 
218
/*----------------------------------------------------------------------------------------------------------------------
219
Configuration space access control and data signals
220
wb_conf_offset_out  - lower 12 bits of address input provided for register offset
221
wb_conf_renable     - read enable signal for configuration space accesses
222
wb_conf_wenable     - write enable signal for configuration space accesses
223
wb_conf_be_out      - byte enable signals for configuration space accesses
224
wb_conf_data_in     - data from configuration space
225
wb_conf_data_in     - data provided for configuration space
226
----------------------------------------------------------------------------------------------------------------------*/
227
output [11:0]   wb_conf_offset_out ;  // register offset output
228
output          wb_conf_renable_out,  // configuration read and write enable outputs
229
                wb_conf_wenable_out ;
230
output [3:0]    wb_conf_be_out ;      // byte enable outputs for configuration space
231
input  [31:0]   wb_conf_data_in ;     // configuration data input from configuration space
232
output [31:0]   wb_conf_data_out ;    // configuration data output for configuration space
233
 
234
/*----------------------------------------------------------------------------------------------------------------------
235
Data from WISHBONE bus output to interiror of the core:
236
Data output is used for normal and configuration accesses.
237
---------------------------------------------------------------------------------------------------------------------*/
238
output [31:0] wb_data_out ;
239
 
240
/*----------------------------------------------------------------------------------------------------------------------
241
Bus command - byte enable output - during address phase of image access this bus holds information about PCI
242
bus command that should be used, during dataphases ( configuration or image access ) this bus contains inverted
243
SEL_I signals
244
---------------------------------------------------------------------------------------------------------------------*/
245
output [3:0] wb_cbe_out ;
246
 
247
/*----------------------------------------------------------------------------------------------------------------------
248
WBW_FIFO control signals used for sinking data into WBW_FIFO and status monitoring
249
---------------------------------------------------------------------------------------------------------------------*/
250
output       wbw_fifo_wenable_out ;    // write enable for WBW_FIFO output
251
output [3:0] wbw_fifo_control_out ;    // control bus output for WBW_FIFO
252
input        wbw_fifo_almost_full_in ; // almost full status indicator from WBW_FIFO
253
input        wbw_fifo_full_in ;        // full status indicator from WBW_FIFO
254 153 mihad
input        wbw_fifo_half_full_in;    //Robert, burst issue
255 77 mihad
 
256
/*----------------------------------------------------------------------------------------------------------------------
257
WBR_FIFO control signals used for fetching data from WBR_FIFO and status monitoring
258
---------------------------------------------------------------------------------------------------------------------*/
259
output          wbr_fifo_renable_out ;      // WBR_FIFO read enable output
260
input   [3:0]   wbr_fifo_be_in ;            // byte enable input from WBR_FIFO
261
input   [31:0]  wbr_fifo_data_in ;          // data input from WBR_FIFO
262
input   [3:0]   wbr_fifo_control_in ;       // control bus input from WBR_FIFO
263
output          wbr_fifo_flush_out ;        // flush signal for WBR_FIFO
264
input           wbr_fifo_empty_in ;         // empty status indicator from WBR_FIFO
265
 
266
// used for transaction ordering requirements - WISHBONE read cannot complete until writes from PCI are completed
267
input           pciw_fifo_empty_in ;        // empty status indicator from PCIW_FIFO
268
 
269
/*----------------------------------------------------------------------------------------------------------------------
270
wbs_lock_in: internal signal that locks out all accesses, except delayed completions or configuration accesses.
271
( when master operation is disabled via master enable bit in configuration spacei )
272 140 mihad
init_complete_in: while initialization sequence is in progress, the state machine
273
remains in the idle state - it does not respond to accesses.
274 77 mihad
---------------------------------------------------------------------------------------------------------------------*/
275
input           wbs_lock_in ;
276 140 mihad
input           init_complete_in ;
277 77 mihad
 
278
// cache line size register must hold appropriate value to enable read bursts and special commands on PCI bus!
279
input           cache_line_size_not_zero ;
280
 
281
// state machine signals to wb_addr_mux when to sample wb address input
282
output          sample_address_out ;
283
reg             sample_address_out ;
284
 
285
/*----------------------------------------------------------------------------------------------------------------------
286
WISHBONE bus interface signals - can be connected directly to WISHBONE bus
287
---------------------------------------------------------------------------------------------------------------------*/
288
input           CYC_I ;     // cycle indicator
289
input           STB_I ;     // strobe input - input data is valid when strobe and cycle indicator are high
290
input           WE_I  ;     // write enable input - 1 - write operation, 0 - read operation
291
input   [3:0]   SEL_I ;     // Byte select inputs
292
input   [31:0]  SDATA_I ;   // WISHBONE slave interface input data bus
293
output  [31:0]  SDATA_O ;   // WISHBONE slave interface output data bus
294
output          ACK_O ;     // Acknowledge output - qualifies valid data on data output bus or received data on data input bus
295
output          RTY_O ;     // retry output - signals to WISHBONE master that cycle should be terminated and retried later
296
output          ERR_O ;     // Signals to WISHBONE master that access resulted in an error
297
input           CAB_I ;     // consecutive address burst input - indicates that master will do a serial address transfer in current cycle
298
 
299
`ifdef REGISTER_WBS_OUTPUTS
300
reg [31:0]  SDATA_O ;
301
reg         ACK_O   ;
302
reg         RTY_O   ;
303
reg         ERR_O   ;
304
 
305
reg [3:0] del_bc_out ; // delayed transaction bus command output
306
reg       del_req_out ; // output for issuing delayed transaction requests
307
reg       del_done_out ; // output indicating current delayed completion finished on WISHBONE bus
308
reg       del_burst_out ; // delayed burst transaction indicator
309
reg       del_in_progress_out ; // delayed in progress indicator - since delayed transaction can be a burst transaction, progress indicator must be used for proper operation
310
reg       del_write_out ;   // write enable for delayed transaction - used for indicating that transaction is a write
311
 
312
`ifdef HOST
313
reg          wb_conf_wenable_out ;
314
reg [31:0]   wb_conf_data_out ;    // configuration data output for configuration space
315
`endif
316
 
317
reg [3:0]  wb_conf_be_out ;      // byte enable outputs for configuration space
318
reg [31:0] wb_data_out ;
319
 
320
reg [3:0] wb_cbe_out ;
321
 
322
reg       wbw_fifo_wenable_out ;    // write enable for WBW_FIFO output
323
reg [3:0] wbw_fifo_control_out ;    // control bus output for WBW_FIFO
324
 
325
reg       wbr_fifo_renable_out ;      // WBR_FIFO read enable output
326
`endif
327
 
328
reg [(`FSM_BITS - 1):0]  c_state ; //current state register
329
 
330
reg [(`FSM_BITS - 1):0]  n_state ; //next state input to current state register
331
 
332
// state machine register control
333
always@(posedge wb_clock_in or posedge reset_in)
334
begin
335
    if (reset_in)
336
        c_state <= #`FF_DELAY S_IDLE ;
337
    else
338
        c_state <= #`FF_DELAY n_state ;
339
end
340
 
341
 
342
// variable for bus command multiplexer logic output for delayed requests
343
reg [3:0] del_bc ;
344
 
345
//register for intermediate data and select storage
346
reg [35:0] d_incoming ;
347
 
348
// enable for incoming data register
349
reg d_incoming_ena ;
350
 
351
// incoming data register control logic
352
always@(posedge wb_clock_in or posedge reset_in)
353
begin
354
    if (reset_in)
355
        d_incoming <= #`FF_DELAY {35{1'b0}} ;
356
    else if (d_incoming_ena)
357
        d_incoming <= #`FF_DELAY {SEL_I, SDATA_I} ;
358
end
359
 
360
/*===================================================================================================================================================================================
361
Write allow for image accesses. Writes through images are allowed when all of following are true:
362
- WBW_FIFO musn't be almost full nor full for image writes to be allowed - Every transaction takes at least two locations in the FIFO
363
- delayed read from from WISHBONE to PCI request musn't be present
364
- delayed read from PCI to WISHBONE completion musn't be present
365
- lock input musn't be set - it can be set because of error reporting or because PCI master state machine is disabled
366
===================================================================================================================================================================================*/
367 153 mihad
//Robert, burst issue
368
//`ifdef BURST_ISSUE
369
wire wimg_wallow           = ~|{ wbw_fifo_half_full_in, wb_del_req_pending_in, pci_drcomp_pending_in, wbs_lock_in } ;
370
//`else
371
//wire wimg_wallow           = ~|{ wbw_fifo_almost_full_in , wbw_fifo_full_in, wb_del_req_pending_in, pci_drcomp_pending_in, wbs_lock_in } ;
372
//`endif
373
 
374 77 mihad
reg img_wallow ;
375
/*===================================================================================================================================================================================
376
WISHBONE slave can request an image read accesses when all of following are true:
377
- delayed completion is not present
378
- delayed request is not present
379
- operation is not locked because of error reporting mechanism or because PCI master is disabled
380
===================================================================================================================================================================================*/
381
wire wdo_del_request     = ~|{ wb_del_req_pending_in, wb_del_comp_pending_in, wbs_lock_in } ;
382
reg do_del_request ;
383
/*===================================================================================================================================================================================
384
WISHBONE slave can complete an image read accesses when all of following are true:
385
- delayed read completion is present
386
- delayed read completion is the same as current read access ( dread_completion_hit is 1 )
387
- PCI Write FIFO is empty - no posted write is waiting to be finished in PCIW_FIFO
388
- WBR_FIFO empty status is not active
389
===================================================================================================================================================================================*/
390
wire wdel_addr_hit = ( wb_del_addr_in == wb_addr_in ) && ( SEL_I == wb_del_be_in ) ;
391
reg  del_addr_hit ;
392
wire wdel_completion_allow = wb_del_comp_pending_in && ((~del_write_in && ~WE_I && pciw_fifo_empty_in && ~wbr_fifo_empty_in) || (del_write_in && WE_I)) ;
393
reg del_completion_allow ;
394
 
395
/*----------------------------------------------------------------------------------------------------------------------
396
img_hit - state of wb_hit_in bus when when state machine signals decode is over
397
---------------------------------------------------------------------------------------------------------------------*/
398
reg [4:0] img_hit ;
399
wire wb_hit = |( img_hit ) ;
400
 
401
/*----------------------------------------------------------------------------------------------------------------------
402
Control logic for image control signals
403
pref_en - prefetch enable of currently selected image
404
mrl_en  - Memory read line enable of currently selected image
405
map     - Address space mapping for currently selected image
406
---------------------------------------------------------------------------------------------------------------------*/
407
reg pref_en, mrl_en, map ;
408
wire wpref_en   = |(wb_pref_en_in & wb_hit_in) ;
409
wire wmrl_en    = |(wb_mrl_en_in & wb_hit_in) ;
410
wire wmap       = |(wb_map_in & wb_hit_in) ;
411
 
412
// state machine controls when results from decoders, comparison etc. are sampled into registers to decode an access
413
reg decode_en ;
414
 
415
reg wb_conf_hit ;
416
always@(posedge reset_in or posedge wb_clock_in)
417
begin
418
    if (reset_in)
419
    begin
420
        img_wallow           <= #`FF_DELAY 1'b0 ;
421
        wb_conf_hit          <= #`FF_DELAY 1'b0 ;
422
        do_del_request       <= #`FF_DELAY 1'b0 ;
423
        del_addr_hit         <= #`FF_DELAY 1'b0 ;
424
        del_completion_allow <= #`FF_DELAY 1'b0 ;
425
        img_hit              <= #`FF_DELAY 5'h00 ;
426
        pref_en              <= #`FF_DELAY 1'b0 ;
427
        mrl_en               <= #`FF_DELAY 1'b0 ;
428
        map                  <= #`FF_DELAY 1'b0 ;
429
    end
430
    else
431
    if (decode_en)
432
    begin
433
        img_wallow           <= #`FF_DELAY wimg_wallow ;
434
        wb_conf_hit          <= #`FF_DELAY wb_conf_hit_in ;
435
        do_del_request       <= #`FF_DELAY wdo_del_request ;
436
        del_addr_hit         <= #`FF_DELAY wdel_addr_hit ;
437
        del_completion_allow <= #`FF_DELAY wdel_completion_allow ;
438
        img_hit              <= #`FF_DELAY wb_hit_in ;
439
        pref_en              <= #`FF_DELAY wpref_en && cache_line_size_not_zero ;
440
        mrl_en               <= #`FF_DELAY wmrl_en  && cache_line_size_not_zero ;
441
        map                  <= #`FF_DELAY wmap ;
442
    end
443
end
444
 
445
wire   del_burst = CAB_I && (pref_en || mrl_en) && ~WE_I && cache_line_size_not_zero ; // delayed burst indicator - only when WB master attempts CAB transfer and cache line size register is set appropriately and
446
                                                                                       // either prefetch enable or memory read line enable of corresponding image are set -
447
                                                                                       // applies for reads only - delayed write cannot be a burst
448
wire do_dread_completion = del_completion_allow && del_addr_hit ;
449
 
450
`ifdef GUEST
451
 
452
    // wires indicating allowance for configuration cycle generation requests
453
    wire do_ccyc_req  = 1'b0 ;
454
    wire do_ccyc_comp = 1'b0 ;
455
 
456
    // wires indicating allowance for interrupt acknowledge cycle generation requests
457
    wire do_iack_req  = 1'b0 ;
458
    wire do_iack_comp = 1'b0 ;
459
 
460
    // variables for configuration access control signals
461
    reg conf_wenable ;
462
    assign wb_conf_wenable_out = 1'b0 ;
463
 
464
    // configuration cycle data register hit
465
    wire ccyc_hit = 1'b0 ;
466
    wire iack_hit = 1'b0 ;
467
 
468
    wire wccyc_hit = 1'b0 ;
469
    wire wiack_hit = 1'b0 ;
470
 
471
`else
472
`ifdef HOST
473
    // only host implementation has access for generating interrupt acknowledge and configuration cycles
474
    // configuration cycle data register hit
475
    reg current_delayed_is_ccyc ;
476
    reg current_delayed_is_iack ;
477
 
478 132 mihad
    wire wccyc_hit = (wb_addr_in[8:2] == {1'b1, `CNF_DATA_ADDR}) ;
479
 
480
    wire wiack_hit = (wb_addr_in[8:2] == {1'b1, `INT_ACK_ADDR})  ;
481
 
482 77 mihad
    reg iack_hit ;
483
    reg ccyc_hit ;
484
    always@(posedge reset_in or posedge wb_clock_in)
485
    begin
486
        if (reset_in)
487
        begin
488
            ccyc_hit <= #`FF_DELAY 1'b0 ;
489
            iack_hit <= #`FF_DELAY 1'b0 ;
490
        end
491
        else
492
        if (decode_en)
493
        begin
494
            ccyc_hit <= #`FF_DELAY wccyc_hit ;
495
            iack_hit <= #`FF_DELAY wiack_hit ;
496
        end
497
    end
498
 
499
    // wires indicating allowance for configuration cycle generation requests
500
    wire do_ccyc_req  = do_del_request && ccyc_hit;
501
    wire do_ccyc_comp = del_completion_allow && ccyc_hit && current_delayed_is_ccyc ; // && del_bc_hit
502
 
503
    // wires indicating allowance for interrupt acknowledge cycle generation requests
504
    wire do_iack_req  = do_del_request && iack_hit ;
505
    wire do_iack_comp = del_completion_allow && iack_hit && current_delayed_is_iack ; // && del_bc_hit
506
 
507
    // variables for configuration access control signals
508
    reg conf_wenable ;
509
 
510
    // following flip-flops remember whether current delayed transaction is interrupt acknowledge or configuration cycle transaction
511
    always@(posedge wb_clock_in or posedge reset_in)
512
    begin
513
        if ( reset_in )
514
        begin
515
            current_delayed_is_ccyc <= #`FF_DELAY 1'b0 ;
516
            current_delayed_is_iack <= #`FF_DELAY 1'b0 ;
517
        end
518
        else
519
        if ( del_done_out )
520
        begin
521
            current_delayed_is_ccyc <= #`FF_DELAY 1'b0 ;
522
            current_delayed_is_iack <= #`FF_DELAY 1'b0 ;
523
        end
524
        else
525
        if ( del_req_out && wb_conf_hit )
526
        begin
527
            current_delayed_is_ccyc <= #`FF_DELAY do_ccyc_req ;
528
            current_delayed_is_iack <= #`FF_DELAY do_iack_req ;
529
        end
530
    end
531
 
532
`endif
533
`endif
534
 
535
// configuration read enable - supplied for host and guest bridges
536
reg conf_renable ;
537
assign wb_conf_renable_out = conf_renable ;
538
 
539
// burst access indicator
540
wire burst_transfer = CYC_I && CAB_I ;
541
 
542
// WBW_FIFO control output
543
reg [3:0] wbw_fifo_control ;
544
 
545
// WBW_FIFO wenable output assignment
546
reg wbw_fifo_wenable ;
547
 
548
// WBR_FIFO control outputs
549
reg wbr_fifo_flush, wbr_fifo_renable ; // flush and read enable outputs
550
 
551
// flush signal for WBR_FIFO must be registered, since it asinchronously resets some status registers
552
wire            wbr_fifo_flush_reg ;
553
pci_async_reset_flop async_reset_as_wbr_flush
554
(
555
    .data_in              (wbr_fifo_flush),
556
    .clk_in               (wb_clock_in),
557
    .async_reset_data_out (wbr_fifo_flush_reg),
558
    .reset_in                     (reset_in)
559
) ;
560
assign  wbr_fifo_flush_out = wbr_fifo_flush_reg ;
561
 
562
// delayed transaction request control signals
563
reg del_req, del_done ;
564
 
565
// WISHBONE handshaking control outputs
566
reg ack, rty, err ;
567
 
568
`ifdef REGISTER_WBS_OUTPUTS
569
// wire for write attempt - 1 when external WB master is attempting a write
570
// wire for read attempt  - 1 when external master is attempting a read
571
wire wattempt = ( CYC_I && STB_I && WE_I ) && (!ACK_O && !ERR_O && !RTY_O) ;
572
wire rattempt = ( CYC_I && STB_I && ~WE_I ) && (!ACK_O && !ERR_O && !RTY_O) ;
573
 
574
`else
575
// wire for write attempt - 1 when external WB master is attempting a write
576
// wire for read attempt  - 1 when external master is attempting a read
577
wire wattempt = ( CYC_I && STB_I && WE_I ) ; // write is qualified when cycle, strobe and write enable inputs are all high
578
wire rattempt = ( CYC_I && STB_I && ~WE_I ) ; // read is qualified when cycle and strobe are high and write enable is low
579
 
580
`endif
581
/*----------------------------------------------------------------------------------------------------------------------
582
Delayed transaction bus command generation
583
Bus command for delayed reads depends on image's address space mapping and control bits and
584
whether or not these are interrupt acknowledge requests or configuration cycle requests
585
---------------------------------------------------------------------------------------------------------------------*/
586
 
587
always@(map or mrl_en or ccyc_hit or WE_I or wb_conf_hit or CAB_I or pref_en)
588
begin
589
`ifdef HOST
590
// only host implementation supports configuration and interrupt acknowledge commands
591
    if (wb_conf_hit)
592
    begin
593
        case( {ccyc_hit, WE_I} )
594
            2'b11:  del_bc = `BC_CONF_WRITE ;
595
            2'b10:  del_bc = `BC_CONF_READ ;
596
            2'b01:  del_bc = `BC_RESERVED0 ; // invalid combination - interrupt acknowledge cycle must be a read
597
            2'b00:  del_bc = `BC_IACK ;
598
        endcase
599
    end
600
    else
601
`endif
602
    begin
603
        if ( map )
604
        begin
605
            del_bc = `BC_IO_READ ;
606
        end
607
        else
608
        begin
609
            case ({(CAB_I && mrl_en), pref_en})
610
                2'b00: del_bc = `BC_MEM_READ ;     // if this is not burst transfer or memory read line command is disabled - use memory read
611
                2'b01: del_bc = `BC_MEM_READ ;     // same as previous case
612
                2'b10: del_bc = `BC_MEM_READ_LN ;  // burst transfer, memory read line command enabled, prefetch disabled - use memory read line command
613
                2'b11: del_bc = `BC_MEM_READ_MUL ; // same as previous case, except prefetch is enabled - use memory read multiple command
614
            endcase
615
        end
616
    end
617
end
618
 
619
reg del_in_progress ; // state machine indicates whether current read completion is in progress on WISHBONE bus
620
 
621 132 mihad
wire image_access_error = (map && burst_transfer) ; // IO write is a burst
622 77 mihad
 
623
`ifdef HOST
624
    reg [1:0]   wbw_data_out_sel ;
625
    parameter SEL_ADDR_IN = 2'b10 ;
626
    parameter SEL_CCYC_ADDR = 2'b11 ;
627
    parameter SEL_DATA_IN   = 2'b00 ;
628
`else
629
`ifdef GUEST
630
    reg wbw_data_out_sel ;
631
    parameter SEL_ADDR_IN = 1'b1 ;
632
    parameter SEL_DATA_IN = 1'b0 ;
633
`endif
634
`endif
635
 
636
`ifdef WB_DECODE_FAST
637
    `ifdef REGISTER_WBS_OUTPUTS
638
        `define PCI_WB_SLAVE_S_DEC1
639
    `endif
640
`endif
641
 
642
`ifdef WB_DECODE_MEDIUM
643
    `define PCI_WB_SLAVE_S_DEC1
644
`endif
645
 
646
`ifdef WB_DECODE_SLOW
647
    `define PCI_WB_SLAVE_S_DEC1
648
    `define PCI_WB_SLAVE_S_DEC2
649
`endif
650
// state machine logic
651
always@(
652
        c_state                     or
653
        wattempt                    or
654
        img_wallow                  or
655
        burst_transfer              or
656
        wb_hit                      or
657
        map                         or
658
        rattempt                    or
659
        do_dread_completion         or
660
        wbr_fifo_control_in         or
661
        wb_conf_hit                 or
662
        do_ccyc_req                 or
663
        do_ccyc_comp                or
664
        ccyc_hit                    or
665
        del_error_in                or
666
        do_iack_req                 or
667
        do_iack_comp                or
668
        iack_hit                    or
669
        image_access_error          or
670
        wbw_fifo_almost_full_in     or
671
        wbw_fifo_full_in            or
672
        do_del_request              or
673 140 mihad
        wbr_fifo_empty_in           or
674
        init_complete_in
675 77 mihad
       )
676
begin
677
    // default signal values
678
    // response signals inactive
679
    ack         = 1'b0 ;
680
    rty         = 1'b0 ;
681
    err         = 1'b0 ;
682
 
683
    //write signals inactive
684
    wbw_fifo_control[`ADDR_CTRL_BIT] = 1'b1 ;
685
    wbw_fifo_control[`DATA_ERROR_CTRL_BIT] = 1'b0 ;
686
    wbw_fifo_control[`LAST_CTRL_BIT] = 1'b0 ;
687
    wbw_fifo_control[`UNUSED_CTRL_BIT] = 1'b0 ;
688
 
689
    wbw_fifo_wenable = 1'b0 ;
690
    d_incoming_ena   = 1'b0 ;
691
 
692
    // read signals inactive
693
    wbr_fifo_flush   = 1'b0 ;
694
    wbr_fifo_renable = 1'b0 ;
695
    del_req          = 1'b0 ;
696
    del_done         = 1'b0 ;
697
 
698
    // configuration space control signals inactive
699
    conf_wenable = 1'b0 ;
700
    conf_renable = 1'b0 ;
701
 
702
    // read is not in progress
703
    del_in_progress = 1'b0 ;
704
 
705
    decode_en = 1'b0 ;
706
 
707
    wbw_data_out_sel         = SEL_ADDR_IN ;
708
 
709
    sample_address_out = 1'b0 ;
710
 
711
    case (c_state)
712
    S_IDLE: begin
713 140 mihad
                if ( (wattempt || rattempt) & init_complete_in )
714 77 mihad
                begin
715
 
716
                `ifdef PCI_WB_SLAVE_S_DEC1
717
                    n_state = S_DEC1 ;
718
                `else
719
                    decode_en = 1'b1 ;
720
                    n_state = S_START ;
721
                `endif
722
 
723
                    sample_address_out = 1'b1 ;
724
                end
725
                else
726
                    n_state = S_IDLE ;
727
            end
728
`ifdef PCI_WB_SLAVE_S_DEC1
729
    S_DEC1: begin
730
                if ( wattempt || rattempt )
731
                begin
732
 
733
                `ifdef PCI_WB_SLAVE_S_DEC2
734
                    n_state = S_DEC2 ;
735
                `else
736
                    decode_en = 1'b1 ;
737
                    n_state = S_START ;
738
                `endif
739
 
740
                end
741
                else
742
                    n_state = S_IDLE ;
743
            end
744
`endif
745
`ifdef PCI_WB_SLAVE_S_DEC2
746
    S_DEC2: begin
747
 
748
                if ( wattempt || rattempt )
749
                begin
750
                    decode_en = 1'b1 ;
751
                    n_state = S_START ;
752
                end
753
                else
754
                    n_state = S_IDLE ;
755
            end
756
`endif
757
    S_START:begin
758
                if (wb_conf_hit) // configuration space hit
759
                begin
760
                    `ifdef HOST
761
                        wbw_data_out_sel = SEL_CCYC_ADDR ;
762
                    `endif
763
 
764
                    if ( wattempt )
765
                        n_state = S_CONF_WRITE ; // go to conf. write state
766
                    else
767
                    if ( rattempt )
768
                    begin
769
                        n_state     = S_CONF_READ ; // go to conf. read state
770
                    end
771
                    else
772
                        n_state = S_IDLE ; // master terminated - go back to idle state
773
 
774
                end // wb_conf_hit
775
                else
776
                if( wb_hit && (wattempt || rattempt) )
777
                begin
778
                    wbw_data_out_sel = SEL_DATA_IN ;
779
 
780
                    // check error conditions for image writes or reads
781
                    if ( image_access_error )
782
                    begin
783
                        n_state = S_IDLE ; // go back to idle state because of an error condition
784
                        err     = 1'b1 ;
785
                    end // error conditions
786
                    else
787
                    // check for retry conditions for image writes or reads
788
                    if ( (wattempt && ~img_wallow) ||
789
                         (rattempt && ~do_dread_completion) // write to image not allowed, no read ready yet - retry
790
                       )
791
                    begin
792
                        n_state = S_IDLE ; // go back to IDLE
793
 
794
                        rty     = 1'b1 ;
795
 
796
                        del_req = do_del_request && rattempt ;
797
 
798
                    end //retry
799
                    else // everything OK - proceed
800
                    if ( wattempt )
801
                    begin
802
                        n_state = S_W_ADDR_DATA ; // goto write transfer state
803
 
804
                        // respond with acknowledge
805
                        ack              = 1'b1 ;
806
 
807
                        wbw_fifo_wenable = 1'b1 ;
808
 
809
                        // data is latched to data incoming intermidiate stage - it will be put in FIFO later
810
                        d_incoming_ena   = 1'b1 ;
811
                    end
812
                    else
813
                    begin
814
                        err = wbr_fifo_control_in[`DATA_ERROR_CTRL_BIT] ;
815
                        ack = ~wbr_fifo_control_in[`DATA_ERROR_CTRL_BIT] ;
816
                        wbr_fifo_renable    = 1'b1 ;
817
                        del_in_progress = 1'b1 ;
818
 
819
                        if ( wbr_fifo_control_in[`DATA_ERROR_CTRL_BIT] || wbr_fifo_control_in[`LAST_CTRL_BIT] )
820
                        begin
821
 
822
                            n_state = S_IDLE ; // go back to idle state
823
                            // respond that read is finished
824
                            del_done     = 1'b1 ;
825
 
826
                        end // end read
827
                        else
828
                            n_state = S_READ ; // go to read state
829
                    end
830
                end
831
                else
832
                    n_state = S_IDLE ;
833
 
834
            end
835
 
836
    S_W_ADDR_DATA: begin
837
                        wbw_data_out_sel = SEL_DATA_IN ;
838 132 mihad
                        err = 1'b0 ;
839 77 mihad
                        rty = burst_transfer && wattempt && (wbw_fifo_almost_full_in || wbw_fifo_full_in) ;
840 132 mihad
                        if ( ~burst_transfer || wattempt && ( wbw_fifo_almost_full_in || wbw_fifo_full_in ) )
841 77 mihad
                        begin
842
                            n_state = S_IDLE ;
843
 
844
                            // write last data to FIFO and don't latch new data
845
                            wbw_fifo_control[`ADDR_CTRL_BIT] = 1'b0 ;
846
                            wbw_fifo_control[`LAST_CTRL_BIT] = 1'b1 ;
847
                            wbw_fifo_wenable = 1'b1 ;
848
                        end
849
                        else
850
                        begin
851
                            n_state = S_W_ADDR_DATA ;
852
                            wbw_fifo_control[`ADDR_CTRL_BIT] = 1'b0 ;
853
                            wbw_fifo_control[`LAST_CTRL_BIT] = 1'b0 ;
854
                            ack              = wattempt ;
855
                            wbw_fifo_wenable = wattempt ;
856
                            d_incoming_ena   = wattempt ;
857
                        end
858
                    end // S_W_ADDR_DATA
859
 
860
    S_READ:begin
861
                // this state is for reads only - in this state read is in progress all the time
862
                del_in_progress = 1'b1 ;
863
 
864 132 mihad
                ack = burst_transfer && rattempt && ~wbr_fifo_control_in[`DATA_ERROR_CTRL_BIT] && ~wbr_fifo_empty_in ;
865
                err = burst_transfer && rattempt && wbr_fifo_control_in[`DATA_ERROR_CTRL_BIT]  && ~wbr_fifo_empty_in  ;
866 77 mihad
 
867
                // if acknowledge is beeing signalled then enable read from wbr fifo
868 132 mihad
                wbr_fifo_renable = burst_transfer && rattempt && ~wbr_fifo_empty_in ;
869 77 mihad
 
870 132 mihad
                if ( ~burst_transfer || rattempt && (wbr_fifo_empty_in || wbr_fifo_control_in[`DATA_ERROR_CTRL_BIT] || wbr_fifo_control_in[`LAST_CTRL_BIT]) )
871 77 mihad
                begin
872
                    n_state = S_IDLE ;
873
                    del_done = 1'b1 ;
874
                    wbr_fifo_flush = ~wbr_fifo_empty_in ;
875
                end
876
                else
877
                begin
878
                    n_state          = S_READ ;
879
                end
880
            end // S_READ
881
 
882
    S_CONF_WRITE:  begin
883
                        `ifdef HOST
884
                            wbw_data_out_sel = SEL_CCYC_ADDR ;
885 132 mihad
                            del_req          = do_ccyc_req && ~burst_transfer  ;
886
                            del_done         = do_ccyc_comp && ~burst_transfer ;
887
                            del_in_progress  = do_ccyc_comp && ~burst_transfer ;
888 77 mihad
                        `endif
889
 
890
                        n_state         = S_IDLE ; // next state after configuration access is always idle
891
 
892 132 mihad
                        if ( burst_transfer )
893 77 mihad
                        begin
894
                            err = 1'b1 ;
895
                        end
896
                        else
897
                        begin
898
                            `ifdef HOST
899
                            if ( do_ccyc_req || (ccyc_hit && ~do_ccyc_comp))
900
                            begin
901
                                rty = 1'b1 ;
902
                            end
903
                            else
904
                            if ( do_ccyc_comp )
905
                            begin
906
                                err = del_error_in ;
907
                                ack = ~del_error_in ;
908
                            end
909
                            else
910
                            begin
911
                                ack = ~ccyc_hit ;
912
                                conf_wenable = ~ccyc_hit ;
913
                            end
914
                            `else
915
                            ack = 1'b1 ;
916
                            conf_wenable = 1'b1 ;
917
                            `endif
918
                        end
919
                    end // S_CONF_WRITE
920
 
921
    S_CONF_READ:   begin
922
                        `ifdef HOST
923
                            wbw_data_out_sel = SEL_CCYC_ADDR ;
924 132 mihad
                            del_req          = ~burst_transfer && ( do_ccyc_req  || do_iack_req  ) ;
925
                            del_done         = ~burst_transfer && ( do_ccyc_comp || do_iack_comp ) ;
926
                            del_in_progress  = ~burst_transfer && ( do_ccyc_comp || do_iack_comp ) ;
927
                            wbr_fifo_renable = ~burst_transfer && ( do_ccyc_comp || do_iack_comp ) ;
928 77 mihad
                        `endif
929
 
930
                        n_state = S_IDLE ; // next state after configuration access is always idle
931
 
932 132 mihad
                        if ( burst_transfer )
933 77 mihad
                        begin
934
                            err = 1'b1 ;
935
                        end
936
                        else
937
                        begin
938
                            `ifdef HOST
939
                            if ( do_ccyc_req || ( ccyc_hit && ~do_ccyc_comp ))
940
                            begin
941
                                rty = 1'b1 ;
942
                            end
943
                            else
944
                            if ( do_iack_req || ( iack_hit && ~do_iack_comp ))
945
                            begin
946
                                rty = 1'b1 ;
947
                            end
948
                            else
949
                            if ( do_iack_comp || do_ccyc_comp )
950
                            begin
951
                                err = del_error_in ;
952
                                ack = ~del_error_in ;
953
                            end
954
                            else
955
                            begin
956
                                ack = ~( ccyc_hit || iack_hit ) ;
957
                                conf_renable = ~( ccyc_hit || iack_hit ) ;
958
                            end
959
                            `else
960
                            ack = 1'b1 ;
961
                            conf_renable = 1'b1 ;
962
                            `endif
963
                        end
964
                    end //S_CONF_READ
965
    default:begin
966
                n_state = S_IDLE ; // return to idle state
967
            end //default
968
    endcase
969
end
970
 
971
// configuration space offset output assignment
972
assign wb_conf_offset_out = {wb_addr_in[11:2], 2'b00} ; // upper 10 bits of address input and two zeros
973
 
974
// data output assignment - for image writes, first data is address, subsequent data comes from intermediate register
975
reg [31:0] wb_data ;
976
`ifdef HOST
977
reg [1:0] wbw_data_out_sel_reg ;
978
always@(posedge wb_clock_in or posedge reset_in)
979
begin
980
    if ( reset_in )
981
        wbw_data_out_sel_reg <= #`FF_DELAY SEL_ADDR_IN ;
982
    else
983
        wbw_data_out_sel_reg <= #`FF_DELAY wbw_data_out_sel ;
984
end
985
 
986
always@(wbw_data_out_sel_reg or wb_addr_in or ccyc_addr_in or d_incoming)
987
begin
988
    case ( wbw_data_out_sel_reg )
989
        SEL_CCYC_ADDR:  wb_data = ccyc_addr_in ;
990
        SEL_DATA_IN:    wb_data = d_incoming ;
991
        default: wb_data        = wb_addr_in ;
992
    endcase
993
end
994
`else
995
`ifdef GUEST
996
reg wbw_data_out_sel_reg ;
997
always@(posedge wb_clock_in or posedge reset_in)
998
begin
999
    if ( reset_in )
1000
        wbw_data_out_sel_reg <= #`FF_DELAY SEL_ADDR_IN ;
1001
    else
1002
        wbw_data_out_sel_reg <= #`FF_DELAY wbw_data_out_sel ;
1003
end
1004
 
1005
always@(wbw_data_out_sel_reg or wb_addr_in or d_incoming)
1006
begin
1007
    if ( wbw_data_out_sel_reg )
1008
        wb_data = wb_addr_in ;
1009
    else
1010
        wb_data = d_incoming ;
1011
end
1012
`endif
1013
`endif
1014
 
1015
// command / byte enable assignment - with address, bus command is provided, with data - byte enables are provided
1016
reg [3:0] wb_cbe ;
1017
 
1018
always@(wbw_data_out_sel_reg or d_incoming or map)
1019
begin
1020
    if (wbw_data_out_sel_reg && map)
1021
        wb_cbe = `BC_IO_WRITE ;
1022
    else
1023
    if (wbw_data_out_sel_reg)
1024
        wb_cbe = `BC_MEM_WRITE ;
1025
    else
1026
        wb_cbe = ~(d_incoming[35:32]) ;
1027
end
1028
 
1029
// for configuration writes, data output is always data from WISHBONE - in guest implementation data is all 0.
1030
`ifdef GUEST
1031
    assign wb_conf_data_out = 32'h00000000 ;
1032
`endif
1033
 
1034
`ifdef GUEST
1035
    `ifdef NO_CNF_IMAGE
1036
    `else
1037
        `define PCI_WB_SLAVE_DO_OUT_MUX
1038
    `endif
1039
`else
1040
`ifdef HOST
1041
    `define PCI_WB_SLAVE_DO_OUT_MUX ;
1042
`endif
1043
`endif
1044
 
1045
`ifdef PCI_WB_SLAVE_DO_OUT_MUX
1046
    reg [31:0] sdata_source ;
1047
 
1048
    // WISHBONE data output select lines for output multiplexor
1049
    wire sdata_o_sel_new = ( wb_conf_hit_in && ~wiack_hit && ~wccyc_hit ) ? CONF_SEL : WBR_SEL ;
1050
    reg sdata_o_sel ;
1051
 
1052
    always@(posedge wb_clock_in or posedge reset_in)
1053
    begin
1054
        if ( reset_in )
1055
            sdata_o_sel <= #`FF_DELAY WBR_SEL ;
1056
        else
1057
        if ( decode_en )
1058
            sdata_o_sel <= #`FF_DELAY sdata_o_sel_new ;
1059
    end
1060
 
1061
    always@(sdata_o_sel or wbr_fifo_data_in or wb_conf_data_in)
1062
    begin
1063
        case (sdata_o_sel)
1064
            WBR_SEL :sdata_source = wbr_fifo_data_in ;
1065
            CONF_SEL:sdata_source = wb_conf_data_in ;
1066
        endcase
1067
    end
1068
`else
1069
    wire [31:0] sdata_source = wbr_fifo_data_in ;
1070
`endif
1071
 
1072
`ifdef REGISTER_WBS_OUTPUTS
1073
 
1074
always@(posedge wb_clock_in or posedge reset_in)
1075
begin
1076
    if ( reset_in )
1077
    begin
1078
        ACK_O         <= #`FF_DELAY 1'b0 ;
1079
        RTY_O         <= #`FF_DELAY 1'b0 ;
1080
        ERR_O         <= #`FF_DELAY 1'b0 ;
1081
        SDATA_O       <= #`FF_DELAY 0 ;
1082
        del_write_out <= #`FF_DELAY 1'b0 ;
1083
 
1084
        `ifdef HOST
1085
        wb_conf_wenable_out <= #`FF_DELAY 1'b0 ;
1086
        wb_conf_data_out    <= #`FF_DELAY 0 ;
1087
        `endif
1088
 
1089
        del_bc_out    <= #`FF_DELAY `BC_RESERVED0 ;
1090
        del_req_out <= #`FF_DELAY 1'b0 ;
1091
        del_done_out <= #`FF_DELAY 1'b0 ;
1092
        del_burst_out <= #`FF_DELAY 1'b0 ;
1093
        del_in_progress_out <= #`FF_DELAY 1'b0 ;
1094
        wb_conf_be_out <= #`FF_DELAY 0 ;
1095
        wb_data_out    <= #`FF_DELAY 0 ;
1096
        wb_cbe_out <= #`FF_DELAY 0 ;
1097
        wbw_fifo_wenable_out <= #`FF_DELAY 0 ;
1098
        wbw_fifo_control_out <= #`FF_DELAY 0 ;
1099
        wbr_fifo_renable_out <= #`FF_DELAY 0 ;
1100
    end
1101
    else
1102
    begin
1103
        ACK_O   <= #`FF_DELAY ack && !ACK_O ;
1104
        RTY_O   <= #`FF_DELAY rty && !RTY_O ;
1105
        ERR_O    <= #`FF_DELAY err && !ERR_O ;
1106
        SDATA_O       <= #`FF_DELAY sdata_source ;
1107
        del_write_out <= #`FF_DELAY WE_I ;
1108
 
1109
        `ifdef HOST
1110
        wb_conf_wenable_out <= #`FF_DELAY conf_wenable ;
1111
        wb_conf_data_out    <= #`FF_DELAY SDATA_I ;
1112
        `endif
1113
 
1114
        del_bc_out <= #`FF_DELAY del_bc ;
1115
        del_req_out <= #`FF_DELAY del_req ;
1116
        del_done_out <= #`FF_DELAY del_done ;
1117
        del_burst_out <= #`FF_DELAY del_burst ;
1118
        del_in_progress_out <= #`FF_DELAY del_in_progress ;
1119
        wb_conf_be_out <= #`FF_DELAY SEL_I ;
1120
        wb_data_out <= #`FF_DELAY wb_data ;
1121
        wb_cbe_out <= #`FF_DELAY wb_cbe ;
1122
        wbw_fifo_wenable_out <= #`FF_DELAY wbw_fifo_wenable ;
1123
        wbw_fifo_control_out <= #`FF_DELAY wbw_fifo_control ;
1124
        wbr_fifo_renable_out <= #`FF_DELAY wbr_fifo_renable ;
1125
    end
1126
end
1127
 
1128
`else
1129
 
1130
assign SDATA_O = sdata_source ;
1131
 
1132
assign ACK_O = ack ;
1133
assign RTY_O = rty ;
1134
assign ERR_O = err ;
1135
 
1136
// write operation indicator for delayed transaction requests
1137
assign del_write_out = WE_I ;
1138
assign del_bc_out = del_bc ;
1139
assign del_req_out  = del_req ; // read request
1140
assign del_done_out = del_done ; // read done
1141
assign del_burst_out = del_burst ;
1142
assign del_in_progress_out = del_in_progress ;
1143
`ifdef HOST
1144
assign wb_conf_data_out = SDATA_I ;
1145
assign wb_conf_wenable_out = conf_wenable ;
1146
`endif
1147
// Configuration space byte enables output
1148
assign wb_conf_be_out = SEL_I ; // just route select lines from WISHBONE to conf space
1149
assign wb_data_out    = wb_data ;
1150
assign wb_cbe_out = wb_cbe ;
1151
assign wbw_fifo_wenable_out = wbw_fifo_wenable ; //write enable for WBW_FIFO
1152
assign wbw_fifo_control_out = wbw_fifo_control ; //control bus output for WBW_FIFO
1153
assign wbr_fifo_renable_out = wbr_fifo_renable ; //read enable for wbr_fifo
1154
`endif
1155
 
1156
endmodule //WB_SLAVE

powered by: WebSVN 2.1.0

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