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

Subversion Repositories pci

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

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

Line No. Rev Author Line
1 2 mihad
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  File name: pci_target32_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
////      - Tadej Markovic, tadej@opencores.org                   ////
10
////                                                              ////
11
////  All additional information is avaliable in the README.txt   ////
12
////  file.                                                       ////
13
////                                                              ////
14
////                                                              ////
15
//////////////////////////////////////////////////////////////////////
16
////                                                              ////
17
//// Copyright (C) 2000 Tadej Markovic, tadej@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.8  2003/01/21 16:06:56  mihad
46
// Bug fixes, testcases added.
47
//
48 73 mihad
// Revision 1.7  2002/09/24 19:09:17  mihad
49
// Number of state bits define was removed
50
//
51 56 mihad
// Revision 1.6  2002/09/24 18:30:00  mihad
52
// Changed state machine encoding to true one-hot
53
//
54 55 mihad
// Revision 1.5  2002/08/22 09:07:06  mihad
55
// Fixed a bug and provided testcase for it. Target was responding to configuration cycle type 1 transactions.
56
//
57 51 mihad
// Revision 1.4  2002/02/19 16:32:37  mihad
58
// Modified testbench and fixed some bugs
59
//
60 26 mihad
// Revision 1.3  2002/02/01 15:25:12  mihad
61
// Repaired a few bugs, updated specification, added test bench files and design document
62
//
63 21 mihad
// Revision 1.2  2001/10/05 08:14:30  mihad
64
// Updated all files with inclusion of timescale file for simulation purposes.
65
//
66 6 mihad
// Revision 1.1.1.1  2001/10/02 15:33:47  mihad
67
// New project directory structure
68 2 mihad
//
69 6 mihad
//
70 2 mihad
 
71 21 mihad
`include "pci_constants.v"
72 2 mihad
 
73 21 mihad
// synopsys translate_off
74 6 mihad
`include "timescale.v"
75 21 mihad
// synopsys translate_on
76 2 mihad
 
77 77 mihad
module pci_target32_sm
78 2 mihad
(
79
    // system inputs
80
    clk_in,
81
    reset_in,
82
    // master inputs
83
    pci_frame_in,
84
    pci_irdy_in,
85
    pci_idsel_in,
86
    pci_frame_reg_in,
87
    pci_irdy_reg_in,
88
    pci_idsel_reg_in,
89
    // target response outputs
90
    pci_trdy_out,
91
    pci_stop_out,
92
    pci_devsel_out,
93
    pci_trdy_en_out,
94
    pci_stop_en_out,
95
    pci_devsel_en_out,
96 21 mihad
    ad_load_out,
97
    ad_load_on_transfer_out,
98 2 mihad
    // address, data, bus command, byte enable in/outs
99
    pci_ad_reg_in,
100
    pci_ad_out,
101
    pci_ad_en_out,
102
    pci_cbe_reg_in,
103
    bckp_trdy_en_in,
104
    bckp_devsel_in,
105
    bckp_trdy_in,
106
    bckp_stop_in,
107 21 mihad
    pci_trdy_reg_in,
108
    pci_stop_reg_in,
109 2 mihad
 
110
    // backend side of state machine with control signals to pci_io_mux ...
111
    address_out,
112
    addr_claim_in,
113
    bc_out,
114
    bc0_out,
115
    data_out,
116
    data_in,
117
    be_out,
118
    req_out,
119
    rdy_out,
120
    addr_phase_out,
121 21 mihad
    bckp_devsel_out,
122 2 mihad
    bckp_trdy_out,
123 21 mihad
    bckp_stop_out,
124 2 mihad
    last_reg_out,
125
    frame_reg_out,
126 21 mihad
    fetch_pcir_fifo_out,
127
    load_medium_reg_out,
128
    sel_fifo_mreg_out,
129
    sel_conf_fifo_out,
130
    fetch_conf_out,
131
    load_to_pciw_fifo_out,
132 2 mihad
    load_to_conf_out,
133 21 mihad
    same_read_in,
134
    norm_access_to_config_in,
135
    read_completed_in,
136
    read_processing_in,
137
    target_abort_in,
138
    disconect_wo_data_in,
139
    disconect_w_data_in,
140
    target_abort_set_out,
141
    pciw_fifo_full_in,
142
    pcir_fifo_data_err_in,
143
    wbw_fifo_empty_in,
144
    wbu_del_read_comp_pending_in,
145
    wbu_frame_en_in
146 2 mihad
 
147
) ;
148
 
149
/*----------------------------------------------------------------------------------------------------------------------
150
Various parameters needed for state machine and other stuff
151
----------------------------------------------------------------------------------------------------------------------*/
152 55 mihad
parameter       S_IDLE          = 3'b001 ;
153
parameter       S_WAIT          = 3'b010 ;
154
parameter       S_TRANSFERE     = 3'b100 ;
155 2 mihad
 
