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

Subversion Repositories pci

[/] [pci/] [tags/] [rel_3/] [rtl/] [verilog/] [pci_target32_sm.v] - Blame information for rev 55

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

powered by: WebSVN 2.1.0

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