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

Subversion Repositories pci

[/] [pci/] [tags/] [rel_3/] [rtl/] [verilog/] [wb_slave.v] - Blame information for rev 21

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

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

powered by: WebSVN 2.1.0

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