156
 
157
/*==================================================================================================================
158
System inputs.
159
==================================================================================================================*/
160
// PCI side clock and reset
161
input   clk_in,
162
        reset_in ;
163
 
164
 
165
/*==================================================================================================================
166
PCI interface signals - bidirectional signals are divided to inputs and outputs in I/O cells instantiation
167
module. Enables are separate signals.
168
==================================================================================================================*/
169
// master inputs
170
input   pci_frame_in,
171 21 mihad
        pci_irdy_in,
172
        pci_idsel_in ;
173 2 mihad
input   pci_frame_reg_in,
174 21 mihad
        pci_irdy_reg_in,
175
        pci_idsel_reg_in ;
176
 
177 2 mihad
// target response outputs
178
output  pci_trdy_out,
179
        pci_stop_out,
180
        pci_devsel_out ;
181
output  pci_trdy_en_out,
182 21 mihad
        pci_stop_en_out,
183
        pci_devsel_en_out ;
184
output  ad_load_out ;
185
output  ad_load_on_transfer_out ;
186 2 mihad
// address, data, bus command, byte enable in/outs
187
input   [31:0]  pci_ad_reg_in ;
188
output  [31:0]  pci_ad_out ;
189
output          pci_ad_en_out ;
190
input   [3:0]   pci_cbe_reg_in ;
191 21 mihad
input           bckp_trdy_en_in ;
192
input           bckp_devsel_in ;
193
input           bckp_trdy_in ;
194
input           bckp_stop_in ;
195
input           pci_trdy_reg_in ;
196
input           pci_stop_reg_in ;
197 2 mihad
 
198
 
199
/*==================================================================================================================
200
Other side of PCI Target state machine
201
==================================================================================================================*/
202
// Data, byte enables, bus commands and address ports
203 21 mihad
output  [31:0]  address_out ;       // current request address output - registered
204
input           addr_claim_in ;     // current request address claim input
205
output  [3:0]   bc_out ;            // current request bus command output - registered
206
output          bc0_out ;           // current cycle RW signal output
207
input   [31:0]  data_in ;           // for read operations - current dataphase data input
208
output  [31:0]  data_out ;          // for write operations - current request data output - registered
209
output   [3:0]  be_out ;            // current dataphase byte enable outputs - registered
210 2 mihad
// Port connection control signals from PCI FSM
211 21 mihad
output          req_out ;           // Read is requested to WB master
212
output          rdy_out ;           // DATA / ADDRESS selection when read or write - registered
213
output          addr_phase_out ;    // Indicates address phase and also fast-back-to-back address phase - registered
214
output                  bckp_devsel_out ;       // DEVSEL output (which is registered) equivalent
215
output          bckp_trdy_out ;     // TRDY output (which is registered) equivalent
216
output                  bckp_stop_out ;         // STOP output (which is registered) equivalent
217
output          last_reg_out ;      // Indicates last data phase - registered
218
output          frame_reg_out ;     // FRAME output signal - registered
219
output          fetch_pcir_fifo_out ;// Read enable for PCIR_FIFO when when read is finishen on WB side
220
output          load_medium_reg_out ;// Load data from PCIR_FIFO to medium register (first data must be prepared on time)
221
output          sel_fifo_mreg_out ; // Read data selection between PCIR_FIFO and medium register
222
output          sel_conf_fifo_out ; // Read data selection between Configuration registers and "FIFO"
223
output          fetch_conf_out ;    // Read enable for configuration space registers
224
output          load_to_pciw_fifo_out ;// Write enable to PCIW_FIFO
225
output          load_to_conf_out ;  // Write enable to Configuration space registers
226 2 mihad
 
227
 
228
/*==================================================================================================================
229
Status
230
==================================================================================================================*/
231 21 mihad
input           same_read_in ;              // Indicates the same read request (important when read is finished on WB side)
232
input           norm_access_to_config_in ;  // Indicates the access to Configuration space with MEMORY commands
233
input           read_completed_in ;         // Indicates that read request is completed on WB side
234
input           read_processing_in ;        // Indicates that read request is processing on WB side
235
input           target_abort_in ;           // Indicates target abort termination
236
input           disconect_wo_data_in ;      // Indicates disconnect without data termination
237
input                   disconect_w_data_in ;           // Indicates disconnect with data termination
238
input           pciw_fifo_full_in ;         // Indicates that write PCIW_FIFO is full
239
input           pcir_fifo_data_err_in ;     // Indicates data error on current data read from PCIR_FIFO
240
input           wbw_fifo_empty_in ;         // Indicates that WB SLAVE UNIT has no data to be written to PCI bus
241
input                   wbu_del_read_comp_pending_in ; // Indicates that WB SÈAVE UNIT has a delayed read pending
242
input           wbu_frame_en_in ;           // Indicates that WB SLAVE UNIT is accessing the PCI bus (important if
243
                                            //   address on PCI bus is also claimed by decoder in this PCI TARGET UNIT
