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

Subversion Repositories pci

[/] [pci/] [tags/] [rel_6/] [rtl/] [verilog/] [pci_wb_slave.v] - Blame information for rev 77

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

powered by: WebSVN 2.1.0

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