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

Subversion Repositories pci

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 mihad
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  File name "pci_master32_sm.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 77 mihad
// Revision 1.4  2003/01/21 16:06:56  mihad
46
// Bug fixes, testcases added.
47
//
48 73 mihad
// Revision 1.3  2002/02/01 15:25:12  mihad
49
// Repaired a few bugs, updated specification, added test bench files and design document
50
//
51 21 mihad
// Revision 1.2  2001/10/05 08:14:29  mihad
52
// Updated all files with inclusion of timescale file for simulation purposes.
53
//
54 6 mihad
// Revision 1.1.1.1  2001/10/02 15:33:46  mihad
55
// New project directory structure
56 2 mihad
//
57 6 mihad
//
58 2 mihad
 
59
// module includes pci master state machine and surrounding logic
60 21 mihad
 
61
// synopsys translate_off
62 6 mihad
`include "timescale.v"
63 21 mihad
// synopsys translate_on
64
`include "pci_constants.v"
65 6 mihad
 
66 77 mihad
module pci_master32_sm
67 2 mihad
(
68
    // system inputs
69
    clk_in,
70
    reset_in,
71
    // arbitration
72
    pci_req_out,
73
    pci_gnt_in,
74
    // master in/outs
75
    pci_frame_in,
76
    pci_frame_out,
77
    pci_frame_out_in,
78
    pci_frame_load_out,
79
    pci_frame_en_in,
80
    pci_frame_en_out,
81
    pci_irdy_in,
82
    pci_irdy_out,
83
    pci_irdy_en_out,
84 21 mihad
 
85 2 mihad
    // target response inputs
86
    pci_trdy_in,
87
    pci_trdy_reg_in,
88
    pci_stop_in,
89
    pci_stop_reg_in,
90
    pci_devsel_in,
91
    pci_devsel_reg_in,
92
 
93
    // address, data, bus command, byte enable in/outs
94
    pci_ad_reg_in,
95
    pci_ad_out,
96
    pci_ad_en_out,
97
    pci_cbe_out,
98
    pci_cbe_en_out,
99
 
100
    // other side of state machine
101
    address_in,
102
    bc_in,
103
    data_in,
104
    data_out,
105
    be_in,
106
    req_in,
107
    rdy_in,
108
    last_in,
109
    next_data_in,
110
    next_be_in,
111
    next_last_in,
112 21 mihad
    ad_load_out,
113
    ad_load_on_transfer_out,
114 2 mihad
    wait_out,
115
    wtransfer_out,
116
    rtransfer_out,
117
    retry_out,
118
    rerror_out,
119
    first_out,
120
    mabort_out,
121
    latency_tim_val_in
122
) ;
123
 
124
// system inputs
125
input   clk_in,
126
        reset_in ;
127
 
128
/*==================================================================================================================
129
PCI interface signals - bidirectional signals are divided to inputs and outputs in I/O cells instantiation
130
module. Enables are separate signals.
131
==================================================================================================================*/
132
// arbitration
133
output  pci_req_out ;
134
 
135
input   pci_gnt_in ;
136
 
137
// master in/outs
138
input   pci_frame_in ;
139
input   pci_frame_en_in ;
140
input   pci_frame_out_in ;
141
 
142
output  pci_frame_out,
143
        pci_frame_en_out ;
144
 
145
output  pci_frame_load_out ;
146
 
147
input   pci_irdy_in ;
148
output  pci_irdy_out,
149
        pci_irdy_en_out;
150 21 mihad
 
151 2 mihad
// target response inputs
152
input   pci_trdy_in,
153
        pci_trdy_reg_in,
154
        pci_stop_in,
155
        pci_stop_reg_in,
156
        pci_devsel_in,
157
        pci_devsel_reg_in ;
158 21 mihad
 
159 2 mihad
// address, data, bus command, byte enable in/outs
160
input   [31:0]  pci_ad_reg_in ;
161
output  [31:0]  pci_ad_out ;
162
 
163
reg     [31:0]  pci_ad_out ;
164
 
165
output          pci_ad_en_out ;
166
 
167
output  [3:0]   pci_cbe_out ;
168
 
169
reg     [3:0]   pci_cbe_out ;
170
 