244
output          target_abort_set_out ;      // Signal used to be set in configuration space registers
245 2 mihad
 
246
/*==================================================================================================================
247
END of input / output PORT DEFINITONS !!!
248
==================================================================================================================*/
249
 
250
// Delayed frame signal for determining the address phase
251 21 mihad
reg             previous_frame ;
252 2 mihad
// Delayed read completed signal for preparing the data from pcir fifo
253 21 mihad
reg             read_completed_reg ;
254
// Delayed disconnect with/without data for stop loading data to PCIW_FIFO
255
//reg             disconect_wo_data_reg ;
256 2 mihad
 
257 21 mihad
wire config_disconnect ;
258
wire disconect_wo_data = disconect_wo_data_in || config_disconnect ;
259
wire disconect_w_data = disconect_w_data_in ;
260 2 mihad
// Delayed frame signal for determining the address phase!
261
always@(posedge clk_in or posedge reset_in)
262
begin
263 21 mihad
    if (reset_in)
264
    begin
265
        previous_frame <= #`FF_DELAY 1'b1 ;
266
        read_completed_reg <= #`FF_DELAY 1'b0 ;
267
    end
268 2 mihad
    else
269 21 mihad
    begin
270
        previous_frame <= #`FF_DELAY pci_frame_reg_in ;
271
        read_completed_reg <= #`FF_DELAY read_completed_in ;
272
    end
273 2 mihad
end
274
 
275
// Address phase is when previous frame was 1 and this frame is 0 and frame isn't generated from pci master (in WBU)
276 21 mihad
wire    addr_phase = (previous_frame && ~pci_frame_reg_in && ~wbu_frame_en_in) ;
277 2 mihad
 
278 21 mihad
`ifdef      HOST
279
    `ifdef  NO_CNF_IMAGE
280
            // Wire tells when there is configuration (read or write) command with IDSEL signal active
281
            wire    config_access = 1'b0 ;
282
            // Write and read progresses are used for determining next state
283
            wire    write_progress  =   ( (read_completed_in && ~pciw_fifo_full_in && ~wbu_del_read_comp_pending_in) ||
284
                                          (~read_processing_in && ~pciw_fifo_full_in && ~wbu_del_read_comp_pending_in) ) ;
285
            wire    read_progress   =   ( (read_completed_in && wbw_fifo_empty_in) ) ;
286
    `else
287
            // Wire tells when there is configuration (read or write) command with IDSEL signal active
288 51 mihad
            wire    config_access = (pci_idsel_reg_in && pci_cbe_reg_in[3]) && (~pci_cbe_reg_in[2] && pci_cbe_reg_in[1]) &&     // idsel asserted with correct bus command(101x)
289
                                    (pci_ad_reg_in[1:0] == 2'b00) ;        // has to be type 0 configuration cycle
290
 
291 21 mihad
            // Write and read progresses are used for determining next state
292
            wire    write_progress  =   ( (norm_access_to_config_in) ||
293
                                                                  (read_completed_in && ~pciw_fifo_full_in && ~wbu_del_read_comp_pending_in) ||
294
                                          (~read_processing_in && ~pciw_fifo_full_in && ~wbu_del_read_comp_pending_in) ) ;
295
            wire    read_progress   =   ( (~read_completed_in && norm_access_to_config_in) ||
296
                                          (read_completed_in && wbw_fifo_empty_in) ) ;
297
    `endif
298
`else
299
            // Wire tells when there is configuration (read or write) command with IDSEL signal active
300 51 mihad
            wire    config_access = (pci_idsel_reg_in && pci_cbe_reg_in[3]) && (~pci_cbe_reg_in[2] && pci_cbe_reg_in[1]) &&     // idsel asserted with correct bus command(101x)
301
                                    (pci_ad_reg_in[1:0] == 2'b00) ;        // has to be type 0 configuration cycle
302
 
303 21 mihad
            // Write and read progresses are used for determining next state
304
            wire    write_progress  =   ( (norm_access_to_config_in) ||
305
                                                                  (read_completed_in && ~pciw_fifo_full_in && ~wbu_del_read_comp_pending_in) ||
306
                                          (~read_processing_in && ~pciw_fifo_full_in && ~wbu_del_read_comp_pending_in) ) ;
307
            wire    read_progress   =   ( (~read_completed_in && norm_access_to_config_in) ||
308
                                          (read_completed_in && wbw_fifo_empty_in) ) ;
309
`endif
310 2 mihad
 
311 21 mihad
// Signal for loading data to medium register from pcir fifo when read completed from WB side!
312
wire    prepare_rd_fifo_data = (read_completed_in && ~read_completed_reg) ;
313 2 mihad
 
