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

powered by: WebSVN 2.1.0

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