171
output          pci_cbe_en_out ;
172
 
173
input   [31:0]  address_in ; // current request address input
174
 
175
input   [3:0]   bc_in ;      // current request bus command input
176
 
177
input   [31:0]  data_in ;    // current dataphase data input
178
 
179
output  [31:0]  data_out ;    // for read operations - current request data output
180
 
181 21 mihad
reg     [31:0]  data_out ;
182 2 mihad
 
183
input   [3:0]   be_in ;      // current dataphase byte enable inputs
184
 
185
input           req_in ;     // initiator cycle is requested
186
input           rdy_in ;     // requestor indicates that data is ready to be sent for write transaction and ready to
187
                            // be received on read transaction
188
input           last_in ;    // last dataphase in current transaction indicator
189
 
190
// status outputs
191
output wait_out,            // wait indicates to the backend that dataphases are not in progress on PCI bus
192
       wtransfer_out,       // on any rising clock edge that this status is 1, data is transferred - heavy constraints here
193
       rtransfer_out,       // registered transfer indicator - when 1 indicates that data was transfered on previous clock cycle
194
       retry_out,           // retry status output - when target signals a retry
195
       rerror_out,          // registered error output - when 1 indicates that error was signalled by a target on previous clock cycle
196
       first_out ,          // indicates whether or not any data was transfered in current transaction
197
       mabort_out;          // master abort indicator
198
 
199
reg wait_out ;
200
 
201
// latency timer value input - state machine starts latency timer whenever it starts a transaction and last is not
202 21 mihad
// asserted ( meaning burst transfer ).
203 2 mihad
input [7:0] latency_tim_val_in ;
204
 
205
// next data, byte enable and last inputs
206
input [31:0] next_data_in ;
207
input [3:0]  next_be_in ;
208
input        next_last_in ;
209
 
210
// clock enable for data output flip-flops - whenever data is transfered, sm loads next data to those flip flops
211 21 mihad
output       ad_load_out,
212
             ad_load_on_transfer_out ;
213 2 mihad
 
214
// parameters - states - one hot
215
// idle state
216
parameter S_IDLE            = 4'h1 ;
217
 
218
// address state
219
parameter S_ADDRESS         = 4'h2 ;
220
 
221
// transfer state - dataphases
222
parameter S_TRANSFER        = 4'h4 ;
223
 
224
// turn arround state
225
parameter S_TA_END          = 4'h8 ;
226
 
227
// change state - clock enable for sm state register
228
wire change_state ;
229
// next state for state machine
230 73 mihad
reg [3:0] next_state ;
231 2 mihad
// SM state register
232 73 mihad
reg [3:0] cur_state ;
233 2 mihad
 
234
// variables for indicating which state state machine is in
235
// this variables are used to reduce logic levels in case of heavily constrained PCI signals
236
reg sm_idle            ;
237
reg sm_address         ;
238
reg sm_data_phases     ;
239
reg sm_turn_arround    ;
240
 
241
// state machine register control logic with clock enable
242
always@(posedge reset_in or posedge clk_in)
243
begin
244
    if (reset_in)
245
        cur_state <= #`FF_DELAY S_IDLE ;
246
    else
247
    if ( change_state )
248
        cur_state <= #`FF_DELAY next_state ;
249
end
250
 
251
// parameters - data selector - ad and bc lines switch between address/data and bus command/byte enable respectively
252
parameter SEL_ADDR_BC      = 2'b01 ;
253
parameter SEL_DATA_BE      = 2'b00 ;
254
parameter SEL_NEXT_DATA_BE = 2'b11 ;
255
 
256
reg [1:0] wdata_selector ;
257
 
258
wire u_dont_have_pci_bus = pci_gnt_in || ~pci_frame_in || ~pci_irdy_in ;    // pci master can't start a transaction when GNT is deasserted ( 1 ) or
259
                                                                            // bus is not in idle state ( FRAME and IRDY both 1 )
260
wire u_have_pci_bus      = ~pci_gnt_in && pci_frame_in && pci_irdy_in ;
261
 