314
// Write allowed to PCIW_FIFO
315 21 mihad
wire    write_to_fifo   =   ((read_completed_in && ~pciw_fifo_full_in && ~wbu_del_read_comp_pending_in) ||
316
                                                         (~read_processing_in && ~pciw_fifo_full_in && ~wbu_del_read_comp_pending_in)) ;
317 2 mihad
// Read allowed from PCIR_FIFO
318 21 mihad
wire    read_from_fifo  =   (read_completed_in && wbw_fifo_empty_in) ;
319
`ifdef      HOST
320
    `ifdef  NO_CNF_IMAGE
321
            // Read request is allowed to be proceed regarding the WB side
322
            wire    read_request    =   (~read_completed_in && ~read_processing_in) ;
323
    `else
324
            // Read request is allowed to be proceed regarding the WB side
325
            wire    read_request    =   (~read_completed_in && ~read_processing_in && ~norm_access_to_config_in) ;
326
    `endif
327
`else
328
            // Read request is allowed to be proceed regarding the WB side
329
            wire    read_request    =   (~read_completed_in && ~read_processing_in && ~norm_access_to_config_in) ;
330
`endif
331 2 mihad
 
332
// Critically calculated signals are latched in this clock period (address phase) to be used in the next clock period
333 21 mihad
reg             rw_cbe0 ;
334
reg             wr_progress ;
335
reg             rd_progress ;
336
reg             rd_from_fifo ;
337
reg             rd_request ;
338
reg             wr_to_fifo ;
339
reg             same_read_reg ;
340 2 mihad
 
341
always@(posedge clk_in or posedge reset_in)
342
begin
343 21 mihad
    if (reset_in)
344
    begin
345
        rw_cbe0                         <= #`FF_DELAY 1'b0 ;
346
        wr_progress                     <= #`FF_DELAY 1'b0 ;
347
        rd_progress                     <= #`FF_DELAY 1'b0 ;
348
        rd_from_fifo                    <= #`FF_DELAY 1'b0 ;
349
        rd_request                      <= #`FF_DELAY 1'b0 ;
350
        wr_to_fifo                      <= #`FF_DELAY 1'b0 ;
351
        same_read_reg                   <= #`FF_DELAY 1'b0 ;
352
    end
353
    else
354
    begin
355
        if (addr_phase)
356
        begin
357
            rw_cbe0                     <= #`FF_DELAY pci_cbe_reg_in[0] ;
358
            wr_progress                 <= #`FF_DELAY write_progress ;
359
            rd_progress                 <= #`FF_DELAY read_progress ;
360
            rd_from_fifo                <= #`FF_DELAY read_from_fifo ;
361
            rd_request                  <= #`FF_DELAY read_request ;
362
            wr_to_fifo                  <= #`FF_DELAY write_to_fifo ;
363
            same_read_reg               <= #`FF_DELAY same_read_in ;
364
        end
365
    end
366 2 mihad
end
367
 
368 21 mihad
`ifdef      HOST
369
    `ifdef  NO_CNF_IMAGE
370
            wire    norm_access_to_conf_reg     = 1'b0 ;
371
            wire    cnf_progress                = 1'b0 ;
372
    `else
373
            reg     norm_access_to_conf_reg ;
374
            reg     cnf_progress ;
375
            always@(posedge clk_in or posedge reset_in)
376
            begin
377
                if (reset_in)
378
                begin
379
                    norm_access_to_conf_reg     <= #`FF_DELAY 1'b0 ;
380
                    cnf_progress                <= #`FF_DELAY 1'b0 ;
381
                end
382
                else
383
                begin
384
                    if (addr_phase)
385
                    begin
386
                        norm_access_to_conf_reg <= #`FF_DELAY norm_access_to_config_in ;
387
                        cnf_progress            <= #`FF_DELAY config_access ;
388
                    end
389
                end
390
            end
391
    `endif
392
`else
393
            reg     norm_access_to_conf_reg ;
394
            reg     cnf_progress ;
395
            always@(posedge clk_in or posedge reset_in)
396
            begin
397
                if (reset_in)
398
                begin
399
                    norm_access_to_conf_reg     <= #`FF_DELAY 1'b0 ;
400
                    cnf_progress                <= #`FF_DELAY 1'b0 ;
401
                end
402
                else
403
                begin
404
                    if (addr_phase)
405
                    begin
406
                        norm_access_to_conf_reg <= #`FF_DELAY norm_access_to_config_in ;
407
                        cnf_progress            <= #`FF_DELAY config_access ;
408
                    end
409
                end
410
            end
