1 //////////////////////////////////////////////////////////////////////
3 //// File name: pci_conf_space.v ////
5 //// This file is part of the "PCI bridge" project ////
6 //// http://www.opencores.org/cores/pci/ ////
9 //// - tadej@opencores.org ////
10 //// - Tadej Markovic ////
12 //// All additional information is avaliable in the README.txt ////
16 //////////////////////////////////////////////////////////////////////
18 //// Copyright (C) 2000 Tadej Markovic, tadej@opencores.org ////
20 //// This source file may be used and distributed without ////
21 //// restriction provided that this copyright statement is not ////
22 //// removed from the file and that any derivative work contains ////
23 //// the original copyright notice and the associated disclaimer. ////
25 //// This source file is free software; you can redistribute it ////
26 //// and/or modify it under the terms of the GNU Lesser General ////
27 //// Public License as published by the Free Software Foundation; ////
28 //// either version 2.1 of the License, or (at your option) any ////
29 //// later version. ////
31 //// This source is distributed in the hope that it will be ////
32 //// useful, but WITHOUT ANY WARRANTY; without even the implied ////
33 //// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
34 //// PURPOSE. See the GNU Lesser General Public License for more ////
37 //// You should have received a copy of the GNU Lesser General ////
38 //// Public License along with this source; if not, download it ////
39 //// from http://www.opencores.org/lgpl.shtml ////
41 //////////////////////////////////////////////////////////////////////
43 // CVS Revision History
45 // $Log: pci_conf_space.v,v $
46 // Revision 1.1 2007-03-20 17:50:56 sithglan
49 // Revision 1.10 2004/08/19 16:04:53 mihad
50 // Removed some unused signals.
52 // Revision 1.9 2004/08/19 15:27:34 mihad
53 // Changed minimum pci image size to 256 bytes because
54 // of some PC system problems with size of IO images.
56 // Revision 1.8 2004/07/07 12:45:01 mihad
57 // Added SubsystemVendorID, SubsystemID, MAXLatency, MinGnt defines.
58 // Enabled value loading from serial EEPROM for all of the above + VendorID and DeviceID registers.
60 // Revision 1.7 2004/01/24 11:54:18 mihad
61 // Update! SPOCI Implemented!
63 // Revision 1.6 2003/12/28 09:54:48 fr2201
64 // def_wb_imagex_addr_map defined correctly
66 // Revision 1.5 2003/12/28 09:20:00 fr2201
67 // Reset values for PCI, WB defined (PCI_TAx,WB_BAx,WB_TAx,WB_AMx,WB_BAx_MEM_IO)
69 // Revision 1.4 2003/12/19 11:11:30 mihad
70 // Compact PCI Hot Swap support added.
71 // New testcases added.
72 // Specification updated.
73 // Test application changed to support WB B3 cycles.
75 // Revision 1.3 2003/08/14 13:06:02 simons
76 // synchronizer_flop replaced with pci_synchronizer_flop, artisan ram instance updated.
78 // Revision 1.2 2003/03/26 13:16:18 mihad
79 // Added the reset value parameter to the synchronizer flop module.
80 // Added resets to all synchronizer flop instances.
81 // Repaired initial sync value in fifos.
83 // Revision 1.1 2003/01/27 16:49:31 mihad
84 // Changed module and file names. Updated scripts accordingly. FIFO synchronizations changed.
86 // Revision 1.4 2002/08/13 11:03:53 mihad
87 // Added a few testcases. Repaired wrong reset value for PCI_AM5 register. Repaired Parity Error Detected bit setting. Changed PCI_AM0 to always enabled(regardles of PCI_AM0 define), if image 0 is used as configuration image
89 // Revision 1.3 2002/02/01 15:25:12 mihad
90 // Repaired a few bugs, updated specification, added test bench files and design document
92 // Revision 1.2 2001/10/05 08:14:28 mihad
93 // Updated all files with inclusion of timescale file for simulation purposes.
95 // Revision 1.1.1.1 2001/10/02 15:33:46 mihad
96 // New project directory structure
100 `include "pci_constants.v"
102 // synopsys translate_off
103 `include "timescale.v"
104 // synopsys translate_on
106 /*-----------------------------------------------------------------------------------------------------------
107 w_ prefix is a sign for Write (and read) side of Dual-Port registers
108 r_ prefix is a sign for Read only side of Dual-Port registers
109 In the first line there are DATA and ADDRESS ports, in the second line there are write enable and read
110 enable signals with chip-select (conf_hit) for config. space.
111 In the third line there are output signlas from Command register of the PCI configuration header !!!
112 In the fourth line there are input signals to Status register of the PCI configuration header !!!
113 In the fifth line there is output from Latency Timer & r_Interrupt pin registers of the PCI conf. header !!!
114 Following are IMAGE specific registers, from which PCI_BASE_ADDR registers are the same as base address
115 registers from the PCI conf. header !!!
116 -----------------------------------------------------------------------------------------------------------*/
117 // normal R/W address, data and control
118 module pci_conf_space
119 ( w_conf_address_in, w_conf_data_in, w_conf_data_out, r_conf_address_in, r_conf_data_out,
120 w_we_i, w_re, r_re, w_byte_en_in, w_clock, reset, pci_clk, wb_clk,
121 // outputs from command register of the PCI header
122 serr_enable, perr_response, pci_master_enable, memory_space_enable, io_space_enable,
123 // inputs to status register of the PCI header
124 perr_in, serr_in, master_abort_recv, target_abort_recv, target_abort_set, master_data_par_err,
125 // output from cache_line_size, latency timer and r_interrupt_pin register of the PCI header
126 cache_line_size_to_pci, cache_line_size_to_wb, cache_lsize_not_zero_to_wb,
128 // output from all pci IMAGE registers
129 pci_base_addr0, pci_base_addr1, pci_base_addr2, pci_base_addr3, pci_base_addr4, pci_base_addr5,
130 pci_memory_io0, pci_memory_io1, pci_memory_io2, pci_memory_io3, pci_memory_io4, pci_memory_io5,
131 pci_addr_mask0, pci_addr_mask1, pci_addr_mask2, pci_addr_mask3, pci_addr_mask4, pci_addr_mask5,
132 pci_tran_addr0, pci_tran_addr1, pci_tran_addr2, pci_tran_addr3, pci_tran_addr4, pci_tran_addr5,
133 pci_img_ctrl0, pci_img_ctrl1, pci_img_ctrl2, pci_img_ctrl3, pci_img_ctrl4, pci_img_ctrl5,
134 // input to pci error control and status register, error address and error data registers
135 pci_error_be, pci_error_bc, pci_error_rty_exp, pci_error_es, pci_error_sig, pci_error_addr,
137 // output from all wishbone IMAGE registers
138 wb_base_addr0, wb_base_addr1, wb_base_addr2, wb_base_addr3, wb_base_addr4, wb_base_addr5,
139 wb_memory_io0, wb_memory_io1, wb_memory_io2, wb_memory_io3, wb_memory_io4, wb_memory_io5,
140 wb_addr_mask0, wb_addr_mask1, wb_addr_mask2, wb_addr_mask3, wb_addr_mask4, wb_addr_mask5,
141 wb_tran_addr0, wb_tran_addr1, wb_tran_addr2, wb_tran_addr3, wb_tran_addr4, wb_tran_addr5,
142 wb_img_ctrl0, wb_img_ctrl1, wb_img_ctrl2, wb_img_ctrl3, wb_img_ctrl4, wb_img_ctrl5,
143 // input to wb error control and status register, error address and error data registers
144 wb_error_be, wb_error_bc, wb_error_rty_exp, wb_error_es, wb_error_sig, wb_error_addr, wb_error_data,
145 // output from conf. cycle generation register (sddress), int. control register & interrupt output
146 config_addr, icr_soft_res, int_out,
147 // input to interrupt status register
148 isr_sys_err_int, isr_par_err_int, isr_int_prop,
150 pci_init_complete_out, wb_init_complete_out
152 `ifdef PCI_CPCI_HS_IMPLEMENT
154 pci_cpci_hs_enum_oe_o, pci_cpci_hs_led_oe_o, pci_cpci_hs_es_i
159 spoci_scl_oe_o, spoci_sda_i, spoci_sda_oe_o
164 /*###########################################################################################################
165 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
166 Input and output ports
167 ======================
168 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
169 ###########################################################################################################*/
172 output [31 : 0] w_conf_data_out ;
173 output [31 : 0] r_conf_data_out ;
174 reg [31 : 0] w_conf_data_out ;
178 reg [31 : 0] r_conf_data_out ;
182 input [31 : 0] w_conf_data_in ;
183 wire [31 : 0] w_conf_pdata_reduced ; // reduced data written into PCI image registers
184 wire [31 : 0] w_conf_wdata_reduced ; // reduced data written into WB image registers
186 input [11 : 0] w_conf_address_in ;
187 input [11 : 0] r_conf_address_in ;
188 // input control signals
192 input [3 : 0] w_byte_en_in ;
197 // PCI header outputs from command register
199 output perr_response ;
200 output pci_master_enable ;
201 output memory_space_enable ;
202 output io_space_enable ;
203 // PCI header inputs to status register
206 input master_abort_recv ;
207 input target_abort_recv ;
208 input target_abort_set ;
209 input master_data_par_err ;
210 // PCI header output from cache_line_size, latency timer and interrupt pin
211 output [7 : 0] cache_line_size_to_pci ; // sinchronized to PCI clock
212 output [7 : 0] cache_line_size_to_wb ; // sinchronized to WB clock
213 output cache_lsize_not_zero_to_wb ; // used in WBU and PCIU
214 output [7 : 0] latency_tim ;
215 //output [2 : 0] int_pin ; // only 3 LSbits are important!
216 // PCI output from image registers
218 output [31:12] pci_base_addr0 ;
223 output [31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] pci_base_addr0 ;
225 output [31:12] pci_base_addr0 ;
229 output [31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] pci_base_addr1 ;
230 output [31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] pci_base_addr2 ;
231 output [31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] pci_base_addr3 ;
232 output [31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] pci_base_addr4 ;
233 output [31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] pci_base_addr5 ;
234 output pci_memory_io0 ;
235 output pci_memory_io1 ;
236 output pci_memory_io2 ;
237 output pci_memory_io3 ;
238 output pci_memory_io4 ;
239 output pci_memory_io5 ;
240 output [31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] pci_addr_mask0 ;
241 output [31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] pci_addr_mask1 ;
242 output [31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] pci_addr_mask2 ;
243 output [31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] pci_addr_mask3 ;
244 output [31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] pci_addr_mask4 ;
245 output [31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] pci_addr_mask5 ;
246 output [31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] pci_tran_addr0 ;
247 output [31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] pci_tran_addr1 ;
248 output [31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] pci_tran_addr2 ;
249 output [31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] pci_tran_addr3 ;
250 output [31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] pci_tran_addr4 ;
251 output [31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] pci_tran_addr5 ;
252 output [2 : 1] pci_img_ctrl0 ;
253 output [2 : 1] pci_img_ctrl1 ;
254 output [2 : 1] pci_img_ctrl2 ;
255 output [2 : 1] pci_img_ctrl3 ;
256 output [2 : 1] pci_img_ctrl4 ;
257 output [2 : 1] pci_img_ctrl5 ;
258 // PCI input to pci error control and status register, error address and error data registers
259 input [3 : 0] pci_error_be ;
260 input [3 : 0] pci_error_bc ;
261 input pci_error_rty_exp ;
263 input pci_error_sig ;
264 input [31 : 0] pci_error_addr ;
265 input [31 : 0] pci_error_data ;
266 // WISHBONE output from image registers
267 output [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_base_addr0 ;
268 output [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_base_addr1 ;
269 output [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_base_addr2 ;
270 output [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_base_addr3 ;
271 output [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_base_addr4 ;
272 output [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_base_addr5 ;
273 output wb_memory_io0 ;
274 output wb_memory_io1 ;
275 output wb_memory_io2 ;
276 output wb_memory_io3 ;
277 output wb_memory_io4 ;
278 output wb_memory_io5 ;
279 output [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_addr_mask0 ;
280 output [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_addr_mask1 ;
281 output [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_addr_mask2 ;
282 output [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_addr_mask3 ;
283 output [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_addr_mask4 ;
284 output [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_addr_mask5 ;
285 output [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_tran_addr0 ;
286 output [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_tran_addr1 ;
287 output [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_tran_addr2 ;
288 output [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_tran_addr3 ;
289 output [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_tran_addr4 ;
290 output [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_tran_addr5 ;
291 output [2 : 0] wb_img_ctrl0 ;
292 output [2 : 0] wb_img_ctrl1 ;
293 output [2 : 0] wb_img_ctrl2 ;
294 output [2 : 0] wb_img_ctrl3 ;
295 output [2 : 0] wb_img_ctrl4 ;
296 output [2 : 0] wb_img_ctrl5 ;
297 // WISHBONE input to wb error control and status register, error address and error data registers
298 input [3 : 0] wb_error_be ;
299 input [3 : 0] wb_error_bc ;
300 input wb_error_rty_exp ;
303 input [31 : 0] wb_error_addr ;
304 input [31 : 0] wb_error_data ;
305 // GENERAL output from conf. cycle generation register & int. control register
306 output [23 : 0] config_addr ;
307 output icr_soft_res ;
309 // GENERAL input to interrupt status register
310 input isr_sys_err_int ;
311 input isr_par_err_int ;
314 output pci_init_complete_out ;
315 output wb_init_complete_out ;
317 `ifdef PCI_CPCI_HS_IMPLEMENT
318 output pci_cpci_hs_enum_oe_o ;
319 output pci_cpci_hs_led_oe_o ;
320 input pci_cpci_hs_es_i ;
322 reg pci_cpci_hs_enum_oe_o ;
323 reg pci_cpci_hs_led_oe_o ;
325 // set the hot swap ejector switch debounce counter width
326 // it is only 4 for simulation purposes
329 parameter hs_es_cnt_width = 4 ;
335 parameter hs_es_cnt_width = 16 ;
341 parameter hs_es_cnt_width = 17 ;
349 output spoci_scl_oe_o ;
351 output spoci_sda_oe_o ;
357 reg [10: 0] spoci_cs_adr ;
358 reg [ 7: 0] spoci_cs_dat ;
361 /*###########################################################################################################
362 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
365 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
366 ###########################################################################################################*/
368 // Decoded Register Select signals for writting (only one address decoder)
369 reg [56 : 0] w_reg_select_dec ;
371 /*###########################################################################################################
372 -------------------------------------------------------------------------------------------------------------
373 PCI CONFIGURATION SPACE HEADER (type 00h) registers
375 BIST and some other registers are not implemented and therefor written in correct
376 place with comment line. There are also some registers with NOT all bits implemented and therefor uses
377 _bitX or _bitX2_X1 to sign which bit or range of bits are implemented.
378 Some special cases and examples are described below!
379 -------------------------------------------------------------------------------------------------------------
380 ###########################################################################################################*/
382 /*-----------------------------------------------------------------------------------------------------------
383 [000h-00Ch] First 4 DWORDs (32-bit) of PCI configuration header - the same regardless of the HEADER type !
384 r_ prefix is a sign for read only registers
385 Vendor_ID is an ID for a specific vendor defined by PCI_SIG - 2321h does not belong to anyone (e.g.
386 Xilinx's Vendor_ID is 10EEh and Altera's Vendor_ID is 1172h). Device_ID and Revision_ID should be used
387 together by application. Class_Code has 3 bytes to define BASE class (06h for PCI Bridge), SUB class
388 (00h for HOST type, 80h for Other Bridge type) and Interface type (00h for normal).
389 -----------------------------------------------------------------------------------------------------------*/
390 reg [15: 0] r_vendor_id ;
391 reg [15: 0] r_device_id ;
392 reg [15: 0] r_subsys_vendor_id ;
393 reg [15: 0] r_subsys_id ;
397 reg [2 : 0] command_bit2_0 ;
398 reg [15 : 11] status_bit15_11 ;
399 parameter r_status_bit10_9 = 2'b01 ; // 2'b01 means MEDIUM devsel timing !!!
401 parameter r_status_bit7 = 1'b1 ; // fast back-to-back capable response !!!
402 parameter r_status_bit5 = `HEADER_66MHz ; // 1'b0 indicates 33 MHz capable !!!
404 `ifdef PCI_CPCI_HS_IMPLEMENT
405 wire r_status_bit4 = 1 ;
408 wire [ 1: 0] hs_pi = 2'b00 ;
411 wire [ 7: 0] hs_cap_id = 8'h06 ;
415 wire r_status_bit4 = 0 ;
418 reg [ 7: 0] r_revision_id ;
421 parameter r_class_code = 24'h06_00_00 ;
423 parameter r_class_code = 24'h06_80_00 ;
425 reg [7 : 0] cache_line_size_reg ;
426 reg [7 : 0] latency_timer ;
427 parameter r_header_type = 8'h00 ;
428 // REG bist NOT implemented !!!
430 /*-----------------------------------------------------------------------------------------------------------
431 [010h-03Ch] all other DWORDs (32-bit) of PCI configuration header - only for HEADER type 00h !
432 r_ prefix is a sign for read only registers
433 BASE_ADDRESS_REGISTERS are the same as ones in the PCI Target configuration registers section. They
434 are duplicated and therefor defined just ones and used with the same name as written below. If
435 IMAGEx is NOT defined there is only parameter image_X assigned to '0' and this parameter is used
436 elsewhere in the code. This parameter is defined in the INTERNAL SIGNALS part !!!
437 Interrupt_Pin value 8'h01 is used for INT_A pin used.
438 MIN_GNT and MAX_LAT are used for device's desired values for Latency Timer value. The value in boath
439 registers specifies a period of time in units of 1/4 microsecond. ZERO indicates that there are no
440 major requirements for the settings of Latency Timer.
441 MIN_GNT specifieshow how long a burst period the device needs at 33MHz. MAX_LAT specifies how often
442 the device needs to gain access to the PCI bus. Values are choosen assuming that the target does not
443 insert any wait states. Follow the expamle of settings for simple display card.
444 If we use 64 (32-bit) FIFO locations for one burst then we need 8 x 1/4 microsecond periods at 33MHz
445 clock rate => MIN_GNT = 08h ! Resolution is 1024 x 768 (= 786432 pixels for one frame) with 16-bit
446 color mode. We can transfere 2 16-bit pixels in one FIFO location. From that we calculate, that for
447 one frame we need 6144 burst transferes in 1/25 second. So we need one burst every 6,51 microsecond
448 and that is 26 x 1/4 microsecond or 1Ah x 1/4 microsecond => MAX_LAT = 1Ah !
449 -----------------------------------------------------------------------------------------------------------*/
450 // REG x 6 base_address_register_X IMPLEMENTED as pci_ba_X !!!
451 // REG r_cardbus_cis_pointer NOT implemented !!!
452 // REG r_subsystem_vendor_id NOT implemented !!!
453 // REG r_subsystem_id NOT implemented !!!
454 // REG r_expansion_rom_base_address NOT implemented !!!
455 // REG r_cap_list_pointer NOT implemented !!!
456 reg [7 : 0] interrupt_line ;
457 parameter r_interrupt_pin = 8'h01 ;
458 reg [7 : 0] r_min_gnt ;
459 reg [7 : 0] r_max_lat ;
461 /*###########################################################################################################
462 -------------------------------------------------------------------------------------------------------------
463 PCI Target configuration registers
464 There are also some registers with NOT all bits implemented and therefor uses _bitX or _bitX2_X1 to
465 sign which bit or range of bits are implemented. Some special cases and examples are described below!
466 -------------------------------------------------------------------------------------------------------------
467 ###########################################################################################################*/
469 /*-----------------------------------------------------------------------------------------------------------
471 Depending on defines (PCI_IMAGE1 or .. or PCI_IMAGE5 or (PCI_IMAGE0 and HOST)) in constants.v file,
472 there are registers corresponding to each IMAGE defined to REG and parameter pci_image_X assigned to '1'.
473 The maximum number of images is "6". By default there are first two images used and the first (PCI_IMAGE0)
474 is assigned to Configuration space! With a 'define' PCI_IMAGEx you choose the number of used PCI IMAGES
475 in a bridge without PCI_IMAGE0 (e.g. PCI_IMAGE3 tells, that PCI_IMAGE1, PCI_IMAGE2 and PCI_IMAGE3 are
476 used for mapping the space from WB to PCI. Offcourse, PCI_IMAGE0 is assigned to Configuration space).
477 That leave us PCI_IMAGE5 as the maximum number of images.
478 There is one exeption, when the core is implemented as HOST. If so, then the PCI specification allowes
479 the Configuration space NOT to be visible on the PCI bus. With `define PCI_IMAGE0 (and `define HOST), we
480 assign PCI_IMAGE0 to normal WB to PCI image and not to configuration space!
482 When error occurs, PCI ERR_ADDR and ERR_DATA registers stores address and data on the bus that
483 caused error. While ERR_CS register stores Byte Enables and Bus Command in the MSByte. In bits 10
484 and 8 it reports Retry Counter Expired (for posted writes), Error Source (Master Abort) and Error
485 Report Signal (signals that error has occured) respectively. With bit 0 we enable Error Reporting
487 -----------------------------------------------------------------------------------------------------------*/
490 `ifdef PCI_IMAGE0 // if PCI bridge is HOST and IMAGE0 is assigned as general image space
491 reg [31 : 8] pci_ba0_bit31_8 ;
492 reg [2 : 1] pci_img_ctrl0_bit2_1 ;
494 reg [31 : 8] pci_am0 ;
495 reg [31 : 8] pci_ta0 ;
496 `else // if PCI bridge is HOST and IMAGE0 is not used
497 wire [31 : 8] pci_ba0_bit31_8 = 24'h0000_00 ; // NO base address needed
498 wire [2 : 1] pci_img_ctrl0_bit2_1 = 2'b00 ; // NO addr.transl. and pre-fetch
499 wire pci_ba0_bit0 = 0 ; // config. space is MEMORY space
500 wire [31 : 8] pci_am0 = 24'h0000_00 ; // NO address mask needed
501 wire [31 : 8] pci_ta0 = 24'h0000_00 ; // NO address translation needed
503 `else // if PCI bridge is HOST and IMAGE0 is assigned to PCI configuration space
504 reg [31 : 8] pci_ba0_bit31_8 ;
505 wire [2 : 1] pci_img_ctrl0_bit2_1 = 2'b00 ; // NO pre-fetch and read line support
506 wire pci_ba0_bit0 = 0 ; // config. space is MEMORY space
507 wire [31 : 8] pci_am0 = 24'hFFFF_F0 ; // address mask for configuration image always 20'hffff_f
508 wire [31 : 8] pci_ta0 = 24'h0000_00 ; // NO address translation needed
512 `ifdef GUEST // if PCI bridge is GUEST, then IMAGE0 is assigned to PCI configuration space
513 reg [31 : 8] pci_ba0_bit31_8 ;
514 wire [2 : 1] pci_img_ctrl0_bit2_1 = 2'b00 ; // NO addr.transl. and pre-fetch
515 wire pci_ba0_bit0 = 0 ; // config. space is MEMORY space
516 wire [31 : 8] pci_am0 = 24'hffff_f0 ; // address mask for configuration image always 24'hffff_f0 - 4KB mem image
517 wire [31 : 8] pci_ta0 = 24'h0000_00 ; // NO address translation needed
520 // IMAGE1 is included by default, meanwhile other IMAGEs are optional !!!
521 reg [2 : 1] pci_img_ctrl1_bit2_1 ;
522 reg [31 : 8] pci_ba1_bit31_8 ;
526 wire pci_ba1_bit0 = `PCI_BA1_MEM_IO ;
528 reg [31 : 8] pci_am1 ;
529 reg [31 : 8] pci_ta1 ;
531 reg [2 : 1] pci_img_ctrl2_bit2_1 ;
532 reg [31 : 8] pci_ba2_bit31_8 ;
536 wire pci_ba2_bit0 = `PCI_BA2_MEM_IO ;
538 reg [31 : 8] pci_am2 ;
539 reg [31 : 8] pci_ta2 ;
541 wire [2 : 1] pci_img_ctrl2_bit2_1 = 2'b00 ;
542 wire [31 : 8] pci_ba2_bit31_8 = 24'h0000_00 ;
543 wire pci_ba2_bit0 = 1'b0 ;
544 wire [31 : 8] pci_am2 = 24'h0000_00 ;
545 wire [31 : 8] pci_ta2 = 24'h0000_00 ;
548 reg [2 : 1] pci_img_ctrl3_bit2_1 ;
549 reg [31 : 8] pci_ba3_bit31_8 ;
553 wire pci_ba3_bit0 = `PCI_BA3_MEM_IO ;
555 reg [31 : 8] pci_am3 ;
556 reg [31 : 8] pci_ta3 ;
558 wire [2 : 1] pci_img_ctrl3_bit2_1 = 2'b00 ;
559 wire [31 : 8] pci_ba3_bit31_8 = 24'h0000_00 ;
560 wire pci_ba3_bit0 = 1'b0 ;
561 wire [31 : 8] pci_am3 = 24'h0000_00 ;
562 wire [31 : 8] pci_ta3 = 24'h0000_00 ;
565 reg [2 : 1] pci_img_ctrl4_bit2_1 ;
566 reg [31 : 8] pci_ba4_bit31_8 ;
570 wire pci_ba4_bit0 = `PCI_BA4_MEM_IO ;
572 reg [31 : 8] pci_am4 ;
573 reg [31 : 8] pci_ta4 ;
575 wire [2 : 1] pci_img_ctrl4_bit2_1 = 2'b00 ;
576 wire [31 : 8] pci_ba4_bit31_8 = 24'h0000_00 ;
577 wire pci_ba4_bit0 = 1'b0 ;
578 wire [31 : 8] pci_am4 = 24'h0000_00 ;
579 wire [31 : 8] pci_ta4 = 24'h0000_00 ;
582 reg [2 : 1] pci_img_ctrl5_bit2_1 ;
583 reg [31 : 8] pci_ba5_bit31_8 ;
587 wire pci_ba5_bit0 = `PCI_BA5_MEM_IO ;
589 reg [31 : 8] pci_am5 ;
590 reg [31 : 8] pci_ta5 ;
592 wire [2 : 1] pci_img_ctrl5_bit2_1 = 2'b00 ;
593 wire [31 : 8] pci_ba5_bit31_8 = 24'h0000_00 ;
594 wire pci_ba5_bit0 = 1'b0 ;
595 wire [31 : 8] pci_am5 = 24'h0000_00 ;
596 wire [31 : 8] pci_ta5 = 24'h0000_00 ;
598 reg [31 : 24] pci_err_cs_bit31_24 ;
599 reg pci_err_cs_bit10 ;
600 reg pci_err_cs_bit9 ;
601 reg pci_err_cs_bit8 ;
602 reg pci_err_cs_bit0 ;
603 reg [31 : 0] pci_err_addr ;
604 reg [31 : 0] pci_err_data ;
607 /*###########################################################################################################
608 -------------------------------------------------------------------------------------------------------------
609 WISHBONE Slave configuration registers
610 There are also some registers with NOT all bits implemented and therefor uses _bitX or _bitX2_X1 to
611 sign which bit or range of bits are implemented. Some special cases and examples are described below!
612 -------------------------------------------------------------------------------------------------------------
613 ###########################################################################################################*/
615 /*-----------------------------------------------------------------------------------------------------------
617 Depending on defines (WB_IMAGE1 or .. or WB_IMAGE4 or WB_IMAGE5) in constants.v file, there are
618 registers corresponding to each IMAGE defined to REG and parameter wb_image_X assigned to '1'.
619 The maximum number of images is "6". By default there are first two images used and the first (WB_IMAGE0)
620 is assigned to Configuration space! With a 'define' WB_IMAGEx you choose the number of used WB IMAGES in
621 a bridge without WB_IMAGE0 (e.g. WB_IMAGE3 tells, that WB_IMAGE1, WB_IMAGE2 and WB_IMAGE3 are used for
622 mapping the space from PCI to WB. Offcourse, WB_IMAGE0 is assigned to Configuration space). That leave
623 us WB_IMAGE5 as the maximum number of images.
625 When error occurs, WISHBONE ERR_ADDR and ERR_DATA registers stores address and data on the bus that
626 caused error. While ERR_CS register stores Byte Enables and Bus Command in the MSByte. In bits 10, 9
627 and 8 it reports Retry Counter Expired (for posted writes), Error Source (Master Abort) and Error
628 Report Signal (signals that error has occured) respectively. With bit 0 we enable Error Reporting
630 -----------------------------------------------------------------------------------------------------------*/
631 // WB_IMAGE0 is always assigned to config. space or is not used
632 wire [2 : 0] wb_img_ctrl0_bit2_0 = 3'b000 ; // NO addr.transl., pre-fetch and read-line
633 wire [31 : 12] wb_ba0_bit31_12 = `WB_CONFIGURATION_BASE ;
634 wire wb_ba0_bit0 = 0 ; // config. space is MEMORY space
635 wire [31 : 12] wb_am0 = `WB_AM0 ; // 4KBytes of configuration space is minimum
636 wire [31 : 12] wb_ta0 = 20'h0000_0 ; // NO address translation needed
637 // WB_IMAGE1 is included by default meanwhile others are optional !
638 reg [2 : 0] wb_img_ctrl1_bit2_0 ;
639 reg [31 : 12] wb_ba1_bit31_12 ;
641 reg [31 : 12] wb_am1 ;
642 reg [31 : 12] wb_ta1 ;
644 reg [2 : 0] wb_img_ctrl2_bit2_0 ;
645 reg [31 : 12] wb_ba2_bit31_12 ;
647 reg [31 : 12] wb_am2 ;
648 reg [31 : 12] wb_ta2 ;
650 wire [2 : 0] wb_img_ctrl2_bit2_0 = 3'b000 ;
651 wire [31 : 12] wb_ba2_bit31_12 = 20'h0000_0 ;
652 wire wb_ba2_bit0 = 1'b0 ;
653 wire [31 : 12] wb_am2 = 20'h0000_0 ;
654 wire [31 : 12] wb_ta2 = 20'h0000_0 ;
657 reg [2 : 0] wb_img_ctrl3_bit2_0 ;
658 reg [31 : 12] wb_ba3_bit31_12 ;
660 reg [31 : 12] wb_am3 ;
661 reg [31 : 12] wb_ta3 ;
663 wire [2 : 0] wb_img_ctrl3_bit2_0 = 3'b000 ;
664 wire [31 : 12] wb_ba3_bit31_12 = 20'h0000_0 ;
665 wire wb_ba3_bit0 = 1'b0 ;
666 wire [31 : 12] wb_am3 = 20'h0000_0 ;
667 wire [31 : 12] wb_ta3 = 20'h0000_0 ;
670 reg [2 : 0] wb_img_ctrl4_bit2_0 ;
671 reg [31 : 12] wb_ba4_bit31_12 ;
673 reg [31 : 12] wb_am4 ;
674 reg [31 : 12] wb_ta4 ;
676 wire [2 : 0] wb_img_ctrl4_bit2_0 = 3'b000 ;
677 wire [31 : 12] wb_ba4_bit31_12 = 20'h0000_0 ;
678 wire wb_ba4_bit0 = 1'b0 ;
679 wire [31 : 12] wb_am4 = 20'h0000_0 ;
680 wire [31 : 12] wb_ta4 = 20'h0000_0 ;
683 reg [2 : 0] wb_img_ctrl5_bit2_0 ;
684 reg [31 : 12] wb_ba5_bit31_12 ;
686 reg [31 : 12] wb_am5 ;
687 reg [31 : 12] wb_ta5 ;
689 wire [2 : 0] wb_img_ctrl5_bit2_0 = 3'b000 ;
690 wire [31 : 12] wb_ba5_bit31_12 = 20'h0000_0 ;
691 wire wb_ba5_bit0 = 1'b0 ;
692 wire [31 : 12] wb_am5 = 20'h0000_0 ;
693 wire [31 : 12] wb_ta5 = 20'h0000_0 ;
695 reg [31 : 24] wb_err_cs_bit31_24 ;
696 /* reg wb_err_cs_bit10 ;*/
700 reg [31 : 0] wb_err_addr ;
701 reg [31 : 0] wb_err_data ;
704 /*###########################################################################################################
705 -------------------------------------------------------------------------------------------------------------
706 Configuration Cycle address register
707 There are also some registers with NOT all bits implemented and therefor uses _bitX or _bitX2_X1 to
708 sign which bit or range of bits are implemented.
709 -------------------------------------------------------------------------------------------------------------
710 ###########################################################################################################*/
712 /*-----------------------------------------------------------------------------------------------------------
714 PCI bridge must ignore Type 1 configuration cycles (Master Abort) since they are used for PCI to PCI
715 bridges. This is single function device, that means responding on configuration cycles to all functions
716 (or responding only to function 0). Configuration address register for generating configuration cycles
717 is prepared for all options (it includes Bus Number, Device, Function, Offset and Type).
718 Interrupt acknowledge register stores interrupt vector data returned during Interrupt Acknowledge cycle.
719 -----------------------------------------------------------------------------------------------------------*/
721 reg [23 : 2] cnf_addr_bit23_2 ;
724 wire [23 : 2] cnf_addr_bit23_2 = 22'h0 ;
725 wire cnf_addr_bit0 = 1'b0 ;
727 // reg [31 : 0] cnf_data ; IMPLEMENTED elsewhere !!!!!
728 // reg [31 : 0] int_ack ; IMPLEMENTED elsewhere !!!!!
731 /*###########################################################################################################
732 -------------------------------------------------------------------------------------------------------------
733 General Interrupt registers
734 There are also some registers with NOT all bits implemented and therefor uses _bitX or _bitX2_X1 to
735 sign which bit or range of bits are implemented.
736 -------------------------------------------------------------------------------------------------------------
737 ###########################################################################################################*/
739 /*-----------------------------------------------------------------------------------------------------------
741 Bit 31 in the Interrupt Control register is set by software and used to generate SOFT RESET. Other 4
742 bits are used to enable interrupt generations.
743 5 LSbits in the Interrupt Status register are indicating System Error Int, Parity Error Int, PCI & WB
744 Error Int and Inerrupt respecively. System and Parity errors are implented only in HOST bridge
746 -----------------------------------------------------------------------------------------------------------*/
749 reg [4 : 3] icr_bit4_3 ;
750 reg [4 : 3] isr_bit4_3 ;
751 reg [2 : 0] icr_bit2_0 ;
752 reg [2 : 0] isr_bit2_0 ;
754 wire [4 : 3] icr_bit4_3 = 2'h0 ;
755 wire [4 : 3] isr_bit4_3 = 2'h0 ;
756 reg [2 : 0] icr_bit2_0 ;
757 reg [2 : 0] isr_bit2_0 ;
760 /*###########################################################################################################
761 -------------------------------------------------------------------------------------------------------------
762 Initialization complete identifier
763 When using I2C or similar initialisation mechanism,
764 the bridge must not respond to transaction requests on PCI bus,
765 not even to configuration cycles.
766 Therefore, only when init_complete is set, the bridge starts
767 participating on the PCI bus as an active device.
768 Two additional flip flops are also provided for GUEST implementation,
769 to synchronize to the pci clock after PCI reset is asynchronously de-asserted.
770 -------------------------------------------------------------------------------------------------------------
771 ###########################################################################################################*/
775 reg rst_inactive_sync ;
780 wire rst_inactive = 1'b1 ;
786 wire sync_init_complete ;
789 assign wb_init_complete_out = init_complete ;
791 pci_synchronizer_flop #(1, 0) i_pci_init_complete_sync
793 .data_in ( init_complete ),
794 .clk_out ( pci_clk ),
795 .sync_data_out ( sync_init_complete ),
796 .async_reset ( reset )
799 reg pci_init_complete_out ;
801 always@(posedge pci_clk or posedge reset)
804 pci_init_complete_out <= 1'b0 ;
806 pci_init_complete_out <= sync_init_complete ;
813 assign pci_init_complete_out = init_complete ;
815 pci_synchronizer_flop #(1, 0) i_wb_init_complete_sync
817 .data_in ( init_complete ),
819 .sync_data_out ( sync_init_complete ),
820 .async_reset ( reset )
823 reg wb_init_complete_out ;
825 always@(posedge wb_clk or posedge reset)
828 wb_init_complete_out <= 1'b0 ;
830 wb_init_complete_out <= sync_init_complete ;
835 /*###########################################################################################################
836 -------------------------------------------------------------------------------------------------------------
839 -----------------------------------------------------------------------------------------------------------*/
841 `ifdef NO_CNF_IMAGE // if IMAGE0 is assigned as general image space
843 assign r_conf_data_out = 32'h0000_0000 ;
847 always@(r_conf_address_in or
848 status_bit15_11 or status_bit8 or r_status_bit4 or command_bit8 or command_bit6 or command_bit2_0 or
849 latency_timer or cache_line_size_reg or r_vendor_id or r_device_id or r_revision_id or
850 r_subsys_vendor_id or r_subsys_id or r_max_lat or r_min_gnt or
852 pci_img_ctrl0_bit2_1 or pci_am0 or pci_ta0 or pci_ba0_bit0 or
853 pci_img_ctrl1_bit2_1 or pci_am1 or pci_ta1 or pci_ba1_bit31_8 or pci_ba1_bit0 or
854 pci_img_ctrl2_bit2_1 or pci_am2 or pci_ta2 or pci_ba2_bit31_8 or pci_ba2_bit0 or
855 pci_img_ctrl3_bit2_1 or pci_am3 or pci_ta3 or pci_ba3_bit31_8 or pci_ba3_bit0 or
856 pci_img_ctrl4_bit2_1 or pci_am4 or pci_ta4 or pci_ba4_bit31_8 or pci_ba4_bit0 or
857 pci_img_ctrl5_bit2_1 or pci_am5 or pci_ta5 or pci_ba5_bit31_8 or pci_ba5_bit0 or
859 pci_err_cs_bit31_24 or pci_err_cs_bit10 or pci_err_cs_bit9 or pci_err_cs_bit8 or pci_err_cs_bit0 or
860 pci_err_addr or pci_err_data or
861 wb_ba0_bit31_12 or wb_ba0_bit0 or
862 wb_img_ctrl1_bit2_0 or wb_ba1_bit31_12 or wb_ba1_bit0 or wb_am1 or wb_ta1 or
863 wb_img_ctrl2_bit2_0 or wb_ba2_bit31_12 or wb_ba2_bit0 or wb_am2 or wb_ta2 or
864 wb_img_ctrl3_bit2_0 or wb_ba3_bit31_12 or wb_ba3_bit0 or wb_am3 or wb_ta3 or
865 wb_img_ctrl4_bit2_0 or wb_ba4_bit31_12 or wb_ba4_bit0 or wb_am4 or wb_ta4 or
866 wb_img_ctrl5_bit2_0 or wb_ba5_bit31_12 or wb_ba5_bit0 or wb_am5 or wb_ta5 or
867 wb_err_cs_bit31_24 or /*wb_err_cs_bit10 or*/ wb_err_cs_bit9 or wb_err_cs_bit8 or wb_err_cs_bit0 or
868 wb_err_addr or wb_err_data or
869 cnf_addr_bit23_2 or cnf_addr_bit0 or icr_bit31 or icr_bit4_3 or icr_bit2_0 or isr_bit4_3 or isr_bit2_0
871 `ifdef PCI_CPCI_HS_IMPLEMENT
872 or hs_ins or hs_ext or hs_pi or hs_loo or hs_eim or hs_cap_id
876 or spoci_cs_nack or spoci_cs_write or spoci_cs_read or spoci_cs_adr or spoci_cs_dat
880 case (r_conf_address_in[9:2])
881 // PCI header - configuration space
882 8'h0: r_conf_data_out = { r_device_id, r_vendor_id } ;
883 8'h1: r_conf_data_out = { status_bit15_11, r_status_bit10_9, status_bit8, r_status_bit7, 1'h0, r_status_bit5, r_status_bit4,
884 4'h0, 7'h00, command_bit8, 1'h0, command_bit6, 3'h0, command_bit2_0 } ;
885 8'h2: r_conf_data_out = { r_class_code, r_revision_id } ;
886 8'h3: r_conf_data_out = { 8'h00, r_header_type, latency_timer, cache_line_size_reg } ;
891 r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba0_bit31_8[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
892 pci_am0[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
893 r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
894 r_conf_data_out[0] = pci_ba0_bit0 & pci_am0[31];
896 r_conf_data_out[31:12] = pci_ba0_bit31_8[31:12] ;
897 r_conf_data_out[11: 0] = 12'h000 ;
902 r_conf_data_out[31:12] = pci_ba0_bit31_8[31:12] ;
903 r_conf_data_out[11: 0] = 12'h000 ;
908 r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba1_bit31_8[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
909 pci_am1[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
910 r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
911 r_conf_data_out[0] = pci_ba1_bit0 & pci_am1[31];
915 r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba2_bit31_8[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
916 pci_am2[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
917 r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
918 r_conf_data_out[0] = pci_ba2_bit0 & pci_am2[31];
922 r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba3_bit31_8[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
923 pci_am3[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
924 r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
925 r_conf_data_out[0] = pci_ba3_bit0 & pci_am3[31];
929 r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba4_bit31_8[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
930 pci_am4[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
931 r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
932 r_conf_data_out[0] = pci_ba4_bit0 & pci_am4[31];
936 r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba5_bit31_8[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
937 pci_am5[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
938 r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
939 r_conf_data_out[0] = pci_ba5_bit0 & pci_am5[31];
943 r_conf_data_out = {r_subsys_id, r_subsys_vendor_id} ;
945 `ifdef PCI_CPCI_HS_IMPLEMENT
948 r_conf_data_out = {24'h0000_00, `PCI_CAP_PTR_VAL} ;
951 8'hf: r_conf_data_out = { r_max_lat, r_min_gnt, r_interrupt_pin, interrupt_line } ;
952 `ifdef PCI_CPCI_HS_IMPLEMENT
953 (`PCI_CAP_PTR_VAL >> 2):
955 r_conf_data_out = {8'h00, hs_ins, hs_ext, hs_pi, hs_loo, 1'b0, hs_eim, 1'b0, 8'h00, hs_cap_id} ;
958 // PCI target - configuration space
959 {2'b01, `P_IMG_CTRL0_ADDR}: r_conf_data_out = { 29'h00000000, pci_img_ctrl0_bit2_1, 1'h0 } ;
960 {2'b01, `P_BA0_ADDR} :
964 r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba0_bit31_8[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
965 pci_am0[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
966 r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
967 r_conf_data_out[0] = pci_ba0_bit0 & pci_am0[31];
969 r_conf_data_out[31:12] = pci_ba0_bit31_8[31:12] ;
970 r_conf_data_out[11: 0] = 12'h000 ;
975 r_conf_data_out[31:12] = pci_ba0_bit31_8[31:12] ;
976 r_conf_data_out[11: 0] = 12'h000 ;
979 {2'b01, `P_AM0_ADDR}:
983 r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_am0[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
984 r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
986 r_conf_data_out[31:12] = pci_am0[31:12] ;
987 r_conf_data_out[11: 0] = 12'h000 ;
992 r_conf_data_out[31:12] = pci_am0[31:12] ;
993 r_conf_data_out[11: 0] = 12'h000 ;
996 {2'b01, `P_TA0_ADDR}:
998 r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ta0[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
999 r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1001 {2'b01, `P_IMG_CTRL1_ADDR}: r_conf_data_out = { 29'h00000000, pci_img_ctrl1_bit2_1, 1'h0 } ;
1002 {2'b01, `P_BA1_ADDR}:
1004 r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba1_bit31_8[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
1005 pci_am1[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1006 r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
1007 r_conf_data_out[0] = pci_ba1_bit0 & pci_am1[31];
1009 {2'b01, `P_AM1_ADDR}:
1011 r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_am1[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1012 r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1014 {2'b01, `P_TA1_ADDR}:
1016 r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ta1[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1017 r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1019 {2'b01, `P_IMG_CTRL2_ADDR}: r_conf_data_out = { 29'h00000000, pci_img_ctrl2_bit2_1, 1'h0 } ;
1020 {2'b01, `P_BA2_ADDR}:
1022 r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba2_bit31_8[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
1023 pci_am2[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1024 r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
1025 r_conf_data_out[0] = pci_ba2_bit0 & pci_am2[31];
1027 {2'b01, `P_AM2_ADDR}:
1029 r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_am2[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1030 r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1032 {2'b01, `P_TA2_ADDR}:
1034 r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ta2[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1035 r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1037 {2'b01, `P_IMG_CTRL3_ADDR}: r_conf_data_out = { 29'h00000000, pci_img_ctrl3_bit2_1, 1'h0 } ;
1038 {2'b01, `P_BA3_ADDR}:
1040 r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba3_bit31_8[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
1041 pci_am3[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1042 r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
1043 r_conf_data_out[0] = pci_ba3_bit0 & pci_am3[31];
1045 {2'b01, `P_AM3_ADDR}:
1047 r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_am3[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1048 r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1050 {2'b01, `P_TA3_ADDR}:
1052 r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ta3[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1053 r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1055 {2'b01, `P_IMG_CTRL4_ADDR}: r_conf_data_out = { 29'h00000000, pci_img_ctrl4_bit2_1, 1'h0 } ;
1056 {2'b01, `P_BA4_ADDR}:
1058 r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba4_bit31_8[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
1059 pci_am4[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1060 r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
1061 r_conf_data_out[0] = pci_ba4_bit0 & pci_am4[31];
1063 {2'b01, `P_AM4_ADDR}:
1065 r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_am4[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1066 r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1068 {2'b01, `P_TA4_ADDR}:
1070 r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ta4[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1071 r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1073 {2'b01, `P_IMG_CTRL5_ADDR}: r_conf_data_out = { 29'h00000000, pci_img_ctrl5_bit2_1, 1'h0 } ;
1074 {2'b01, `P_BA5_ADDR}:
1076 r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba5_bit31_8[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
1077 pci_am5[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1078 r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
1079 r_conf_data_out[0] = pci_ba5_bit0 & pci_am5[31];
1081 {2'b01, `P_AM5_ADDR}:
1083 r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_am5[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1084 r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1086 {2'b01, `P_TA5_ADDR}:
1088 r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ta5[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1089 r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1091 {2'b01, `P_ERR_CS_ADDR}: r_conf_data_out = { pci_err_cs_bit31_24, 13'h0000, pci_err_cs_bit10, pci_err_cs_bit9,
1092 pci_err_cs_bit8, 7'h00, pci_err_cs_bit0 } ;
1093 {2'b01, `P_ERR_ADDR_ADDR}: r_conf_data_out = pci_err_addr ;
1094 {2'b01, `P_ERR_DATA_ADDR}: r_conf_data_out = pci_err_data ;
1095 // WB slave - configuration space
1096 {2'b01, `WB_CONF_SPC_BAR_ADDR}: r_conf_data_out = { wb_ba0_bit31_12, 11'h000, wb_ba0_bit0 } ;
1097 {2'b01, `W_IMG_CTRL1_ADDR}: r_conf_data_out = { 29'h00000000, wb_img_ctrl1_bit2_0 } ;
1098 {2'b01, `W_BA1_ADDR}:
1100 r_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ba1_bit31_12[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] &
1101 wb_am1[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1102 r_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
1103 r_conf_data_out[0] = wb_ba1_bit0 ;
1105 {2'b01, `W_AM1_ADDR}:
1107 r_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_am1[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1108 r_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1110 {2'b01, `W_TA1_ADDR}:
1112 r_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ta1[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1113 r_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1115 {2'b01, `W_IMG_CTRL2_ADDR}: r_conf_data_out = { 29'h00000000, wb_img_ctrl2_bit2_0 } ;
1118 r_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ba2_bit31_12[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] &
1119 wb_am2[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1120 r_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
1121 r_conf_data_out[0] = wb_ba2_bit0 ;
1123 {2'b01, `W_AM2_ADDR}:
1125 r_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_am2[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1126 r_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1128 {2'b01, `W_TA2_ADDR}:
1130 r_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ta2[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1131 r_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1133 {2'b01, `W_IMG_CTRL3_ADDR}: r_conf_data_out = { 29'h00000000, wb_img_ctrl3_bit2_0 } ;
1134 {2'b01, `W_BA3_ADDR}:
1136 r_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ba3_bit31_12[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] &
1137 wb_am3[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1138 r_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
1139 r_conf_data_out[0] = wb_ba3_bit0 ;
1141 {2'b01, `W_AM3_ADDR}:
1143 r_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_am3[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1144 r_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1146 {2'b01, `W_TA3_ADDR}:
1148 r_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ta3[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1149 r_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1151 {2'b01, `W_IMG_CTRL4_ADDR}: r_conf_data_out = { 29'h00000000, wb_img_ctrl4_bit2_0 } ;
1152 {2'b01, `W_BA4_ADDR}:
1154 r_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ba4_bit31_12[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] &
1155 wb_am4[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1156 r_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
1157 r_conf_data_out[0] = wb_ba4_bit0 ;
1159 {2'b01, `W_AM4_ADDR}:
1161 r_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_am4[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1162 r_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1164 {2'b01, `W_TA4_ADDR}:
1166 r_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ta4[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1167 r_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1169 {2'b01, `W_IMG_CTRL5_ADDR}: r_conf_data_out = { 29'h00000000, wb_img_ctrl5_bit2_0 } ;
1170 {2'b01, `W_BA5_ADDR}:
1172 r_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ba5_bit31_12[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] &
1173 wb_am5[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1174 r_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
1175 r_conf_data_out[0] = wb_ba5_bit0 ;
1177 {2'b01, `W_AM5_ADDR}:
1179 r_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_am5[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1180 r_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1182 {2'b01, `W_TA5_ADDR}:
1184 r_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ta5[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1185 r_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1187 {2'b01, `W_ERR_CS_ADDR}: r_conf_data_out = { wb_err_cs_bit31_24, /*13*/14'h0000, /*wb_err_cs_bit10,*/
1188 wb_err_cs_bit9, wb_err_cs_bit8, 7'h00, wb_err_cs_bit0 } ;
1189 {2'b01, `W_ERR_ADDR_ADDR}: r_conf_data_out = wb_err_addr ;
1190 {2'b01, `W_ERR_DATA_ADDR}: r_conf_data_out = wb_err_data ;
1192 {2'b01, `CNF_ADDR_ADDR}: r_conf_data_out = { 8'h00, cnf_addr_bit23_2, 1'h0, cnf_addr_bit0 } ;
1193 // `CNF_DATA_ADDR: implemented elsewhere !!!
1194 // `INT_ACK_ADDR : implemented elsewhere !!!
1195 {2'b01, `ICR_ADDR}: r_conf_data_out = { icr_bit31, 26'h0000_000, icr_bit4_3, icr_bit2_0 } ;
1196 {2'b01, `ISR_ADDR}: r_conf_data_out = { 27'h0000_000, isr_bit4_3, isr_bit2_0 } ;
1199 8'hff: r_conf_data_out = {spoci_cs_nack, 5'h0, spoci_cs_write, spoci_cs_read,
1200 5'h0, spoci_cs_adr[10:8],
1202 spoci_cs_dat[7:0]} ;
1204 default : r_conf_data_out = 32'h0000_0000 ;
1211 reg [ 7: 0] spoci_reg_num ;
1212 wire [11: 0] w_conf_address = init_complete ? w_conf_address_in : {2'b00, spoci_reg_num, 2'b00} ;
1214 wire [11: 0] w_conf_address = w_conf_address_in ;
1215 wire [ 7: 0] spoci_reg_num = 'hff ;
1218 always@(w_conf_address or
1219 status_bit15_11 or status_bit8 or r_status_bit4 or command_bit8 or command_bit6 or command_bit2_0 or
1220 latency_timer or cache_line_size_reg or r_vendor_id or r_device_id or r_revision_id or
1221 r_subsys_id or r_subsys_vendor_id or r_max_lat or r_min_gnt or
1223 pci_img_ctrl0_bit2_1 or pci_am0 or pci_ta0 or pci_ba0_bit0 or
1224 pci_img_ctrl1_bit2_1 or pci_am1 or pci_ta1 or pci_ba1_bit31_8 or pci_ba1_bit0 or
1225 pci_img_ctrl2_bit2_1 or pci_am2 or pci_ta2 or pci_ba2_bit31_8 or pci_ba2_bit0 or
1226 pci_img_ctrl3_bit2_1 or pci_am3 or pci_ta3 or pci_ba3_bit31_8 or pci_ba3_bit0 or
1227 pci_img_ctrl4_bit2_1 or pci_am4 or pci_ta4 or pci_ba4_bit31_8 or pci_ba4_bit0 or
1228 pci_img_ctrl5_bit2_1 or pci_am5 or pci_ta5 or pci_ba5_bit31_8 or pci_ba5_bit0 or
1230 pci_err_cs_bit31_24 or pci_err_cs_bit10 or pci_err_cs_bit9 or pci_err_cs_bit8 or pci_err_cs_bit0 or
1231 pci_err_addr or pci_err_data or
1232 wb_ba0_bit31_12 or wb_ba0_bit0 or
1233 wb_img_ctrl1_bit2_0 or wb_ba1_bit31_12 or wb_ba1_bit0 or wb_am1 or wb_ta1 or
1234 wb_img_ctrl2_bit2_0 or wb_ba2_bit31_12 or wb_ba2_bit0 or wb_am2 or wb_ta2 or
1235 wb_img_ctrl3_bit2_0 or wb_ba3_bit31_12 or wb_ba3_bit0 or wb_am3 or wb_ta3 or
1236 wb_img_ctrl4_bit2_0 or wb_ba4_bit31_12 or wb_ba4_bit0 or wb_am4 or wb_ta4 or
1237 wb_img_ctrl5_bit2_0 or wb_ba5_bit31_12 or wb_ba5_bit0 or wb_am5 or wb_ta5 or
1238 wb_err_cs_bit31_24 or /*wb_err_cs_bit10 or*/ wb_err_cs_bit9 or wb_err_cs_bit8 or wb_err_cs_bit0 or
1239 wb_err_addr or wb_err_data or
1240 cnf_addr_bit23_2 or cnf_addr_bit0 or icr_bit31 or icr_bit4_3 or icr_bit2_0 or isr_bit4_3 or isr_bit2_0
1242 `ifdef PCI_CPCI_HS_IMPLEMENT
1243 or hs_ins or hs_ext or hs_pi or hs_loo or hs_eim or hs_cap_id
1247 or spoci_cs_nack or spoci_cs_write or spoci_cs_read or spoci_cs_adr or spoci_cs_dat
1251 case (w_conf_address[9:2])
1254 w_conf_data_out = { r_device_id, r_vendor_id } ;
1255 w_reg_select_dec = 57'h000_0000_0000_0000 ; // Read-Only register
1257 8'h1: // w_reg_select_dec bit 0
1259 w_conf_data_out = { status_bit15_11, r_status_bit10_9, status_bit8, r_status_bit7, 1'h0, r_status_bit5, r_status_bit4,
1260 4'h0, 7'h00, command_bit8, 1'h0, command_bit6, 3'h0, command_bit2_0 } ;
1261 w_reg_select_dec = 57'h000_0000_0000_0001 ;
1265 w_conf_data_out = { r_class_code, r_revision_id } ;
1266 w_reg_select_dec = 57'h000_0000_0000_0000 ; // Read-Only register
1268 8'h3: // w_reg_select_dec bit 1
1270 w_conf_data_out = { 8'h00, r_header_type, latency_timer, cache_line_size_reg } ;
1271 w_reg_select_dec = 57'h000_0000_0000_0002 ;
1273 8'h4: // w_reg_select_dec bit 4
1277 w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba0_bit31_8[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
1278 pci_am0[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1279 w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
1280 w_conf_data_out[0] = pci_ba0_bit0 & pci_am0[31];
1282 w_conf_data_out[31:12] = pci_ba0_bit31_8[31:12] ;
1283 w_conf_data_out[11: 0] = 12'h000 ;
1288 w_conf_data_out[31:12] = pci_ba0_bit31_8[31:12] ;
1289 w_conf_data_out[11: 0] = 12'h000 ;
1291 w_reg_select_dec = 57'h000_0000_0000_0010 ; // The same for another address
1293 8'h5: // w_reg_select_dec bit 8
1295 w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba1_bit31_8[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
1296 pci_am1[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1297 w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
1298 w_conf_data_out[0] = pci_ba1_bit0 & pci_am1[31];
1299 w_reg_select_dec = 57'h000_0000_0000_0100 ; // The same for another address
1301 8'h6: // w_reg_select_dec bit 12
1303 w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba2_bit31_8[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
1304 pci_am2[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1305 w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
1306 w_conf_data_out[0] = pci_ba2_bit0 & pci_am2[31];
1307 w_reg_select_dec = 57'h000_0000_0000_1000 ; // The same for another address
1309 8'h7: // w_reg_select_dec bit 16
1311 w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba3_bit31_8[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
1312 pci_am3[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1313 w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
1314 w_conf_data_out[0] = pci_ba3_bit0 & pci_am3[31];
1315 w_reg_select_dec = 57'h000_0000_0001_0000 ; // The same for another address
1317 8'h8: // w_reg_select_dec bit 20
1319 w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba4_bit31_8[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
1320 pci_am4[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1321 w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
1322 w_conf_data_out[0] = pci_ba4_bit0 & pci_am4[31];
1323 w_reg_select_dec = 57'h000_0000_0010_0000 ; // The same for another address
1325 8'h9: // w_reg_select_dec bit 24
1327 w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba5_bit31_8[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
1328 pci_am5[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1329 w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
1330 w_conf_data_out[0] = pci_ba5_bit0 & pci_am5[31];
1331 w_reg_select_dec = 57'h000_0000_0100_0000 ; // The same for another address
1335 w_conf_data_out = {r_subsys_id, r_subsys_vendor_id} ;
1336 w_reg_select_dec = 57'h000_0000_0000_0000 ;
1339 `ifdef PCI_CPCI_HS_IMPLEMENT
1342 w_conf_data_out = {24'h0000_00, `PCI_CAP_PTR_VAL} ;
1343 w_reg_select_dec = 57'h000_0000_0000_0000 ; // Read-Only register
1346 8'hf: // w_reg_select_dec bit 2
1348 w_conf_data_out = { r_max_lat, r_min_gnt, r_interrupt_pin, interrupt_line } ;
1349 w_reg_select_dec = 57'h000_0000_0000_0004 ;
1351 `ifdef PCI_CPCI_HS_IMPLEMENT
1352 (`PCI_CAP_PTR_VAL >> 2):
1354 w_reg_select_dec = 57'h100_0000_0000_0000 ;
1355 w_conf_data_out = {8'h00, hs_ins, hs_ext, hs_pi, hs_loo, 1'b0, hs_eim, 1'b0, 8'h00, hs_cap_id} ;
1358 {2'b01, `P_IMG_CTRL0_ADDR}: // w_reg_select_dec bit 3
1360 w_conf_data_out = { 29'h00000000, pci_img_ctrl0_bit2_1, 1'h0 } ;
1361 w_reg_select_dec = 57'h000_0000_0000_0008 ;
1363 {2'b01, `P_BA0_ADDR}: // w_reg_select_dec bit 4
1367 w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba0_bit31_8[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
1368 pci_am0[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1369 w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
1370 w_conf_data_out[0] = pci_ba0_bit0 & pci_am0[31];
1372 w_conf_data_out[31:12] = pci_ba0_bit31_8[31:12] ;
1373 w_conf_data_out[11: 0] = 12'h000 ;
1378 w_conf_data_out[31:12] = pci_ba0_bit31_8[31:12] ;
1379 w_conf_data_out[11: 0] = 12'h000 ;
1381 w_reg_select_dec = 57'h000_0000_0000_0010 ; // The same for another address
1383 {2'b01, `P_AM0_ADDR}: // w_reg_select_dec bit 5
1387 w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_am0[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1388 w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1390 w_conf_data_out[31:12] = pci_am0[31:12] ;
1391 w_conf_data_out[11: 0] = 12'h000 ;
1396 w_conf_data_out[31:12] = pci_am0[31:12] ;
1397 w_conf_data_out[11: 0] = 12'h000 ;
1399 w_reg_select_dec = 57'h000_0000_0000_0020 ;
1401 {2'b01, `P_TA0_ADDR}: // w_reg_select_dec bit 6
1403 w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ta0[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1404 w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1405 w_reg_select_dec = 57'h000_0000_0000_0040 ;
1407 {2'b01, `P_IMG_CTRL1_ADDR}: // w_reg_select_dec bit 7
1409 w_conf_data_out = { 29'h00000000, pci_img_ctrl1_bit2_1, 1'h0 } ;
1410 w_reg_select_dec = 57'h000_0000_0000_0080 ;
1412 {2'b01, `P_BA1_ADDR}: // w_reg_select_dec bit 8
1414 w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba1_bit31_8[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
1415 pci_am1[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1416 w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
1417 w_conf_data_out[0] = pci_ba1_bit0 & pci_am1[31];
1418 w_reg_select_dec = 57'h000_0000_0000_0100 ; // The same for another address
1420 {2'b01, `P_AM1_ADDR}: // w_reg_select_dec bit 9
1422 w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_am1[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1423 w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1424 w_reg_select_dec = 57'h000_0000_0000_0200 ;
1426 {2'b01, `P_TA1_ADDR}: // w_reg_select_dec bit 10
1428 w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ta1[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1429 w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1430 w_reg_select_dec = 57'h000_0000_0000_0400 ;
1432 {2'b01, `P_IMG_CTRL2_ADDR}: // w_reg_select_dec bit 11
1434 w_conf_data_out = { 29'h00000000, pci_img_ctrl2_bit2_1, 1'h0 } ;
1435 w_reg_select_dec = 57'h000_0000_0000_0800 ;
1437 {2'b01, `P_BA2_ADDR}: // w_reg_select_dec bit 12
1439 w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba2_bit31_8[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
1440 pci_am2[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1441 w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
1442 w_conf_data_out[0] = pci_ba2_bit0 & pci_am2[31];
1443 w_reg_select_dec = 57'h000_0000_0000_1000 ; // The same for another address
1445 {2'b01, `P_AM2_ADDR}: // w_reg_select_dec bit 13
1447 w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_am2[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1448 w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1449 w_reg_select_dec = 57'h000_0000_0000_2000 ;
1451 {2'b01, `P_TA2_ADDR}: // w_reg_select_dec bit 14
1453 w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ta2[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1454 w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1455 w_reg_select_dec = 57'h000_0000_0000_4000 ;
1457 {2'b01, `P_IMG_CTRL3_ADDR}: // w_reg_select_dec bit 15
1459 w_conf_data_out = { 29'h00000000, pci_img_ctrl3_bit2_1, 1'h0 } ;
1460 w_reg_select_dec = 57'h000_0000_0000_8000 ;
1462 {2'b01, `P_BA3_ADDR}: // w_reg_select_dec bit 16
1464 w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba3_bit31_8[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
1465 pci_am3[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1466 w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
1467 w_conf_data_out[0] = pci_ba3_bit0 & pci_am3[31];
1468 w_reg_select_dec = 57'h000_0000_0001_0000 ; // The same for another address
1470 {2'b01, `P_AM3_ADDR}: // w_reg_select_dec bit 17
1472 w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_am3[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1473 w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1474 w_reg_select_dec = 57'h000_0000_0002_0000 ;
1476 {2'b01, `P_TA3_ADDR}: // w_reg_select_dec bit 18
1478 w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ta3[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1479 w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1480 w_reg_select_dec = 57'h000_0000_0004_0000 ;
1482 {2'b01, `P_IMG_CTRL4_ADDR}: // w_reg_select_dec bit 19
1484 w_conf_data_out = { 29'h00000000, pci_img_ctrl4_bit2_1, 1'h0 } ;
1485 w_reg_select_dec = 57'h000_0000_0008_0000 ;
1487 {2'b01, `P_BA4_ADDR}: // w_reg_select_dec bit 20
1489 w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba4_bit31_8[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
1490 pci_am4[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1491 w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
1492 w_conf_data_out[0] = pci_ba4_bit0 & pci_am4[31];
1493 w_reg_select_dec = 57'h000_0000_0010_0000 ; // The same for another address
1495 {2'b01, `P_AM4_ADDR}: // w_reg_select_dec bit 21
1497 w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_am4[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1498 w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1499 w_reg_select_dec = 57'h000_0000_0020_0000 ;
1501 {2'b01, `P_TA4_ADDR}: // w_reg_select_dec bit 22
1503 w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ta4[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1504 w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1505 w_reg_select_dec = 57'h000_0000_0040_0000 ;
1507 {2'b01, `P_IMG_CTRL5_ADDR}: // w_reg_select_dec bit 23
1509 w_conf_data_out = { 29'h00000000, pci_img_ctrl5_bit2_1, 1'h0 } ;
1510 w_reg_select_dec = 57'h000_0000_0080_0000 ;
1512 {2'b01, `P_BA5_ADDR}: // w_reg_select_dec bit 24
1514 w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba5_bit31_8[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
1515 pci_am5[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1516 w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
1517 w_conf_data_out[0] = pci_ba5_bit0 & pci_am5[31];
1518 w_reg_select_dec = 57'h000_0000_0100_0000 ; // The same for another address
1520 {2'b01, `P_AM5_ADDR}: // w_reg_select_dec bit 25
1522 w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_am5[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1523 w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1524 w_reg_select_dec = 57'h000_0000_0200_0000 ;
1526 {2'b01, `P_TA5_ADDR}: // w_reg_select_dec bit 26
1528 w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ta5[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1529 w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1530 w_reg_select_dec = 57'h000_0000_0400_0000 ;
1532 {2'b01, `P_ERR_CS_ADDR}: // w_reg_select_dec bit 27
1534 w_conf_data_out = { pci_err_cs_bit31_24, 13'h0000, pci_err_cs_bit10, pci_err_cs_bit9,
1535 pci_err_cs_bit8, 7'h00, pci_err_cs_bit0 } ;
1536 w_reg_select_dec = 57'h000_0000_0800_0000 ;
1538 {2'b01, `P_ERR_ADDR_ADDR}: // w_reg_select_dec bit 28
1540 w_conf_data_out = pci_err_addr ;
1541 w_reg_select_dec = 57'h000_0000_0000_0000 ; // = 56'h00_0000_1000_0000 ;
1543 {2'b01, `P_ERR_DATA_ADDR}: // w_reg_select_dec bit 29
1545 w_conf_data_out = pci_err_data ;
1546 w_reg_select_dec = 57'h000_0000_0000_0000 ; // = 56'h00_0000_2000_0000 ;
1548 // WB slave - configuration space
1549 {2'b01, `WB_CONF_SPC_BAR_ADDR}:
1551 w_conf_data_out = { wb_ba0_bit31_12, 11'h000, wb_ba0_bit0 } ;
1552 w_reg_select_dec = 57'h000_0000_0000_0000 ; // Read-Only register
1554 {2'b01, `W_IMG_CTRL1_ADDR}: // w_reg_select_dec bit 30
1556 w_conf_data_out = { 29'h00000000, wb_img_ctrl1_bit2_0 } ;
1557 w_reg_select_dec = 57'h000_0000_4000_0000 ;
1559 {2'b01, `W_BA1_ADDR}: // w_reg_select_dec bit 31
1561 w_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ba1_bit31_12[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] &
1562 wb_am1[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1563 w_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
1564 w_conf_data_out[0] = wb_ba1_bit0 ;
1565 w_reg_select_dec = 57'h000_0000_8000_0000 ;
1567 {2'b01, `W_AM1_ADDR}: // w_reg_select_dec bit 32
1569 w_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_am1[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1570 w_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1571 w_reg_select_dec = 57'h000_0001_0000_0000 ;
1573 {2'b01, `W_TA1_ADDR}: // w_reg_select_dec bit 33
1575 w_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ta1[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1576 w_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1577 w_reg_select_dec = 57'h000_0002_0000_0000 ;
1579 {2'b01, `W_IMG_CTRL2_ADDR}: // w_reg_select_dec bit 34
1581 w_conf_data_out = { 29'h00000000, wb_img_ctrl2_bit2_0 } ;
1582 w_reg_select_dec = 57'h000_0004_0000_0000 ;
1584 {2'b01, `W_BA2_ADDR}: // w_reg_select_dec bit 35
1586 w_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ba2_bit31_12[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] &
1587 wb_am2[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1588 w_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
1589 w_conf_data_out[0] = wb_ba2_bit0 ;
1590 w_reg_select_dec = 57'h000_0008_0000_0000 ;
1592 {2'b01, `W_AM2_ADDR}: // w_reg_select_dec bit 36
1594 w_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_am2[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1595 w_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1596 w_reg_select_dec = 57'h000_0010_0000_0000 ;
1598 {2'b01, `W_TA2_ADDR}: // w_reg_select_dec bit 37
1600 w_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ta2[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1601 w_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1602 w_reg_select_dec = 57'h000_0020_0000_0000 ;
1604 {2'b01, `W_IMG_CTRL3_ADDR}: // w_reg_select_dec bit 38
1606 w_conf_data_out = { 29'h00000000, wb_img_ctrl3_bit2_0 } ;
1607 w_reg_select_dec = 57'h000_0040_0000_0000 ;
1609 {2'b01, `W_BA3_ADDR}: // w_reg_select_dec bit 39
1611 w_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ba3_bit31_12[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] &
1612 wb_am3[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1613 w_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
1614 w_conf_data_out[0] = wb_ba3_bit0 ;
1615 w_reg_select_dec = 57'h000_0080_0000_0000 ;
1617 {2'b01, `W_AM3_ADDR}: // w_reg_select_dec bit 40
1619 w_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_am3[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1620 w_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1621 w_reg_select_dec = 57'h000_0100_0000_0000 ;
1623 {2'b01, `W_TA3_ADDR}: // w_reg_select_dec bit 41
1625 w_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ta3[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1626 w_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1627 w_reg_select_dec = 57'h000_0200_0000_0000 ;
1629 {2'b01, `W_IMG_CTRL4_ADDR}: // w_reg_select_dec bit 42
1631 w_conf_data_out = { 29'h00000000, wb_img_ctrl4_bit2_0 } ;
1632 w_reg_select_dec = 57'h000_0400_0000_0000 ;
1634 {2'b01, `W_BA4_ADDR}: // w_reg_select_dec bit 43
1636 w_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ba4_bit31_12[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] &
1637 wb_am4[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1638 w_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
1639 w_conf_data_out[0] = wb_ba4_bit0 ;
1640 w_reg_select_dec = 57'h000_0800_0000_0000 ;
1642 {2'b01, `W_AM4_ADDR}: // w_reg_select_dec bit 44
1644 w_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_am4[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1645 w_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1646 w_reg_select_dec = 57'h000_1000_0000_0000 ;
1648 {2'b01, `W_TA4_ADDR}: // w_reg_select_dec bit 45
1650 w_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ta4[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1651 w_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1652 w_reg_select_dec = 57'h000_2000_0000_0000 ;
1654 {2'b01, `W_IMG_CTRL5_ADDR}: // w_reg_select_dec bit 46
1656 w_conf_data_out = { 29'h00000000, wb_img_ctrl5_bit2_0 } ;
1657 w_reg_select_dec = 57'h000_4000_0000_0000 ;
1659 {2'b01, `W_BA5_ADDR}: // w_reg_select_dec bit 47
1661 w_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ba5_bit31_12[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] &
1662 wb_am5[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1663 w_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
1664 w_conf_data_out[0] = wb_ba5_bit0 ;
1665 w_reg_select_dec = 57'h000_8000_0000_0000 ;
1667 {2'b01, `W_AM5_ADDR}: // w_reg_select_dec bit 48
1669 w_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_am5[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1670 w_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1671 w_reg_select_dec = 57'h001_0000_0000_0000 ;
1673 {2'b01, `W_TA5_ADDR}: // w_reg_select_dec bit 49
1675 w_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ta5[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1676 w_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1677 w_reg_select_dec = 57'h002_0000_0000_0000 ;
1679 {2'b01, `W_ERR_CS_ADDR}: // w_reg_select_dec bit 50
1681 w_conf_data_out = { wb_err_cs_bit31_24, /*13*/14'h0000, /*wb_err_cs_bit10,*/
1682 wb_err_cs_bit9, wb_err_cs_bit8, 7'h00, wb_err_cs_bit0 } ;
1683 w_reg_select_dec = 57'h004_0000_0000_0000 ;
1685 {2'b01, `W_ERR_ADDR_ADDR}: // w_reg_select_dec bit 51
1687 w_conf_data_out = wb_err_addr ;
1688 w_reg_select_dec = 57'h008_0000_0000_0000 ;
1690 {2'b01, `W_ERR_DATA_ADDR}: // w_reg_select_dec bit 52
1692 w_conf_data_out = wb_err_data ;
1693 w_reg_select_dec = 57'h010_0000_0000_0000 ;
1695 {2'b01, `CNF_ADDR_ADDR}: // w_reg_select_dec bit 53
1697 w_conf_data_out = { 8'h00, cnf_addr_bit23_2, 1'h0, cnf_addr_bit0 } ;
1698 w_reg_select_dec = 57'h020_0000_0000_0000 ;
1700 // `CNF_DATA_ADDR: implemented elsewhere !!!
1701 // `INT_ACK_ADDR: implemented elsewhere !!!
1702 {2'b01, `ICR_ADDR}: // w_reg_select_dec bit 54
1704 w_conf_data_out = { icr_bit31, 26'h0000_000, icr_bit4_3, icr_bit2_0 } ;
1705 w_reg_select_dec = 57'h040_0000_0000_0000 ;
1707 {2'b01, `ISR_ADDR}: // w_reg_select_dec bit 55
1709 w_conf_data_out = { 27'h0000_000, isr_bit4_3, isr_bit2_0 } ;
1710 w_reg_select_dec = 57'h080_0000_0000_0000 ;
1716 w_conf_data_out = {spoci_cs_nack, 5'h0, spoci_cs_write, spoci_cs_read,
1717 5'h0, spoci_cs_adr[10:8],
1719 spoci_cs_dat[7:0]} ;
1721 // this register is implemented separate from other registers, because
1722 // it has special features implemented
1723 w_reg_select_dec = 57'h000_0000_0000_0000 ;
1729 w_conf_data_out = 32'h0000_0000 ;
1730 w_reg_select_dec = 57'h000_0000_0000_0000 ;
1738 reg [31: 0] spoci_dat ;
1739 wire [31: 0] w_conf_data = init_cfg_done ? w_conf_data_in : spoci_dat ;
1740 wire [ 3: 0] w_byte_en = init_cfg_done ? w_byte_en_in : 4'b0000 ;
1742 wire init_we = 1'b0 ;
1743 wire init_cfg_done = 1'b1 ;
1744 wire [31: 0] w_conf_data = w_conf_data_in ;
1745 wire [ 3: 0] w_byte_en = w_byte_en_in ;
1746 wire [31: 0] spoci_dat = 'h0000_0000 ;
1749 // Reduced write data for BASE, MASK and TRANSLATION registers of PCI and WB images
1750 assign w_conf_pdata_reduced[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = w_conf_data[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1751 assign w_conf_pdata_reduced[(31-`PCI_NUM_OF_DEC_ADDR_LINES): 0] = 0 ;
1752 assign w_conf_wdata_reduced[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = w_conf_data[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1753 assign w_conf_wdata_reduced[(31-`WB_NUM_OF_DEC_ADDR_LINES): 0] = 0 ;
1755 wire w_we = w_we_i | init_we ;
1757 always@(posedge w_clock or posedge reset)
1759 // Here are implemented all registers that are reset with RESET signal otherwise they can be normaly written!!!
1760 // Registers that are commented are implemented after this alwasy statement, because they are e.g. reset with
1761 // RESET signal, set with some status signal and they are erased with writting '1' into them !!!
1764 /*status_bit15_11 ; status_bit8 ;*/ command_bit8 <= 1'h0 ; command_bit6 <= 1'h0 ; command_bit2_0 <= 3'h0 ;
1765 latency_timer <= 8'h00 ; cache_line_size_reg <= 8'h00 ;
1766 // ALL pci_base address registers are the same as pci_baX registers !
1767 interrupt_line <= 8'h00 ;
1770 `ifdef NO_CNF_IMAGE // if PCI bridge is HOST and IMAGE0 is assigned as general image space
1772 pci_img_ctrl0_bit2_1 <= {`PCI_AT_EN0, 1'b0} ;
1773 pci_ba0_bit31_8 <= 24'h0000_00 ;
1774 pci_ba0_bit0 <= `PCI_BA0_MEM_IO ;
1775 pci_am0 <= `PCI_AM0 ;
1776 pci_ta0 <= `PCI_TA0 ;//fr2201 translation address
1779 pci_ba0_bit31_8 <= 24'h0000_00 ;
1784 pci_ba0_bit31_8 <= 24'h0000_00 ;
1787 pci_img_ctrl1_bit2_1 <= {`PCI_AT_EN1, 1'b0} ;
1789 pci_ba1_bit31_8 <= 24'h0000_00 ;
1791 pci_ba1_bit0 <= `PCI_BA1_MEM_IO ;
1793 pci_am1 <= `PCI_AM1;
1794 pci_ta1 <= `PCI_TA1 ;//FR2201 translation address ;
1797 pci_img_ctrl2_bit2_1 <= {`PCI_AT_EN2, 1'b0} ;
1799 pci_ba2_bit31_8 <= 24'h0000_00 ;
1801 pci_ba2_bit0 <= `PCI_BA2_MEM_IO ;
1803 pci_am2 <= `PCI_AM2;
1804 pci_ta2 <= `PCI_TA2 ;//FR2201 translation address ;
1808 pci_img_ctrl3_bit2_1 <= {`PCI_AT_EN3, 1'b0} ; //FR2201 when defined enabled
1810 pci_ba3_bit31_8 <= 24'h0000_00 ;
1812 pci_ba3_bit0 <= `PCI_BA3_MEM_IO ;
1814 pci_am3 <= `PCI_AM3;
1815 pci_ta3 <= `PCI_TA3 ;//FR2201 translation address ;
1819 pci_img_ctrl4_bit2_1 <= {`PCI_AT_EN4, 1'b0} ; //FR2201 when defined enabled
1821 pci_ba4_bit31_8 <= 24'h0000_00 ;
1823 pci_ba4_bit0 <= `PCI_BA4_MEM_IO ;
1825 pci_am4 <= `PCI_AM4;
1826 pci_ta4 <= `PCI_TA4 ;//FR2201 translation address ;
1830 pci_img_ctrl5_bit2_1 <= {`PCI_AT_EN5, 1'b0} ; //FR2201 when defined enabled
1832 pci_ba5_bit31_8 <= 24'h0000_00 ;
1834 pci_ba5_bit0 <= `PCI_BA5_MEM_IO ;
1836 pci_am5 <= `PCI_AM5; //FR2201 pci_am0
1837 pci_ta5 <= `PCI_TA5 ;//FR2201 translation address ;
1839 /*pci_err_cs_bit31_24 ; pci_err_cs_bit10; pci_err_cs_bit9 ; pci_err_cs_bit8 ;*/ pci_err_cs_bit0 <= 1'h0 ;
1843 wb_img_ctrl1_bit2_0 <= {`WB_AT_EN1, 2'b00} ;
1845 wb_ba1_bit31_12 <=`WB_BA1; //FR2201 Address bar
1846 wb_ba1_bit0 <=`WB_BA1_MEM_IO;//
1847 wb_am1 <= `WB_AM1 ;//FR2201 Address mask
1848 wb_ta1 <= `WB_TA1 ;//FR2201 20'h0000_0 ;
1850 wb_img_ctrl2_bit2_0 <= {`WB_AT_EN2, 2'b00} ;
1852 wb_ba2_bit31_12 <=`WB_BA2; //FR2201 Address bar
1853 wb_ba2_bit0 <=`WB_BA2_MEM_IO;//
1854 wb_am2 <=`WB_AM2 ;//FR2201 Address mask
1855 wb_ta2 <=`WB_TA2 ;//FR2201 translation address ;
1858 wb_img_ctrl3_bit2_0 <= {`WB_AT_EN3, 2'b00} ;
1860 wb_ba3_bit31_12 <=`WB_BA3; //FR2201 Address bar
1861 wb_ba3_bit0 <=`WB_BA3_MEM_IO;//
1862 wb_am3 <=`WB_AM3 ;//FR2201 Address mask
1863 wb_ta3 <=`WB_TA3 ;//FR2201 translation address ;
1866 wb_img_ctrl4_bit2_0 <= {`WB_AT_EN4, 2'b00} ;
1868 wb_ba4_bit31_12 <=`WB_BA4; //FR2201 Address bar
1869 wb_ba4_bit0 <=`WB_BA4_MEM_IO;//
1870 wb_am4 <=`WB_AM4 ;//FR2201 Address mask
1871 wb_ta4 <=`WB_TA4 ;//FR2201 translation address ;
1874 wb_img_ctrl5_bit2_0 <= {`WB_AT_EN5, 2'b00} ;
1876 wb_ba5_bit31_12 <=`WB_BA5; //FR2201 Address bar ;
1877 wb_ba5_bit0 <=`WB_BA5_MEM_IO;//FR2201 1'h0 ;
1878 wb_am5 <=`WB_AM5 ;//FR2201 Address mask
1879 wb_ta5 <=`WB_TA5 ;//FR2201 translation address ;
1881 /*wb_err_cs_bit31_24 ; wb_err_cs_bit10 ; wb_err_cs_bit9 ; wb_err_cs_bit8 ;*/ wb_err_cs_bit0 <= 1'h0 ;
1886 cnf_addr_bit23_2 <= 22'h0000_00 ; cnf_addr_bit0 <= 1'h0 ;
1891 icr_bit2_0 <= 3'h0 ;
1892 icr_bit4_3 <= 2'h0 ;
1894 icr_bit2_0[2:0] <= 3'h0 ;
1896 /*isr_bit4_3 ; isr_bit2_0 ;*/
1898 // Not register bit; used only internally after reset!
1899 init_complete <= 1'b0 ;
1902 rst_inactive_sync <= 1'b0 ;
1903 rst_inactive <= 1'b0 ;
1906 `ifdef PCI_CPCI_HS_IMPLEMENT
1907 /*hs_ins hs_ext*/ hs_loo <= 1'b0; hs_eim <= 1'b0;
1908 // Not register bits; used only internally after reset!
1909 /*hs_ins_armed hs_ext_armed*/
1912 /* -----------------------------------------------------------------------------------------------------------
1913 Following register bits should have asynchronous RESET & SET! That is why they are IMPLEMENTED separately
1914 after this ALWAYS block!!! (for every register bit, there are two D-FF implemented)
1915 status_bit15_11[15] <= 1'b1 ;
1916 status_bit15_11[14] <= 1'b1 ;
1917 status_bit15_11[13] <= 1'b1 ;
1918 status_bit15_11[12] <= 1'b1 ;
1919 status_bit15_11[11] <= 1'b1 ;
1920 status_bit8 <= 1'b1 ;
1921 pci_err_cs_bit10 <= 1'b1 ;
1922 pci_err_cs_bit9 <= 1'b1 ;
1923 pci_err_cs_bit8 <= 1'b1 ;
1924 pci_err_cs_bit31_24 <= { pci_error_be, pci_error_bc } ;
1925 pci_err_addr <= pci_error_addr ;
1926 pci_err_data <= pci_error_data ;
1927 wb_err_cs_bit10 <= 1'b1 ;
1928 wb_err_cs_bit9 <= 1'b1 ;
1929 wb_err_cs_bit8 <= 1'b1 ;
1930 wb_err_cs_bit31_24 <= { wb_error_be, wb_error_bc } ;
1931 wb_err_addr <= wb_error_addr ;
1932 wb_err_data <= wb_error_data ;
1933 isr_bit4_0[4] <= 1'b1 & icr_bit4_0[4] ;
1934 isr_bit4_0[3] <= 1'b1 & icr_bit4_0[3] ;
1935 isr_bit4_0[2] <= 1'b1 & icr_bit4_0[2] ;
1936 isr_bit4_0[1] <= 1'b1 & icr_bit4_0[1] ;
1937 isr_bit4_0[0] <= 1'b1 & icr_bit4_0[0] ;
1940 -----------------------------------------------------------------------------------------------------------*/
1941 // Here follows normal writting to registers (only to their valid bits) !
1946 // PCI header - configuration space
1947 if (w_reg_select_dec[0]) // w_conf_address[5:2] = 4'h1:
1950 command_bit8 <= w_conf_data[8] ;
1953 command_bit6 <= w_conf_data[6] ;
1954 command_bit2_0 <= w_conf_data[2:0] ;
1957 if (w_reg_select_dec[1]) // w_conf_address[5:2] = 4'h3:
1960 latency_timer <= w_conf_data[15:8] ;
1962 cache_line_size_reg <= w_conf_data[7:0] ;
1964 // if (w_reg_select_dec[4]) // w_conf_address[5:2] = 4'h4:
1965 // Also used with IMAGE0
1967 // if (w_reg_select_dec[8]) // w_conf_address[5:2] = 4'h5:
1968 // Also used with IMAGE1
1970 // if (w_reg_select_dec[12]) // w_conf_address[5:2] = 4'h6:
1971 // Also used with IMAGE2
1973 // if (w_reg_select_dec[16]) // w_conf_address[5:2] = 4'h7:
1974 // Also used with IMAGE3
1976 // if (w_reg_select_dec[20]) // w_conf_address[5:2] = 4'h8:
1977 // Also used with IMAGE4
1979 // if (w_reg_select_dec[24]) // w_conf_address[5:2] = 4'h9:
1980 // Also used with IMAGE5 and IMAGE6
1981 if (w_reg_select_dec[2]) // w_conf_address[5:2] = 4'hf:
1984 interrupt_line <= w_conf_data[7:0] ;
1986 // PCI target - configuration space
1989 `ifdef PCI_IMAGE0 // if PCI bridge is HOST and IMAGE0 is assigned as general image space
1990 if (w_reg_select_dec[3]) // case (w_conf_address[7:2]) = `P_IMG_CTRL0_ADDR:
1993 pci_img_ctrl0_bit2_1 <= w_conf_data[2:1] ;
1995 if (w_reg_select_dec[4]) // case (w_conf_address[7:2]) = `P_BA0_ADDR:
1998 pci_ba0_bit31_8[31:24] <= w_conf_pdata_reduced[31:24] ;
2000 pci_ba0_bit31_8[23:16] <= w_conf_pdata_reduced[23:16] ;
2002 pci_ba0_bit31_8[15: 8] <= w_conf_pdata_reduced[15: 8] ;
2004 pci_ba0_bit0 <= w_conf_data[0] ;
2006 if (w_reg_select_dec[5]) // case (w_conf_address[7:2]) = `P_AM0_ADDR:
2009 pci_am0[31:24] <= w_conf_pdata_reduced[31:24] ;
2011 pci_am0[23:16] <= w_conf_pdata_reduced[23:16] ;
2013 pci_am0[15: 8] <= w_conf_pdata_reduced[15: 8] ;
2015 if (w_reg_select_dec[6]) // case (w_conf_address[7:2]) = `P_TA0_ADDR:
2018 pci_ta0[31:24] <= w_conf_pdata_reduced[31:24] ;
2020 pci_ta0[23:16] <= w_conf_pdata_reduced[23:16] ;
2022 pci_ta0[15: 8] <= w_conf_pdata_reduced[15: 8] ;
2026 if (w_reg_select_dec[4]) // case (w_conf_address[7:2]) = `P_BA0_ADDR:
2029 pci_ba0_bit31_8[31:24] <= w_conf_data[31:24] ;
2031 pci_ba0_bit31_8[23:16] <= w_conf_data[23:16] ;
2033 pci_ba0_bit31_8[15:12] <= w_conf_data[15:12] ;
2039 if (w_reg_select_dec[4]) // case (w_conf_address[7:2]) = `P_BA0_ADDR:
2042 pci_ba0_bit31_8[31:24] <= w_conf_data[31:24] ;
2044 pci_ba0_bit31_8[23:16] <= w_conf_data[23:16] ;
2046 pci_ba0_bit31_8[15:12] <= w_conf_data[15:12] ;
2049 if (w_reg_select_dec[7]) // case (w_conf_address[7:2]) = `P_IMG_CTRL1_ADDR:
2052 pci_img_ctrl1_bit2_1 <= w_conf_data[2:1] ;
2054 if (w_reg_select_dec[8]) // case (w_conf_address[7:2]) = `P_BA1_ADDR:
2057 pci_ba1_bit31_8[31:24] <= w_conf_pdata_reduced[31:24] ;
2059 pci_ba1_bit31_8[23:16] <= w_conf_pdata_reduced[23:16] ;
2061 pci_ba1_bit31_8[15: 8] <= w_conf_pdata_reduced[15: 8] ;
2064 pci_ba1_bit0 <= w_conf_data[0] ;
2067 if (w_reg_select_dec[9]) // case (w_conf_address[7:2]) = `P_AM1_ADDR:
2070 pci_am1[31:24] <= w_conf_pdata_reduced[31:24] ;
2072 pci_am1[23:16] <= w_conf_pdata_reduced[23:16] ;
2074 pci_am1[15: 8] <= w_conf_pdata_reduced[15: 8] ;
2076 if (w_reg_select_dec[10]) // case (w_conf_address[7:2]) = `P_TA1_ADDR:
2079 pci_ta1[31:24] <= w_conf_pdata_reduced[31:24] ;
2081 pci_ta1[23:16] <= w_conf_pdata_reduced[23:16] ;
2083 pci_ta1[15: 8] <= w_conf_pdata_reduced[15: 8] ;
2086 if (w_reg_select_dec[11]) // case (w_conf_address[7:2]) = `P_IMG_CTRL2_ADDR:
2089 pci_img_ctrl2_bit2_1 <= w_conf_data[2:1] ;
2091 if (w_reg_select_dec[12]) // case (w_conf_address[7:2]) = `P_BA2_ADDR:
2094 pci_ba2_bit31_8[31:24] <= w_conf_pdata_reduced[31:24] ;
2096 pci_ba2_bit31_8[23:16] <= w_conf_pdata_reduced[23:16] ;
2098 pci_ba2_bit31_8[15: 8] <= w_conf_pdata_reduced[15: 8] ;
2101 pci_ba2_bit0 <= w_conf_data[0] ;
2104 if (w_reg_select_dec[13]) // case (w_conf_address[7:2]) = `P_AM2_ADDR:
2107 pci_am2[31:24] <= w_conf_pdata_reduced[31:24] ;
2109 pci_am2[23:16] <= w_conf_pdata_reduced[23:16] ;
2111 pci_am2[15: 8] <= w_conf_pdata_reduced[15: 8] ;
2113 if (w_reg_select_dec[14]) // case (w_conf_address[7:2]) = `P_TA2_ADDR:
2116 pci_ta2[31:24] <= w_conf_pdata_reduced[31:24] ;
2118 pci_ta2[23:16] <= w_conf_pdata_reduced[23:16] ;
2120 pci_ta2[15: 8] <= w_conf_pdata_reduced[15: 8] ;
2124 if (w_reg_select_dec[15]) // case (w_conf_address[7:2]) = `P_IMG_CTRL3_ADDR:
2127 pci_img_ctrl3_bit2_1 <= w_conf_data[2:1] ;
2129 if (w_reg_select_dec[16]) // case (w_conf_address[7:2]) = `P_BA3_ADDR:
2132 pci_ba3_bit31_8[31:24] <= w_conf_pdata_reduced[31:24] ;
2134 pci_ba3_bit31_8[23:16] <= w_conf_pdata_reduced[23:16] ;
2136 pci_ba3_bit31_8[15: 8] <= w_conf_pdata_reduced[15: 8] ;
2139 pci_ba3_bit0 <= w_conf_data[0] ;
2142 if (w_reg_select_dec[17]) // case (w_conf_address[7:2]) = `P_AM3_ADDR:
2145 pci_am3[31:24] <= w_conf_pdata_reduced[31:24] ;
2147 pci_am3[23:16] <= w_conf_pdata_reduced[23:16] ;
2149 pci_am3[15: 8] <= w_conf_pdata_reduced[15: 8] ;
2151 if (w_reg_select_dec[18]) // case (w_conf_address[7:2]) = `P_TA3_ADDR:
2154 pci_ta3[31:24] <= w_conf_pdata_reduced[31:24] ;
2156 pci_ta3[23:16] <= w_conf_pdata_reduced[23:16] ;
2158 pci_ta3[15: 8] <= w_conf_pdata_reduced[15: 8] ;
2162 if (w_reg_select_dec[19]) // case (w_conf_address[7:2]) = `P_IMG_CTRL4_ADDR:
2165 pci_img_ctrl4_bit2_1 <= w_conf_data[2:1] ;
2167 if (w_reg_select_dec[20]) // case (w_conf_address[7:2]) = `P_BA4_ADDR:
2170 pci_ba4_bit31_8[31:24] <= w_conf_pdata_reduced[31:24] ;
2172 pci_ba4_bit31_8[23:16] <= w_conf_pdata_reduced[23:16] ;
2174 pci_ba4_bit31_8[15: 8] <= w_conf_pdata_reduced[15: 8] ;
2177 pci_ba4_bit0 <= w_conf_data[0] ;
2180 if (w_reg_select_dec[21]) // case (w_conf_address[7:2]) = `P_AM4_ADDR:
2183 pci_am4[31:24] <= w_conf_pdata_reduced[31:24] ;
2185 pci_am4[23:16] <= w_conf_pdata_reduced[23:16] ;
2187 pci_am4[15: 8] <= w_conf_pdata_reduced[15: 8] ;
2189 if (w_reg_select_dec[22]) // case (w_conf_address[7:2]) = `P_TA4_ADDR:
2192 pci_ta4[31:24] <= w_conf_pdata_reduced[31:24] ;
2194 pci_ta4[23:16] <= w_conf_pdata_reduced[23:16] ;
2196 pci_ta4[15: 8] <= w_conf_pdata_reduced[15: 8] ;
2200 if (w_reg_select_dec[23]) // case (w_conf_address[7:2]) = `P_IMG_CTRL5_ADDR:
2203 pci_img_ctrl5_bit2_1 <= w_conf_data[2:1] ;
2205 if (w_reg_select_dec[24]) // case (w_conf_address[7:2]) = `P_BA5_ADDR:
2208 pci_ba5_bit31_8[31:24] <= w_conf_pdata_reduced[31:24] ;
2210 pci_ba5_bit31_8[23:16] <= w_conf_pdata_reduced[23:16] ;
2212 pci_ba5_bit31_8[15: 8] <= w_conf_pdata_reduced[15: 8] ;
2215 pci_ba5_bit0 <= w_conf_data[0] ;
2218 if (w_reg_select_dec[25]) // case (w_conf_address[7:2]) = `P_AM5_ADDR:
2221 pci_am5[31:24] <= w_conf_pdata_reduced[31:24] ;
2223 pci_am5[23:16] <= w_conf_pdata_reduced[23:16] ;
2225 pci_am5[15: 8] <= w_conf_pdata_reduced[15: 8] ;
2227 if (w_reg_select_dec[26]) // case (w_conf_address[7:2]) = `P_TA5_ADDR:
2230 pci_ta5[31:24] <= w_conf_pdata_reduced[31:24] ;
2232 pci_ta5[23:16] <= w_conf_pdata_reduced[23:16] ;
2234 pci_ta5[15: 8] <= w_conf_pdata_reduced[15: 8] ;
2237 if (w_reg_select_dec[27]) // case (w_conf_address[7:2]) = `P_ERR_CS_ADDR:
2240 pci_err_cs_bit0 <= w_conf_data[0] ;
2242 // WB slave - configuration space
2243 if (w_reg_select_dec[30]) // case (w_conf_address[7:2]) = `W_IMG_CTRL1_ADDR:
2246 wb_img_ctrl1_bit2_0 <= w_conf_data[2:0] ;
2248 if (w_reg_select_dec[31]) // case (w_conf_address[7:2]) = `W_BA1_ADDR:
2251 wb_ba1_bit31_12[31:24] <= w_conf_wdata_reduced[31:24] ;
2253 wb_ba1_bit31_12[23:16] <= w_conf_wdata_reduced[23:16] ;
2255 wb_ba1_bit31_12[15:12] <= w_conf_wdata_reduced[15:12] ;
2257 wb_ba1_bit0 <= w_conf_data[0] ;
2259 if (w_reg_select_dec[32]) // case (w_conf_address[7:2]) = `W_AM1_ADDR:
2262 wb_am1[31:24] <= w_conf_wdata_reduced[31:24] ;
2264 wb_am1[23:16] <= w_conf_wdata_reduced[23:16] ;
2266 wb_am1[15:12] <= w_conf_wdata_reduced[15:12] ;
2268 if (w_reg_select_dec[33]) // case (w_conf_address[7:2]) = `W_TA1_ADDR:
2271 wb_ta1[31:24] <= w_conf_wdata_reduced[31:24] ;
2273 wb_ta1[23:16] <= w_conf_wdata_reduced[23:16] ;
2275 wb_ta1[15:12] <= w_conf_wdata_reduced[15:12] ;
2278 if (w_reg_select_dec[34]) // case (w_conf_address[7:2]) = `W_IMG_CTRL2_ADDR:
2281 wb_img_ctrl2_bit2_0 <= w_conf_data[2:0] ;
2283 if (w_reg_select_dec[35]) // case (w_conf_address[7:2]) = `W_BA2_ADDR:
2286 wb_ba2_bit31_12[31:24] <= w_conf_wdata_reduced[31:24] ;
2288 wb_ba2_bit31_12[23:16] <= w_conf_wdata_reduced[23:16] ;
2290 wb_ba2_bit31_12[15:12] <= w_conf_wdata_reduced[15:12] ;
2292 wb_ba2_bit0 <= w_conf_data[0] ;
2294 if (w_reg_select_dec[36]) // case (w_conf_address[7:2]) = `W_AM2_ADDR:
2297 wb_am2[31:24] <= w_conf_wdata_reduced[31:24] ;
2299 wb_am2[23:16] <= w_conf_wdata_reduced[23:16] ;
2301 wb_am2[15:12] <= w_conf_wdata_reduced[15:12] ;
2303 if (w_reg_select_dec[37]) // case (w_conf_address[7:2]) = `W_TA2_ADDR:
2306 wb_ta2[31:24] <= w_conf_wdata_reduced[31:24] ;
2308 wb_ta2[23:16] <= w_conf_wdata_reduced[23:16] ;
2310 wb_ta2[15:12] <= w_conf_wdata_reduced[15:12] ;
2314 if (w_reg_select_dec[38]) // case (w_conf_address[7:2]) = `W_IMG_CTRL3_ADDR:
2317 wb_img_ctrl3_bit2_0 <= w_conf_data[2:0] ;
2319 if (w_reg_select_dec[39]) // case (w_conf_address[7:2]) = `W_BA3_ADDR:
2322 wb_ba3_bit31_12[31:24] <= w_conf_wdata_reduced[31:24] ;
2324 wb_ba3_bit31_12[23:16] <= w_conf_wdata_reduced[23:16] ;
2326 wb_ba3_bit31_12[15:12] <= w_conf_wdata_reduced[15:12] ;
2328 wb_ba3_bit0 <= w_conf_data[0] ;
2330 if (w_reg_select_dec[40]) // case (w_conf_address[7:2]) = `W_AM3_ADDR:
2333 wb_am3[31:24] <= w_conf_wdata_reduced[31:24] ;
2335 wb_am3[23:16] <= w_conf_wdata_reduced[23:16] ;
2337 wb_am3[15:12] <= w_conf_wdata_reduced[15:12] ;
2339 if (w_reg_select_dec[41]) // case (w_conf_address[7:2]) = `W_TA3_ADDR:
2342 wb_ta3[31:24] <= w_conf_wdata_reduced[31:24] ;
2344 wb_ta3[23:16] <= w_conf_wdata_reduced[23:16] ;
2346 wb_ta3[15:12] <= w_conf_wdata_reduced[15:12] ;
2350 if (w_reg_select_dec[42]) // case (w_conf_address[7:2]) = `W_IMG_CTRL4_ADDR:
2353 wb_img_ctrl4_bit2_0 <= w_conf_data[2:0] ;
2355 if (w_reg_select_dec[43]) // case (w_conf_address[7:2]) = `W_BA4_ADDR:
2358 wb_ba4_bit31_12[31:24] <= w_conf_wdata_reduced[31:24] ;
2360 wb_ba4_bit31_12[23:16] <= w_conf_wdata_reduced[23:16] ;
2362 wb_ba4_bit31_12[15:12] <= w_conf_wdata_reduced[15:12] ;
2364 wb_ba4_bit0 <= w_conf_data[0] ;
2366 if (w_reg_select_dec[44]) // case (w_conf_address[7:2]) = `W_AM4_ADDR:
2369 wb_am4[31:24] <= w_conf_wdata_reduced[31:24] ;
2371 wb_am4[23:16] <= w_conf_wdata_reduced[23:16] ;
2373 wb_am4[15:12] <= w_conf_wdata_reduced[15:12] ;
2375 if (w_reg_select_dec[45]) // case (w_conf_address[7:2]) = `W_TA4_ADDR:
2378 wb_ta4[31:24] <= w_conf_wdata_reduced[31:24] ;
2380 wb_ta4[23:16] <= w_conf_wdata_reduced[23:16] ;
2382 wb_ta4[15:12] <= w_conf_wdata_reduced[15:12] ;
2386 if (w_reg_select_dec[46]) // case (w_conf_address[7:2]) = `W_IMG_CTRL5_ADDR:
2389 wb_img_ctrl5_bit2_0 <= w_conf_data[2:0] ;
2391 if (w_reg_select_dec[47]) // case (w_conf_address[7:2]) = `W_BA5_ADDR:
2394 wb_ba5_bit31_12[31:24] <= w_conf_wdata_reduced[31:24] ;
2396 wb_ba5_bit31_12[23:16] <= w_conf_wdata_reduced[23:16] ;
2398 wb_ba5_bit31_12[15:12] <= w_conf_wdata_reduced[15:12] ;
2400 wb_ba5_bit0 <= w_conf_data[0] ;
2402 if (w_reg_select_dec[48]) // case (w_conf_address[7:2]) = `W_AM5_ADDR:
2405 wb_am5[31:24] <= w_conf_wdata_reduced[31:24] ;
2407 wb_am5[23:16] <= w_conf_wdata_reduced[23:16] ;
2409 wb_am5[15:12] <= w_conf_wdata_reduced[15:12] ;
2411 if (w_reg_select_dec[49]) // case (w_conf_address[7:2]) = `W_TA5_ADDR:
2414 wb_ta5[31:24] <= w_conf_wdata_reduced[31:24] ;
2416 wb_ta5[23:16] <= w_conf_wdata_reduced[23:16] ;
2418 wb_ta5[15:12] <= w_conf_wdata_reduced[15:12] ;
2421 if (w_reg_select_dec[50]) // case (w_conf_address[7:2]) = `W_ERR_CS_ADDR:
2424 wb_err_cs_bit0 <= w_conf_data[0] ;
2428 if (w_reg_select_dec[53]) // case (w_conf_address[7:2]) = `CNF_ADDR_ADDR:
2431 cnf_addr_bit23_2[23:16] <= w_conf_data[23:16] ;
2433 cnf_addr_bit23_2[15:8] <= w_conf_data[15:8] ;
2436 cnf_addr_bit23_2[7:2] <= w_conf_data[7:2] ;
2437 cnf_addr_bit0 <= w_conf_data[0] ;
2441 // `CNF_DATA_ADDR: implemented elsewhere !!!
2442 // `INT_ACK_ADDR : implemented elsewhere !!!
2443 if (w_reg_select_dec[54]) // case (w_conf_address[7:2]) = `ICR_ADDR:
2446 icr_bit31 <= w_conf_data[31] ;
2451 icr_bit4_3 <= w_conf_data[4:3] ;
2452 icr_bit2_0 <= w_conf_data[2:0] ;
2454 icr_bit2_0[2:0] <= w_conf_data[2:0] ;
2459 `ifdef PCI_CPCI_HS_IMPLEMENT
2460 if (w_reg_select_dec[56])
2464 hs_loo <= w_conf_data[19];
2465 hs_eim <= w_conf_data[17];
2471 // Not register bits; used only internally after reset!
2473 rst_inactive_sync <= 1'b1 ;
2474 rst_inactive <= rst_inactive_sync ;
2477 if (rst_inactive & ~init_complete & init_cfg_done)
2478 init_complete <= 1'b1 ;
2482 // implementation of read only device identification registers
2483 always@(posedge w_clock or posedge reset)
2487 r_vendor_id <= `HEADER_VENDOR_ID ;
2488 r_device_id <= `HEADER_DEVICE_ID ;
2489 r_revision_id <= `HEADER_REVISION_ID ;
2490 r_subsys_vendor_id <= `HEADER_SUBSYS_VENDOR_ID ;
2491 r_subsys_id <= `HEADER_SUBSYS_ID ;
2492 r_max_lat <= `HEADER_MAX_LAT ;
2493 r_min_gnt <= `HEADER_MIN_GNT ;
2498 if (spoci_reg_num == 'h0)
2500 r_vendor_id <= spoci_dat[15: 0] ;
2501 r_device_id <= spoci_dat[31:16] ;
2504 if (spoci_reg_num == 'hB)
2506 r_subsys_vendor_id <= spoci_dat[15: 0] ;
2507 r_subsys_id <= spoci_dat[31:16] ;
2510 if (spoci_reg_num == 'h2)
2512 r_revision_id <= spoci_dat[ 7: 0] ;
2515 if (spoci_reg_num == 'hF)
2517 r_max_lat <= spoci_dat[31:24] ;
2518 r_min_gnt <= spoci_dat[23:16] ;
2524 // This signals are synchronous resets for registers, whic occures when asynchronous RESET is '1' or
2525 // data '1' is synchronously written into them!
2526 reg delete_status_bit15 ;
2527 reg delete_status_bit14 ;
2528 reg delete_status_bit13 ;
2529 reg delete_status_bit12 ;
2530 reg delete_status_bit11 ;
2531 reg delete_status_bit8 ;
2532 reg delete_pci_err_cs_bit8 ;
2533 reg delete_wb_err_cs_bit8 ;
2534 reg delete_isr_bit4 ;
2535 reg delete_isr_bit3 ;
2536 reg delete_isr_bit2 ;
2537 reg delete_isr_bit1 ;
2539 // This are aditional register bits, which are resets when their value is '1' !!!
2540 always@(w_we or w_reg_select_dec or w_conf_data or w_byte_en)
2542 // I' is written into, then it also sets signals to '1'
2543 delete_status_bit15 = w_conf_data[31] & !w_byte_en[3] & w_we & w_reg_select_dec[0] ;
2544 delete_status_bit14 = w_conf_data[30] & !w_byte_en[3] & w_we & w_reg_select_dec[0] ;
2545 delete_status_bit13 = w_conf_data[29] & !w_byte_en[3] & w_we & w_reg_select_dec[0] ;
2546 delete_status_bit12 = w_conf_data[28] & !w_byte_en[3] & w_we & w_reg_select_dec[0] ;
2547 delete_status_bit11 = w_conf_data[27] & !w_byte_en[3] & w_we & w_reg_select_dec[0] ;
2548 delete_status_bit8 = w_conf_data[24] & !w_byte_en[3] & w_we & w_reg_select_dec[0] ;
2549 delete_pci_err_cs_bit8 = w_conf_data[8] & !w_byte_en[1] & w_we & w_reg_select_dec[27] ;
2550 delete_wb_err_cs_bit8 = w_conf_data[8] & !w_byte_en[1] & w_we & w_reg_select_dec[50] ;
2551 delete_isr_bit4 = w_conf_data[4] & !w_byte_en[0] & w_we & w_reg_select_dec[55] ;
2552 delete_isr_bit3 = w_conf_data[3] & !w_byte_en[0] & w_we & w_reg_select_dec[55] ;
2553 delete_isr_bit2 = w_conf_data[2] & !w_byte_en[0] & w_we & w_reg_select_dec[55] ;
2554 delete_isr_bit1 = w_conf_data[1] & !w_byte_en[0] & w_we & w_reg_select_dec[55] ;
2557 // STATUS BITS of PCI Header status register
2558 `ifdef SYNCHRONEOUS_CLOCK_DOMAINS
2560 always@(posedge pci_clk or posedge reset)
2562 if (reset) // Asynchronous reset
2563 status_bit15_11[15] <= 1'b0 ;
2566 if (perr_in) // Synchronous set
2567 status_bit15_11[15] <= 1'b1 ;
2568 else if (delete_status_bit15) // Synchronous reset
2569 status_bit15_11[15] <= 1'b0 ;
2573 always@(posedge pci_clk or posedge reset)
2575 if (reset) // Asynchronous reset
2576 status_bit15_11[14] <= 1'b0 ;
2579 if (serr_in) // Synchronous set
2580 status_bit15_11[14] <= 1'b1 ;
2581 else if (delete_status_bit14) // Synchronous reset
2582 status_bit15_11[14] <= 1'b0 ;
2586 always@(posedge pci_clk or posedge reset)
2588 if (reset) // Asynchronous reset
2589 status_bit15_11[13] <= 1'b0 ;
2592 if (master_abort_recv) // Synchronous set
2593 status_bit15_11[13] <= 1'b1 ;
2594 else if (delete_status_bit13) // Synchronous reset
2595 status_bit15_11[13] <= 1'b0 ;
2599 always@(posedge pci_clk or posedge reset)
2601 if (reset) // Asynchronous reset
2602 status_bit15_11[12] <= 1'b0 ;
2605 if (target_abort_recv) // Synchronous set
2606 status_bit15_11[12] <= 1'b1 ;
2607 else if (delete_status_bit12) // Synchronous reset
2608 status_bit15_11[12] <= 1'b0 ;
2612 always@(posedge pci_clk or posedge reset)
2614 if (reset) // Asynchronous reset
2615 status_bit15_11[11] <= 1'b0 ;
2618 if (target_abort_set) // Synchronous set
2619 status_bit15_11[11] <= 1'b1 ;
2620 else if (delete_status_bit11) // Synchronous reset
2621 status_bit15_11[11] <= 1'b0 ;
2625 always@(posedge pci_clk or posedge reset)
2627 if (reset) // Asynchronous reset
2628 status_bit8 <= 1'b0 ;
2631 if (master_data_par_err) // Synchronous set
2632 status_bit8 <= 1'b1 ;
2633 else if (delete_status_bit8) // Synchronous reset
2634 status_bit8 <= 1'b0 ;
2637 `else // not SYNCHRONEOUS_CLOCK_DOMAINS
2639 reg [15:11] set_status_bit15_11;
2640 reg set_status_bit8;
2641 wire delete_set_status_bit15;
2642 wire delete_set_status_bit14;
2643 wire delete_set_status_bit13;
2644 wire delete_set_status_bit12;
2645 wire delete_set_status_bit11;
2646 wire delete_set_status_bit8;
2647 wire block_set_status_bit15;
2648 wire block_set_status_bit14;
2649 wire block_set_status_bit13;
2650 wire block_set_status_bit12;
2651 wire block_set_status_bit11;
2652 wire block_set_status_bit8;
2653 // Synchronization module for clearing FF between two clock domains
2654 pci_sync_module sync_status_15
2656 .set_clk_in (pci_clk),
2657 .delete_clk_in (wb_clk),
2659 .delete_set_out (delete_set_status_bit15),
2660 .block_set_out (block_set_status_bit15),
2661 .delete_in (delete_status_bit15)
2664 always@(posedge pci_clk or posedge reset)
2666 if (reset) // Asynchronous reset
2667 set_status_bit15_11[15] <= 1'b0 ;
2670 if (perr_in) // Synchronous set
2671 set_status_bit15_11[15] <= 1'b1 ;
2672 else if (delete_set_status_bit15) // Synchronous reset
2673 set_status_bit15_11[15] <= 1'b0 ;
2676 // Synchronization module for clearing FF between two clock domains
2677 pci_sync_module sync_status_14
2679 .set_clk_in (pci_clk),
2680 .delete_clk_in (wb_clk),
2682 .delete_set_out (delete_set_status_bit14),
2683 .block_set_out (block_set_status_bit14),
2684 .delete_in (delete_status_bit14)
2687 always@(posedge pci_clk or posedge reset)
2689 if (reset) // Asynchronous reset
2690 set_status_bit15_11[14] <= 1'b0 ;
2693 if (serr_in) // Synchronous set
2694 set_status_bit15_11[14] <= 1'b1 ;
2695 else if (delete_set_status_bit14) // Synchronous reset
2696 set_status_bit15_11[14] <= 1'b0 ;
2699 // Synchronization module for clearing FF between two clock domains
2700 pci_sync_module sync_status_13
2702 .set_clk_in (pci_clk),
2703 .delete_clk_in (wb_clk),
2705 .delete_set_out (delete_set_status_bit13),
2706 .block_set_out (block_set_status_bit13),
2707 .delete_in (delete_status_bit13)
2710 always@(posedge pci_clk or posedge reset)
2712 if (reset) // Asynchronous reset
2713 set_status_bit15_11[13] <= 1'b0 ;
2716 if (master_abort_recv) // Synchronous set
2717 set_status_bit15_11[13] <= 1'b1 ;
2718 else if (delete_set_status_bit13) // Synchronous reset
2719 set_status_bit15_11[13] <= 1'b0 ;
2722 // Synchronization module for clearing FF between two clock domains
2723 pci_sync_module sync_status_12
2725 .set_clk_in (pci_clk),
2726 .delete_clk_in (wb_clk),
2728 .delete_set_out (delete_set_status_bit12),
2729 .block_set_out (block_set_status_bit12),
2730 .delete_in (delete_status_bit12)
2733 always@(posedge pci_clk or posedge reset)
2735 if (reset) // Asynchronous reset
2736 set_status_bit15_11[12] <= 1'b0 ;
2739 if (target_abort_recv) // Synchronous set
2740 set_status_bit15_11[12] <= 1'b1 ;
2741 else if (delete_set_status_bit12) // Synchronous reset
2742 set_status_bit15_11[12] <= 1'b0 ;
2745 // Synchronization module for clearing FF between two clock domains
2746 pci_sync_module sync_status_11
2748 .set_clk_in (pci_clk),
2749 .delete_clk_in (wb_clk),
2751 .delete_set_out (delete_set_status_bit11),
2752 .block_set_out (block_set_status_bit11),
2753 .delete_in (delete_status_bit11)
2756 always@(posedge pci_clk or posedge reset)
2758 if (reset) // Asynchronous reset
2759 set_status_bit15_11[11] <= 1'b0 ;
2762 if (target_abort_set) // Synchronous set
2763 set_status_bit15_11[11] <= 1'b1 ;
2764 else if (delete_set_status_bit11) // Synchronous reset
2765 set_status_bit15_11[11] <= 1'b0 ;
2768 // Synchronization module for clearing FF between two clock domains
2769 pci_sync_module sync_status_8
2771 .set_clk_in (pci_clk),
2772 .delete_clk_in (wb_clk),
2774 .delete_set_out (delete_set_status_bit8),
2775 .block_set_out (block_set_status_bit8),
2776 .delete_in (delete_status_bit8)
2779 always@(posedge pci_clk or posedge reset)
2781 if (reset) // Asynchronous reset
2782 set_status_bit8 <= 1'b0 ;
2785 if (master_data_par_err) // Synchronous set
2786 set_status_bit8 <= 1'b1 ;
2787 else if (delete_set_status_bit8) // Synchronous reset
2788 set_status_bit8 <= 1'b0 ;
2791 wire [5:0] status_bits = {set_status_bit15_11[15] && !block_set_status_bit15,
2792 set_status_bit15_11[14] && !block_set_status_bit14,
2793 set_status_bit15_11[13] && !block_set_status_bit13,
2794 set_status_bit15_11[12] && !block_set_status_bit12,
2795 set_status_bit15_11[11] && !block_set_status_bit11,
2796 set_status_bit8 && !block_set_status_bit8 } ;
2797 wire [5:0] meta_status_bits ;
2798 // interemediate stage to clk synchronization flip - flops - this ones are prone to metastability
2799 pci_synchronizer_flop #(6, 0) status_bits_sync
2801 .data_in (status_bits),
2803 .sync_data_out (meta_status_bits),
2804 .async_reset (reset)
2806 always@(posedge wb_clk or posedge reset)
2810 status_bit15_11[15:11] <= 5'b0 ;
2811 status_bit8 <= 1'b0 ;
2815 status_bit15_11[15:11] <= meta_status_bits[5:1] ;
2816 status_bit8 <= meta_status_bits[0] ;
2821 always@(posedge pci_clk or posedge reset)
2823 if (reset) // Asynchronous reset
2824 status_bit15_11[15] <= 1'b0 ;
2827 if (perr_in) // Synchronous set
2828 status_bit15_11[15] <= 1'b1 ;
2829 else if (delete_status_bit15) // Synchronous reset
2830 status_bit15_11[15] <= 1'b0 ;
2834 always@(posedge pci_clk or posedge reset)
2836 if (reset) // Asynchronous reset
2837 status_bit15_11[14] <= 1'b0 ;
2840 if (serr_in) // Synchronous set
2841 status_bit15_11[14] <= 1'b1 ;
2842 else if (delete_status_bit14) // Synchronous reset
2843 status_bit15_11[14] <= 1'b0 ;
2847 always@(posedge pci_clk or posedge reset)
2849 if (reset) // Asynchronous reset
2850 status_bit15_11[13] <= 1'b0 ;
2853 if (master_abort_recv) // Synchronous set
2854 status_bit15_11[13] <= 1'b1 ;
2855 else if (delete_status_bit13) // Synchronous reset
2856 status_bit15_11[13] <= 1'b0 ;
2860 always@(posedge pci_clk or posedge reset)
2862 if (reset) // Asynchronous reset
2863 status_bit15_11[12] <= 1'b0 ;
2866 if (target_abort_recv) // Synchronous set
2867 status_bit15_11[12] <= 1'b1 ;
2868 else if (delete_status_bit12) // Synchronous reset
2869 status_bit15_11[12] <= 1'b0 ;
2873 always@(posedge pci_clk or posedge reset)
2875 if (reset) // Asynchronous reset
2876 status_bit15_11[11] <= 1'b0 ;
2879 if (target_abort_set) // Synchronous set
2880 status_bit15_11[11] <= 1'b1 ;
2881 else if (delete_status_bit11) // Synchronous reset
2882 status_bit15_11[11] <= 1'b0 ;
2886 always@(posedge pci_clk or posedge reset)
2888 if (reset) // Asynchronous reset
2889 status_bit8 <= 1'b0 ;
2892 if (master_data_par_err) // Synchronous set
2893 status_bit8 <= 1'b1 ;
2894 else if (delete_status_bit8) // Synchronous reset
2895 status_bit8 <= 1'b0 ;
2901 // STATUS BITS of P_ERR_CS - PCI error control and status register
2902 `ifdef SYNCHRONEOUS_CLOCK_DOMAINS
2904 always@(posedge pci_clk or posedge reset)
2906 if (reset) // Asynchronous reset
2907 pci_err_cs_bit8 <= 1'b0 ;
2910 if (pci_error_sig && pci_err_cs_bit0) // Synchronous set
2911 pci_err_cs_bit8 <= 1'b1 ;
2912 else if (delete_pci_err_cs_bit8) // Synchronous reset
2913 pci_err_cs_bit8 <= 1'b0 ;
2916 `else // not SYNCHRONEOUS_CLOCK_DOMAINS
2919 always@(posedge wb_clk or posedge reset)
2921 if (reset) // Asynchronous reset
2922 pci_err_cs_bit8 <= 1'b0 ;
2925 if (pci_error_sig && pci_err_cs_bit0) // Synchronous set
2926 pci_err_cs_bit8 <= 1'b1 ;
2927 else if (delete_pci_err_cs_bit8) // Synchronous reset
2928 pci_err_cs_bit8 <= 1'b0 ;
2932 reg set_pci_err_cs_bit8;
2933 wire delete_set_pci_err_cs_bit8;
2934 wire block_set_pci_err_cs_bit8;
2935 // Synchronization module for clearing FF between two clock domains
2936 pci_sync_module sync_pci_err_cs_8
2938 .set_clk_in (wb_clk),
2939 .delete_clk_in (pci_clk),
2941 .delete_set_out (delete_set_pci_err_cs_bit8),
2942 .block_set_out (block_set_pci_err_cs_bit8),
2943 .delete_in (delete_pci_err_cs_bit8)
2946 always@(posedge wb_clk or posedge reset)
2948 if (reset) // Asynchronous reset
2949 set_pci_err_cs_bit8 <= 1'b0 ;
2952 if (pci_error_sig && pci_err_cs_bit0) // Synchronous set
2953 set_pci_err_cs_bit8 <= 1'b1 ;
2954 else if (delete_set_pci_err_cs_bit8) // Synchronous reset
2955 set_pci_err_cs_bit8 <= 1'b0 ;
2958 wire pci_err_cs_bits = set_pci_err_cs_bit8 && !block_set_pci_err_cs_bit8 ;
2959 wire meta_pci_err_cs_bits ;
2960 // interemediate stage to clk synchronization flip - flops - this ones are prone to metastability
2961 pci_synchronizer_flop #(1,0) pci_err_cs_bits_sync
2963 .data_in (pci_err_cs_bits),
2965 .sync_data_out (meta_pci_err_cs_bits),
2966 .async_reset (reset)
2968 always@(posedge pci_clk or posedge reset)
2971 pci_err_cs_bit8 <= 1'b0 ;
2973 pci_err_cs_bit8 <= meta_pci_err_cs_bits ;
2978 always@(posedge wb_clk or posedge reset)
2980 if (reset) // Asynchronous reset
2981 pci_err_cs_bit10 <= 1'b0 ;
2984 if (pci_error_sig) // Synchronous report
2985 pci_err_cs_bit10 <= pci_error_rty_exp ;
2989 always@(posedge wb_clk or posedge reset)
2991 if (reset) // Asynchronous reset
2992 pci_err_cs_bit9 <= 1'b0 ;
2995 if (pci_error_sig) // Synchronous report
2996 pci_err_cs_bit9 <= pci_error_es ;
3000 always@(posedge wb_clk or posedge reset)
3002 if (reset) // Asynchronous reset
3004 pci_err_cs_bit31_24 <= 8'h00 ;
3005 pci_err_addr <= 32'h0000_0000 ;
3006 pci_err_data <= 32'h0000_0000 ;
3009 if (pci_error_sig) // Synchronous report
3011 pci_err_cs_bit31_24 <= { pci_error_be, pci_error_bc } ;
3012 pci_err_addr <= pci_error_addr ;
3013 pci_err_data <= pci_error_data ;
3017 // STATUS BITS of W_ERR_CS - WB error control and status register
3018 `ifdef SYNCHRONEOUS_CLOCK_DOMAINS
3020 always@(posedge pci_clk or posedge reset)
3022 if (reset) // Asynchronous reset
3023 wb_err_cs_bit8 <= 1'b0 ;
3026 if (wb_error_sig && wb_err_cs_bit0) // Synchronous set
3027 wb_err_cs_bit8 <= 1'b1 ;
3028 else if (delete_wb_err_cs_bit8) // Synchronous reset
3029 wb_err_cs_bit8 <= 1'b0 ;
3032 `else // not SYNCHRONEOUS_CLOCK_DOMAINS
3034 reg set_wb_err_cs_bit8;
3035 wire delete_set_wb_err_cs_bit8;
3036 wire block_set_wb_err_cs_bit8;
3037 // Synchronization module for clearing FF between two clock domains
3038 pci_sync_module sync_wb_err_cs_8
3040 .set_clk_in (pci_clk),
3041 .delete_clk_in (wb_clk),
3043 .delete_set_out (delete_set_wb_err_cs_bit8),
3044 .block_set_out (block_set_wb_err_cs_bit8),
3045 .delete_in (delete_wb_err_cs_bit8)
3048 always@(posedge pci_clk or posedge reset)
3050 if (reset) // Asynchronous reset
3051 set_wb_err_cs_bit8 <= 1'b0 ;
3054 if (wb_error_sig && wb_err_cs_bit0) // Synchronous set
3055 set_wb_err_cs_bit8 <= 1'b1 ;
3056 else if (delete_set_wb_err_cs_bit8) // Synchronous reset
3057 set_wb_err_cs_bit8 <= 1'b0 ;
3060 wire wb_err_cs_bits = set_wb_err_cs_bit8 && !block_set_wb_err_cs_bit8 ;
3061 wire meta_wb_err_cs_bits ;
3062 // interemediate stage to clk synchronization flip - flops - this ones are prone to metastability
3063 pci_synchronizer_flop #(1,0) wb_err_cs_bits_sync
3065 .data_in (wb_err_cs_bits),
3067 .sync_data_out (meta_wb_err_cs_bits),
3068 .async_reset (reset)
3070 always@(posedge wb_clk or posedge reset)
3073 wb_err_cs_bit8 <= 1'b0 ;
3075 wb_err_cs_bit8 <= meta_wb_err_cs_bits ;
3079 always@(posedge pci_clk or posedge reset)
3081 if (reset) // Asynchronous reset
3082 wb_err_cs_bit8 <= 1'b0 ;
3085 if (wb_error_sig && wb_err_cs_bit0) // Synchronous set
3086 wb_err_cs_bit8 <= 1'b1 ;
3087 else if (delete_wb_err_cs_bit8) // Synchronous reset
3088 wb_err_cs_bit8 <= 1'b0 ;
3093 /* // Set and clear FF
3094 always@(posedge pci_clk or posedge reset)
3096 if (reset) // Asynchronous reset
3097 wb_err_cs_bit10 <= 1'b0 ;
3100 if (wb_error_sig) // Synchronous report
3101 wb_err_cs_bit10 <= wb_error_rty_exp ;
3105 always@(posedge pci_clk or posedge reset)
3107 if (reset) // Asynchronous reset
3108 wb_err_cs_bit9 <= 1'b0 ;
3111 if (wb_error_sig) // Synchronous report
3112 wb_err_cs_bit9 <= wb_error_es ;
3116 always@(posedge pci_clk or posedge reset)
3118 if (reset) // Asynchronous reset
3120 wb_err_cs_bit31_24 <= 8'h00 ;
3121 wb_err_addr <= 32'h0000_0000 ;
3122 wb_err_data <= 32'h0000_0000 ;
3127 wb_err_cs_bit31_24 <= { wb_error_be, wb_error_bc } ;
3128 wb_err_addr <= wb_error_addr ;
3129 wb_err_data <= wb_error_data ;
3133 // SERR_INT and PERR_INT STATUS BITS of ISR - interrupt status register
3134 `ifdef SYNCHRONEOUS_CLOCK_DOMAINS
3137 always@(posedge pci_clk or posedge reset)
3139 if (reset) // Asynchronous reset
3140 isr_bit4_3[4] <= 1'b0 ;
3143 if (isr_sys_err_int && icr_bit4_3[4]) // Synchronous set
3144 isr_bit4_3[4] <= 1'b1 ;
3145 else if (delete_isr_bit4) // Synchronous reset
3146 isr_bit4_3[4] <= 1'b0 ;
3150 always@(posedge pci_clk or posedge reset)
3152 if (reset) // Asynchronous reset
3153 isr_bit4_3[3] <= 1'b0 ;
3156 if (isr_par_err_int && icr_bit4_3[3]) // Synchronous set
3157 isr_bit4_3[3] <= 1'b1 ;
3158 else if (delete_isr_bit3) // Synchronous reset
3159 isr_bit4_3[3] <= 1'b0 ;
3163 `else // not SYNCHRONEOUS_CLOCK_DOMAINS
3165 reg [4:3] set_isr_bit4_3;
3166 wire delete_set_isr_bit4;
3167 wire delete_set_isr_bit3;
3168 wire block_set_isr_bit4;
3169 wire block_set_isr_bit3;
3170 // Synchronization module for clearing FF between two clock domains
3171 pci_sync_module sync_isr_4
3173 .set_clk_in (pci_clk),
3174 .delete_clk_in (wb_clk),
3176 .delete_set_out (delete_set_isr_bit4),
3177 .block_set_out (block_set_isr_bit4),
3178 .delete_in (delete_isr_bit4)
3181 always@(posedge pci_clk or posedge reset)
3183 if (reset) // Asynchronous reset
3184 set_isr_bit4_3[4] <= 1'b0 ;
3187 if (isr_sys_err_int && icr_bit4_3[4]) // Synchronous set
3188 set_isr_bit4_3[4] <= 1'b1 ;
3189 else if (delete_set_isr_bit4) // Synchronous reset
3190 set_isr_bit4_3[4] <= 1'b0 ;
3193 // Synchronization module for clearing FF between two clock domains
3194 pci_sync_module sync_isr_3
3196 .set_clk_in (pci_clk),
3197 .delete_clk_in (wb_clk),
3199 .delete_set_out (delete_set_isr_bit3),
3200 .block_set_out (block_set_isr_bit3),
3201 .delete_in (delete_isr_bit3)
3204 always@(posedge pci_clk or posedge reset)
3206 if (reset) // Asynchronous reset
3207 set_isr_bit4_3[3] <= 1'b0 ;
3210 if (isr_par_err_int && icr_bit4_3[3]) // Synchronous set
3211 set_isr_bit4_3[3] <= 1'b1 ;
3212 else if (delete_set_isr_bit3) // Synchronous reset
3213 set_isr_bit4_3[3] <= 1'b0 ;
3216 wire [4:3] isr_bits4_3 = {set_isr_bit4_3[4] && !block_set_isr_bit4,
3217 set_isr_bit4_3[3] && !block_set_isr_bit3 } ;
3218 wire [4:3] meta_isr_bits4_3 ;
3219 // interemediate stage to clk synchronization flip - flops - this ones are prone to metastability
3220 pci_synchronizer_flop #(2, 0) isr_bits_sync
3222 .data_in (isr_bits4_3),
3224 .sync_data_out (meta_isr_bits4_3),
3225 .async_reset (reset)
3227 always@(posedge wb_clk or posedge reset)
3230 isr_bit4_3[4:3] <= 2'b0 ;
3232 isr_bit4_3[4:3] <= meta_isr_bits4_3[4:3] ;
3237 // PCI_EINT and WB_EINT STATUS BITS of ISR - interrupt status register
3238 `ifdef SYNCHRONEOUS_CLOCK_DOMAINS
3239 // WB_EINT STATUS BIT
3241 always@(posedge pci_clk or posedge reset)
3243 if (reset) // Asynchronous reset
3244 isr_bit2_0[1] <= 1'b0 ;
3247 if (wb_error_sig && icr_bit2_0[1] && wb_err_cs_bit0) // Synchronous set
3248 isr_bit2_0[1] <= 1'b1 ;
3249 else if (delete_isr_bit1) // Synchronous reset
3250 isr_bit2_0[1] <= 1'b0 ;
3253 // PCI_EINT STATUS BIT
3255 always@(posedge pci_clk or posedge reset)
3257 if (reset) // Asynchronous reset
3258 isr_bit2_0[2] <= 1'b0 ;
3261 if (pci_error_sig && icr_bit2_0[2] && pci_err_cs_bit0) // Synchronous set
3262 isr_bit2_0[2] <= 1'b1 ;
3263 else if (delete_isr_bit2) // Synchronous reset
3264 isr_bit2_0[2] <= 1'b0 ;
3267 `else // not SYNCHRONEOUS_CLOCK_DOMAINS
3269 // WB_EINT STATUS BIT
3271 wire delete_set_isr_bit1;
3272 wire block_set_isr_bit1;
3273 // Synchronization module for clearing FF between two clock domains
3274 pci_sync_module sync_isr_1
3276 .set_clk_in (pci_clk),
3277 .delete_clk_in (wb_clk),
3279 .delete_set_out (delete_set_isr_bit1),
3280 .block_set_out (block_set_isr_bit1),
3281 .delete_in (delete_isr_bit1)
3284 always@(posedge pci_clk or posedge reset)
3286 if (reset) // Asynchronous reset
3287 set_isr_bit1 <= 1'b0 ;
3290 if (wb_error_sig && icr_bit2_0[1] && wb_err_cs_bit0) // Synchronous set
3291 set_isr_bit1 <= 1'b1 ;
3292 else if (delete_set_isr_bit1) // Synchronous reset
3293 set_isr_bit1 <= 1'b0 ;
3296 wire isr_bit1 = set_isr_bit1 && !block_set_isr_bit1 ;
3297 wire meta_isr_bit1 ;
3298 // interemediate stage to clk synchronization flip - flops - this ones are prone to metastability
3299 pci_synchronizer_flop #(1, 0) isr_bit1_sync
3301 .data_in (isr_bit1),
3303 .sync_data_out (meta_isr_bit1),
3304 .async_reset (reset)
3306 always@(posedge wb_clk or posedge reset)
3309 isr_bit2_0[1] <= 1'b0 ;
3311 isr_bit2_0[1] <= meta_isr_bit1 ;
3313 // PCI_EINT STATUS BIT
3315 always@(posedge wb_clk or posedge reset)
3317 if (reset) // Asynchronous reset
3318 isr_bit2_0[2] <= 1'b0 ;
3321 if (pci_error_sig && icr_bit2_0[2] && pci_err_cs_bit0) // Synchronous set
3322 isr_bit2_0[2] <= 1'b1 ;
3323 else if (delete_isr_bit2) // Synchronous reset
3324 isr_bit2_0[2] <= 1'b0 ;
3328 // WB_EINT STATUS BIT
3330 always@(posedge pci_clk or posedge reset)
3332 if (reset) // Asynchronous reset
3333 isr_bit2_0[1] <= 1'b0 ;
3336 if (wb_error_sig && icr_bit2_0[1] && wb_err_cs_bit0) // Synchronous set
3337 isr_bit2_0[1] <= 1'b1 ;
3338 else if (delete_isr_bit1) // Synchronous reset
3339 isr_bit2_0[1] <= 1'b0 ;
3342 // PCI_EINT STATUS BIT
3344 wire delete_set_isr_bit2;
3345 wire block_set_isr_bit2;
3346 // Synchronization module for clearing FF between two clock domains
3347 pci_sync_module sync_isr_2
3349 .set_clk_in (wb_clk),
3350 .delete_clk_in (pci_clk),
3352 .delete_set_out (delete_set_isr_bit2),
3353 .block_set_out (block_set_isr_bit2),
3354 .delete_in (delete_isr_bit2)
3357 always@(posedge wb_clk or posedge reset)
3359 if (reset) // Asynchronous reset
3360 set_isr_bit2 <= 1'b0 ;
3363 if (pci_error_sig && icr_bit2_0[2] && pci_err_cs_bit0) // Synchronous set
3364 set_isr_bit2 <= 1'b1 ;
3365 else if (delete_set_isr_bit2) // Synchronous reset
3366 set_isr_bit2 <= 1'b0 ;
3369 wire isr_bit2 = set_isr_bit2 && !block_set_isr_bit2 ;
3370 wire meta_isr_bit2 ;
3371 // interemediate stage to clk synchronization flip - flops - this ones are prone to metastability
3372 pci_synchronizer_flop #(1, 0) isr_bit2_sync
3374 .data_in (isr_bit2),
3376 .sync_data_out (meta_isr_bit2),
3377 .async_reset (reset)
3379 always@(posedge pci_clk or posedge reset)
3382 isr_bit2_0[2] <= 1'b0 ;
3384 isr_bit2_0[2] <= meta_isr_bit2 ;
3389 // INT BIT of ISR - interrupt status register
3391 wire isr_int_prop_bit = isr_int_prop && icr_bit2_0[0] ;
3392 wire meta_isr_int_prop_bit ;
3393 // interemediate stage to clk synchronization flip - flops - this ones are prone to metastability
3394 pci_synchronizer_flop #(1, 0) isr_bit0_sync
3396 .data_in (isr_int_prop_bit),
3398 .sync_data_out (meta_isr_int_prop_bit),
3399 .async_reset (reset)
3401 always@(posedge wb_clk or posedge reset)
3404 isr_bit2_0[0] <= 1'b0 ;
3406 isr_bit2_0[0] <= meta_isr_int_prop_bit ;
3409 `ifdef SYNCHRONEOUS_CLOCK_DOMAINS
3410 wire isr_int_prop_bit = isr_int_prop && icr_bit2_0[0] ;
3411 always@(posedge pci_clk or posedge reset)
3414 isr_bit2_0[0] <= 1'b0 ;
3416 isr_bit2_0[0] <= isr_int_prop_bit ;
3418 `else // not SYNCHRONEOUS_CLOCK_DOMAINS
3419 wire isr_int_prop_bit = isr_int_prop && icr_bit2_0[0] ;
3420 wire meta_isr_int_prop_bit ;
3421 // interemediate stage to clk synchronization flip - flops - this ones are prone to metastability
3422 pci_synchronizer_flop #(1, 0) isr_bit0_sync
3424 .data_in (isr_int_prop_bit),
3426 .sync_data_out (meta_isr_int_prop_bit),
3427 .async_reset (reset)
3429 always@(posedge pci_clk or posedge reset)
3432 isr_bit2_0[0] <= 1'b0 ;
3434 isr_bit2_0[0] <= meta_isr_int_prop_bit ;
3444 `ifdef SYNCHRONEOUS_CLOCK_DOMAINS
3445 assign int_in = isr_int_prop_bit || isr_bit2_0[1] || isr_bit2_0[2] || isr_bit4_3[3] || isr_bit4_3[4];
3446 `else // not SYNCHRONEOUS_CLOCK_DOMAINS
3447 assign int_in = isr_int_prop_bit || isr_bit1 || isr_bit2_0[2] || isr_bits4_3[3] || isr_bits4_3[4];
3449 // interemediate stage to clk synchronization flip - flops - this ones are prone to metastability
3450 pci_synchronizer_flop #(1, 0) int_pin_sync
3454 .sync_data_out (int_meta),
3455 .async_reset (reset)
3457 always@(posedge wb_clk or posedge reset)
3460 interrupt_out <= 1'b0 ;
3462 interrupt_out <= int_meta ;
3465 `ifdef SYNCHRONEOUS_CLOCK_DOMAINS
3466 assign int_in = isr_int_prop_bit || isr_bit2_0[1] || isr_bit2_0[2];
3467 `else // not SYNCHRONEOUS_CLOCK_DOMAINS
3468 assign int_in = isr_int_prop_bit || isr_bit2_0[1] || isr_bit2;
3470 // interemediate stage to clk synchronization flip - flops - this ones are prone to metastability
3471 pci_synchronizer_flop #(1, 0) int_pin_sync
3475 .sync_data_out (int_meta),
3476 .async_reset (reset)
3478 always@(posedge pci_clk or posedge reset)
3481 interrupt_out <= 1'b0 ;
3483 interrupt_out <= int_meta ;
3488 `ifdef PCI_CPCI_HS_IMPLEMENT
3489 reg [hs_es_cnt_width - 1:0] hs_es_cnt ; // debounce counter
3490 reg hs_es_in_state, // current state of ejector switch input - synchronized
3491 hs_es_sync, // synchronization flop for ejector switch input
3492 hs_es_cur_state ; // current valid state of ejector switch
3494 `ifdef ACTIVE_HIGH_OE
3495 wire oe_active_val = 1'b1 ;
3498 `ifdef ACTIVE_LOW_OE
3499 wire oe_active_val = 1'b0 ;
3502 always@(posedge pci_clk or posedge reset)
3507 hs_ins_armed <= 1'b1 ;
3509 hs_ext_armed <= 1'b0 ;
3510 hs_es_in_state <= 1'b0 ;
3511 hs_es_sync <= 1'b0 ;
3512 hs_es_cur_state <= 1'b0 ;
3515 `ifdef ACTIVE_LOW_OE
3516 pci_cpci_hs_enum_oe_o <= 1'b1 ;
3517 pci_cpci_hs_led_oe_o <= 1'b0 ;
3520 `ifdef ACTIVE_HIGH_OE
3521 pci_cpci_hs_enum_oe_o <= 1'b0 ;
3522 pci_cpci_hs_led_oe_o <= 1'b1 ;
3531 if (w_conf_data[23] & ~w_byte_en[2] & w_we & w_reg_select_dec[56]) // clear
3534 else if (hs_ins_armed) // set
3535 hs_ins <= init_complete & (hs_es_cur_state == 1'b1) ;
3538 if (~hs_ins & hs_ins_armed & init_complete & (hs_es_cur_state == 1'b1)) // clear
3539 hs_ins_armed <= 1'b0 ;
3540 else if (hs_ext) // set
3541 hs_ins_armed <= w_conf_data[22] & ~w_byte_en[2] & w_we & w_reg_select_dec[56] ;
3544 if (hs_ext) // clear
3546 if (w_conf_data[22] & ~w_byte_en[2] & w_we & w_reg_select_dec[56])
3549 else if (hs_ext_armed) // set
3550 hs_ext <= (hs_es_cur_state == 1'b0) ;
3553 if (~hs_ext & hs_ext_armed & (hs_es_cur_state == 1'b0)) // clear
3554 hs_ext_armed <= 1'b0 ;
3555 else if (hs_ins) // set
3556 hs_ext_armed <= w_conf_data[23] & !w_byte_en[2] & w_we & w_reg_select_dec[56] ;
3558 // ejector switch debounce counter logic
3559 hs_es_sync <= pci_cpci_hs_es_i ;
3560 hs_es_in_state <= hs_es_sync ;
3562 if (hs_es_in_state == hs_es_cur_state)
3565 hs_es_cnt <= hs_es_cnt + 1'b1 ;
3567 if (hs_es_cnt == {hs_es_cnt_width{1'b1}})
3568 hs_es_cur_state <= hs_es_in_state ;
3570 if ((hs_ins | hs_ext) & ~hs_eim)
3571 pci_cpci_hs_enum_oe_o <= oe_active_val ;
3573 pci_cpci_hs_enum_oe_o <= ~oe_active_val ;
3575 if (~init_complete | hs_loo)
3576 pci_cpci_hs_led_oe_o <= oe_active_val ;
3578 pci_cpci_hs_led_oe_o <= ~oe_active_val ;
3585 wire spoci_write_done,
3589 wire [ 7: 0] spoci_wdat ;
3590 wire [ 7: 0] spoci_rdat ;
3592 // power on configuration control and status register
3593 always@(posedge pci_clk or posedge reset)
3597 spoci_cs_nack <= 1'b0 ;
3598 spoci_cs_write <= 1'b0 ;
3599 spoci_cs_read <= 1'b0 ;
3600 spoci_cs_adr <= 'h0 ;
3601 spoci_cs_dat <= 'h0 ;
3607 if (spoci_write_done | spoci_no_ack)
3608 spoci_cs_write <= 1'b0 ;
3610 else if ( w_we & (w_conf_address[9:2] == 8'hFF) & ~w_byte_en[3])
3611 spoci_cs_write <= w_conf_data[25] ;
3615 if (spoci_dat_rdy | spoci_no_ack)
3616 spoci_cs_read <= 1'b0 ;
3618 else if ( w_we & (w_conf_address[9:2] == 8'hFF) & ~w_byte_en[3] )
3619 spoci_cs_read <= w_conf_data[24] ;
3623 if ( w_we & (w_conf_address[9:2] == 8'hFF) & ~w_byte_en[3] & w_conf_data[31] )
3624 spoci_cs_nack <= 1'b0 ;
3626 else if (spoci_cs_write | spoci_cs_read | ~init_cfg_done)
3628 spoci_cs_nack <= spoci_no_ack ;
3631 if ( w_we & (w_conf_address[9:2] == 8'hFF) )
3634 spoci_cs_adr[10: 8] <= w_conf_data[18:16] ;
3637 spoci_cs_adr[ 7: 0] <= w_conf_data[15: 8] ;
3640 if ( w_we & (w_conf_address[9:2] == 8'hFF) & ~w_byte_en[0] )
3641 spoci_cs_dat <= w_conf_data[ 7: 0] ;
3642 else if (spoci_cs_read & spoci_dat_rdy)
3643 spoci_cs_dat <= spoci_rdat ;
3648 reg [ 2 : 0] bytes_received ;
3650 always@(posedge pci_clk or posedge reset)
3655 init_cfg_done <= 1'b0 ;
3656 bytes_received <= 1'b0 ;
3658 spoci_reg_num <= 'h0 ;
3660 else if (~init_cfg_done)
3664 case (bytes_received)
3665 'h0:spoci_reg_num <= spoci_rdat ;
3666 'h1:spoci_dat[ 7: 0] <= spoci_rdat ;
3667 'h2:spoci_dat[15: 8] <= spoci_rdat ;
3668 'h3:spoci_dat[23:16] <= spoci_rdat ;
3669 'h4:spoci_dat[31:24] <= spoci_rdat ;
3672 spoci_dat <= 32'hxxxx_xxxx ;
3673 spoci_reg_num <= 'hxx ;
3679 bytes_received <= 'h0 ;
3680 else if (spoci_dat_rdy)
3681 bytes_received <= bytes_received + 1'b1 ;
3685 else if (bytes_received == 'h5)
3688 if (spoci_no_ack | ((bytes_received == 'h1) & (spoci_reg_num == 'hff)) )
3689 init_cfg_done <= 1'b1 ;
3693 assign spoci_wdat = spoci_cs_dat ;
3695 pci_spoci_ctrl i_pci_spoci_ctrl
3700 .do_rnd_read_i (spoci_cs_read ),
3701 .do_seq_read_i (rst_inactive & ~init_cfg_done ),
3702 .do_write_i (spoci_cs_write ),
3704 .write_done_o (spoci_write_done ),
3705 .dat_rdy_o (spoci_dat_rdy ),
3706 .no_ack_o (spoci_no_ack ),
3708 .adr_i (spoci_cs_adr ),
3709 .dat_i (spoci_wdat ),
3710 .dat_o (spoci_rdat ),
3712 .pci_spoci_sda_i (spoci_sda_i ),
3713 .pci_spoci_sda_oe_o (spoci_sda_oe_o ),
3714 .pci_spoci_scl_oe_o (spoci_scl_oe_o )
3718 /*-----------------------------------------------------------------------------------------------------------
3719 OUTPUTs from registers !!!
3720 -----------------------------------------------------------------------------------------------------------*/
3722 // if bridge is HOST then write clock is equal to WB clock, and synchronization of outputs has to be done
3724 wire [3:0] command_bits = {command_bit8, command_bit6, command_bit2_0[1:0]} ;
3725 wire [3:0] meta_command_bits ;
3726 reg [3:0] sync_command_bits ;
3727 pci_synchronizer_flop #(4, 0) command_bits_sync
3729 .data_in (command_bits),
3731 .sync_data_out (meta_command_bits),
3732 .async_reset (reset)
3734 always@(posedge pci_clk or posedge reset)
3737 sync_command_bits <= 4'b0 ;
3739 sync_command_bits <= meta_command_bits ;
3741 wire sync_command_bit8 = sync_command_bits[3] ;
3742 wire sync_command_bit6 = sync_command_bits[2] ;
3743 wire sync_command_bit1 = sync_command_bits[1] ;
3744 wire sync_command_bit0 = sync_command_bits[0] ;
3745 wire sync_command_bit2 = command_bit2_0[2] ;
3747 wire command_bit = command_bit2_0[2] ;
3748 wire meta_command_bit ;
3749 reg sync_command_bit ;
3750 pci_synchronizer_flop #(1, 0) command_bit_sync
3752 .data_in (command_bit),
3754 .sync_data_out (meta_command_bit),
3755 .async_reset (reset)
3757 always@(posedge pci_clk or posedge reset)
3760 sync_command_bit <= 1'b0 ;
3762 sync_command_bit <= meta_command_bit ;
3764 wire sync_command_bit8 = command_bit8 ;
3765 wire sync_command_bit6 = command_bit6 ;
3766 wire sync_command_bit1 = command_bit2_0[1] ;
3767 wire sync_command_bit0 = command_bit2_0[0] ;
3768 wire sync_command_bit2 = sync_command_bit ;
3770 // PCI header outputs from command register
3771 assign serr_enable = sync_command_bit8 & pci_init_complete_out ; // to PCI clock
3772 assign perr_response = sync_command_bit6 & pci_init_complete_out ; // to PCI clock
3773 assign pci_master_enable = sync_command_bit2 & wb_init_complete_out ; // to WB clock
3774 assign memory_space_enable = sync_command_bit1 & pci_init_complete_out ; // to PCI clock
3775 assign io_space_enable = sync_command_bit0 & pci_init_complete_out ; // to PCI clock
3777 // if bridge is HOST then write clock is equal to WB clock, and synchronization of outputs has to be done
3778 // We don't support cache line sizes smaller that 4 and it must have last two bits zero!!!
3779 wire cache_lsize_not_zero = ((cache_line_size_reg[7] || cache_line_size_reg[6] || cache_line_size_reg[5] ||
3780 cache_line_size_reg[4] || cache_line_size_reg[3] || cache_line_size_reg[2]) &&
3781 (!cache_line_size_reg[1] && !cache_line_size_reg[0]) );
3783 wire [7:2] cache_lsize_to_pci_bits = { cache_line_size_reg[7:2] } ;
3784 wire [7:2] meta_cache_lsize_to_pci_bits ;
3785 reg [7:2] sync_cache_lsize_to_pci_bits ;
3786 pci_synchronizer_flop #(6, 0) cache_lsize_to_pci_bits_sync
3788 .data_in (cache_lsize_to_pci_bits),
3790 .sync_data_out (meta_cache_lsize_to_pci_bits),
3791 .async_reset (reset)
3793 always@(posedge pci_clk or posedge reset)
3796 sync_cache_lsize_to_pci_bits <= 6'b0 ;
3798 sync_cache_lsize_to_pci_bits <= meta_cache_lsize_to_pci_bits ;
3800 wire [7:2] sync_cache_line_size_to_pci_reg = sync_cache_lsize_to_pci_bits[7:2] ;
3801 wire [7:2] sync_cache_line_size_to_wb_reg = cache_line_size_reg[7:2] ;
3802 wire sync_cache_lsize_not_zero_to_wb = cache_lsize_not_zero ;
3803 // Latency timer is sinchronized only to PCI clock when bridge implementation is HOST
3804 wire [7:0] latency_timer_bits = latency_timer ;
3805 wire [7:0] meta_latency_timer_bits ;
3806 reg [7:0] sync_latency_timer_bits ;
3807 pci_synchronizer_flop #(8, 0) latency_timer_bits_sync
3809 .data_in (latency_timer_bits),
3811 .sync_data_out (meta_latency_timer_bits),
3812 .async_reset (reset)
3814 always@(posedge pci_clk or posedge reset)
3817 sync_latency_timer_bits <= 8'b0 ;
3819 sync_latency_timer_bits <= meta_latency_timer_bits ;
3821 wire [7:0] sync_latency_timer = sync_latency_timer_bits ;
3823 wire [8:2] cache_lsize_to_wb_bits = { cache_lsize_not_zero, cache_line_size_reg[7:2] } ;
3824 wire [8:2] meta_cache_lsize_to_wb_bits ;
3825 reg [8:2] sync_cache_lsize_to_wb_bits ;
3826 pci_synchronizer_flop #(7, 0) cache_lsize_to_wb_bits_sync
3828 .data_in (cache_lsize_to_wb_bits),
3830 .sync_data_out (meta_cache_lsize_to_wb_bits),
3831 .async_reset (reset)
3833 always@(posedge wb_clk or posedge reset)
3836 sync_cache_lsize_to_wb_bits <= 7'b0 ;
3838 sync_cache_lsize_to_wb_bits <= meta_cache_lsize_to_wb_bits ;
3840 wire [7:2] sync_cache_line_size_to_pci_reg = cache_line_size_reg[7:2] ;
3841 wire [7:2] sync_cache_line_size_to_wb_reg = sync_cache_lsize_to_wb_bits[7:2] ;
3842 wire sync_cache_lsize_not_zero_to_wb = sync_cache_lsize_to_wb_bits[8] ;
3844 wire [7:0] sync_latency_timer = latency_timer ;
3846 // PCI header output from cache_line_size, latency timer and interrupt pin
3847 assign cache_line_size_to_pci = {sync_cache_line_size_to_pci_reg, 2'h0} ; // [7 : 0] to PCI clock
3848 assign cache_line_size_to_wb = {sync_cache_line_size_to_wb_reg, 2'h0} ; // [7 : 0] to WB clock
3849 assign cache_lsize_not_zero_to_wb = sync_cache_lsize_not_zero_to_wb ;
3851 assign latency_tim[7 : 0] = sync_latency_timer ; // to PCI clock
3852 //assign int_pin[2 : 0] = r_interrupt_pin ;
3853 assign int_out = interrupt_out ;
3854 // PCI output from image registers
3855 // base address, address mask, translation address and control registers are sinchronized in PCI_DECODER.V module
3858 assign pci_base_addr0 = pci_ba0_bit31_8[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
3860 assign pci_base_addr0 = pci_ba0_bit31_8[31:12] ;
3865 assign pci_base_addr0 = pci_ba0_bit31_8[31:12] ;
3868 assign pci_base_addr1 = pci_ba1_bit31_8[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
3869 assign pci_base_addr2 = pci_ba2_bit31_8[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
3870 assign pci_base_addr3 = pci_ba3_bit31_8[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
3871 assign pci_base_addr4 = pci_ba4_bit31_8[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
3872 assign pci_base_addr5 = pci_ba5_bit31_8[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
3873 assign pci_memory_io0 = pci_ba0_bit0 ;
3874 assign pci_memory_io1 = pci_ba1_bit0 ;
3875 assign pci_memory_io2 = pci_ba2_bit0 ;
3876 assign pci_memory_io3 = pci_ba3_bit0 ;
3877 assign pci_memory_io4 = pci_ba4_bit0 ;
3878 assign pci_memory_io5 = pci_ba5_bit0 ;
3880 assign pci_addr_mask0 = pci_am0[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
3881 assign pci_addr_mask1 = pci_am1[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
3882 assign pci_addr_mask2 = pci_am2[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
3883 assign pci_addr_mask3 = pci_am3[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
3884 assign pci_addr_mask4 = pci_am4[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
3885 assign pci_addr_mask5 = pci_am5[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
3886 assign pci_tran_addr0 = pci_ta0[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
3887 assign pci_tran_addr1 = pci_ta1[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
3888 assign pci_tran_addr2 = pci_ta2[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
3889 assign pci_tran_addr3 = pci_ta3[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
3890 assign pci_tran_addr4 = pci_ta4[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
3891 assign pci_tran_addr5 = pci_ta5[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
3892 assign pci_img_ctrl0[2 : 1] = pci_img_ctrl0_bit2_1 ;
3893 assign pci_img_ctrl1[2 : 1] = pci_img_ctrl1_bit2_1 ;
3894 assign pci_img_ctrl2[2 : 1] = pci_img_ctrl2_bit2_1 ;
3895 assign pci_img_ctrl3[2 : 1] = pci_img_ctrl3_bit2_1 ;
3896 assign pci_img_ctrl4[2 : 1] = pci_img_ctrl4_bit2_1 ;
3897 assign pci_img_ctrl5[2 : 1] = pci_img_ctrl5_bit2_1 ;
3898 // WISHBONE output from image registers
3899 // base address, address mask, translation address and control registers are sinchronized in DECODER.V module
3900 assign wb_base_addr0 = wb_ba0_bit31_12[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
3901 assign wb_base_addr1 = wb_ba1_bit31_12[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
3902 assign wb_base_addr2 = wb_ba2_bit31_12[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
3903 assign wb_base_addr3 = wb_ba3_bit31_12[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
3904 assign wb_base_addr4 = wb_ba4_bit31_12[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
3905 assign wb_base_addr5 = wb_ba5_bit31_12[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
3906 assign wb_memory_io0 = wb_ba0_bit0 ;
3907 assign wb_memory_io1 = wb_ba1_bit0 ;
3908 assign wb_memory_io2 = wb_ba2_bit0 ;
3909 assign wb_memory_io3 = wb_ba3_bit0 ;
3910 assign wb_memory_io4 = wb_ba4_bit0 ;
3911 assign wb_memory_io5 = wb_ba5_bit0 ;
3912 assign wb_addr_mask0 = wb_am0[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
3913 assign wb_addr_mask1 = wb_am1[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
3914 assign wb_addr_mask2 = wb_am2[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
3915 assign wb_addr_mask3 = wb_am3[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
3916 assign wb_addr_mask4 = wb_am4[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
3917 assign wb_addr_mask5 = wb_am5[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
3918 assign wb_tran_addr0 = wb_ta0[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
3919 assign wb_tran_addr1 = wb_ta1[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
3920 assign wb_tran_addr2 = wb_ta2[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
3921 assign wb_tran_addr3 = wb_ta3[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
3922 assign wb_tran_addr4 = wb_ta4[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
3923 assign wb_tran_addr5 = wb_ta5[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
3924 assign wb_img_ctrl0[2 : 0] = wb_img_ctrl0_bit2_0 ;
3925 assign wb_img_ctrl1[2 : 0] = wb_img_ctrl1_bit2_0 ;
3926 assign wb_img_ctrl2[2 : 0] = wb_img_ctrl2_bit2_0 ;
3927 assign wb_img_ctrl3[2 : 0] = wb_img_ctrl3_bit2_0 ;
3928 assign wb_img_ctrl4[2 : 0] = wb_img_ctrl4_bit2_0 ;
3929 assign wb_img_ctrl5[2 : 0] = wb_img_ctrl5_bit2_0 ;
3930 // GENERAL output from conf. cycle generation register & int. control register
3931 assign config_addr[23 : 0] = { cnf_addr_bit23_2, 1'b0, cnf_addr_bit0 } ;
3932 assign icr_soft_res = icr_bit31 ;