1 //////////////////////////////////////////////////////////////////////
3 //// File name "pci_wbs_wbb3_2_wbb2.v" ////
5 //// This file is part of the "PCI bridge" project ////
6 //// http://www.opencores.org/cores/pci/ ////
9 //// - Miha Dolenc (mihad@opencores.org) ////
13 //////////////////////////////////////////////////////////////////////
15 //// Copyright (C) 2003 Miha Dolenc, mihad@opencores.org ////
17 //// This source file may be used and distributed without ////
18 //// restriction provided that this copyright statement is not ////
19 //// removed from the file and that any derivative work contains ////
20 //// the original copyright notice and the associated disclaimer. ////
22 //// This source file is free software; you can redistribute it ////
23 //// and/or modify it under the terms of the GNU Lesser General ////
24 //// Public License as published by the Free Software Foundation; ////
25 //// either version 2.1 of the License, or (at your option) any ////
26 //// later version. ////
28 //// This source is distributed in the hope that it will be ////
29 //// useful, but WITHOUT ANY WARRANTY; without even the implied ////
30 //// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
31 //// PURPOSE. See the GNU Lesser General Public License for more ////
34 //// You should have received a copy of the GNU Lesser General ////
35 //// Public License along with this source; if not, download it ////
36 //// from http://www.opencores.org/lgpl.shtml ////
38 //////////////////////////////////////////////////////////////////////
40 // CVS Revision History
42 // $Log: pci_wbs_wbb3_2_wbb2.v,v $
43 // Revision 1.1 2007-03-20 17:50:56 sithglan
46 // Revision 1.5 2004/08/16 09:12:01 mihad
47 // Removed unsinthesizable !== comparation.
49 // Revision 1.4 2004/01/24 11:54:18 mihad
50 // Update! SPOCI Implemented!
52 // Revision 1.3 2003/12/19 11:11:30 mihad
53 // Compact PCI Hot Swap support added.
54 // New testcases added.
55 // Specification updated.
56 // Test application changed to support WB B3 cycles.
58 // Revision 1.2 2003/12/01 16:20:56 simons
59 // ifdef - endif statements put in separate lines for flint compatibility.
61 // Revision 1.1 2003/08/12 13:58:19 mihad
62 // Module that converts slave WISHBONE B3 accesses to
63 // WISHBONE B2 accesses with CAB.
67 module pci_wbs_wbb3_2_wbb2
105 input [31:0] wbs_adr_i ;
106 output [31:0] wbs_adr_o ;
107 input [31:0] wbs_dat_i_i ;
108 output [31:0] wbs_dat_i_o ;
109 input [31:0] wbs_dat_o_i ;
110 output [31:0] wbs_dat_o_o ;
113 input [ 3:0] wbs_sel_i ;
114 output [ 3:0] wbs_sel_o ;
121 input [ 2:0] wbs_cti_i ;
122 input [ 1:0] wbs_bte_i ;
124 input wb_init_complete_i ;
127 reg [31:0] wbs_adr_o ;
128 reg [31:0] wbs_dat_i_o ;
129 reg wbs_dat_i_o_valid ;
130 reg [31:0] wbs_dat_o_o ;
132 reg [ 3:0] wbs_sel_o ;
138 always@(posedge wb_rst_i or posedge wb_clk_i)
144 wbs_dat_i_o <= 32'h0 ;
145 wbs_dat_o_o <= 32'h0 ;
148 wbs_dat_i_o_valid <= 1'b0 ;
152 begin:transfer_and_transfer_adr_ctrl_blk
154 reg [3:0] end_cycle ;
155 reg generate_int_adr ;
157 start_cycle = ~wbs_cyc_o & wbs_cyc_i & wbs_stb_i & ~wbs_ack_o & ~wbs_err_o & ~wbs_rty_o & wb_init_complete_i ;
159 // there is a few conditions when cycle must be terminated
160 // I've put them into bit array for better readability of the code
162 // 1st condition - pci bridge is signaling an error
163 end_cycle[0] = wbs_err_i ;
165 // 2nd condition - pci bridge is signaling a retry - that can be ignored via the defines
166 end_cycle[1] = wbs_rty_i
167 `ifdef PCI_WBS_B3_RTY_DISABLE
172 // 3rd condition - end non burst cycles as soon as pci bridge response is received
173 end_cycle[2] = wbs_cyc_i & wbs_stb_i & wbs_ack_i & ~wbs_cab_o ;
175 // 4th condition - end cycle when acknowledge and strobe are both asserted and master is signaling end of burst
176 end_cycle[3] = wbs_cyc_i & wbs_stb_i & wbs_ack_o & wbs_cab_o & (wbs_cti_i == 3'b111) ;
178 if (wbs_dat_i_o_valid)
180 if (wbs_ack_i | wbs_err_i
181 `ifdef PCI_WBS_B3_RTY_DISABLE
186 wbs_dat_i_o_valid <= 1'b0 ;
190 if (wbs_cyc_i & wbs_stb_i & wbs_we_i & ~wbs_ack_o & ~wbs_err_o & ~wbs_rty_o & wb_init_complete_i)
192 wbs_dat_i_o <= wbs_dat_i_i ;
193 wbs_dat_i_o_valid <= 1'b1 ;
200 wbs_sel_o <= wbs_sel_i ;
201 wbs_we_o <= wbs_we_i ;
203 if (wbs_cti_i == 3'b010)
210 if (wbs_adr_i[3:2] == 2'b00)
216 if (wbs_adr_i[4:2] == 3'b000)
222 if (wbs_adr_i[5:2] == 4'b0000)
234 else if ( wbs_cyc_o & (|end_cycle) )
240 wbs_adr_o <= wbs_adr_i ;
242 wbs_adr_o[31:2] <= wbs_adr_o[31:2] + 1'b1 ;
244 if (~wbs_we_o & wbs_ack_i)
245 wbs_dat_o_o <= wbs_dat_o_i ;
249 always@(posedge wb_rst_i or posedge wb_clk_i)
260 wbs_ack_o <= wbs_ack_i | ~wbs_stb_i ;
262 wbs_ack_o <= wbs_ack_i ;
265 wbs_err_o <= ~wbs_stb_i ;
267 wbs_err_o <= wbs_err_i ;
269 `ifdef PCI_WBS_B3_RTY_DISABLE
273 wbs_rty_o <= ~wbs_stb_i ;
275 wbs_rty_o <= wbs_rty_i ;
280 assign wbs_stb_o = (wbs_cyc_o & ~wbs_we_o & ~wbs_ack_o & ~wbs_err_o & ~wbs_rty_o) |
281 (wbs_cyc_o & wbs_stb_i & wbs_cab_o & ~wbs_we_o & wbs_cti_i != 3'b111) |
282 (wbs_cyc_o & wbs_we_o & wbs_dat_i_o_valid) ;