411
`endif
412
 
413 2 mihad
// Signal used in S_WAIT state to determin next state
414 21 mihad
wire s_wait_progress =  (
415
                        (~cnf_progress && rw_cbe0 && wr_progress && ~target_abort_in) ||
416
                        (~cnf_progress && ~rw_cbe0 && same_read_reg && rd_progress && ~target_abort_in && ~pcir_fifo_data_err_in) ||
417
                        (~cnf_progress && ~rw_cbe0 && ~same_read_reg && norm_access_to_conf_reg && ~target_abort_in) ||
418
                        (cnf_progress && ~target_abort_in)
419
                        ) ;
420 2 mihad
 
421
// Signal used in S_TRANSFERE state to determin next state
422 21 mihad
wire s_tran_progress =  (
423
                        (rw_cbe0 && !disconect_wo_data) ||
424
                        (~rw_cbe0 && !disconect_wo_data && !target_abort_in && !pcir_fifo_data_err_in)
425
                        ) ;
426
 
427 2 mihad
// Clock enable for PCI state machine driven directly from critical inputs - FRAME and IRDY
428 21 mihad
wire            pcit_sm_clk_en ;
429 2 mihad
// FSM states signals indicating the current state
430 21 mihad
reg             state_idle ;
431
reg             state_wait ;
432
reg             sm_transfere ;
433
reg             backoff ;
434
reg             state_default ;
435
wire            state_backoff   = sm_transfere && backoff ;
436
wire            state_transfere = sm_transfere && !backoff ;
437
 
438
always@(posedge clk_in or posedge reset_in)
439
begin
440
    if ( reset_in )
441
        backoff <= #`FF_DELAY 1'b0 ;
442
    else if ( state_idle )
443
        backoff <= #`FF_DELAY 1'b0 ;
444
    else
445
        backoff <= #`FF_DELAY (state_wait && !s_wait_progress) ||
446
                              (sm_transfere && !s_tran_progress && !pci_frame_in && !pci_irdy_in) ||
447
                              backoff ;
448
end
449
assign config_disconnect = sm_transfere && (norm_access_to_conf_reg || cnf_progress) ;
450
 
451 2 mihad
// Clock enable module used for preserving the architecture because of minimum delay for critical inputs
452 77 mihad
pci_target32_clk_en pci_target_clock_en
453 2 mihad
(
454 21 mihad
    .addr_phase             (addr_phase),
455
    .config_access          (config_access),
456
    .addr_claim_in          (addr_claim_in),
457
    .pci_frame_in           (pci_frame_in),
458
    .state_wait             (state_wait),
459
    .state_transfere        (sm_transfere),
460
    .state_default          (state_default),
461
    .clk_enable             (pcit_sm_clk_en)
462 2 mihad
);
463
 
464 56 mihad
reg [2:0]  c_state ; //current state register
465
reg [2:0]  n_state ; //next state input to current state register
466 2 mihad
 
467
// state machine register control
468
always@(posedge clk_in or posedge reset_in)
469
begin
470
    if (reset_in) // reset state machine to S_IDLE state
471
        c_state <= #`FF_DELAY S_IDLE ;
472
    else
473 21 mihad
        if (pcit_sm_clk_en) // if conditions are true, then FSM goes to next state!
474
            c_state <= #`FF_DELAY n_state ;
475
end
476 2 mihad
 
477
// state machine logic
478 21 mihad
always@(c_state)
479 2 mihad
begin
480 21 mihad
    case (c_state)
481
    S_IDLE :
482
    begin
483
        state_idle      <= 1'b1 ;
484
        state_wait      <= 1'b0 ;
485
        sm_transfere <= 1'b0 ;
486
        state_default   <= 1'b0 ;
487
        n_state <= S_WAIT ;
488
    end
489
    S_WAIT :
490
    begin
491
        state_idle      <= 1'b0 ;
492
        state_wait      <= 1'b1 ;
493
        sm_transfere <= 1'b0 ;
494
        state_default   <= 1'b0 ;
495
        n_state <= S_TRANSFERE ;
496
    end
497
    S_TRANSFERE :
498
    begin
499
        state_idle      <= 1'b0 ;
500
        state_wait      <= 1'b0 ;
501
        sm_transfere <= 1'b1 ;
502
        state_default   <= 1'b0 ;
503
        n_state <= S_IDLE ;
504
    end
505
    default :
506
    begin
507
        state_idle      <= 1'b0 ;
508
        state_wait      <= 1'b0 ;
509
        sm_transfere <= 1'b0 ;
510
        state_default   <= 1'b1 ;
511
        n_state <= S_IDLE ;
512
    end
513
    endcase
514 2 mihad
end
515
 
516
        // if not retry and not target abort
517
        // NO CRITICAL SIGNALS
518 21 mihad
wire    trdy_w          =   (
519
        (state_wait && ~cnf_progress && rw_cbe0 && wr_progress && ~target_abort_in) ||
520
        (state_wait && ~cnf_progress && ~rw_cbe0 && same_read_reg && rd_progress && ~target_abort_in && !pcir_fifo_data_err_in) ||
521
        (state_wait && ~cnf_progress && ~rw_cbe0 && ~same_read_reg && norm_access_to_conf_reg && ~target_abort_in) ||
522 2 mihad
        (state_wait && cnf_progress && ~target_abort_in)
523 21 mihad
                            ) ;