262
// decode count enable - counter that counts cycles passed since address phase
263 21 mihad
wire        sm_decode_count_enable = sm_data_phases ;                                                               // counter is enabled when master wants to transfer
264 2 mihad
wire        decode_count_enable    = sm_decode_count_enable && pci_trdy_in && pci_stop_in && pci_devsel_in ;        // and target is not responding
265 21 mihad
wire        decode_count_load      = ~decode_count_enable ;
266 2 mihad
reg [2:0]   decode_count ;
267
 
268
wire decode_to = ~( decode_count[2] || decode_count[1]) ;
269
 
270
always@(posedge reset_in or posedge clk_in)
271
begin
272
    if ( reset_in )
273
        // initial value of counter is 4
274
        decode_count <= #`FF_DELAY 3'h4 ;
275
    else
276
    if ( decode_count_load )
277
        decode_count <= #`FF_DELAY 3'h4 ;
278
    else
279
    if ( decode_count_enable )
280
        decode_count <= #`FF_DELAY decode_count - 1'b1 ;
281
end
282
 
283
// Bus commands LSbit indicates whether operation is a read or a write
284
wire do_write = bc_in[0] ;
285
 
286
// latency timer
287
reg [7:0]   latency_timer ;
288
 
289 21 mihad
wire latency_time_out     = ~(
290
                               (latency_timer[7] || latency_timer[6] || latency_timer[5] || latency_timer[4]) ||
291
                               (latency_timer[3] || latency_timer[2] || latency_timer[1] )
292
                             ) ;
293 2 mihad
 
294 21 mihad
wire latency_timer_enable = (sm_address || sm_data_phases) && ~latency_time_out ;
295 2 mihad
wire latency_timer_load   = ~sm_address && ~sm_data_phases ;
296
 
297
always@(posedge clk_in or posedge reset_in)
298
begin
299
    if (reset_in)
300 21 mihad
        latency_timer <= #`FF_DELAY 8'h00 ;
301 2 mihad
    else
302
    if ( latency_timer_load )
303
        latency_timer <= #`FF_DELAY latency_tim_val_in ;
304
    else
305 21 mihad
    if ( latency_timer_enable)         // latency timer counts down until it expires - then it stops
306 2 mihad
        latency_timer <= #`FF_DELAY latency_timer - 1'b1 ;
307
end
308
 
309
// master abort indicators - when decode time out occurres and still no target response is received
310
wire do_master_abort = decode_to && pci_trdy_in && pci_stop_in && pci_devsel_in ;
311
reg mabort1 ;
312
always@(posedge reset_in or posedge clk_in)
313
begin
314
    if (reset_in)
315
        mabort1 <= #`FF_DELAY 1'b0 ;
316
    else
317
        mabort1 <= #`FF_DELAY do_master_abort ;
318
end
319
 
320
reg mabort2 ;
321
always@(posedge reset_in or posedge clk_in)
322
begin
323
    if ( reset_in )
324
        mabort2 <= #`FF_DELAY 1'b0 ;
325
    else
326
        mabort2 <= #`FF_DELAY mabort1 ;
327
end
328
 
329
// master abort is only asserted for one clock cycle
330
assign mabort_out = mabort1 && ~mabort2 ;
331
 
332
// register indicating when master should do timeout termination (latency timer expires)
333
reg timeout ;
334
always@(posedge reset_in or posedge clk_in)
335
begin
336
    if (reset_in)
337
        timeout <= #`FF_DELAY 1'b0 ;
338 21 mihad
    else
339 2 mihad
        timeout <= #`FF_DELAY (latency_time_out && ~pci_frame_out_in && pci_gnt_in || timeout ) && ~wait_out ;
340
end
341
 
342
wire timeout_termination = sm_turn_arround && timeout && pci_stop_reg_in ;
343
 
344
// frame control logic
345
// frame is forced to 0 (active) when state machine is in idle state, since only possible next state is address state which always drives frame active
346
wire force_frame = ~sm_idle ;
347
// slow signal for frame calculated from various registers in the core
348 21 mihad
wire slow_frame  = last_in || (latency_time_out && pci_gnt_in) || (next_last_in && sm_data_phases) || mabort1 ;
349 2 mihad
// critical timing frame logic in separate module - some combinations of target signals force frame to inactive state immediately after sampled asserted
350
// (STOP)
351 77 mihad
pci_frame_crit frame_iob_feed
352 2 mihad
(
353
    .pci_frame_out      (pci_frame_out),
354
    .force_frame_in     (force_frame),
355
    .slow_frame_in      (slow_frame),
356
    .pci_stop_in        (pci_stop_in)
357
) ;
358
 
