]> git.zerfleddert.de Git - raggedstone/blame - ethernet/source/pci/pci_master32_sm_if.v
changes
[raggedstone] / ethernet / source / pci / pci_master32_sm_if.v
CommitLineData
40a1f26c 1//////////////////////////////////////////////////////////////////////
2//// ////
3//// File name "pci_master32_sm_if.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: pci_master32_sm_if.v,v $
45// Revision 1.1 2007-03-20 17:50:56 sithglan
46// add shit
47//
48// Revision 1.7 2004/03/19 16:36:55 mihad
49// Single PCI Master write fix.
50//
51// Revision 1.6 2003/12/19 11:11:30 mihad
52// Compact PCI Hot Swap support added.
53// New testcases added.
54// Specification updated.
55// Test application changed to support WB B3 cycles.
56//
57// Revision 1.5 2003/06/12 10:12:22 mihad
58// Changed one critical PCI bus signal logic.
59//
60// Revision 1.4 2003/01/27 16:49:31 mihad
61// Changed module and file names. Updated scripts accordingly. FIFO synchronizations changed.
62//
63// Revision 1.3 2002/02/01 15:25:12 mihad
64// Repaired a few bugs, updated specification, added test bench files and design document
65//
66// Revision 1.2 2001/10/05 08:14:29 mihad
67// Updated all files with inclusion of timescale file for simulation purposes.
68//
69// Revision 1.1.1.1 2001/10/02 15:33:46 mihad
70// New project directory structure
71//
72//
73
74`include "pci_constants.v"
75`include "bus_commands.v"
76
77// synopsys translate_off
78`include "timescale.v"
79// synopsys translate_on
80
81/*====================================================================
82Module provides interface between PCI bridge internals and PCI master
83state machine
84====================================================================*/
85module pci_master32_sm_if
86(
87 clk_in,
88 reset_in,
89
90 // interconnect to pci master state machine
91 address_out,
92 bc_out,
93 data_out,
94 data_in,
95 be_out,
96 req_out,
97 rdy_out,
98 last_out,
99
100 next_data_out,
101 next_be_out,
102 next_last_out,
103
104 // status inputs from master SM
105 wait_in,
106 wtransfer_in,
107 rtransfer_in,
108 retry_in,
109 rerror_in,
110 first_in ,
111 mabort_in,
112
113
114 // WISHBONE WRITE fifo inputs and outputs
115 wbw_renable_out,
116 wbw_fifo_addr_data_in,
117 wbw_fifo_cbe_in,
118 wbw_fifo_control_in,
119 wbw_fifo_empty_in,
120 wbw_fifo_transaction_ready_in,
121
122 // WISHBONE READ fifo inputs and outputs
123 wbr_fifo_wenable_out,
124 wbr_fifo_data_out,
125 wbr_fifo_be_out,
126 wbr_fifo_control_out,
127
128 // delayed transaction control logic inputs and outputs
129 del_wdata_in,
130 del_complete_out,
131 del_req_in,
132 del_addr_in,
133 del_bc_in,
134 del_be_in,
135 del_burst_in,
136 del_error_out,
137 del_rty_exp_out,
138 del_we_in,
139
140 // configuration space interconnect
141 // error reporting
142 err_addr_out,
143 err_bc_out,
144 err_signal_out,
145 err_source_out,
146 err_rty_exp_out,
147
148 cache_line_size_in,
149
150 // two signals for pci control and status
151 mabort_received_out,
152 tabort_received_out,
153
154 posted_write_not_present_out
155);
156
157// system inputs
158input clk_in ;
159input reset_in ;
160
161// PCI master state machine interconnect
162output [31:0] address_out ; // address output
163
164output [3:0] bc_out ; // bus command output
165reg [3:0] bc_out ;
166
167output [31:0] data_out ; // data output for writes
168reg [31:0] data_out ;
169
170input [31:0] data_in ; // data input for reads
171output [3:0] be_out ; // byte enable output
172reg [3:0] be_out ;
173
174output req_out ; // request output
175
176output rdy_out ; // ready output
177reg rdy_out ;
178
179output last_out ; // last data indicator output
180
181output [31:0] next_data_out ; // next data output
182output [3:0] next_be_out ; // next byte enable output
183output next_last_out ; // next transfer last indicator
184
185input wait_in,
186 wtransfer_in,
187 rtransfer_in,
188 retry_in,
189 rerror_in,
190 first_in ,
191 mabort_in ;
192
193// WISHBONE write fifo interconnect
194output wbw_renable_out ; // WBW_FIFO read enable signal
195
196input [31:0] wbw_fifo_addr_data_in ; // WBW_FIFO address/data bus
197input [3:0] wbw_fifo_cbe_in ; // WBW_FIFO command/byte enable bus
198input [3:0] wbw_fifo_control_in ; // WBW_FIFO control bus
199input wbw_fifo_empty_in ; // WBW_FIFO's empty status indicator
200input wbw_fifo_transaction_ready_in ; // WBW_FIFO transaction ready indicator
201
202// WISHBONE read FIFO interconnect
203output wbr_fifo_wenable_out ; // write enable for WBR_FIFO
204
205output [31:0] wbr_fifo_data_out ; // data output to WBR_FIFO
206
207output [3:0] wbr_fifo_be_out ; // byte enable output for WBR_FIFO
208
209output [3:0] wbr_fifo_control_out ; // WBR_FIFO control output
210
211// delayed transaction control logic inputs and outputs
212input [31:0] del_wdata_in ; // delayed write data input
213output del_complete_out ; // delayed transaction completed output
214
215input del_req_in ; // delayed transaction request
216input [31:0] del_addr_in ; // delayed transaction address
217input [3:0] del_bc_in ; // delayed transaction bus command input
218input [3:0] del_be_in ; // delayed transaction byte enables input
219input del_burst_in ; // delayed transaction burst req. indicator
220output del_error_out ; // delayed transation error termination signal
221
222output del_rty_exp_out ; // retry expired output for delayed transactions
223
224input del_we_in ; // delayed write request indicator
225
226output [31:0] err_addr_out ; // erroneous address output
227output [3:0] err_bc_out ; // erroneous bus command output
228
229output err_signal_out ; // error signalization
230
231output err_source_out ; // error source indicator
232
233input [7:0] cache_line_size_in ; // cache line size value input
234
235output err_rty_exp_out ; // retry expired error output
236
237output mabort_received_out ; // master abort signaled to status register
238output tabort_received_out ; // target abort signaled to status register
239
240output posted_write_not_present_out ; // used in target state machine - must deny read completions when this signal is 0
241
242
243assign err_bc_out = bc_out ;
244
245// assign read outputs
246/*==================================================================================================================
247WISHBONE read FIFO data outputs - just link them to SM data outputs and delayed BE input
248==================================================================================================================*/
249assign wbr_fifo_data_out = data_in ;
250assign wbr_fifo_be_out = del_be_in ;
251
252// decode if current bus command is configuration command
253wire conf_cyc_bc = ( bc_out[3:1] == `BC_CONF_RW ) ;
254
255// register for indicating that current data is also last in transfer
256reg current_last ;
257
258// register indicating that last data was transfered OK
259reg last_transfered ;
260always@(posedge reset_in or posedge clk_in)
261begin
262 if (reset_in)
263 last_transfered <= #`FF_DELAY 1'b0 ;
264 else
265 last_transfered <= #`FF_DELAY ~wait_in && last_out && wtransfer_in ;
266end
267
268// status signals output assignement
269assign mabort_received_out = mabort_in ;
270
271wire tabort_ff_in = ~wait_in && rerror_in ;
272
273reg tabort_received_out ;
274always@(posedge reset_in or posedge clk_in)
275begin
276 if ( reset_in )
277 tabort_received_out <= #`FF_DELAY 1'b0 ;
278 else
279 tabort_received_out <= #`FF_DELAY tabort_ff_in ;
280end
281
282// error recovery indicator
283reg err_recovery ;
284
285// operation is locked until error recovery is in progress or error bit is not cleared in configuration space
286wire err_lock = err_recovery ;
287
288// three requests are possible - posted write, delayed write and delayed read
289reg del_write_req ;
290reg posted_write_req ;
291reg del_read_req ;
292
293// assign request output
294assign req_out = del_write_req || posted_write_req || del_read_req ;
295
296// posted write is not present, when WB Write Fifo is empty and posted write transaction is not beeing requested at present time
297assign posted_write_not_present_out = !posted_write_req && wbw_fifo_empty_in ;
298
299// write requests are staged, so data is read from source into current data register and next data register
300reg write_req_int ;
301always@(posedge reset_in or posedge clk_in)
302begin
303 if ( reset_in )
304 write_req_int <= #`FF_DELAY 1'b0 ;
305 else
306 write_req_int <= #`FF_DELAY posted_write_req || del_write_req ;
307
308end
309
310// ready output is generated one clock after request for reads and two after for writes
311always@(posedge reset_in or posedge clk_in)
312begin
313 if (reset_in)
314 rdy_out <= #`FF_DELAY 1'b0 ;
315 else
316 rdy_out <= #`FF_DELAY del_read_req || ( (posted_write_req || del_write_req) && write_req_int) ;
317end
318
319// wires with logic used as inputs to request FFs
320wire do_posted_write = ( wbw_fifo_transaction_ready_in && ~wbw_fifo_empty_in && ~err_lock ) ;
321wire do_del = ( del_req_in && ~err_lock && wbw_fifo_empty_in ) ;
322wire do_del_write = do_del && del_we_in ;
323wire do_del_read = do_del && ~del_we_in ;
324
325// register for indicating current operation's data source
326parameter DELAYED_WRITE = 1'b1 ;
327parameter POSTED_WRITE = 1'b0 ;
328
329// new data source - depending on which transaction will be processed next - delayed read is here because source of byte enables must
330// be specified for delayed reads also - data source is not relevant for delayed reads, so value is don't care anyway
331wire new_data_source = (do_del_write || do_del_read) ? DELAYED_WRITE : POSTED_WRITE ; // input to data source register
332wire data_source_change = ~req_out ; // change (enable) for data source register - when no requests are in progress
333
334reg data_source ; // data source value
335always@(posedge reset_in or posedge clk_in)
336begin
337 if (reset_in)
338 // default value is posted write source - wbw_fifo
339 data_source <= #`FF_DELAY POSTED_WRITE ;
340 else
341 if (data_source_change)
342 // change data source on rising clock edge
343 data_source <= #`FF_DELAY new_data_source ;
344end
345
346// multiplexer for data output to PCI MASTER state machine
347reg [31:0] source_data ;
348reg [3:0] source_be ;
349always@(data_source or wbw_fifo_addr_data_in or wbw_fifo_cbe_in or del_wdata_in or del_be_in or del_burst_in)
350begin
351 case (data_source)
352 POSTED_WRITE: begin
353 source_data = wbw_fifo_addr_data_in ;
354 source_be = wbw_fifo_cbe_in ;
355 end
356 DELAYED_WRITE: begin
357 source_data = del_wdata_in ;
358 // read all bytes during delayed burst read!
359 source_be = ~( del_be_in | {4{del_burst_in}} ) ;
360 end
361 endcase
362end
363
364wire waddr = wbw_fifo_control_in[`ADDR_CTRL_BIT] ;
365
366// address change indicator - address is allowed to be loaded only when no transaction is in progress!
367wire address_change = ~req_out ; // address change - whenever there is no request in progress
368
369// new address - input to register storing address of current request - if posted write request will be next,
370// load address and bus command from wbw_fifo, else load data from delayed transaction logic
371wire [31:0] new_address = ( ~req_out && do_posted_write ) ? wbw_fifo_addr_data_in[31:0] : del_addr_in[31:0] ;
372wire [3:0] new_bc = ( ~req_out && do_posted_write ) ? wbw_fifo_cbe_in : del_bc_in ;
373
374// address counter enable - only for posted writes when data is actually transfered
375wire addr_count_en = !wait_in && posted_write_req && rtransfer_in ;
376
377always@(posedge reset_in or posedge clk_in)
378begin
379 if (reset_in)
380 bc_out <= #`FF_DELAY `BC_RESERVED0 ;
381 else
382 if (address_change)
383 bc_out <= #`FF_DELAY new_bc ;
384end
385
386reg [29:0] current_dword_address ;
387
388// DWORD address counter with load
389always@(posedge reset_in or posedge clk_in)
390begin
391 if (reset_in)
392 current_dword_address <= #`FF_DELAY 30'h0000_0000 ;
393 else
394 if (address_change)
395 current_dword_address <= #`FF_DELAY new_address[31:2] ;
396 else
397 if (addr_count_en)
398 current_dword_address <= #`FF_DELAY current_dword_address + 1'b1 ;
399end
400
401reg [1:0] current_byte_address ;
402always@(posedge reset_in or posedge clk_in)
403begin
404 if (reset_in)
405 current_byte_address <= #`FF_DELAY 2'b00 ;
406 else
407 if (address_change)
408 current_byte_address <= #`FF_DELAY new_address[1:0] ;
409end
410
411// byte address generation logic
412reg [ 1: 0] generated_byte_adr ;
413reg [ 1: 0] pci_byte_adr ;
414
415always@(be_out)
416begin
417 casex(be_out)
418 4'bxxx0:generated_byte_adr = 2'b00 ;
419 4'bxx01:generated_byte_adr = 2'b01 ;
420 4'bx011:generated_byte_adr = 2'b10 ;
421 4'b0111:generated_byte_adr = 2'b11 ;
422 4'b1111:generated_byte_adr = 2'b00 ;
423 endcase
424end
425
426always@(generated_byte_adr or bc_out or current_byte_address)
427begin
428 // for memory access commands, set lower 2 address bits to 0
429 if ((bc_out == `BC_MEM_READ) | (bc_out == `BC_MEM_WRITE) |
430 (bc_out == `BC_MEM_READ_MUL) | (bc_out == `BC_MEM_READ_LN) |
431 (bc_out == `BC_MEM_WRITE_INVAL))
432 begin
433 pci_byte_adr = 2'b00 ;
434 end
435 else if ((bc_out == `BC_IO_WRITE) | (bc_out == `BC_IO_READ))
436 begin
437 pci_byte_adr = generated_byte_adr ;
438 end
439 else
440 begin
441 pci_byte_adr = current_byte_address ;
442 end
443end
444
445// address output to PCI master state machine assignment
446assign address_out = { current_dword_address, pci_byte_adr } ;
447
448// the same for erroneous address assignement
449assign err_addr_out = { current_dword_address, pci_byte_adr } ;
450
451// cacheline size counter - for read transaction length control
452// cache line count is enabled during burst reads when data is actually transfered
453wire read_count_enable = ~wait_in && del_read_req && del_burst_in && wtransfer_in ;
454
455// cache line counter is loaded when del read request is not in progress
456wire read_count_load = ~del_read_req ;
457
458reg [(`WBR_ADDR_LENGTH - 1):0] max_read_count ;
459always@(cache_line_size_in or del_bc_in)
460begin
461 if ( (cache_line_size_in >= `WBR_DEPTH) || (~del_bc_in[1] && ~del_bc_in[0]) )
462 max_read_count = `WBR_DEPTH - 1'b1;
463 else
464 max_read_count = cache_line_size_in ;
465end
466
467reg [(`WBR_ADDR_LENGTH - 1):0] read_count ;
468
469// cache line bound indicator - it signals when data for one complete cacheline was read
470wire read_bound_comb = ~|(read_count[(`WBR_ADDR_LENGTH - 1):2]) ;
471reg read_bound ;
472always@(posedge clk_in or posedge reset_in)
473begin
474 if ( reset_in )
475 read_bound <= #`FF_DELAY 1'b0 ;
476 else if (read_count_load)
477 read_bound <= #`FF_DELAY 1'b0 ;
478 else if ( read_count_enable )
479 read_bound <= #`FF_DELAY read_bound_comb ;
480end
481
482wire read_count_change_val = read_count_load | read_count_enable ;
483
484wire [(`WBR_ADDR_LENGTH - 1):0] read_count_next = read_count_load ? max_read_count : (read_count - 1'b1) ;
485
486// down counter with load
487always@(posedge reset_in or posedge clk_in)
488begin
489 if (reset_in)
490 read_count <= #`FF_DELAY 0 ;
491 else
492/* if (read_count_load)
493 read_count <= #`FF_DELAY max_read_count ;
494 else
495 if (read_count_enable)
496 read_count <= #`FF_DELAY read_count - 1'b1 ;
497*/ if (read_count_change_val)
498 read_count <= #`FF_DELAY read_count_next ;
499end
500
501// flip flop indicating error recovery is in progress
502reg err_recovery_in ;
503always@(posedge reset_in or posedge clk_in)
504begin
505 if (reset_in)
506 err_recovery <= #`FF_DELAY 1'b0 ;
507 else
508 err_recovery <= #`FF_DELAY err_recovery_in ;
509end
510
511/*// retry counter implementation
512reg [7:0] retry_count ;
513
514wire retry_expired = ~|(retry_count[7:1]) ;
515
516// loading of retry counter - whenever no request is present or other termination than retry or wait is signalled
517wire retry_load = ~req_out || (~wait_in && rtransfer_in) ;
518
519// retry DOWN counter with load
520always@(posedge reset_in or posedge clk_in)
521begin
522 if (reset_in)
523 retry_count <= #`FF_DELAY 8'hFF ;
524 else
525 if ( retry_load )
526 retry_count <= #`FF_DELAY `PCI_RTY_CNT_MAX ;
527 else
528 if (retry_in)
529 retry_count <= #`FF_DELAY retry_count - 1'b1 ;
530end*/
531
532/*==================================================================================================================
533Delayed write requests are always single transfers!
534Delayed write request starts, when no request is currently beeing processed and it is signaled from other side
535of the bridge.
536==================================================================================================================*/
537// delayed write request FF input control
538reg del_write_req_input ;
539
540always@(
541 do_del_write or
542 del_write_req or
543 posted_write_req or
544 del_read_req or
545 wait_in or
546 //retry_in or
547 //retry_expired or
548 rtransfer_in or
549 rerror_in or
550 mabort_in
551)
552begin
553 if (~del_write_req)
554 begin
555 // delayed write is not in progress and is requested
556 // delayed write can be requested when no other request is in progress
557 del_write_req_input = ~posted_write_req && ~del_read_req && do_del_write ;
558 end
559 else
560 begin
561 // delayed write request is in progress - assign input
562 del_write_req_input = wait_in ||
563 ( /*~( retry_in && retry_expired) &&*/
564 ~rtransfer_in && ~rerror_in && ~mabort_in
565 );
566 end
567end
568
569// delayed write request FLIP-FLOP
570always@(posedge reset_in or posedge clk_in)
571begin
572 if (reset_in)
573 del_write_req <= #`FF_DELAY 1'b0 ;
574 else
575 del_write_req <= #`FF_DELAY del_write_req_input ;
576end
577
578/*================================================================================================
579Posted write request indicator.
580Posted write starts whenever no request is in progress and one whole posted write is
581stored in WBW_FIFO. It ends on error terminations ( master, target abort, retry expired) or
582data transfer terminations if last data is on top of FIFO.
583Continues on wait, retry, and disconnect without data.
584================================================================================================*/
585// posted write request FF input control
586reg posted_write_req_input ;
587always@(
588 do_posted_write or
589 del_write_req or
590 posted_write_req or
591 del_read_req or
592 wait_in or
593 //retry_in or
594 rerror_in or
595 mabort_in or
596 //retry_expired or
597 rtransfer_in or
598 last_transfered
599)
600begin
601 if (~posted_write_req)
602 begin
603 // posted write is not in progress
604 posted_write_req_input = ~del_write_req && ~del_read_req && do_posted_write ;
605 end
606 else
607 begin
608 posted_write_req_input = wait_in ||
609 (/*~(retry_in && retry_expired && ~rtransfer_in) &&*/
610 ~rerror_in && ~mabort_in &&
611 ~(last_transfered)
612 ) ;
613
614 end
615end
616
617// posted write request flip flop
618always@(posedge reset_in or posedge clk_in)
619begin
620 if (reset_in)
621 posted_write_req <= #`FF_DELAY 1'b0 ;
622 else
623 posted_write_req <= #`FF_DELAY posted_write_req_input ;
624
625end
626
627/*================================================================================================
628Delayed read request indicator.
629Delayed read starts whenever no request is in progress and delayed read request is signaled from
630other side of bridge. It ends on error terminations ( master, target abort, retry expired) or
631data transfer terminations if it is not burst transfer or on cache line bounds on burst transfer.
632It also ends on disconnects.
633Continues on wait and retry.
634================================================================================================*/
635// delayed read FF input control
636reg del_read_req_input ;
637always@(
638 do_del_read or
639 del_write_req or
640 posted_write_req or
641 del_read_req or
642 last_transfered or
643 wait_in or
644 retry_in or
645 //retry_expired or
646 mabort_in or
647 rtransfer_in or
648 rerror_in or
649 first_in or
650 del_complete_out
651)
652begin
653 if (~del_read_req)
654 begin
655 del_read_req_input = ~del_write_req && ~posted_write_req && ~del_complete_out && do_del_read ;
656 end
657 else
658 begin
659 del_read_req_input = wait_in ||
660 ( ~(retry_in && (~first_in /*|| retry_expired */)) &&
661 ~mabort_in && ~rerror_in &&
662 ~(last_transfered)
663 ) ;
664 end
665end
666
667// delayed read request FF
668always@(posedge reset_in or posedge clk_in)
669begin
670 if (reset_in)
671 del_read_req <= #`FF_DELAY 1'b0 ;
672 else
673 del_read_req <= #`FF_DELAY del_read_req_input ;
674end
675
676// wire indicating last entry of transaction on top of fifo
677wire wlast = wbw_fifo_control_in[`LAST_CTRL_BIT] ;
678
679wire last_int = posted_write_req && wlast || del_write_req ;
680
681// intermidiate data, byte enable and last registers
682reg [31:0] intermediate_data ;
683reg [3:0] intermediate_be ;
684reg intermediate_last ;
685
686wire intermediate_enable = ( posted_write_req || del_write_req ) && ( ~write_req_int || (( ~rdy_out || ~wait_in && rtransfer_in ) && ~intermediate_last)) ;
687
688always@(posedge reset_in or posedge clk_in)
689begin
690 if ( reset_in )
691 begin
692 intermediate_data <= #`FF_DELAY 32'h0000_0000 ;
693 intermediate_be <= #`FF_DELAY 4'h0 ;
694 intermediate_last <= #`FF_DELAY 1'b0 ;
695 end
696 else
697 if ( intermediate_enable )
698 begin
699 intermediate_data <= #`FF_DELAY source_data ;
700 intermediate_be <= #`FF_DELAY source_be ;
701 intermediate_last <= #`FF_DELAY last_int ;
702 end
703end
704
705// multiplexer for next data
706reg [31:0] next_data_out ;
707reg [3:0] next_be_out ;
708reg write_next_last ;
709reg [3:0] write_next_be ;
710
711always@
712(
713 rtransfer_in or
714 intermediate_data or
715 intermediate_be or
716 intermediate_last or
717 wbw_fifo_addr_data_in or
718 wbw_fifo_cbe_in or
719 wlast or
720 wait_in
721)
722begin
723 if( rtransfer_in & ~wait_in )
724 begin
725 next_data_out = wbw_fifo_addr_data_in ;
726 write_next_last = wlast ;
727 write_next_be = wbw_fifo_cbe_in ;
728 end
729 else
730 begin
731 next_data_out = intermediate_data ;
732 write_next_last = intermediate_last ;
733 write_next_be = intermediate_be ;
734 end
735end
736
737always@(del_read_req or source_be or write_next_be)
738begin
739 if (del_read_req)
740 next_be_out = source_be ;
741 else
742 next_be_out = write_next_be ;
743end
744/*================================================================================================
745WBW_FIFO read enable - read from WBW_FIFO is performed on posted writes, when data transfer
746termination is received - transfer or disconnect with data. Reads are enabled during error
747recovery also, since erroneous transaction must be pulled out of FIFO!
748================================================================================================*/
749// wbw_fifo read enable input control
750
751assign wbw_renable_out = ~req_out && (do_posted_write || err_recovery) ||
752 posted_write_req && ( ~write_req_int || (~rdy_out && ~intermediate_last) || (~wait_in && rtransfer_in && ~intermediate_last)) ;
753
754/*================================================================================================
755WBR_FIFO write enable control -
756writes to FIFO are possible only when delayed read request is in progress and data transfer
757or error termination is signalled. It is not enabled on retry or disconnect without data.
758================================================================================================*/
759// wbr_fifo write enable control - enabled when transfer is in progress and data is transfered or error is signalled
760assign wbr_fifo_wenable_out = del_read_req && ~wait_in && ( rtransfer_in || mabort_in || rerror_in ) ;
761
762/*================================================================================================
763WBR_FIFO control output for identifying data entries.
764This is necesary because of prefetched reads, which partially succeed. On error, error entry
765gets in to signal it on WISHBONE bus if WISHBONE master reads up to this entry.
766================================================================================================*/
767assign wbr_fifo_control_out[`ADDR_CTRL_BIT] = 1'b0 ;
768assign wbr_fifo_control_out[`LAST_CTRL_BIT] = last_transfered ;
769assign wbr_fifo_control_out[`DATA_ERROR_CTRL_BIT] = rerror_in || (mabort_in && ~conf_cyc_bc) ;
770assign wbr_fifo_control_out[`UNUSED_CTRL_BIT] = 1'b0 ;
771
772// retry expired error for posted writes control
773//assign err_rty_exp_out = posted_write_req && ~wait_in && retry_in && retry_expired && ~rtransfer_in;
774assign err_rty_exp_out = 1'b0 ;
775
776// error source and error signal output control logic - only for posted writes
777assign err_source_out = mabort_in /*|| err_rty_exp_out*/ ;
778
779assign err_signal_out = /*err_rty_exp_out || */ posted_write_req && ~wait_in && (mabort_in || rerror_in) ;
780
781//assign del_rty_exp_out = (~wait_in && (del_read_req || del_write_req)) && (retry_in && retry_expired && ~rtransfer_in) ;
782assign del_rty_exp_out = 1'b0 ;
783
784assign del_error_out = ~wait_in && (del_write_req || del_read_req) && ( (mabort_in && ~conf_cyc_bc) || rerror_in ) ;
785
786wire del_write_complete = del_write_req && ~wait_in && ( rtransfer_in || rerror_in || mabort_in ) ;
787wire del_read_complete = del_read_req && ~wait_in && ( rerror_in || mabort_in || last_transfered || ( retry_in && ~first_in ) ) ;
788
789assign del_complete_out = ~wait_in && ( del_write_complete || del_read_complete ) ;
790
791// next last output generation
792assign next_last_out = del_write_req || del_read_req && ( ~del_burst_in || read_bound ) || posted_write_req && ( write_next_last ) ;
793/*==================================================================================================================
794Error recovery FF gets a value of one, when during posted write error occurs. It is cleared when all the data provided
795for erroneous transaction is pulled out of WBW_FIFO
796==================================================================================================================*/
797
798// error recovery flip flop input - used when posted write is terminated with an error
799always@(
800 err_recovery or
801 last_out or
802 wlast or
803 err_signal_out or
804 intermediate_last
805)
806begin
807 // when error recovery is not set - drive its input so it gets set
808 if ( ~err_recovery )
809 err_recovery_in = ~last_out && ~intermediate_last && err_signal_out ;
810 else
811 // when error recovery is set, wbw_fifo is enabled - clear err_recovery when last data entry of erroneous transaction is pulled out of fifo
812 err_recovery_in = ~wlast ;
813end
814
815wire data_out_load = (posted_write_req || del_write_req) && ( !rdy_out || ( !wait_in && rtransfer_in ) ) ;
816
817wire be_out_load = (req_out && !rdy_out) || ( posted_write_req && !wait_in && rtransfer_in ) ;
818
819wire last_load = req_out && ( ~rdy_out || ~wait_in && wtransfer_in ) ;
820
821always@(posedge reset_in or posedge clk_in)
822begin
823 if (reset_in)
824 data_out <= #`FF_DELAY 32'h0000_0000 ;
825 else
826 if ( data_out_load )
827 data_out <= #`FF_DELAY intermediate_data ;
828end
829
830always@(posedge clk_in or posedge reset_in)
831begin
832 if ( reset_in )
833 be_out <= #`FF_DELAY 4'hF ;
834 else
835 if ( be_out_load )
836 be_out <= #`FF_DELAY posted_write_req ? intermediate_be : source_be ;
837end
838
839always@(posedge reset_in or posedge clk_in)
840begin
841 if (reset_in)
842 current_last <= #`FF_DELAY 1'b0 ;
843 else
844 if ( last_load )
845 current_last <= #`FF_DELAY next_last_out ;
846end
847
848assign last_out = current_last ;
849endmodule
Impressum, Datenschutz