524 2 mihad
        // if not disconnect without data and not target abort (only during reads)
525
        // MUST BE ANDED WITH CRITICAL ~FRAME
526 21 mihad
wire    trdy_w_frm      =   (
527
        (state_transfere && !cnf_progress && !norm_access_to_conf_reg && rw_cbe0 && !disconect_wo_data) ||
528
        (state_transfere && !cnf_progress && !norm_access_to_conf_reg && ~rw_cbe0 && !disconect_wo_data && ~pcir_fifo_data_err_in) ||
529 73 mihad
        (state_transfere && !cnf_progress && !norm_access_to_conf_reg && disconect_w_data && pci_irdy_reg_in && (!rw_cbe0 && !pcir_fifo_data_err_in))
530 21 mihad
                            ) ;
531 2 mihad
        // if not disconnect without data and not target abort (only during reads)
532
        // MUST BE ANDED WITH CRITICAL ~FRAME AND IRDY
533 21 mihad
wire    trdy_w_frm_irdy =   ( ~bckp_trdy_in ) ;
534 2 mihad
// TRDY critical module used for preserving the architecture because of minimum delay for critical inputs
535 77 mihad
pci_target32_trdy_crit pci_target_trdy_critical
536 2 mihad
(
537 21 mihad
    .trdy_w                 (trdy_w),
538
    .trdy_w_frm             (trdy_w_frm),
539
    .trdy_w_frm_irdy        (trdy_w_frm_irdy),
540
    .pci_frame_in           (pci_frame_in),
541
    .pci_irdy_in            (pci_irdy_in),
542
    .pci_trdy_out           (pci_trdy_out)
543 2 mihad
);
544
 
545 21 mihad
        // if target abort or retry
546 2 mihad
        // NO CRITICAL SIGNALS
547 21 mihad
wire    stop_w          =   (
548
        (state_wait && target_abort_in) ||
549
        (state_wait && ~cnf_progress && rw_cbe0 && ~wr_progress) ||
550
        (state_wait && ~cnf_progress && ~rw_cbe0 && same_read_reg && ~rd_progress) ||
551
        (state_wait && ~cnf_progress && ~rw_cbe0 && same_read_reg && rd_progress && pcir_fifo_data_err_in) ||
552
        (state_wait && ~cnf_progress && ~rw_cbe0 && ~same_read_reg && ~norm_access_to_conf_reg)
553
                            ) ;
554
        // if asserted, wait for deactivating the frame
555 2 mihad
        // MUST BE ANDED WITH CRITICAL ~FRAME
556 21 mihad
wire    stop_w_frm      =   (
557
        (state_backoff && ~bckp_stop_in)
558
                            ) ;
559
        // if target abort or if disconnect without data (after data transfere)
560 2 mihad
        // MUST BE ANDED WITH CRITICAL ~FRAME AND ~IRDY
561 21 mihad
wire    stop_w_frm_irdy =   (
562
        (state_transfere && (disconect_wo_data)) ||
563
        (state_transfere && ~rw_cbe0 && pcir_fifo_data_err_in)
564
                            ) ;
565 2 mihad
// STOP critical module used for preserving the architecture because of minimum delay for critical inputs
566 77 mihad
pci_target32_stop_crit pci_target_stop_critical
567 2 mihad
(
568 21 mihad
    .stop_w                 (stop_w),
569
    .stop_w_frm             (stop_w_frm),
570
    .stop_w_frm_irdy        (stop_w_frm_irdy),
571
    .pci_frame_in           (pci_frame_in),
572
    .pci_irdy_in            (pci_irdy_in),
573
    .pci_stop_out           (pci_stop_out)
574 2 mihad
);
575
 
576 21 mihad
        // if OK to respond and not target abort
577 2 mihad
        // NO CRITICAL SIGNALS
578 21 mihad
wire    devs_w          =   (
579
        (addr_phase && config_access) ||
580
        (addr_phase && ~config_access && addr_claim_in) ||
581
        (state_wait && ~target_abort_in && !(~cnf_progress && ~rw_cbe0 && same_read_reg && rd_progress && pcir_fifo_data_err_in) )
582
                            ) ;
583
 
584
        // if not target abort (only during reads) or if asserted, wait for deactivating the frame
585 2 mihad
        // MUST BE ANDED WITH CRITICAL ~FRAME
586 21 mihad
wire    devs_w_frm      =   (
587
        (state_transfere && rw_cbe0) ||
588
        (state_transfere && ~rw_cbe0 && ~pcir_fifo_data_err_in) ||
589
        (state_backoff && ~bckp_devsel_in)
590
                            ) ;
591
        // if not target abort (only during reads)
592 2 mihad
        // MUST BE ANDED WITH CRITICAL ~FRAME AND IRDY
593 21 mihad
wire    devs_w_frm_irdy =   (
594
        (state_transfere && ~rw_cbe0 && pcir_fifo_data_err_in)
595
                            ) ;