359
// frame IOB flip flop's clock enable signal
360
// slow clock enable - calculated from internal - non critical paths
361
wire frame_load_slow = sm_idle || sm_address || mabort1 ;
362
 
363
// critical clock enable for frame IOB in separate module - target response signals actually allow frame value change - critical timing
364 77 mihad
pci_frame_load_crit frame_iob_ce
365 2 mihad
(
366
    .pci_frame_load_out (pci_frame_load_out),
367
    .sm_data_phases_in  (sm_data_phases),
368
    .frame_load_slow_in (frame_load_slow),
369
    .pci_trdy_in        (pci_trdy_in),
370
    .pci_stop_in        (pci_stop_in)
371
) ;
372
 
373
// IRDY driving
374
// non critical path for IRDY calculation
375
wire irdy_slow = pci_frame_out_in && mabort1 || mabort2 ;
376
 
377
// critical path in separate module
378 77 mihad
pci_irdy_out_crit irdy_iob_feed
379 2 mihad
(
380
    .pci_irdy_out       (pci_irdy_out),
381
    .irdy_slow_in       (irdy_slow),
382
    .pci_frame_out_in   (pci_frame_out_in),
383
    .pci_trdy_in        (pci_trdy_in),
384
    .pci_stop_in        (pci_stop_in)
385
) ;
386 21 mihad
 
387 2 mihad
// transfer FF indicator - when first transfer occurs it is set to 1 so backend can distinguish between disconnects and retries.
388
wire sm_transfer = sm_data_phases ;
389
reg transfer ;
390
 
391
wire transfer_input = sm_transfer && (~(pci_trdy_in || pci_devsel_in) || transfer) ;
392
 
393
always@(posedge clk_in or posedge reset_in)
394
begin
395
    if (reset_in)
396
        transfer <= #`FF_DELAY 1'b0 ;
397
    else
398
        transfer <= #`FF_DELAY transfer_input ;
399
end
400
 
401
assign first_out = ~transfer ;
402
 
403
// fast transfer status output - it's only negated target ready, since wait indicator qualifies valid transfer
404
assign wtransfer_out = ~pci_trdy_in ;
405
 
406
// registered transfer status output - calculated from registered target response inputs
407
assign rtransfer_out = ~(pci_trdy_reg_in || pci_devsel_reg_in) ;
408
 
409
// registered error status - calculated from registered target response inputs
410
assign rerror_out    = (~pci_stop_reg_in && pci_devsel_reg_in) ;
411
 
412
// retry is signalled to backend depending on registered target response or when latency timer expires
413
assign retry_out = timeout_termination || (~pci_stop_reg_in && ~pci_devsel_reg_in) ;
414
 
415
// AD output flip flops' clock enable
416
// new data is loaded to AD outputs whenever state machine is idle, bus was granted and bus is in idle state or
417
// when address phase is about to be finished
418 21 mihad
wire ad_load_slow = sm_address ;
419
wire ad_load_on_grant = sm_idle && pci_frame_in && pci_irdy_in ;
420 2 mihad
 
421 77 mihad
pci_mas_ad_load_crit mas_ad_load_feed
422 21 mihad
(
423
    .ad_load_out         (ad_load_out),
424
    .ad_load_in          (ad_load_slow),
425
    .ad_load_on_grant_in (ad_load_on_grant),
426
    .pci_gnt_in          (pci_gnt_in)
427
);
428
 
429 2 mihad
// next data loading is allowed when state machine is in transfer state and operation is a write
430 21 mihad
assign ad_load_on_transfer_out = sm_data_phases && do_write ;
431 2 mihad
 
432
// request for a bus is issued anytime when backend is requesting a transaction and state machine is in idle state
433
assign pci_req_out = ~(req_in && sm_idle) ;
434
 