596 2 mihad
// DEVSEL critical module used for preserving the architecture because of minimum delay for critical inputs
597 77 mihad
pci_target32_devs_crit pci_target_devsel_critical
598 2 mihad
(
599 21 mihad
    .devs_w                 (devs_w),
600
    .devs_w_frm             (devs_w_frm),
601
    .devs_w_frm_irdy        (devs_w_frm_irdy),
602
    .pci_frame_in           (pci_frame_in),
603
    .pci_irdy_in            (pci_irdy_in),
604
    .pci_devsel_out         (pci_devsel_out)
605 2 mihad
);
606
 
607 21 mihad
// signal used in AD enable module with preserving the hierarchy because of minimum delay for critical inputs
608
assign  pci_ad_en_out =    (
609
        (addr_phase && config_access && ~pci_cbe_reg_in[0]) ||
610
        (addr_phase && ~config_access && addr_claim_in && ~pci_cbe_reg_in[0]) ||
611
        (state_wait && ~rw_cbe0) ||
612
        (state_transfere && ~rw_cbe0) ||
613
        (state_backoff && ~rw_cbe0 && ~pci_frame_reg_in)
614
                            ) ;
615 2 mihad
 
616 21 mihad
wire fast_back_to_back  =   (addr_phase && ~pci_irdy_reg_in) ;
617 2 mihad
 
618 21 mihad
        // if cycle will progress or will not be stopped
619 2 mihad
        // NO CRITICAL SIGNALS
620 21 mihad
wire    ctrl_en       =
621
        /*(~wbu_frame_en_in && fast_back_to_back) ||*/
622
        (addr_phase && config_access) ||
623
        (addr_phase && ~config_access && addr_claim_in) ||
624
        (state_wait) ||
625
        (state_transfere && ~(pci_frame_reg_in && ~pci_irdy_reg_in && (~pci_stop_reg_in || ~pci_trdy_reg_in))) ||
626
        (state_backoff && ~(pci_frame_reg_in && ~pci_irdy_reg_in && (~pci_stop_reg_in || ~pci_trdy_reg_in))) ;
627 2 mihad
 
628 21 mihad
assign pci_trdy_en_out   = ctrl_en ;
629
assign pci_stop_en_out   = ctrl_en ;
630
assign pci_devsel_en_out = ctrl_en ;
631
 
632 2 mihad
// target ready output signal delayed for one clock used in conjunction with irdy_reg to select which
633
//   data are registered in io mux module - from fifo or medoum register
634 21 mihad
reg             bckp_trdy_reg ;
635 2 mihad
// delayed indicators for states transfere and backoff
636 21 mihad
reg             state_transfere_reg ;
637
reg             state_backoff_reg ;
638 2 mihad
always@(posedge clk_in or posedge reset_in)
639
begin
640 21 mihad
    if (reset_in)
641 2 mihad
    begin
642 21 mihad
        bckp_trdy_reg <= #`FF_DELAY 1'b1 ;
643
        state_transfere_reg <= #`FF_DELAY 1'b0 ;
644
        state_backoff_reg <= #`FF_DELAY 1'b0 ;
645
    end
646
    else
647
    begin
648
        bckp_trdy_reg <= #`FF_DELAY bckp_trdy_in ;
649
        state_transfere_reg <= #`FF_DELAY state_transfere ;
650
        state_backoff_reg <= #`FF_DELAY state_backoff ;
651
    end
652 2 mihad
end
653
 
654
// Read control signals assignments
655 21 mihad
assign
656
    fetch_pcir_fifo_out =   (
657
        (prepare_rd_fifo_data) ||
658
        (state_wait && ~cnf_progress && ~rw_cbe0 && same_read_reg && rd_from_fifo && ~target_abort_in) ||
659
        (bckp_trdy_en_in && ~pci_trdy_reg_in && ~cnf_progress && ~rw_cbe0 && same_read_reg && rd_from_fifo && ~pci_irdy_reg_in)
660
                            ) ;
661 2 mihad
 
662 21 mihad
assign  ad_load_out         =   (state_wait) ;
663 2 mihad
 
664 21 mihad
assign  ad_load_on_transfer_out = (bckp_trdy_en_in && ~rw_cbe0) ;
665 2 mihad
 
666 21 mihad
assign  load_medium_reg_out =   (
667
        (prepare_rd_fifo_data) ||
668
        (state_wait && ~rw_cbe0 && ~cnf_progress && same_read_reg && rd_from_fifo && ~target_abort_in) ||
669
        (~pci_irdy_reg_in && ~rw_cbe0 && ~cnf_progress && same_read_reg && rd_from_fifo && ~pci_trdy_reg_in && bckp_trdy_en_in)
670
                                ) ;
671 2 mihad
 