435
// change state signal is actually clock enable for state register
436
// Non critical path for state change enable:
437
// state is always changed when:
438
// - address phase is finishing
439
// - state machine is in turn arround state
440
// - state machine is in transfer state and master abort termination is in progress
441
 
442
wire ch_state_slow = sm_address || sm_turn_arround || sm_data_phases && ( pci_frame_out_in && mabort1 || mabort2 ) ;
443
 
444
// a bit more critical change state enable is calculated with GNT signal
445
wire ch_state_med  = ch_state_slow || sm_idle && u_have_pci_bus && req_in && rdy_in ;
446
 
447
// most critical change state enable - calculated from target response signals
448 77 mihad
pci_mas_ch_state_crit state_machine_ce
449 2 mihad
(
450
    .change_state_out   (change_state),
451
    .ch_state_med_in    (ch_state_med),
452
    .sm_data_phases_in  (sm_data_phases),
453
    .pci_trdy_in        (pci_trdy_in),
454
    .pci_stop_in        (pci_stop_in)
455
) ;
456
 
457
// ad enable driving
458
// also divided in several categories - from less critical to most critical in separate module
459 21 mihad
//wire ad_en_slowest  = do_write && (sm_address || sm_data_phases && ~pci_frame_out_in) ;
460
//wire ad_en_on_grant = sm_idle && pci_frame_in && pci_irdy_in || sm_turn_arround ;
461
//wire ad_en_slow     = ad_en_on_grant && ~pci_gnt_in || ad_en_slowest ;
462
//wire ad_en_keep     = sm_data_phases && do_write && (pci_frame_out_in && ~mabort1 && ~mabort2) ;
463 2 mihad
 
464 21 mihad
wire ad_en_slow     = do_write && ( sm_address || ( sm_data_phases && !( ( pci_frame_out_in && mabort1 ) || mabort2 ) ) ) ;
465
wire ad_en_on_grant = ( sm_idle && pci_frame_in && pci_irdy_in ) || sm_turn_arround ;
466
 
467
// critical timing ad enable - calculated from grant input
468 77 mihad
pci_mas_ad_en_crit ad_iob_oe_feed
469 2 mihad
(
470
    .pci_ad_en_out      (pci_ad_en_out),
471
    .ad_en_slow_in      (ad_en_slow),
472 21 mihad
    .ad_en_on_grant_in  (ad_en_on_grant),
473
    .pci_gnt_in         (pci_gnt_in)
474 2 mihad
) ;
475
 
476
// cbe enable driving
477
wire cbe_en_on_grant = sm_idle && pci_frame_in && pci_irdy_in || sm_turn_arround ;
478
wire cbe_en_slow     = cbe_en_on_grant && ~pci_gnt_in || sm_address || sm_data_phases && ~pci_frame_out_in ;
479
wire cbe_en_keep     = sm_data_phases && pci_frame_out_in && ~mabort1 && ~mabort2 ;
480
 
481
// most critical cbe enable in separate module - calculated with most critical target inputs
482 77 mihad
pci_cbe_en_crit cbe_iob_feed
483 2 mihad
(
484
    .pci_cbe_en_out     (pci_cbe_en_out),
485
    .cbe_en_slow_in     (cbe_en_slow),
486
    .cbe_en_keep_in     (cbe_en_keep),
487
    .pci_stop_in        (pci_stop_in),
488
    .pci_trdy_in        (pci_trdy_in)
489
 
490
) ;
491
 
492
// IRDY enable is equal to FRAME enable delayed for one clock
493
assign pci_irdy_en_out   = pci_frame_en_in ;
494
 
495
// frame enable driving - sometimes it's calculated from non critical paths
496
wire frame_en_slow = (sm_idle && u_have_pci_bus && req_in && rdy_in) || sm_address || (sm_data_phases && ~pci_frame_out_in) ;
497
wire frame_en_keep = sm_data_phases && pci_frame_out_in && ~mabort1 && ~mabort2 ;
498
 
499
// most critical frame enable - calculated from heavily constrained target inputs in separate module
500 77 mihad
pci_frame_en_crit frame_iob_en_feed
501 2 mihad
(
502
    .pci_frame_en_out   (pci_frame_en_out),
503
    .frame_en_slow_in   (frame_en_slow),
504
    .frame_en_keep_in   (frame_en_keep),
505
    .pci_stop_in        (pci_stop_in),
506 21 mihad
    .pci_trdy_in        (pci_trdy_in)
507 2 mihad
) ;
508
 