672 21 mihad
assign  sel_fifo_mreg_out = (~pci_irdy_reg_in && ~bckp_trdy_reg) ;
673 2 mihad
 
674 21 mihad
`ifdef      HOST
675
    `ifdef  NO_CNF_IMAGE
676
            assign  sel_conf_fifo_out = 1'b0 ;
677
    `else
678
            assign  sel_conf_fifo_out = (cnf_progress || norm_access_to_conf_reg) ;
679
    `endif
680
`else
681
            assign  sel_conf_fifo_out = (cnf_progress || norm_access_to_conf_reg) ;
682
`endif
683
 
684
// NOT USED NOW, SINCE READ IS ASYNCHRONOUS
685
//assign    fetch_conf_out = ((cnf_progress || norm_access_to_conf_reg) && ~rw_cbe0 && ~bckp_devsel_in) ;
686
assign  fetch_conf_out = 1'b0 ;
687
 
688 2 mihad
// Write control signals assignments
689
assign
690 21 mihad
    load_to_pciw_fifo_out = (
691
        (state_wait && (~cnf_progress && ~norm_access_to_conf_reg) && rw_cbe0 && wr_to_fifo && ~target_abort_in) ||
692
        (state_transfere_reg && ~state_backoff && rw_cbe0 && wr_to_fifo /*&& ~disconect_wo_data_reg*/ && ~pci_irdy_reg_in && ~bckp_trdy_reg && (~cnf_progress && ~norm_access_to_conf_reg)) ||
693
        ((state_backoff || state_backoff_reg) && rw_cbe0 && wr_to_fifo && ~pci_irdy_reg_in && ~bckp_trdy_reg && (~cnf_progress && ~norm_access_to_conf_reg))
694
                            ) ;
695 2 mihad
 
696 21 mihad
`ifdef      HOST
697
    `ifdef  NO_CNF_IMAGE
698
            assign  load_to_conf_out =  1'b0 ;
699
    `else
700
            assign  load_to_conf_out =  (
701
            (state_transfere_reg && cnf_progress && rw_cbe0 && ~pci_irdy_reg_in && ~bckp_trdy_reg) ||
702
            (state_transfere_reg && norm_access_to_conf_reg && rw_cbe0 && ~pci_irdy_reg_in && ~bckp_trdy_reg)
703
                                        ) ;
704
    `endif
705
`else
706
            assign  load_to_conf_out =  (
707
            (state_transfere_reg && cnf_progress && rw_cbe0 && ~pci_irdy_reg_in && ~bckp_trdy_reg) ||
708
            (state_transfere_reg && norm_access_to_conf_reg && rw_cbe0 && ~pci_irdy_reg_in && ~bckp_trdy_reg)
709
                                        ) ;
710
`endif
711 2 mihad
 
712
// General control sigal assignments
713 21 mihad
assign  addr_phase_out = addr_phase ;
714
assign  last_reg_out = (pci_frame_reg_in && ~pci_irdy_reg_in) ;
715
assign  frame_reg_out = pci_frame_reg_in ;
716
assign  bckp_devsel_out = bckp_devsel_in ;
717
assign  bckp_trdy_out   = bckp_trdy_in ;
718
assign  bckp_stop_out   = bckp_stop_in ;
719
assign  target_abort_set_out = (bckp_devsel_in && bckp_trdy_in && ~bckp_stop_in && bckp_trdy_en_in) ;
720 2 mihad
// request signal for delayed sinc. module
721 21 mihad
reg master_will_request_read ;
722
always@(posedge clk_in or posedge reset_in)
723
begin
724
    if ( reset_in )
725
        master_will_request_read <= #`FF_DELAY 1'b0 ;
726
    else
727 26 mihad
        master_will_request_read <= #`FF_DELAY ((state_wait && ~target_abort_in) || (state_backoff && ~target_abort_set_out)) && ~cnf_progress && ~norm_access_to_conf_reg && ~rw_cbe0 && rd_request ;
728 21 mihad
end
729
// MORE OPTIMIZED READS, but not easy to control in a testbench!
730
//assign  req_out = master_will_request_read ; 
731
assign req_out = master_will_request_read && !pci_irdy_reg_in && !read_processing_in ;
732
 
733 2 mihad
// ready tells when address or data are written into fifo - RDY ? DATA : ADDRESS
734 21 mihad
assign  rdy_out = ~bckp_trdy_reg ;
735 2 mihad
 
736
// data and address outputs assignments!
737 21 mihad
assign  pci_ad_out = data_in ;
738 2 mihad
 
739 21 mihad
assign  data_out = pci_ad_reg_in ;
740
assign  be_out = pci_cbe_reg_in ;
741
assign  address_out = pci_ad_reg_in ;
742
assign  bc_out = pci_cbe_reg_in ;
743
assign  bc0_out = rw_cbe0 ;
744 2 mihad
 
745
 
746 21 mihad
endmodule

powered by: WebSVN 2.1.0

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