509
// state machine next state definitions
510
always@(
511
    cur_state or
512
    do_write or
513
    pci_frame_out_in
514
)
515
begin
516
    // default values for state machine outputs
517
    wait_out                = 1'b1 ;
518
    wdata_selector          = SEL_ADDR_BC ;
519
    sm_idle                 = 1'b0 ;
520
    sm_address              = 1'b0 ;
521
    sm_data_phases          = 1'b0 ;
522
    sm_turn_arround         = 1'b0 ;
523
 
524
    case ( cur_state )
525
 
526
        S_IDLE: begin
527
                    // indicate the state
528
                    sm_idle      = 1'b1 ;
529
                    // assign next state - only possible is address - if state machine is supposed to stay in idle state
530
                    // outside signals disable the clock
531 21 mihad
                    next_state     = S_ADDRESS ;
532
                    wdata_selector = SEL_DATA_BE ;
533 2 mihad
                end
534
 
535
        S_ADDRESS:  begin
536
                        // indicate the state
537
                        sm_address  = 1'b1 ;
538
                        // select appropriate data/be for outputs
539 21 mihad
                        wdata_selector = SEL_NEXT_DATA_BE ;
540 2 mihad
                        // only possible next state is transfer state
541
                        next_state = S_TRANSFER ;
542
                    end
543
 
544
        S_TRANSFER: begin
545
                        // during transfers wait indicator is inactive - all status signals are now valid
546
                        wait_out               = 1'b0 ;
547
                        // indicate the state
548
                        sm_data_phases         = 1'b1 ;
549
                        // select appropriate data/be for outputs
550
                        wdata_selector = SEL_NEXT_DATA_BE ;
551
                        if ( pci_frame_out_in )
552
                        begin
553
                            // when frame is inactive next state will be turn arround
554
                            next_state = S_TA_END ;
555
                        end
556
                        else
557
                            // while frame is active state cannot be anything else then transfer
558
                            next_state = S_TRANSFER ;
559
                    end
560 21 mihad
 
561 2 mihad
        S_TA_END:   begin
562
                        // wait is still inactive because of registered statuses
563
                        wait_out = 1'b0 ;
564
                        // indicate the state
565
                        sm_turn_arround = 1'b1 ;
566
                        // next state is always idle
567
                        next_state = S_IDLE ;
568
                    end
569
        default:    next_state = S_IDLE ;
570
    endcase
571
end
572
 
573
// ad and cbe lines multiplexer for write data
574 21 mihad
reg [1:0] rdata_selector ;
575
always@(posedge clk_in or posedge reset_in)
576 2 mihad
begin
577 21 mihad
    if ( reset_in )
578
        rdata_selector <= #`FF_DELAY SEL_ADDR_BC ;
579
    else
580
    if ( change_state )
581
        rdata_selector <= #`FF_DELAY wdata_selector ;
582
end
583
 
584
always@(rdata_selector or address_in or bc_in or data_in or be_in or next_data_in or next_be_in)
585
begin
586
    case ( rdata_selector )
587 2 mihad
        SEL_ADDR_BC:    begin
588
                            pci_ad_out  = address_in ;
589
                            pci_cbe_out = bc_in ;
590
                        end
591
 
592
        SEL_DATA_BE:    begin
593
                            pci_ad_out  = data_in ;
594
                            pci_cbe_out = be_in ;
595
                        end
596
        SEL_NEXT_DATA_BE,
597
        2'b10:              begin
598
                                pci_ad_out  = next_data_in ;
599
                                pci_cbe_out = next_be_in ;
600
                            end
601
    endcase
602
end
603
 
604
// data output mux for reads
605
always@(mabort_out or pci_ad_reg_in)
606
begin
607
    if ( mabort_out )
608
        data_out = 32'hFFFF_FFFF ;
609
    else
610
        data_out = pci_ad_reg_in ;
611
end
612 21 mihad
endmodule

powered by: WebSVN 2.1.0

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