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

Subversion Repositories pci

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

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

Line No. Rev Author Line
1 77 mihad
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  File name: conf_space.v                                     ////
4
////                                                              ////
5
////  This file is part of the "PCI bridge" project               ////
6
////  http://www.opencores.org/cores/pci/                         ////
7
////                                                              ////
8
////  Author(s):                                                  ////
9
////      - tadej@opencores.org                                   ////
10
////      - Tadej Markovic                                        ////
11
////                                                              ////
12
////  All additional information is avaliable in the README.txt   ////
13
////  file.                                                       ////
14
////                                                              ////
15
////                                                              ////
16
//////////////////////////////////////////////////////////////////////
17
////                                                              ////
18
//// Copyright (C) 2000 Tadej Markovic, tadej@opencores.org       ////
19
////                                                              ////
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. ////
24
////                                                              ////
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.                                               ////
30
////                                                              ////
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 ////
35
//// details.                                                     ////
36
////                                                              ////
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                     ////
40
////                                                              ////
41
//////////////////////////////////////////////////////////////////////
42
//
43
// CVS Revision History
44
//
45
// $Log: not supported by cvs2svn $
46
// Revision 1.4  2002/08/13 11:03:53  mihad
47
// 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
48
//
49
// Revision 1.3  2002/02/01 15:25:12  mihad
50
// Repaired a few bugs, updated specification, added test bench files and design document
51
//
52
// Revision 1.2  2001/10/05 08:14:28  mihad
53
// Updated all files with inclusion of timescale file for simulation purposes.
54
//
55
// Revision 1.1.1.1  2001/10/02 15:33:46  mihad
56
// New project directory structure
57
//
58
//
59
 
60
`include "pci_constants.v"
61
 
62
// synopsys translate_off
63
`include "timescale.v"
64
// synopsys translate_on
65
 
66
/*-----------------------------------------------------------------------------------------------------------
67
        w_ prefix is a sign for Write (and read) side of Dual-Port registers
68
        r_ prefix is a sign for Read only side of Dual-Port registers
69
In the first line there are DATA and ADDRESS ports, in the second line there are write enable and read
70
enable signals with chip-select (conf_hit) for config. space.
71
In the third line there are output signlas from Command register of the PCI configuration header !!!
72
In the fourth line there are input signals to Status register of the PCI configuration header !!!
73
In the fifth line there is output from Latency Timer & r_Interrupt pin registers of the PCI conf. header !!!
74
Following are IMAGE specific registers, from which PCI_BASE_ADDR registers are the same as base address
75
registers from the PCI conf. header !!!
76
-----------------------------------------------------------------------------------------------------------*/
77
                                        // normal R/W address, data and control
78
module pci_conf_space
79
                (       w_conf_address_in, w_conf_data_in, w_conf_data_out, r_conf_address_in, r_conf_data_out,
80
                                        w_we, w_re, r_re, w_byte_en, w_clock, reset, pci_clk, wb_clk,
81
                                        // outputs from command register of the PCI header
82
                                        serr_enable, perr_response, pci_master_enable, memory_space_enable, io_space_enable,
83
                                        // inputs to status register of the PCI header
84
                                        perr_in, serr_in, master_abort_recv, target_abort_recv, target_abort_set, master_data_par_err,
85
                                        // output from cache_line_size, latency timer and r_interrupt_pin register of the PCI header
86
                                        cache_line_size_to_pci, cache_line_size_to_wb, cache_lsize_not_zero_to_wb,
87
                                        latency_tim,
88
                                        // output from all pci IMAGE registers
89
                                        pci_base_addr0, pci_base_addr1, pci_base_addr2, pci_base_addr3, pci_base_addr4, pci_base_addr5,
90
                                        pci_memory_io0, pci_memory_io1, pci_memory_io2, pci_memory_io3, pci_memory_io4, pci_memory_io5,
91
                                        pci_addr_mask0, pci_addr_mask1, pci_addr_mask2, pci_addr_mask3, pci_addr_mask4, pci_addr_mask5,
92
                                        pci_tran_addr0, pci_tran_addr1, pci_tran_addr2, pci_tran_addr3, pci_tran_addr4, pci_tran_addr5,
93
                                        pci_img_ctrl0,  pci_img_ctrl1,  pci_img_ctrl2,  pci_img_ctrl3,  pci_img_ctrl4,  pci_img_ctrl5,
94
                                        // input to pci error control and status register, error address and error data registers
95
                                        pci_error_be, pci_error_bc, pci_error_rty_exp, pci_error_es, pci_error_sig, pci_error_addr,
96
                                        pci_error_data,
97
                                        // output from all wishbone IMAGE registers
98
                                        wb_base_addr0, wb_base_addr1, wb_base_addr2, wb_base_addr3, wb_base_addr4, wb_base_addr5,
99
                                        wb_memory_io0, wb_memory_io1, wb_memory_io2, wb_memory_io3, wb_memory_io4, wb_memory_io5,
100
                                        wb_addr_mask0, wb_addr_mask1, wb_addr_mask2, wb_addr_mask3, wb_addr_mask4, wb_addr_mask5,
101
                                        wb_tran_addr0, wb_tran_addr1, wb_tran_addr2, wb_tran_addr3, wb_tran_addr4, wb_tran_addr5,
102
                                        wb_img_ctrl0,  wb_img_ctrl1,  wb_img_ctrl2,  wb_img_ctrl3,  wb_img_ctrl4,  wb_img_ctrl5,
103
                                        // input to wb error control and status register, error address and error data registers
104
                                        wb_error_be, wb_error_bc, wb_error_rty_exp, wb_error_es, wb_error_sig, wb_error_addr, wb_error_data,
105
                                        // output from conf. cycle generation register (sddress), int. control register & interrupt output
106
                                        config_addr, icr_soft_res, int_out,
107
                                        // input to interrupt status register
108
                                        isr_sys_err_int, isr_par_err_int, isr_int_prop ) ;
109
 
110
 
111
/*###########################################################################################################
112
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
113
        Input and output ports
114
        ======================
115
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
116
###########################################################################################################*/
117
 
118
// output data
119
output  [31 : 0]                         w_conf_data_out ;
120
output  [31 : 0]                         r_conf_data_out ;
121
reg             [31 : 0]                         w_conf_data_out ;
122
 
123
`ifdef  NO_CNF_IMAGE
124
`else
125
reg             [31 : 0]                         r_conf_data_out ;
126
`endif
127
 
128
// input data
129
input   [31 : 0]                         w_conf_data_in ;
130
wire    [31 : 0]                         w_conf_pdata_reduced ; // reduced data written into PCI image registers
131
wire    [31 : 0]                         w_conf_wdata_reduced ; // reduced data written into WB  image registers
132
// input address
133
input   [11 : 0]                         w_conf_address_in ;
134
input   [11 : 0]                         r_conf_address_in ;
135
// input control signals
136
input                                                   w_we ;
137
input                                                   w_re ;
138
input                                                   r_re ;
139
input   [3 : 0]                                  w_byte_en ;
140
input                                                   w_clock ;
141
input                                                   reset ;
142
input                                                   pci_clk ;
143
input                                                   wb_clk ;
144
// PCI header outputs from command register
145
output                                                  serr_enable ;
146
output                                                  perr_response ;
147
output                                                  pci_master_enable ;
148
output                                                  memory_space_enable ;
149
output                                                  io_space_enable ;
150
// PCI header inputs to status register
151
input                                                   perr_in ;
152
input                                                   serr_in ;
153
input                                                   master_abort_recv ;
154
input                                                   target_abort_recv ;
155
input                                                   target_abort_set ;
156
input                                                   master_data_par_err ;
157
// PCI header output from cache_line_size, latency timer and interrupt pin
158
output  [7 : 0]                                  cache_line_size_to_pci ; // sinchronized to PCI clock
159
output  [7 : 0]                                  cache_line_size_to_wb ;  // sinchronized to WB clock
160
output                                                  cache_lsize_not_zero_to_wb ; // used in WBU and PCIU
161
output  [7 : 0]                                  latency_tim ;
162
//output        [2 : 0]                                 int_pin ; // only 3 LSbits are important!
163
// PCI output from image registers
164
output  [31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] pci_base_addr0 ;
165
output  [31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] pci_base_addr1 ;
166
output  [31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] pci_base_addr2 ;
167
output  [31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] pci_base_addr3 ;
168
output  [31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] pci_base_addr4 ;
169
output  [31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] pci_base_addr5 ;
170
output                                                  pci_memory_io0 ;
171
output                                                  pci_memory_io1 ;
172
output                                                  pci_memory_io2 ;
173
output                                                  pci_memory_io3 ;
174
output                                                  pci_memory_io4 ;
175
output                                                  pci_memory_io5 ;
176
output  [31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] pci_addr_mask0 ;
177
output  [31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] pci_addr_mask1 ;
178
output  [31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] pci_addr_mask2 ;
179
output  [31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] pci_addr_mask3 ;
180
output  [31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] pci_addr_mask4 ;
181
output  [31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] pci_addr_mask5 ;
182
output  [31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] pci_tran_addr0 ;
183
output  [31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] pci_tran_addr1 ;
184
output  [31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] pci_tran_addr2 ;
185
output  [31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] pci_tran_addr3 ;
186
output  [31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] pci_tran_addr4 ;
187
output  [31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] pci_tran_addr5 ;
188
output  [2 : 1]                 pci_img_ctrl0 ;
189
output  [2 : 1]                 pci_img_ctrl1 ;
190
output  [2 : 1]                 pci_img_ctrl2 ;
191
output  [2 : 1]                 pci_img_ctrl3 ;
192
output  [2 : 1]                 pci_img_ctrl4 ;
193
output  [2 : 1]                 pci_img_ctrl5 ;
194
// PCI input to pci error control and status register, error address and error data registers
195
input   [3 : 0]                                  pci_error_be ;
196
input   [3 : 0]                 pci_error_bc ;
197
input                           pci_error_rty_exp ;
198
input                                                   pci_error_es ;
199
input                           pci_error_sig ;
200
input   [31 : 0]                pci_error_addr ;
201
input   [31 : 0]                pci_error_data ;
202
// WISHBONE output from image registers
203
output  [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_base_addr0 ;
204
output  [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_base_addr1 ;
205
output  [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_base_addr2 ;
206
output  [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_base_addr3 ;
207
output  [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_base_addr4 ;
208
output  [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_base_addr5 ;
209
output                                                  wb_memory_io0 ;
210
output                                                  wb_memory_io1 ;
211
output                                                  wb_memory_io2 ;
212
output                                                  wb_memory_io3 ;
213
output                                                  wb_memory_io4 ;
214
output                                                  wb_memory_io5 ;
215
output  [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_addr_mask0 ;
216
output  [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_addr_mask1 ;
217
output  [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_addr_mask2 ;
218
output  [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_addr_mask3 ;
219
output  [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_addr_mask4 ;
220
output  [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_addr_mask5 ;
221
output  [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_tran_addr0 ;
222
output  [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_tran_addr1 ;
223
output  [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_tran_addr2 ;
224
output  [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_tran_addr3 ;
225
output  [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_tran_addr4 ;
226
output  [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_tran_addr5 ;
227
output  [2 : 0]                 wb_img_ctrl0 ;
228
output  [2 : 0]                 wb_img_ctrl1 ;
229
output  [2 : 0]                 wb_img_ctrl2 ;
230
output  [2 : 0]                 wb_img_ctrl3 ;
231
output  [2 : 0]                 wb_img_ctrl4 ;
232
output  [2 : 0]                 wb_img_ctrl5 ;
233
// WISHBONE input to wb error control and status register, error address and error data registers
234
input   [3 : 0]                          wb_error_be ;
235
input   [3 : 0]                  wb_error_bc ;
236
input                                   wb_error_rty_exp ;
237
input                           wb_error_es ;
238
input                           wb_error_sig ;
239
input   [31 : 0]                wb_error_addr ;
240
input   [31 : 0]                wb_error_data ;
241
// GENERAL output from conf. cycle generation register & int. control register
242
output  [23 : 0]                         config_addr ;
243
output                          icr_soft_res ;
244
output                                                  int_out ;
245
// GENERAL input to interrupt status register
246
input                           isr_sys_err_int ;
247
input                           isr_par_err_int ;
248
input                                                   isr_int_prop ;
249
 
250
 
251
/*###########################################################################################################
252
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
253
        REGISTERS definition
254
        ====================
255
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
256
###########################################################################################################*/
257
 
258
// Decoded Register Select signals for writting (only one address decoder)
259
reg             [55 : 0]                         w_reg_select_dec ;
260
 
261
/*###########################################################################################################
262
-------------------------------------------------------------------------------------------------------------
263
PCI CONFIGURATION SPACE HEADER (type 00h) registers
264
 
265
        BIST and some other registers are not implemented and therefor written in correct
266
        place with comment line. There are also some registers with NOT all bits implemented and therefor uses
267
        _bitX or _bitX2_X1 to sign which bit or range of bits are implemented.
268
        Some special cases and examples are described below!
269
-------------------------------------------------------------------------------------------------------------
270
###########################################################################################################*/
271
 
272
/*-----------------------------------------------------------------------------------------------------------
273
[000h-00Ch] First 4 DWORDs (32-bit) of PCI configuration header - the same regardless of the HEADER type !
274
                        r_ prefix is a sign for read only registers
275
        Vendor_ID is an ID for a specific vendor defined by PCI_SIG - 2321h does not belong to anyone (e.g.
276
        Xilinx's Vendor_ID is 10EEh and Altera's Vendor_ID is 1172h). Device_ID and Revision_ID should be used
277
        together by application. Class_Code has 3 bytes to define BASE class (06h for PCI Bridge), SUB class
278
        (00h for HOST type, 80h for Other Bridge type) and Interface type (00h for normal).
279
-----------------------------------------------------------------------------------------------------------*/
280
                        parameter                       r_vendor_id = `HEADER_VENDOR_ID ;       // 16'h2321 = 16'd8993 !!!
281
                        parameter                       r_device_id = `HEADER_DEVICE_ID ;
282
                        reg                                     command_bit8 ;
283
                        reg                                     command_bit6 ;
284
                        reg             [2 : 0]          command_bit2_0 ;
285
                        reg             [15 : 11]       status_bit15_11 ;
286
                        parameter                       r_status_bit10_9 = 2'b01 ;      // 2'b01 means MEDIUM devsel timing !!!
287
                        reg                                     status_bit8 ;
288
                        parameter                       r_status_bit7 = 1'b1 ; // fast back-to-back capable response !!!
289
                        parameter                       r_status_bit5 = `HEADER_66MHz ;         // 1'b0 indicates 33 MHz capable !!!
290
                        parameter                       r_revision_id = `HEADER_REVISION_ID ;
291
`ifdef          HOST
292
                        parameter                       r_class_code = 24'h06_00_00 ;
293
`else
294
                        parameter                       r_class_code = 24'h06_80_00 ;
295
`endif
296
                        reg             [7 : 0]          cache_line_size_reg     ;
297
                        reg             [7 : 0]          latency_timer ;
298
                        parameter                       r_header_type = 8'h00 ;
299
                        // REG                          bist                                                    NOT implemented !!!
300
 
301
/*-----------------------------------------------------------------------------------------------------------
302
[010h-03Ch] all other DWORDs (32-bit) of PCI configuration header - only for HEADER type 00h !
303
                        r_ prefix is a sign for read only registers
304
        BASE_ADDRESS_REGISTERS are the same as ones in the PCI Target configuration registers section. They
305
        are duplicated and therefor defined just ones and used with the same name as written below. If
306
        IMAGEx is NOT defined there is only parameter image_X assigned to '0' and this parameter is used
307
        elsewhere in the code. This parameter is defined in the INTERNAL SIGNALS part !!!
308
        Interrupt_Pin value 8'h01 is used for INT_A pin used.
309
        MIN_GNT and MAX_LAT are used for device's desired values for Latency Timer value. The value in boath
310
        registers specifies a period of time in units of 1/4 microsecond. ZERO indicates that there are no
311
        major requirements for the settings of Latency Timer.
312
        MIN_GNT specifieshow how long a burst period the device needs at 33MHz. MAX_LAT specifies how often
313
        the device needs to gain access to the PCI bus. Values are choosen assuming that the target does not
314
        insert any wait states. Follow the expamle of settings for simple display card.
315
        If we use 64 (32-bit) FIFO locations for one burst then we need 8 x 1/4 microsecond periods at 33MHz
316
        clock rate => MIN_GNT = 08h ! Resolution is 1024 x 768 (= 786432 pixels for one frame) with 16-bit
317
        color mode. We can transfere 2 16-bit pixels in one FIFO location. From that we calculate, that for
318
        one frame we need 6144 burst transferes in 1/25 second. So we need one burst every 6,51 microsecond
319
        and that is 26 x 1/4 microsecond or 1Ah x 1/4 microsecond => MAX_LAT = 1Ah !
320
-----------------------------------------------------------------------------------------------------------*/
321
                        // REG x 6              base_address_register_X                 IMPLEMENTED as          pci_ba_X !!!
322
                        // REG                  r_cardbus_cis_pointer                   NOT implemented !!!
323
                        // REG                  r_subsystem_vendor_id                   NOT implemented !!!
324
                        // REG                  r_subsystem_id                                  NOT implemented !!!
325
                        // REG                  r_expansion_rom_base_address    NOT implemented !!!
326
                        // REG                  r_cap_list_pointer                              NOT implemented !!!
327
                        reg             [7 : 0]  interrupt_line ;
328
                        parameter               r_interrupt_pin = 8'h01 ;
329
                        parameter               r_min_gnt = 8'h08 ;
330
                        parameter               r_max_lat = 8'h1a ;
331
 
332
 
333
/*###########################################################################################################
334
-------------------------------------------------------------------------------------------------------------
335
PCI Bridge default image SIZE parameters
336
        This parameters are not part of any register group, but are needed for default image size configuration
337
        used in PCI Target and WISHBONE Slave configuration registers!
338
-------------------------------------------------------------------------------------------------------------
339
###########################################################################################################*/
340
 
341
/*-----------------------------------------------------------------------------------------------------------
342
        PCI Target default image size parameters are defined with masked bits for address mask registers of
343
        each image space. By default there are 1MByte of address space defined for def_pci_imageX_addr_map
344
        parameters!
345
-----------------------------------------------------------------------------------------------------------*/
346
                wire    [19:0]   def_pci_image0_addr_map = `PCI_AM0 ;
347
                wire    [19:0]   def_pci_image1_addr_map = `PCI_AM1 ;
348
                wire    [19:0]   def_pci_image2_addr_map = `PCI_AM2 ;
349
                wire    [19:0]   def_pci_image3_addr_map = `PCI_AM3 ;
350
                wire    [19:0]   def_pci_image4_addr_map = `PCI_AM4 ;
351
                wire    [19:0]   def_pci_image5_addr_map = `PCI_AM5 ;
352
 
353
/*-----------------------------------------------------------------------------------------------------------
354
        WISHBONE Slave default image size parameters are defined with masked bits for address mask registers
355
        of each image space. By default there are 1MByte of address space defined for def_wb_imageX_addr_map
356
        parameters except for def_wb_image0_addr_map which is used for configuration space!
357
-----------------------------------------------------------------------------------------------------------*/
358
                        // PARAMETER    def_wb_image0_addr_map  IMPLEMENTED as r_wb_am0 parameter for CONF. space !!!
359
                wire    [19:0]   def_wb_image1_addr_map = 20'h0000_0 ;
360
                wire    [19:0]   def_wb_image2_addr_map = 20'h0000_0 ;
361
                wire    [19:0]   def_wb_image3_addr_map = 20'h0000_0 ;
362
                wire    [19:0]   def_wb_image4_addr_map = 20'h0000_0 ;
363
                wire    [19:0]   def_wb_image5_addr_map = 20'h0000_0 ;
364
 
365
 
366
/*###########################################################################################################
367
-------------------------------------------------------------------------------------------------------------
368
PCI Target configuration registers
369
        There are also some registers with NOT all bits implemented and therefor uses _bitX or _bitX2_X1 to
370
        sign which bit or range of bits are implemented. Some special cases and examples are described below!
371
-------------------------------------------------------------------------------------------------------------
372
###########################################################################################################*/
373
 
374
/*-----------------------------------------------------------------------------------------------------------
375
[100h-168h]
376
        Depending on defines (PCI_IMAGE1 or .. or PCI_IMAGE5 or (PCI_IMAGE0 and HOST)) in constants.v file,
377
        there are registers corresponding to each IMAGE defined to REG and parameter pci_image_X assigned to '1'.
378
        The maximum number of images is "6". By default there are first two images used and the first (PCI_IMAGE0)
379
        is assigned to Configuration space! With a 'define' PCI_IMAGEx you choose the number of used PCI IMAGES
380
        in a bridge without PCI_IMAGE0 (e.g. PCI_IMAGE3 tells, that PCI_IMAGE1, PCI_IMAGE2 and PCI_IMAGE3 are
381
        used for mapping the space from WB to PCI. Offcourse, PCI_IMAGE0 is assigned to Configuration space).
382
        That leave us PCI_IMAGE5 as the maximum number of images.
383
        There is one exeption, when the core is implemented as HOST. If so, then the PCI specification allowes
384
        the Configuration space NOT to be visible on the PCI bus. With `define PCI_IMAGE0 (and `define HOST), we
385
        assign PCI_IMAGE0 to normal WB to PCI image and not to configuration space!
386
 
387
        When error occurs, PCI ERR_ADDR and ERR_DATA registers stores address and data on the bus that
388
        caused error. While ERR_CS register stores Byte Enables and Bus Command in the MSByte. In bits 10
389
        and 8 it reports Retry Counter Expired (for posted writes), Error Source (Master Abort) and Error
390
        Report Signal (signals that error has occured) respectively. With bit 0 we enable Error Reporting
391
        mechanism.
392
-----------------------------------------------------------------------------------------------------------*/
393
`ifdef          HOST
394
        `ifdef  NO_CNF_IMAGE
395
                `ifdef  PCI_IMAGE0      // if PCI bridge is HOST and IMAGE0 is assigned as general image space
396
                        reg             [31 : 12]       pci_ba0_bit31_12 ;
397
                        reg             [2 : 1]         pci_img_ctrl0_bit2_1 ;
398
                        reg                                     pci_ba0_bit0 ;
399
                        reg             [31 : 12]       pci_am0 ;
400
                        reg             [31 : 12]       pci_ta0 ;
401
                `else // if PCI bridge is HOST and IMAGE0 is not used
402
                        wire    [31 : 12]       pci_ba0_bit31_12 = 20'h0000_0 ; // NO base address needed
403
                        wire    [2 : 1]         pci_img_ctrl0_bit2_1 = 2'b00 ; // NO addr.transl. and pre-fetch
404
                        wire                            pci_ba0_bit0 = 0 ; // config. space is MEMORY space
405
                        wire    [31 : 12]       pci_am0 = 20'h0000_0 ; // NO address mask needed
406
                        wire    [31 : 12]       pci_ta0 = 20'h0000_0 ; // NO address translation needed
407
                `endif
408
        `else // if PCI bridge is HOST and IMAGE0 is assigned to PCI configuration space
409
                        reg             [31 : 12]       pci_ba0_bit31_12 ;
410
                        wire    [2 : 1]         pci_img_ctrl0_bit2_1 = 2'b00 ; // NO pre-fetch and read line support
411
                        wire                            pci_ba0_bit0 = 0 ; // config. space is MEMORY space
412
                        wire    [31 : 12]       pci_am0 = 20'hFFFF_F ; // address mask for configuration image always 20'hffff_f
413
                        wire    [31 : 12]       pci_ta0 = 20'h0000_0 ; // NO address translation needed
414
        `endif
415
`else // if PCI bridge is GUEST, then IMAGE0 is assigned to PCI configuration space
416
                        reg             [31 : 12]       pci_ba0_bit31_12 ;
417
                        wire    [2 : 1]         pci_img_ctrl0_bit2_1 = 2'b00 ; // NO addr.transl. and pre-fetch
418
                        wire                            pci_ba0_bit0 = 0 ; // config. space is MEMORY space
419
                        wire    [31 : 12]       pci_am0 = 20'hffff_f ; // address mask for configuration image always 20'hffff_f
420
                        wire    [31 : 12]       pci_ta0 = 20'h0000_0 ; // NO address translation needed
421
`endif
422
// IMAGE1 is included by default, meanwhile other IMAGEs are optional !!!
423
                        reg             [2 : 1]         pci_img_ctrl1_bit2_1 ;
424
                        reg             [31 : 12]       pci_ba1_bit31_12 ;
425
        `ifdef  HOST
426
                        reg                                     pci_ba1_bit0 ;
427
        `else
428
                        wire                            pci_ba1_bit0 = `PCI_BA1_MEM_IO ;
429
        `endif
430
                        reg             [31 : 12]       pci_am1 ;
431
                        reg             [31 : 12]       pci_ta1 ;
432
`ifdef          PCI_IMAGE2
433
                        reg             [2 : 1]         pci_img_ctrl2_bit2_1 ;
434
                        reg             [31 : 12]       pci_ba2_bit31_12 ;
435
        `ifdef  HOST
436
                        reg                                     pci_ba2_bit0 ;
437
        `else
438
                        wire                            pci_ba2_bit0 = `PCI_BA2_MEM_IO ;
439
        `endif
440
                        reg             [31 : 12]       pci_am2 ;
441
                        reg             [31 : 12]       pci_ta2 ;
442
`else
443
            wire        [2 : 1]         pci_img_ctrl2_bit2_1 = 2'b00 ;
444
                        wire    [31 : 12]       pci_ba2_bit31_12 = 20'h0000_0 ;
445
            wire                                pci_ba2_bit0 = 1'b0 ;
446
            wire        [31 : 12]       pci_am2 = 20'h0000_0 ;
447
            wire        [31 : 12]       pci_ta2 = 20'h0000_0 ;
448
`endif
449
`ifdef          PCI_IMAGE3
450
                        reg             [2 : 1]         pci_img_ctrl3_bit2_1 ;
451
                        reg             [31 : 12]       pci_ba3_bit31_12 ;
452
        `ifdef  HOST
453
                        reg                                     pci_ba3_bit0 ;
454
        `else
455
                        wire                            pci_ba3_bit0 = `PCI_BA3_MEM_IO ;
456
        `endif
457
                        reg             [31 : 12]       pci_am3 ;
458
                        reg             [31 : 12]       pci_ta3 ;
459
`else
460
            wire        [2 : 1]         pci_img_ctrl3_bit2_1 = 2'b00 ;
461
                        wire    [31 : 12]       pci_ba3_bit31_12 = 20'h0000_0 ;
462
            wire                                pci_ba3_bit0 = 1'b0 ;
463
            wire        [31 : 12]       pci_am3 = 20'h0000_0 ;
464
            wire        [31 : 12]       pci_ta3 = 20'h0000_0 ;
465
`endif
466
`ifdef          PCI_IMAGE4
467
                        reg             [2 : 1]         pci_img_ctrl4_bit2_1 ;
468
                        reg             [31 : 12]       pci_ba4_bit31_12 ;
469
        `ifdef  HOST
470
                        reg                                     pci_ba4_bit0 ;
471
        `else
472
                        wire                            pci_ba4_bit0 = `PCI_BA4_MEM_IO ;
473
        `endif
474
                        reg             [31 : 12]       pci_am4 ;
475
                        reg             [31 : 12]       pci_ta4 ;
476
`else
477
            wire        [2 : 1]         pci_img_ctrl4_bit2_1 = 2'b00 ;
478
                        wire    [31 : 12]       pci_ba4_bit31_12 = 20'h0000_0 ;
479
            wire                                pci_ba4_bit0 = 1'b0 ;
480
            wire        [31 : 12]       pci_am4 = 20'h0000_0 ;
481
            wire        [31 : 12]       pci_ta4 = 20'h0000_0 ;
482
`endif
483
`ifdef          PCI_IMAGE5
484
                        reg             [2 : 1]         pci_img_ctrl5_bit2_1 ;
485
                        reg             [31 : 12]       pci_ba5_bit31_12 ;
486
        `ifdef  HOST
487
                        reg                                     pci_ba5_bit0 ;
488
        `else
489
                        wire                            pci_ba5_bit0 = `PCI_BA5_MEM_IO ;
490
        `endif
491
                        reg             [31 : 12]       pci_am5 ;
492
                        reg             [31 : 12]       pci_ta5 ;
493
`else
494
            wire        [2 : 1]         pci_img_ctrl5_bit2_1 = 2'b00 ;
495
                        wire    [31 : 12]       pci_ba5_bit31_12 = 20'h0000_0 ;
496
            wire                                pci_ba5_bit0 = 1'b0 ;
497
            wire        [31 : 12]       pci_am5 = 20'h0000_0 ;
498
            wire        [31 : 12]       pci_ta5 = 20'h0000_0 ;
499
`endif
500
                        reg             [31 : 24]       pci_err_cs_bit31_24 ;
501
                        reg                                     pci_err_cs_bit10 ;
502
                        reg                                     pci_err_cs_bit9 ;
503
                        reg                                     pci_err_cs_bit8 ;
504
                        reg                                     pci_err_cs_bit0 ;
505
                        reg             [31 : 0] pci_err_addr ;
506
                        reg             [31 : 0] pci_err_data ;
507
 
508
 
509
/*###########################################################################################################
510
-------------------------------------------------------------------------------------------------------------
511
WISHBONE Slave configuration registers
512
        There are also some registers with NOT all bits implemented and therefor uses _bitX or _bitX2_X1 to
513
        sign which bit or range of bits are implemented. Some special cases and examples are described below!
514
-------------------------------------------------------------------------------------------------------------
515
###########################################################################################################*/
516
 
517
/*-----------------------------------------------------------------------------------------------------------
518
[800h-85Ch]
519
        Depending on defines (WB_IMAGE1 or .. or WB_IMAGE4 or WB_IMAGE5) in constants.v file, there are
520
        registers corresponding to each IMAGE defined to REG and parameter wb_image_X assigned to '1'.
521
        The maximum number of images is "6". By default there are first two images used and the first (WB_IMAGE0)
522
        is assigned to Configuration space! With a 'define' WB_IMAGEx you choose the number of used WB IMAGES in
523
        a bridge without WB_IMAGE0 (e.g. WB_IMAGE3 tells, that WB_IMAGE1, WB_IMAGE2 and WB_IMAGE3 are used for
524
        mapping the space from PCI to WB. Offcourse, WB_IMAGE0 is assigned to Configuration space). That leave
525
        us WB_IMAGE5 as the maximum number of images.
526
 
527
        When error occurs, WISHBONE ERR_ADDR and ERR_DATA registers stores address and data on the bus that
528
        caused error. While ERR_CS register stores Byte Enables and Bus Command in the MSByte. In bits 10, 9
529
        and 8 it reports Retry Counter Expired (for posted writes), Error Source (Master Abort) and Error
530
        Report Signal (signals that error has occured) respectively. With bit 0 we enable Error Reporting
531
        mechanism.
532
-----------------------------------------------------------------------------------------------------------*/
533
// WB_IMAGE0 is always assigned to config. space or is not used
534
                        wire    [2 : 0]          wb_img_ctrl0_bit2_0 = 3'b000 ; // NO addr.transl., pre-fetch and read-line
535
                        wire    [31 : 12]       wb_ba0_bit31_12 = `WB_CONFIGURATION_BASE ;
536
                        wire                            wb_ba0_bit0 = 0 ; // config. space is MEMORY space
537
                        wire    [31 : 12]       wb_am0 = `WB_AM0 ; // 4KBytes of configuration space is minimum
538
                        wire    [31 : 12]       wb_ta0 = 20'h0000_0 ; // NO address translation needed
539
// WB_IMAGE1 is included by default meanwhile others are optional !
540
                        reg             [2 : 0]          wb_img_ctrl1_bit2_0 ;
541
                        reg             [31 : 12]       wb_ba1_bit31_12 ;
542
                        reg                                     wb_ba1_bit0 ;
543
                        reg             [31 : 12]       wb_am1 ;
544
                        reg             [31 : 12]       wb_ta1 ;
545
`ifdef          WB_IMAGE2
546
                        reg             [2 : 0]          wb_img_ctrl2_bit2_0 ;
547
                        reg             [31 : 12]       wb_ba2_bit31_12 ;
548
                        reg                                     wb_ba2_bit0 ;
549
                        reg             [31 : 12]       wb_am2 ;
550
                        reg             [31 : 12]       wb_ta2 ;
551
`else
552
            wire        [2 : 0]          wb_img_ctrl2_bit2_0 = 3'b000 ;
553
                        wire    [31 : 12]       wb_ba2_bit31_12 = 20'h0000_0 ;
554
            wire                                wb_ba2_bit0 = 1'b0 ;
555
            wire        [31 : 12]       wb_am2 = 20'h0000_0 ;
556
            wire        [31 : 12]       wb_ta2 = 20'h0000_0 ;
557
`endif
558
`ifdef          WB_IMAGE3
559
                        reg             [2 : 0]          wb_img_ctrl3_bit2_0 ;
560
                        reg             [31 : 12]       wb_ba3_bit31_12 ;
561
                        reg                                     wb_ba3_bit0 ;
562
                        reg             [31 : 12]       wb_am3 ;
563
                        reg             [31 : 12]       wb_ta3 ;
564
`else
565
            wire        [2 : 0]          wb_img_ctrl3_bit2_0 = 3'b000 ;
566
                        wire    [31 : 12]       wb_ba3_bit31_12 = 20'h0000_0 ;
567
            wire                                wb_ba3_bit0 = 1'b0 ;
568
            wire        [31 : 12]       wb_am3 = 20'h0000_0 ;
569
            wire        [31 : 12]       wb_ta3 = 20'h0000_0 ;
570
`endif
571
`ifdef          WB_IMAGE4
572
                        reg             [2 : 0]          wb_img_ctrl4_bit2_0 ;
573
                        reg             [31 : 12]       wb_ba4_bit31_12 ;
574
                        reg                                     wb_ba4_bit0 ;
575
                        reg             [31 : 12]       wb_am4 ;
576
                        reg             [31 : 12]       wb_ta4 ;
577
`else
578
            wire        [2 : 0]          wb_img_ctrl4_bit2_0 = 3'b000 ;
579
                        wire    [31 : 12]       wb_ba4_bit31_12 = 20'h0000_0 ;
580
            wire                                wb_ba4_bit0 = 1'b0 ;
581
            wire        [31 : 12]       wb_am4 = 20'h0000_0 ;
582
            wire        [31 : 12]       wb_ta4 = 20'h0000_0 ;
583
`endif
584
`ifdef          WB_IMAGE5
585
                        reg             [2 : 0]          wb_img_ctrl5_bit2_0 ;
586
                        reg             [31 : 12]       wb_ba5_bit31_12 ;
587
                        reg                                     wb_ba5_bit0 ;
588
                        reg             [31 : 12]       wb_am5 ;
589
                        reg             [31 : 12]       wb_ta5 ;
590
`else
591
            wire        [2 : 0]          wb_img_ctrl5_bit2_0 = 3'b000 ;
592
                        wire    [31 : 12]       wb_ba5_bit31_12 = 20'h0000_0 ;
593
            wire                                wb_ba5_bit0 = 1'b0 ;
594
            wire        [31 : 12]       wb_am5 = 20'h0000_0 ;
595
            wire        [31 : 12]       wb_ta5 = 20'h0000_0 ;
596
`endif
597
                        reg             [31 : 24]       wb_err_cs_bit31_24 ;
598
/*                      reg                                     wb_err_cs_bit10 ;*/
599
                        reg                                     wb_err_cs_bit9 ;
600
                        reg                                     wb_err_cs_bit8 ;
601
                        reg                                     wb_err_cs_bit0 ;
602
                        reg             [31 : 0] wb_err_addr ;
603
                        reg             [31 : 0] wb_err_data ;
604
 
605
 
606
/*###########################################################################################################
607
-------------------------------------------------------------------------------------------------------------
608
Configuration Cycle address register
609
        There are also some registers with NOT all bits implemented and therefor uses _bitX or _bitX2_X1 to
610
        sign which bit or range of bits are implemented.
611
-------------------------------------------------------------------------------------------------------------
612
###########################################################################################################*/
613
 
614
/*-----------------------------------------------------------------------------------------------------------
615
[860h-868h]
616
        PCI bridge must ignore Type 1 configuration cycles (Master Abort) since they are used for PCI to PCI
617
        bridges. This is single function device, that means responding on configuration cycles to all functions
618
        (or responding only to function 0). Configuration address register for generating configuration cycles
619
        is prepared for all options (it includes Bus Number, Device, Function, Offset and Type).
620
        Interrupt acknowledge register stores interrupt vector data returned during Interrupt Acknowledge cycle.
621
-----------------------------------------------------------------------------------------------------------*/
622
`ifdef          HOST
623
                        reg             [23 : 2]        cnf_addr_bit23_2 ;
624
                        reg                                     cnf_addr_bit0 ;
625
`else // GUEST
626
                        wire    [23 : 2]        cnf_addr_bit23_2        = 22'h0 ;
627
                        wire                            cnf_addr_bit0           = 1'b0 ;
628
`endif
629
                        // reg  [31 : 0]        cnf_data ;              IMPLEMENTED elsewhere !!!!!
630
                        // reg  [31 : 0]        int_ack ;               IMPLEMENTED elsewhere !!!!!
631
 
632
 
633
/*###########################################################################################################
634
-------------------------------------------------------------------------------------------------------------
635
General Interrupt registers
636
        There are also some registers with NOT all bits implemented and therefor uses _bitX or _bitX2_X1 to
637
        sign which bit or range of bits are implemented.
638
-------------------------------------------------------------------------------------------------------------
639
###########################################################################################################*/
640
 
641
/*-----------------------------------------------------------------------------------------------------------
642
[FF8h-FFCh]
643
        Bit 31 in the Interrupt Control register is set by software and used to generate SOFT RESET. Other 4
644
        bits are used to enable interrupt generations.
645
        5 LSbits in the Interrupt Status register are indicating System Error Int, Parity Error Int, PCI & WB
646
        Error Int and Inerrupt respecively. System and Parity errors are implented only in HOST bridge
647
        implementations!
648
-----------------------------------------------------------------------------------------------------------*/
649
                        reg                                     icr_bit31 ;
650
`ifdef          HOST
651
                        reg             [4 : 3]         icr_bit4_3 ;
652
                        reg             [4 : 3]         isr_bit4_3 ;
653
                        reg             [2 : 0]          icr_bit2_0 ;
654
                        reg             [2 : 0]          isr_bit2_0 ;
655
`else // GUEST
656
                        wire    [4 : 3]         icr_bit4_3 = 2'h0 ;
657
                        wire    [4 : 3]         isr_bit4_3 = 2'h0 ;
658
                        reg             [2 : 0]          icr_bit2_0 ;
659
                        reg             [2 : 0]          isr_bit2_0 ;
660
`endif
661
 
662
 
663
/*###########################################################################################################
664
-------------------------------------------------------------------------------------------------------------
665
 
666
 
667
-----------------------------------------------------------------------------------------------------------*/
668
 
669
`ifdef NO_CNF_IMAGE // if IMAGE0 is assigned as general image space
670
 
671
                assign  r_conf_data_out = 32'h0000_0000 ;
672
 
673
`else
674
 
675
    always@(r_conf_address_in or
676
                status_bit15_11 or status_bit8 or command_bit8 or command_bit6 or command_bit2_0 or
677
                latency_timer or cache_line_size_reg or
678
                pci_ba0_bit31_12 or
679
                pci_img_ctrl0_bit2_1 or pci_am0 or pci_ta0 or pci_ba0_bit0 or
680
                pci_img_ctrl1_bit2_1 or pci_am1 or pci_ta1 or pci_ba1_bit31_12 or pci_ba1_bit0 or
681
                pci_img_ctrl2_bit2_1 or pci_am2 or pci_ta2 or pci_ba2_bit31_12 or pci_ba2_bit0 or
682
                pci_img_ctrl3_bit2_1 or pci_am3 or pci_ta3 or pci_ba3_bit31_12 or pci_ba3_bit0 or
683
                pci_img_ctrl4_bit2_1 or pci_am4 or pci_ta4 or pci_ba4_bit31_12 or pci_ba4_bit0 or
684
                pci_img_ctrl5_bit2_1 or pci_am5 or pci_ta5 or pci_ba5_bit31_12 or pci_ba5_bit0 or
685
                interrupt_line or
686
                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
687
                pci_err_addr or pci_err_data or
688
                wb_ba0_bit31_12 or wb_ba0_bit0 or
689
                wb_img_ctrl1_bit2_0 or wb_ba1_bit31_12 or wb_ba1_bit0 or wb_am1 or wb_ta1 or
690
                wb_img_ctrl2_bit2_0 or wb_ba2_bit31_12 or wb_ba2_bit0 or wb_am2 or wb_ta2 or
691
                wb_img_ctrl3_bit2_0 or wb_ba3_bit31_12 or wb_ba3_bit0 or wb_am3 or wb_ta3 or
692
                wb_img_ctrl4_bit2_0 or wb_ba4_bit31_12 or wb_ba4_bit0 or wb_am4 or wb_ta4 or
693
                wb_img_ctrl5_bit2_0 or wb_ba5_bit31_12 or wb_ba5_bit0 or wb_am5 or wb_ta5 or
694
                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
695
                wb_err_addr or wb_err_data or
696
                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
697
                )
698
    begin
699
        case (r_conf_address_in[8])
700
        1'b0 :
701
        begin
702
          case ({r_conf_address_in[7], r_conf_address_in[6]})
703
          2'b00 :
704
          begin
705
                // PCI header - configuration space
706
                case (r_conf_address_in[5:2])
707
                4'h0: r_conf_data_out = { r_device_id, r_vendor_id } ;
708
                4'h1: r_conf_data_out = { status_bit15_11, r_status_bit10_9, status_bit8, r_status_bit7, 1'h0, r_status_bit5,
709
                                                                         5'h00, 7'h00, command_bit8, 1'h0, command_bit6, 3'h0, command_bit2_0 } ;
710
                4'h2: r_conf_data_out = { r_class_code, r_revision_id } ;
711
                4'h3: r_conf_data_out = { 8'h00, r_header_type, latency_timer, cache_line_size_reg } ;
712
                4'h4:
713
                begin
714
                        r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba0_bit31_12[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
715
                                                                                                                                 pci_am0[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
716
                        r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
717
                        r_conf_data_out[0] = pci_ba0_bit0 & pci_am0[31];
718
                end
719
                4'h5:
720
                begin
721
                        r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba1_bit31_12[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
722
                                                                                                                                 pci_am1[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
723
                        r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
724
                        r_conf_data_out[0] = pci_ba1_bit0 & pci_am1[31];
725
                end
726
                4'h6:
727
                begin
728
                        r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba2_bit31_12[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
729
                                                                                                                                 pci_am2[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
730
                        r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
731
                        r_conf_data_out[0] = pci_ba2_bit0 & pci_am2[31];
732
                end
733
                4'h7:
734
                begin
735
                        r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba3_bit31_12[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
736
                                                                                                                                 pci_am3[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
737
                        r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
738
                        r_conf_data_out[0] = pci_ba3_bit0 & pci_am3[31];
739
                end
740
                4'h8:
741
                begin
742
                        r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba4_bit31_12[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
743
                                                                                                                                 pci_am4[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
744
                        r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
745
                        r_conf_data_out[0] = pci_ba4_bit0 & pci_am4[31];
746
                end
747
                4'h9:
748
                begin
749
                        r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba5_bit31_12[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
750
                                                                                                                                 pci_am5[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
751
                        r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
752
                        r_conf_data_out[0] = pci_ba5_bit0 & pci_am5[31];
753
                end
754
                4'hf: r_conf_data_out = { r_max_lat, r_min_gnt, r_interrupt_pin, interrupt_line } ;
755
                default : r_conf_data_out = 32'h0000_0000 ;
756
                endcase
757
          end
758
          default :
759
            r_conf_data_out = 32'h0000_0000 ;
760
          endcase
761
        end
762
        default :
763
        begin
764
                // PCI target - configuration space
765
                case (r_conf_address_in[7:2])
766
                `P_IMG_CTRL0_ADDR: r_conf_data_out = { 29'h00000000, pci_img_ctrl0_bit2_1, 1'h0 } ;
767
            `P_BA0_ADDR          :
768
                begin
769
                        r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba0_bit31_12[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
770
                                                                                                                                 pci_am0[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
771
                        r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
772
                        r_conf_data_out[0] = pci_ba0_bit0 & pci_am0[31];
773
                end
774
            `P_AM0_ADDR          :
775
                begin
776
                r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_am0[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
777
                        r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
778
                end
779
            `P_TA0_ADDR          :
780
                begin
781
                r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ta0[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
782
                        r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
783
                end
784
            `P_IMG_CTRL1_ADDR: r_conf_data_out = { 29'h00000000, pci_img_ctrl1_bit2_1, 1'h0 } ;
785
            `P_BA1_ADDR          :
786
                begin
787
                        r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba1_bit31_12[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
788
                                                                                                                                 pci_am1[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
789
                        r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
790
                        r_conf_data_out[0] = pci_ba1_bit0 & pci_am1[31];
791
                end
792
            `P_AM1_ADDR          :
793
                begin
794
                r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_am1[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
795
                        r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
796
                end
797
            `P_TA1_ADDR          :
798
                begin
799
                r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ta1[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
800
                        r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
801
                end
802
            `P_IMG_CTRL2_ADDR: r_conf_data_out = { 29'h00000000, pci_img_ctrl2_bit2_1, 1'h0 } ;
803
            `P_BA2_ADDR          :
804
                begin
805
                        r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba2_bit31_12[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
806
                                                                                                                                 pci_am2[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
807
                        r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
808
                        r_conf_data_out[0] = pci_ba2_bit0 & pci_am2[31];
809
                end
810
            `P_AM2_ADDR          :
811
                begin
812
                r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_am2[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
813
                        r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
814
                end
815
            `P_TA2_ADDR          :
816
                begin
817
                r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ta2[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
818
                        r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
819
                end
820
            `P_IMG_CTRL3_ADDR: r_conf_data_out = { 29'h00000000, pci_img_ctrl3_bit2_1, 1'h0 } ;
821
            `P_BA3_ADDR          :
822
                begin
823
                        r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba3_bit31_12[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
824
                                                                                                                                 pci_am3[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
825
                        r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
826
                        r_conf_data_out[0] = pci_ba3_bit0 & pci_am3[31];
827
                end
828
            `P_AM3_ADDR          :
829
                begin
830
                r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_am3[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
831
                        r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
832
                end
833
            `P_TA3_ADDR          :
834
                begin
835
                r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ta3[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
836
                        r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
837
                end
838
            `P_IMG_CTRL4_ADDR: r_conf_data_out = { 29'h00000000, pci_img_ctrl4_bit2_1, 1'h0 } ;
839
            `P_BA4_ADDR          :
840
                begin
841
                        r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba4_bit31_12[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
842
                                                                                                                                 pci_am4[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
843
                        r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
844
                        r_conf_data_out[0] = pci_ba4_bit0 & pci_am4[31];
845
                end
846
            `P_AM4_ADDR          :
847
                begin
848
                r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_am4[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
849
                        r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
850
                end
851
            `P_TA4_ADDR          :
852
                begin
853
                r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ta4[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
854
                        r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
855
                end
856
            `P_IMG_CTRL5_ADDR: r_conf_data_out = { 29'h00000000, pci_img_ctrl5_bit2_1, 1'h0 } ;
857
            `P_BA5_ADDR          :
858
                begin
859
                        r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba5_bit31_12[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
860
                                                                                                                                 pci_am5[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
861
                        r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
862
                        r_conf_data_out[0] = pci_ba5_bit0 & pci_am5[31];
863
                end
864
            `P_AM5_ADDR          :
865
                begin
866
                r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_am5[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
867
                        r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
868
                end
869
            `P_TA5_ADDR          :
870
                begin
871
                r_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ta5[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
872
                        r_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
873
                end
874
            `P_ERR_CS_ADDR       : r_conf_data_out = { pci_err_cs_bit31_24, 13'h0000, pci_err_cs_bit10, pci_err_cs_bit9,
875
                                                                                   pci_err_cs_bit8, 7'h00, pci_err_cs_bit0 } ;
876
            `P_ERR_ADDR_ADDR : r_conf_data_out = pci_err_addr ;
877
            `P_ERR_DATA_ADDR : r_conf_data_out = pci_err_data ;
878
                // WB slave - configuration space
879
                `WB_CONF_SPC_BAR_ADDR: r_conf_data_out = { wb_ba0_bit31_12, 11'h000, wb_ba0_bit0 } ;
880
                `W_IMG_CTRL1_ADDR: r_conf_data_out = { 29'h00000000, wb_img_ctrl1_bit2_0 } ;
881
                `W_BA1_ADDR              :
882
                begin
883
                        r_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ba1_bit31_12[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] &
884
                                                                                                                                wb_am1[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
885
                        r_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):1]  = 0 ;
886
                        r_conf_data_out[0] = wb_ba1_bit0 ;
887
                end
888
                `W_AM1_ADDR              :
889
                begin
890
                        r_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_am1[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
891
                        r_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0]  = 0 ;
892
                end
893
                `W_TA1_ADDR              :
894
                begin
895
                        r_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ta1[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
896
                        r_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0]  = 0 ;
897
                end
898
                `W_IMG_CTRL2_ADDR: r_conf_data_out = { 29'h00000000, wb_img_ctrl2_bit2_0 } ;
899
                `W_BA2_ADDR              :
900
                begin
901
                        r_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ba2_bit31_12[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] &
902
                                                                                                                                wb_am2[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
903
                        r_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):1]  = 0 ;
904
                        r_conf_data_out[0] = wb_ba2_bit0 ;
905
                end
906
                `W_AM2_ADDR              :
907
                begin
908
                        r_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_am2[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
909
                        r_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0]  = 0 ;
910
                end
911
                `W_TA2_ADDR              :
912
                begin
913
                        r_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ta2[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
914
                        r_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0]  = 0 ;
915
                end
916
                `W_IMG_CTRL3_ADDR: r_conf_data_out = { 29'h00000000, wb_img_ctrl3_bit2_0 } ;
917
                `W_BA3_ADDR              :
918
                begin
919
                        r_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ba3_bit31_12[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] &
920
                                                                                                                                wb_am3[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
921
                        r_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):1]  = 0 ;
922
                        r_conf_data_out[0] = wb_ba3_bit0 ;
923
                end
924
                `W_AM3_ADDR              :
925
                begin
926
                        r_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_am3[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
927
                        r_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0]  = 0 ;
928
                end
929
                `W_TA3_ADDR              :
930
                begin
931
                        r_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ta3[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
932
                        r_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0]  = 0 ;
933
                end
934
                `W_IMG_CTRL4_ADDR: r_conf_data_out = { 29'h00000000, wb_img_ctrl4_bit2_0 } ;
935
                `W_BA4_ADDR              :
936
                begin
937
                        r_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ba4_bit31_12[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] &
938
                                                                                                                                wb_am4[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
939
                        r_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):1]  = 0 ;
940
                        r_conf_data_out[0] = wb_ba4_bit0 ;
941
                end
942
                `W_AM4_ADDR              :
943
                begin
944
                        r_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_am4[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
945
                        r_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0]  = 0 ;
946
                end
947
                `W_TA4_ADDR              :
948
                begin
949
                        r_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ta4[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
950
                        r_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0]  = 0 ;
951
                end
952
                `W_IMG_CTRL5_ADDR: r_conf_data_out = { 29'h00000000, wb_img_ctrl5_bit2_0 } ;
953
                `W_BA5_ADDR              :
954
                begin
955
                        r_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ba5_bit31_12[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] &
956
                                                                                                                                wb_am5[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
957
                        r_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):1]  = 0 ;
958
                        r_conf_data_out[0] = wb_ba5_bit0 ;
959
                end
960
                `W_AM5_ADDR              :
961
                begin
962
                        r_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_am5[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
963
                        r_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0]  = 0 ;
964
                end
965
                `W_TA5_ADDR              :
966
                begin
967
                        r_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ta5[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
968
                        r_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0]  = 0 ;
969
                end
970
                `W_ERR_CS_ADDR   : r_conf_data_out = { wb_err_cs_bit31_24, /*13*/14'h0000, /*wb_err_cs_bit10,*/
971
                                                                                   wb_err_cs_bit9, wb_err_cs_bit8, 7'h00, wb_err_cs_bit0 } ;
972
                `W_ERR_ADDR_ADDR : r_conf_data_out = wb_err_addr ;
973
                `W_ERR_DATA_ADDR : r_conf_data_out = wb_err_data ;
974
 
975
                `CNF_ADDR_ADDR   : r_conf_data_out = { 8'h00, cnf_addr_bit23_2, 1'h0, cnf_addr_bit0 } ;
976
                // `CNF_DATA_ADDR: implemented elsewhere !!!
977
                // `INT_ACK_ADDR : implemented elsewhere !!!
978
            `ICR_ADDR            : r_conf_data_out = { icr_bit31, 26'h0000_000, icr_bit4_3, icr_bit2_0 } ;
979
            `ISR_ADDR            : r_conf_data_out = { 27'h0000_000, isr_bit4_3, isr_bit2_0 } ;
980
 
981
                default : r_conf_data_out = 32'h0000_0000 ;
982
                endcase
983
        end
984
        endcase
985
    end
986
 
987
`endif
988
 
989
always@(w_conf_address_in or
990
                status_bit15_11 or status_bit8 or command_bit8 or command_bit6 or command_bit2_0 or
991
                latency_timer or cache_line_size_reg or
992
                pci_ba0_bit31_12 or
993
                pci_img_ctrl0_bit2_1 or pci_am0 or pci_ta0 or pci_ba0_bit0 or
994
                pci_img_ctrl1_bit2_1 or pci_am1 or pci_ta1 or pci_ba1_bit31_12 or pci_ba1_bit0 or
995
                pci_img_ctrl2_bit2_1 or pci_am2 or pci_ta2 or pci_ba2_bit31_12 or pci_ba2_bit0 or
996
                pci_img_ctrl3_bit2_1 or pci_am3 or pci_ta3 or pci_ba3_bit31_12 or pci_ba3_bit0 or
997
                pci_img_ctrl4_bit2_1 or pci_am4 or pci_ta4 or pci_ba4_bit31_12 or pci_ba4_bit0 or
998
                pci_img_ctrl5_bit2_1 or pci_am5 or pci_ta5 or pci_ba5_bit31_12 or pci_ba5_bit0 or
999
                interrupt_line or
1000
                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
1001
                pci_err_addr or pci_err_data or
1002
                wb_ba0_bit31_12 or wb_ba0_bit0 or
1003
                wb_img_ctrl1_bit2_0 or wb_ba1_bit31_12 or wb_ba1_bit0 or wb_am1 or wb_ta1 or
1004
                wb_img_ctrl2_bit2_0 or wb_ba2_bit31_12 or wb_ba2_bit0 or wb_am2 or wb_ta2 or
1005
                wb_img_ctrl3_bit2_0 or wb_ba3_bit31_12 or wb_ba3_bit0 or wb_am3 or wb_ta3 or
1006
                wb_img_ctrl4_bit2_0 or wb_ba4_bit31_12 or wb_ba4_bit0 or wb_am4 or wb_ta4 or
1007
                wb_img_ctrl5_bit2_0 or wb_ba5_bit31_12 or wb_ba5_bit0 or wb_am5 or wb_ta5 or
1008
                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
1009
                wb_err_addr or wb_err_data or
1010
                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
1011
                )
1012
begin
1013
        case (w_conf_address_in[8])
1014
        1'b0 :
1015
        begin
1016
          case ({w_conf_address_in[7], w_conf_address_in[6]})
1017
          2'b00 :
1018
          begin
1019
                // PCI header - configuration space
1020
                case (w_conf_address_in[5:2])
1021
                4'h0:
1022
                begin
1023
                        w_conf_data_out = { r_device_id, r_vendor_id } ;
1024
                        w_reg_select_dec = 56'h00_0000_0000_0000 ; // Read-Only register
1025
                end
1026
                4'h1: // w_reg_select_dec bit 0
1027
                begin
1028
                        w_conf_data_out = { status_bit15_11, r_status_bit10_9, status_bit8, r_status_bit7, 1'h0, r_status_bit5,
1029
                                                                 5'h00, 7'h00, command_bit8, 1'h0, command_bit6, 3'h0, command_bit2_0 } ;
1030
                        w_reg_select_dec = 56'h00_0000_0000_0001 ;
1031
                end
1032
                4'h2:
1033
                begin
1034
                        w_conf_data_out = { r_class_code, r_revision_id } ;
1035
                        w_reg_select_dec = 56'h00_0000_0000_0000 ; // Read-Only register
1036
                end
1037
                4'h3: // w_reg_select_dec bit 1
1038
                begin
1039
                        w_conf_data_out = { 8'h00, r_header_type, latency_timer, cache_line_size_reg } ;
1040
                        w_reg_select_dec = 56'h00_0000_0000_0002 ;
1041
                end
1042
                4'h4: // w_reg_select_dec bit 4
1043
                begin
1044
                w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba0_bit31_12[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
1045
                                                                                                                         pci_am0[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1046
                w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
1047
                w_conf_data_out[0] = pci_ba0_bit0 & pci_am0[31];
1048
                        w_reg_select_dec = 56'h00_0000_0000_0010 ; // The same for another address
1049
                end
1050
                4'h5: // w_reg_select_dec bit 8
1051
                begin
1052
                w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba1_bit31_12[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
1053
                                                                                                                         pci_am1[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1054
                w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
1055
                w_conf_data_out[0] = pci_ba1_bit0 & pci_am1[31];
1056
                        w_reg_select_dec = 56'h00_0000_0000_0100 ; // The same for another address
1057
                end
1058
                4'h6: // w_reg_select_dec bit 12
1059
                begin
1060
                w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba2_bit31_12[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
1061
                                                                                                                         pci_am2[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1062
                w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
1063
                w_conf_data_out[0] = pci_ba2_bit0 & pci_am2[31];
1064
                        w_reg_select_dec = 56'h00_0000_0000_1000 ; // The same for another address
1065
                end
1066
                4'h7: // w_reg_select_dec bit 16
1067
                begin
1068
                w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba3_bit31_12[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
1069
                                                                                                                         pci_am3[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1070
                w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
1071
                w_conf_data_out[0] = pci_ba3_bit0 & pci_am3[31];
1072
                        w_reg_select_dec = 56'h00_0000_0001_0000 ; // The same for another address
1073
                end
1074
                4'h8: // w_reg_select_dec bit 20
1075
                begin
1076
                w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba4_bit31_12[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
1077
                                                                                                                         pci_am4[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1078
                w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
1079
                w_conf_data_out[0] = pci_ba4_bit0 & pci_am4[31];
1080
                        w_reg_select_dec = 56'h00_0000_0010_0000 ; // The same for another address
1081
                end
1082
                4'h9: // w_reg_select_dec bit 24
1083
                begin
1084
                w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba5_bit31_12[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
1085
                                                                                                                         pci_am5[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1086
                w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
1087
                w_conf_data_out[0] = pci_ba5_bit0 & pci_am5[31];
1088
                        w_reg_select_dec = 56'h00_0000_0100_0000 ; // The same for another address
1089
                end
1090
                4'hf: // w_reg_select_dec bit 2
1091
                begin
1092
                        w_conf_data_out = { r_max_lat, r_min_gnt, r_interrupt_pin, interrupt_line } ;
1093
                        w_reg_select_dec = 56'h00_0000_0000_0004 ;
1094
                end
1095
                default :
1096
                begin
1097
                        w_conf_data_out = 32'h0000_0000 ;
1098
                        w_reg_select_dec = 56'h00_0000_0000_0000 ;
1099
                end
1100
                endcase
1101
          end
1102
          default :
1103
          begin
1104
            w_conf_data_out = 32'h0000_0000 ;
1105
                w_reg_select_dec = 56'h00_0000_0000_0000 ;
1106
          end
1107
          endcase
1108
        end
1109
        default :
1110
        begin
1111
                // PCI target - configuration space
1112
                case (w_conf_address_in[7:2])
1113
                `P_IMG_CTRL0_ADDR:  // w_reg_select_dec bit 3
1114
                begin
1115
                        w_conf_data_out = { 29'h00000000, pci_img_ctrl0_bit2_1, 1'h0 } ;
1116
                        w_reg_select_dec = 56'h00_0000_0000_0008 ;
1117
                end
1118
        `P_BA0_ADDR:   // w_reg_select_dec bit 4
1119
                begin
1120
                w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba0_bit31_12[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
1121
                                                                                                                         pci_am0[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1122
                w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
1123
                w_conf_data_out[0] = pci_ba0_bit0 & pci_am0[31];
1124
                        w_reg_select_dec = 56'h00_0000_0000_0010 ; // The same for another address
1125
                end
1126
        `P_AM0_ADDR:   // w_reg_select_dec bit 5
1127
                begin
1128
            w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_am0[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1129
                w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1130
                        w_reg_select_dec = 56'h00_0000_0000_0020 ;
1131
                end
1132
        `P_TA0_ADDR:   // w_reg_select_dec bit 6
1133
                begin
1134
            w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ta0[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1135
                w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1136
                        w_reg_select_dec = 56'h00_0000_0000_0040 ;
1137
                end
1138
        `P_IMG_CTRL1_ADDR:   // w_reg_select_dec bit 7
1139
                begin
1140
                        w_conf_data_out = { 29'h00000000, pci_img_ctrl1_bit2_1, 1'h0 } ;
1141
                        w_reg_select_dec = 56'h00_0000_0000_0080 ;
1142
                end
1143
        `P_BA1_ADDR:   // w_reg_select_dec bit 8
1144
                begin
1145
                w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba1_bit31_12[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
1146
                                                                                                                         pci_am1[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1147
                w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
1148
                w_conf_data_out[0] = pci_ba1_bit0 & pci_am1[31];
1149
                        w_reg_select_dec = 56'h00_0000_0000_0100 ; // The same for another address
1150
                end
1151
        `P_AM1_ADDR:   // w_reg_select_dec bit 9
1152
                begin
1153
            w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_am1[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1154
                w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1155
                        w_reg_select_dec = 56'h00_0000_0000_0200 ;
1156
                end
1157
        `P_TA1_ADDR:   // w_reg_select_dec bit 10
1158
                begin
1159
            w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ta1[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1160
                w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1161
                        w_reg_select_dec = 56'h00_0000_0000_0400 ;
1162
                end
1163
        `P_IMG_CTRL2_ADDR:   // w_reg_select_dec bit 11
1164
                begin
1165
                        w_conf_data_out = { 29'h00000000, pci_img_ctrl2_bit2_1, 1'h0 } ;
1166
                        w_reg_select_dec = 56'h00_0000_0000_0800 ;
1167
                end
1168
        `P_BA2_ADDR:   // w_reg_select_dec bit 12
1169
                begin
1170
                w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba2_bit31_12[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
1171
                                                                                                                         pci_am2[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1172
                w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
1173
                w_conf_data_out[0] = pci_ba2_bit0 & pci_am2[31];
1174
                        w_reg_select_dec = 56'h00_0000_0000_1000 ; // The same for another address
1175
                end
1176
        `P_AM2_ADDR:   // w_reg_select_dec bit 13
1177
                begin
1178
            w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_am2[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1179
                w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1180
                        w_reg_select_dec = 56'h00_0000_0000_2000 ;
1181
                end
1182
        `P_TA2_ADDR:   // w_reg_select_dec bit 14
1183
                begin
1184
            w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ta2[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1185
                w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1186
                        w_reg_select_dec = 56'h00_0000_0000_4000 ;
1187
                end
1188
        `P_IMG_CTRL3_ADDR:   // w_reg_select_dec bit 15
1189
                begin
1190
                        w_conf_data_out = { 29'h00000000, pci_img_ctrl3_bit2_1, 1'h0 } ;
1191
                        w_reg_select_dec = 56'h00_0000_0000_8000 ;
1192
                end
1193
        `P_BA3_ADDR:   // w_reg_select_dec bit 16
1194
                begin
1195
                w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba3_bit31_12[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
1196
                                                                                                                         pci_am3[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1197
                w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
1198
                w_conf_data_out[0] = pci_ba3_bit0 & pci_am3[31];
1199
                        w_reg_select_dec = 56'h00_0000_0001_0000 ; // The same for another address
1200
                end
1201
        `P_AM3_ADDR:   // w_reg_select_dec bit 17
1202
                begin
1203
            w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_am3[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1204
                w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1205
                        w_reg_select_dec = 56'h00_0000_0002_0000 ;
1206
                end
1207
        `P_TA3_ADDR:   // w_reg_select_dec bit 18
1208
                begin
1209
            w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ta3[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1210
                w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1211
                        w_reg_select_dec = 56'h00_0000_0004_0000 ;
1212
                end
1213
        `P_IMG_CTRL4_ADDR:   // w_reg_select_dec bit 19
1214
                begin
1215
                        w_conf_data_out = { 29'h00000000, pci_img_ctrl4_bit2_1, 1'h0 } ;
1216
                        w_reg_select_dec = 56'h00_0000_0008_0000 ;
1217
                end
1218
        `P_BA4_ADDR:   // w_reg_select_dec bit 20
1219
                begin
1220
                w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba4_bit31_12[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
1221
                                                                                                                         pci_am4[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1222
                w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
1223
                w_conf_data_out[0] = pci_ba4_bit0 & pci_am4[31];
1224
                        w_reg_select_dec = 56'h00_0000_0010_0000 ; // The same for another address
1225
                end
1226
        `P_AM4_ADDR:   // w_reg_select_dec bit 21
1227
                begin
1228
            w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_am4[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1229
                w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1230
                        w_reg_select_dec = 56'h00_0000_0020_0000 ;
1231
                end
1232
        `P_TA4_ADDR:   // w_reg_select_dec bit 22
1233
                begin
1234
            w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ta4[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1235
                w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1236
                        w_reg_select_dec = 56'h00_0000_0040_0000 ;
1237
                end
1238
        `P_IMG_CTRL5_ADDR:   // w_reg_select_dec bit 23
1239
                begin
1240
                        w_conf_data_out = { 29'h00000000, pci_img_ctrl5_bit2_1, 1'h0 } ;
1241
                        w_reg_select_dec = 56'h00_0000_0080_0000 ;
1242
                end
1243
        `P_BA5_ADDR:   // w_reg_select_dec bit 24
1244
                begin
1245
                w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ba5_bit31_12[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] &
1246
                                                                                                                         pci_am5[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1247
                w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):1] = 0 ;
1248
                w_conf_data_out[0] = pci_ba5_bit0 & pci_am5[31];
1249
                        w_reg_select_dec = 56'h00_0000_0100_0000 ; // The same for another address
1250
                end
1251
        `P_AM5_ADDR:   // w_reg_select_dec bit 25
1252
                begin
1253
            w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_am5[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1254
                w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1255
                        w_reg_select_dec = 56'h00_0000_0200_0000 ;
1256
                end
1257
        `P_TA5_ADDR:   // w_reg_select_dec bit 26
1258
                begin
1259
            w_conf_data_out[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] = pci_ta5[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1260
                w_conf_data_out[(31-`PCI_NUM_OF_DEC_ADDR_LINES):0] = 0 ;
1261
                        w_reg_select_dec = 56'h00_0000_0400_0000 ;
1262
                end
1263
        `P_ERR_CS_ADDR:   // w_reg_select_dec bit 27
1264
                begin
1265
                        w_conf_data_out = { pci_err_cs_bit31_24, 13'h0000, pci_err_cs_bit10, pci_err_cs_bit9,
1266
                                                                                   pci_err_cs_bit8, 7'h00, pci_err_cs_bit0 } ;
1267
                        w_reg_select_dec = 56'h00_0000_0800_0000 ;
1268
                end
1269
        `P_ERR_ADDR_ADDR:   // w_reg_select_dec bit 28
1270
                begin
1271
                        w_conf_data_out = pci_err_addr ;
1272
                        w_reg_select_dec = 56'h00_0000_0000_0000 ; // = 56'h00_0000_1000_0000 ;
1273
                end
1274
        `P_ERR_DATA_ADDR:   // w_reg_select_dec bit 29
1275
                begin
1276
                        w_conf_data_out = pci_err_data ;
1277
                        w_reg_select_dec = 56'h00_0000_0000_0000 ; // = 56'h00_0000_2000_0000 ;
1278
                end
1279
                // WB slave - configuration space
1280
                `WB_CONF_SPC_BAR_ADDR:
1281
                begin
1282
                        w_conf_data_out = { wb_ba0_bit31_12, 11'h000, wb_ba0_bit0 } ;
1283
                        w_reg_select_dec = 56'h00_0000_0000_0000 ; // Read-Only register
1284
                end
1285
                `W_IMG_CTRL1_ADDR:   // w_reg_select_dec bit 30
1286
                begin
1287
                        w_conf_data_out = { 29'h00000000, wb_img_ctrl1_bit2_0 } ;
1288
                        w_reg_select_dec = 56'h00_0000_4000_0000 ;
1289
                end
1290
                `W_BA1_ADDR:   // w_reg_select_dec bit 31
1291
                begin
1292
                w_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ba1_bit31_12[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] &
1293
                                                                                                                        wb_am1[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1294
                w_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):1]  = 0 ;
1295
                w_conf_data_out[0] = wb_ba1_bit0 ;
1296
                        w_reg_select_dec = 56'h00_0000_8000_0000 ;
1297
                end
1298
                `W_AM1_ADDR:   // w_reg_select_dec bit 32
1299
                begin
1300
                w_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_am1[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1301
                w_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0]  = 0 ;
1302
                        w_reg_select_dec = 56'h00_0001_0000_0000 ;
1303
                end
1304
                `W_TA1_ADDR:   // w_reg_select_dec bit 33
1305
                begin
1306
                w_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ta1[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1307
                w_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0]  = 0 ;
1308
                        w_reg_select_dec = 56'h00_0002_0000_0000 ;
1309
                end
1310
                `W_IMG_CTRL2_ADDR:   // w_reg_select_dec bit 34
1311
                begin
1312
                        w_conf_data_out = { 29'h00000000, wb_img_ctrl2_bit2_0 } ;
1313
                        w_reg_select_dec = 56'h00_0004_0000_0000 ;
1314
                end
1315
                `W_BA2_ADDR:   // w_reg_select_dec bit 35
1316
                begin
1317
                w_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ba2_bit31_12[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] &
1318
                                                                                                                        wb_am2[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1319
                w_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):1]  = 0 ;
1320
                w_conf_data_out[0] = wb_ba2_bit0 ;
1321
                        w_reg_select_dec = 56'h00_0008_0000_0000 ;
1322
                end
1323
                `W_AM2_ADDR:   // w_reg_select_dec bit 36
1324
                begin
1325
                w_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_am2[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1326
                w_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0]  = 0 ;
1327
                        w_reg_select_dec = 56'h00_0010_0000_0000 ;
1328
                end
1329
                `W_TA2_ADDR:   // w_reg_select_dec bit 37
1330
                begin
1331
                w_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ta2[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1332
                w_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0]  = 0 ;
1333
                        w_reg_select_dec = 56'h00_0020_0000_0000 ;
1334
                end
1335
                `W_IMG_CTRL3_ADDR:   // w_reg_select_dec bit 38
1336
                begin
1337
                        w_conf_data_out = { 29'h00000000, wb_img_ctrl3_bit2_0 } ;
1338
                        w_reg_select_dec = 56'h00_0040_0000_0000 ;
1339
                end
1340
                `W_BA3_ADDR:   // w_reg_select_dec bit 39
1341
                begin
1342
                w_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ba3_bit31_12[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] &
1343
                                                                                                                        wb_am3[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1344
                w_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):1]  = 0 ;
1345
                w_conf_data_out[0] = wb_ba3_bit0 ;
1346
                        w_reg_select_dec = 56'h00_0080_0000_0000 ;
1347
                end
1348
                `W_AM3_ADDR:   // w_reg_select_dec bit 40
1349
                begin
1350
                w_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_am3[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1351
                w_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0]  = 0 ;
1352
                        w_reg_select_dec = 56'h00_0100_0000_0000 ;
1353
                end
1354
                `W_TA3_ADDR:   // w_reg_select_dec bit 41
1355
                begin
1356
                w_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ta3[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1357
                w_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0]  = 0 ;
1358
                        w_reg_select_dec = 56'h00_0200_0000_0000 ;
1359
                end
1360
                `W_IMG_CTRL4_ADDR:   // w_reg_select_dec bit 42
1361
                begin
1362
                        w_conf_data_out = { 29'h00000000, wb_img_ctrl4_bit2_0 } ;
1363
                        w_reg_select_dec = 56'h00_0400_0000_0000 ;
1364
                end
1365
                `W_BA4_ADDR:   // w_reg_select_dec bit 43
1366
                begin
1367
                w_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ba4_bit31_12[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] &
1368
                                                                                                                        wb_am4[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1369
                w_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):1]  = 0 ;
1370
                w_conf_data_out[0] = wb_ba4_bit0 ;
1371
                        w_reg_select_dec = 56'h00_0800_0000_0000 ;
1372
                end
1373
                `W_AM4_ADDR:   // w_reg_select_dec bit 44
1374
                begin
1375
                w_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_am4[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1376
                w_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0]  = 0 ;
1377
                        w_reg_select_dec = 56'h00_1000_0000_0000 ;
1378
                end
1379
                `W_TA4_ADDR:   // w_reg_select_dec bit 45
1380
                begin
1381
                w_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ta4[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1382
                w_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0]  = 0 ;
1383
                        w_reg_select_dec = 56'h00_2000_0000_0000 ;
1384
                end
1385
                `W_IMG_CTRL5_ADDR:   // w_reg_select_dec bit 46
1386
                begin
1387
                        w_conf_data_out = { 29'h00000000, wb_img_ctrl5_bit2_0 } ;
1388
                        w_reg_select_dec = 56'h00_4000_0000_0000 ;
1389
                end
1390
                `W_BA5_ADDR:   // w_reg_select_dec bit 47
1391
                begin
1392
                w_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ba5_bit31_12[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] &
1393
                                                                                                                        wb_am5[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1394
                w_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):1]  = 0 ;
1395
                w_conf_data_out[0] = wb_ba5_bit0 ;
1396
                        w_reg_select_dec = 56'h00_8000_0000_0000 ;
1397
                end
1398
                `W_AM5_ADDR:   // w_reg_select_dec bit 48
1399
                begin
1400
                w_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_am5[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1401
                w_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0]  = 0 ;
1402
                        w_reg_select_dec = 56'h01_0000_0000_0000 ;
1403
                end
1404
                `W_TA5_ADDR:   // w_reg_select_dec bit 49
1405
                begin
1406
                w_conf_data_out[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = wb_ta5[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1407
                w_conf_data_out[(31-`WB_NUM_OF_DEC_ADDR_LINES):0]  = 0 ;
1408
                        w_reg_select_dec = 56'h02_0000_0000_0000 ;
1409
                end
1410
                `W_ERR_CS_ADDR:   // w_reg_select_dec bit 50
1411
                begin
1412
                        w_conf_data_out = { wb_err_cs_bit31_24, /*13*/14'h0000, /*wb_err_cs_bit10,*/
1413
                                                                                   wb_err_cs_bit9, wb_err_cs_bit8, 7'h00, wb_err_cs_bit0 } ;
1414
                        w_reg_select_dec = 56'h04_0000_0000_0000 ;
1415
                end
1416
                `W_ERR_ADDR_ADDR:   // w_reg_select_dec bit 51
1417
                begin
1418
                        w_conf_data_out = wb_err_addr ;
1419
                        w_reg_select_dec = 56'h08_0000_0000_0000 ;
1420
                end
1421
                `W_ERR_DATA_ADDR:   // w_reg_select_dec bit 52
1422
                begin
1423
                        w_conf_data_out = wb_err_data ;
1424
                        w_reg_select_dec = 56'h10_0000_0000_0000 ;
1425
                end
1426
                `CNF_ADDR_ADDR:   // w_reg_select_dec bit 53
1427
                begin
1428
                        w_conf_data_out = { 8'h00, cnf_addr_bit23_2, 1'h0, cnf_addr_bit0 } ;
1429
                        w_reg_select_dec = 56'h20_0000_0000_0000 ;
1430
                end
1431
                // `CNF_DATA_ADDR: implemented elsewhere !!!
1432
                // `INT_ACK_ADDR: implemented elsewhere !!!
1433
        `ICR_ADDR:   // w_reg_select_dec bit 54
1434
                begin
1435
                        w_conf_data_out = { icr_bit31, 26'h0000_000, icr_bit4_3, icr_bit2_0 } ;
1436
                        w_reg_select_dec = 56'h40_0000_0000_0000 ;
1437
                end
1438
        `ISR_ADDR:   // w_reg_select_dec bit 55
1439
                begin
1440
                        w_conf_data_out = { 27'h0000_000, isr_bit4_3, isr_bit2_0 } ;
1441
                        w_reg_select_dec = 56'h80_0000_0000_0000 ;
1442
                end
1443
                default:
1444
                begin
1445
                        w_conf_data_out = 32'h0000_0000 ;
1446
                        w_reg_select_dec = 56'h00_0000_0000_0000 ;
1447
                end
1448
                endcase
1449
        end
1450
        endcase
1451
end
1452
 
1453
// Reduced write data for BASE, MASK and TRANSLATION registers of PCI and WB images
1454
assign  w_conf_pdata_reduced[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)]        = w_conf_data_in[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
1455
assign  w_conf_pdata_reduced[(31-`PCI_NUM_OF_DEC_ADDR_LINES): 0] = 0 ;
1456
assign  w_conf_wdata_reduced[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] = w_conf_data_in[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
1457
assign  w_conf_wdata_reduced[(31-`WB_NUM_OF_DEC_ADDR_LINES): 0]  = 0 ;
1458
 
1459
always@(posedge w_clock or posedge reset)
1460
begin
1461
        // Here are implemented all registers that are reset with RESET signal otherwise they can be normaly written!!!
1462
        // Registers that are commented are implemented after this alwasy statement, because they are e.g. reset with
1463
        //   RESET signal, set with some status signal and they are erased with writting '1' into them !!!
1464
        if (reset)
1465
        begin
1466
                /*status_bit15_11 ; status_bit8 ;*/ command_bit8 <= 1'h0 ; command_bit6 <= 1'h0 ; command_bit2_0 <= 3'h0 ;
1467
                latency_timer <= 8'h00 ; cache_line_size_reg <= 8'h00 ;
1468
                // ALL pci_base address registers are the same as pci_baX registers !
1469
                interrupt_line <= 8'h00 ;
1470
 
1471
                `ifdef          HOST
1472
                  `ifdef        NO_CNF_IMAGE    // if PCI bridge is HOST and IMAGE0 is assigned as general image space
1473
                        `ifdef  PCI_IMAGE0
1474
                                        pci_img_ctrl0_bit2_1 <= 2'h0 ;
1475
                                        pci_ba0_bit31_12 <= 20'h0000_0 ;
1476
                                        pci_ba0_bit0 <= `PCI_BA0_MEM_IO ;
1477
                                        pci_am0 <= `PCI_AM0 ;
1478
                                        pci_ta0 <= 20'h0000_0 ;
1479
                        `endif
1480
                  `else
1481
                                        pci_ba0_bit31_12 <= 20'h0000_0 ;
1482
                  `endif
1483
                `else // GUEST
1484
                                        pci_ba0_bit31_12 <= 20'h0000_0 ;
1485
                `endif
1486
 
1487
                pci_img_ctrl1_bit2_1 <= 2'h0 ;
1488
                pci_ba1_bit31_12 <= 20'h0000_0 ;
1489
        `ifdef  HOST
1490
                pci_ba1_bit0 <= `PCI_BA1_MEM_IO ;
1491
        `endif
1492
                pci_am1 <= `PCI_AM1;
1493
                pci_ta1 <= 20'h0000_0 ;
1494
                `ifdef  PCI_IMAGE2
1495
                                pci_img_ctrl2_bit2_1 <= 2'h0 ;
1496
                                        pci_ba2_bit31_12 <= 20'h0000_0 ;
1497
                        `ifdef  HOST
1498
                                        pci_ba2_bit0 <= `PCI_BA2_MEM_IO ;
1499
                        `endif
1500
                                        pci_am2 <= `PCI_AM2;
1501
                                        pci_ta2 <= 20'h0000_0 ;
1502
                `endif
1503
                `ifdef  PCI_IMAGE3
1504
                                        pci_img_ctrl3_bit2_1 <= 2'h0 ;
1505
                                pci_ba3_bit31_12 <= 20'h0000_0 ;
1506
                `ifdef  HOST
1507
                                pci_ba3_bit0 <= `PCI_BA3_MEM_IO ;
1508
                `endif
1509
                                pci_am3 <= `PCI_AM3;
1510
                                        pci_ta3 <= 20'h0000_0 ;
1511
                `endif
1512
                `ifdef  PCI_IMAGE4
1513
                                        pci_img_ctrl4_bit2_1 <= 2'h0 ;
1514
                                        pci_ba4_bit31_12 <= 20'h0000_0 ;
1515
                        `ifdef  HOST
1516
                                        pci_ba4_bit0 <= `PCI_BA4_MEM_IO ;
1517
                        `endif
1518
                                        pci_am4 <= `PCI_AM4;
1519
                                        pci_ta4 <= 20'h0000_0 ;
1520
                `endif
1521
                `ifdef  PCI_IMAGE5
1522
                                        pci_img_ctrl5_bit2_1 <= 2'h0 ;
1523
                                        pci_ba5_bit31_12 <= 20'h0000_0 ;
1524
                        `ifdef  HOST
1525
                                        pci_ba5_bit0 <= `PCI_BA5_MEM_IO ;
1526
                        `endif
1527
                                        pci_am5 <= `PCI_AM5;
1528
                                        pci_ta5 <= 20'h0000_0 ;
1529
                `endif
1530
                /*pci_err_cs_bit31_24 ; pci_err_cs_bit10; pci_err_cs_bit9 ; pci_err_cs_bit8 ;*/ pci_err_cs_bit0 <= 1'h0 ;
1531
                /*pci_err_addr ;*/
1532
        /*pci_err_data ;*/
1533
                //
1534
                wb_img_ctrl1_bit2_0 <= 3'h0 ;
1535
                wb_ba1_bit31_12 <= 20'h0000_0 ; wb_ba1_bit0 <= 1'h0 ;
1536
                wb_am1 <= 20'h0000_0 ;
1537
                wb_ta1 <= 20'h0000_0 ;
1538
        `ifdef  WB_IMAGE2
1539
                                        wb_img_ctrl2_bit2_0 <= 3'h0 ;
1540
                                        wb_ba2_bit31_12 <= 20'h0000_0 ; wb_ba2_bit0 <= 1'h0 ;
1541
                                        wb_am2 <= 20'h0000_0 ;
1542
                                        wb_ta2 <= 20'h0000_0 ;
1543
                `endif
1544
                `ifdef  WB_IMAGE3
1545
                                        wb_img_ctrl3_bit2_0 <= 3'h0 ;
1546
                                        wb_ba3_bit31_12 <= 20'h0000_0 ; wb_ba3_bit0 <= 1'h0 ;
1547
                                        wb_am3 <= 20'h0000_0 ;
1548
                                        wb_ta3 <= 20'h0000_0 ;
1549
                `endif
1550
                `ifdef  WB_IMAGE4
1551
                                        wb_img_ctrl4_bit2_0 <= 3'h0 ;
1552
                                        wb_ba4_bit31_12 <= 20'h0000_0 ; wb_ba4_bit0 <= 1'h0 ;
1553
                                        wb_am4 <= 20'h0000_0 ;
1554
                                        wb_ta4 <= 20'h0000_0 ;
1555
                `endif
1556
                `ifdef  WB_IMAGE5
1557
                                        wb_img_ctrl5_bit2_0 <= 3'h0 ;
1558
                                wb_ba5_bit31_12 <= 20'h0000_0 ; wb_ba5_bit0 <= 1'h0 ;
1559
                                        wb_am5 <= 20'h0000_0 ;
1560
                                        wb_ta5 <= 20'h0000_0 ;
1561
                `endif
1562
                /*wb_err_cs_bit31_24 ; wb_err_cs_bit10 ; wb_err_cs_bit9 ; wb_err_cs_bit8 ;*/ wb_err_cs_bit0 <= 1'h0 ;
1563
                /*wb_err_addr ;*/
1564
                /*wb_err_data ;*/
1565
 
1566
                `ifdef          HOST
1567
                cnf_addr_bit23_2 <= 22'h0000_00 ; cnf_addr_bit0 <= 1'h0 ;
1568
                `endif
1569
 
1570
                icr_bit31 <= 1'h0 ;
1571
                `ifdef  HOST
1572
                        icr_bit2_0 <= 3'h0 ;
1573
                        icr_bit4_3 <= 2'h0 ;
1574
                `else
1575
                        icr_bit2_0[2:0] <= 3'h0 ;
1576
                `endif
1577
                /*isr_bit4_3 ; isr_bit2_0 ;*/
1578
        end
1579
/* -----------------------------------------------------------------------------------------------------------
1580
Following register bits should have asynchronous RESET & SET! That is why they are IMPLEMENTED separately
1581
after this ALWAYS block!!! (for every register bit, there are two D-FF implemented)
1582
                status_bit15_11[15] <= 1'b1 ;
1583
                status_bit15_11[14] <= 1'b1 ;
1584
                status_bit15_11[13] <= 1'b1 ;
1585
                status_bit15_11[12] <= 1'b1 ;
1586
                status_bit15_11[11] <= 1'b1 ;
1587
                status_bit8 <= 1'b1 ;
1588
                pci_err_cs_bit10 <= 1'b1 ;
1589
                pci_err_cs_bit9 <= 1'b1 ;
1590
                pci_err_cs_bit8 <= 1'b1 ;
1591
                pci_err_cs_bit31_24 <= { pci_error_be, pci_error_bc } ;
1592
                pci_err_addr <= pci_error_addr ;
1593
                pci_err_data <= pci_error_data ;
1594
                wb_err_cs_bit10 <= 1'b1 ;
1595
                wb_err_cs_bit9 <= 1'b1 ;
1596
                wb_err_cs_bit8 <= 1'b1 ;
1597
                wb_err_cs_bit31_24 <= { wb_error_be, wb_error_bc } ;
1598
                wb_err_addr <= wb_error_addr ;
1599
                wb_err_data <= wb_error_data ;
1600
                isr_bit4_0[4] <= 1'b1 & icr_bit4_0[4] ;
1601
                isr_bit4_0[3] <= 1'b1 & icr_bit4_0[3] ;
1602
                isr_bit4_0[2] <= 1'b1 & icr_bit4_0[2] ;
1603
                isr_bit4_0[1] <= 1'b1 & icr_bit4_0[1] ;
1604
                isr_bit4_0[0] <= 1'b1 & icr_bit4_0[0] ;
1605
-----------------------------------------------------------------------------------------------------------*/
1606
        // Here follows normal writting to registers (only to their valid bits) !
1607
        else
1608
        begin
1609
                if (w_we)
1610
                begin
1611
                                // PCI header - configuration space
1612
                                if (w_reg_select_dec[0]) // w_conf_address_in[5:2] = 4'h1:
1613
                                begin
1614
                                        if (~w_byte_en[1])
1615
                                                command_bit8 <= w_conf_data_in[8] ;
1616
                                        if (~w_byte_en[0])
1617
                                        begin
1618
                                                command_bit6 <= w_conf_data_in[6] ;
1619
                                                command_bit2_0 <= w_conf_data_in[2:0] ;
1620
                                        end
1621
                                end
1622
                                if (w_reg_select_dec[1]) // w_conf_address_in[5:2] = 4'h3:
1623
                                begin
1624
                                        if (~w_byte_en[1])
1625
                                                latency_timer <= w_conf_data_in[15:8] ;
1626
                                        if (~w_byte_en[0])
1627
                                                cache_line_size_reg <= w_conf_data_in[7:0] ;
1628
                                end
1629
//                  if (w_reg_select_dec[4]) // w_conf_address_in[5:2] = 4'h4:
1630
//                              Also used with IMAGE0
1631
 
1632
//                  if (w_reg_select_dec[8]) // w_conf_address_in[5:2] = 4'h5:
1633
//                              Also used with IMAGE1
1634
 
1635
//                  if (w_reg_select_dec[12]) // w_conf_address_in[5:2] = 4'h6:
1636
//                              Also used with IMAGE2
1637
 
1638
//                  if (w_reg_select_dec[16]) // w_conf_address_in[5:2] = 4'h7:
1639
//                              Also used with IMAGE3
1640
 
1641
//                  if (w_reg_select_dec[20]) // w_conf_address_in[5:2] = 4'h8:
1642
//                              Also used with IMAGE4
1643
 
1644
//                  if (w_reg_select_dec[24]) // w_conf_address_in[5:2] = 4'h9:
1645
//                              Also used with IMAGE5 and IMAGE6
1646
                                if (w_reg_select_dec[2]) // w_conf_address_in[5:2] = 4'hf:
1647
                                begin
1648
                                        if (~w_byte_en[0])
1649
                                                interrupt_line <= w_conf_data_in[7:0] ;
1650
                                end
1651
                                // PCI target - configuration space
1652
`ifdef          HOST
1653
  `ifdef        NO_CNF_IMAGE
1654
        `ifdef  PCI_IMAGE0      // if PCI bridge is HOST and IMAGE0 is assigned as general image space
1655
                                if (w_reg_select_dec[3]) // case (w_conf_address_in[7:2]) = `P_IMG_CTRL0_ADDR:
1656
                                begin
1657
                                        if (~w_byte_en[0])
1658
                                                pci_img_ctrl0_bit2_1 <= w_conf_data_in[2:1] ;
1659
                                end
1660
                    if (w_reg_select_dec[4]) // case (w_conf_address_in[7:2]) = `P_BA0_ADDR:
1661
                                begin
1662
                                        if (~w_byte_en[3])
1663
                                                pci_ba0_bit31_12[31:24] <= w_conf_pdata_reduced[31:24] ;
1664
                                        if (~w_byte_en[2])
1665
                                                pci_ba0_bit31_12[23:16] <= w_conf_pdata_reduced[23:16] ;
1666
                                        if (~w_byte_en[1])
1667
                                                pci_ba0_bit31_12[15:12] <= w_conf_pdata_reduced[15:12] ;
1668
                                        if (~w_byte_en[0])
1669
                                                pci_ba0_bit0 <= w_conf_data_in[0] ;
1670
                                end
1671
                    if (w_reg_select_dec[5]) // case (w_conf_address_in[7:2]) = `P_AM0_ADDR:
1672
                                begin
1673
                                        if (~w_byte_en[3])
1674
                                                pci_am0[31:24] <= w_conf_pdata_reduced[31:24] ;
1675
                                        if (~w_byte_en[2])
1676
                                                pci_am0[23:16] <= w_conf_pdata_reduced[23:16] ;
1677
                                        if (~w_byte_en[1])
1678
                                                pci_am0[15:12] <= w_conf_pdata_reduced[15:12] ;
1679
                                end
1680
                    if (w_reg_select_dec[6]) // case (w_conf_address_in[7:2]) = `P_TA0_ADDR:
1681
                                begin
1682
                                        if (~w_byte_en[3])
1683
                                                pci_ta0[31:24] <= w_conf_pdata_reduced[31:24] ;
1684
                                        if (~w_byte_en[2])
1685
                                                pci_ta0[23:16] <= w_conf_pdata_reduced[23:16] ;
1686
                                        if (~w_byte_en[1])
1687
                                                pci_ta0[15:12] <= w_conf_pdata_reduced[15:12] ;
1688
                                end
1689
        `endif
1690
  `else
1691
                    if (w_reg_select_dec[4]) // case (w_conf_address_in[7:2]) = `P_BA0_ADDR:
1692
                                begin
1693
                                        if (~w_byte_en[3])
1694
                                                pci_ba0_bit31_12[31:24] <= w_conf_pdata_reduced[31:24] ;
1695
                                        if (~w_byte_en[2])
1696
                                                pci_ba0_bit31_12[23:16] <= w_conf_pdata_reduced[23:16] ;
1697
                                        if (~w_byte_en[1])
1698
                                                pci_ba0_bit31_12[15:12] <= w_conf_pdata_reduced[15:12] ;
1699
                                end
1700
  `endif
1701
`else // GUEST
1702
                    if (w_reg_select_dec[4]) // case (w_conf_address_in[7:2]) = `P_BA0_ADDR:
1703
                                begin
1704
                                        if (~w_byte_en[3])
1705
                                                pci_ba0_bit31_12[31:24] <= w_conf_pdata_reduced[31:24] ;
1706
                                        if (~w_byte_en[2])
1707
                                                pci_ba0_bit31_12[23:16] <= w_conf_pdata_reduced[23:16] ;
1708
                                        if (~w_byte_en[1])
1709
                                                pci_ba0_bit31_12[15:12] <= w_conf_pdata_reduced[15:12] ;
1710
                                end
1711
`endif
1712
                    if (w_reg_select_dec[7]) // case (w_conf_address_in[7:2]) = `P_IMG_CTRL1_ADDR:
1713
                                begin
1714
                                        if (~w_byte_en[0])
1715
                                                pci_img_ctrl1_bit2_1 <= w_conf_data_in[2:1] ;
1716
                                end
1717
                    if (w_reg_select_dec[8]) // case (w_conf_address_in[7:2]) = `P_BA1_ADDR:
1718
                                begin
1719
                                        if (~w_byte_en[3])
1720
                                                pci_ba1_bit31_12[31:24] <= w_conf_pdata_reduced[31:24] ;
1721
                                        if (~w_byte_en[2])
1722
                                                pci_ba1_bit31_12[23:16] <= w_conf_pdata_reduced[23:16] ;
1723
                                        if (~w_byte_en[1])
1724
                                                pci_ba1_bit31_12[15:12] <= w_conf_pdata_reduced[15:12] ;
1725
        `ifdef  HOST
1726
                                        if (~w_byte_en[0])
1727
                                                pci_ba1_bit0 <= w_conf_data_in[0] ;
1728
        `endif
1729
                                end
1730
                    if (w_reg_select_dec[9]) // case (w_conf_address_in[7:2]) = `P_AM1_ADDR:
1731
                                begin
1732
                                        if (~w_byte_en[3])
1733
                                                pci_am1[31:24] <= w_conf_pdata_reduced[31:24] ;
1734
                                        if (~w_byte_en[2])
1735
                                                pci_am1[23:16] <= w_conf_pdata_reduced[23:16] ;
1736
                                        if (~w_byte_en[1])
1737
                                                pci_am1[15:12] <= w_conf_pdata_reduced[15:12] ;
1738
                                end
1739
                    if (w_reg_select_dec[10]) // case (w_conf_address_in[7:2]) = `P_TA1_ADDR:
1740
                                begin
1741
                                        if (~w_byte_en[3])
1742
                                                pci_ta1[31:24] <= w_conf_pdata_reduced[31:24] ;
1743
                                        if (~w_byte_en[2])
1744
                                                pci_ta1[23:16] <= w_conf_pdata_reduced[23:16] ;
1745
                                        if (~w_byte_en[1])
1746
                                                pci_ta1[15:12] <= w_conf_pdata_reduced[15:12] ;
1747
                                end
1748
`ifdef          PCI_IMAGE2
1749
                    if (w_reg_select_dec[11]) // case (w_conf_address_in[7:2]) = `P_IMG_CTRL2_ADDR:
1750
                                begin
1751
                                        if (~w_byte_en[0])
1752
                                                pci_img_ctrl2_bit2_1 <= w_conf_data_in[2:1] ;
1753
                                end
1754
                    if (w_reg_select_dec[12]) // case (w_conf_address_in[7:2]) = `P_BA2_ADDR:
1755
                                begin
1756
                                        if (~w_byte_en[3])
1757
                                                pci_ba2_bit31_12[31:24] <= w_conf_pdata_reduced[31:24] ;
1758
                                        if (~w_byte_en[2])
1759
                                                pci_ba2_bit31_12[23:16] <= w_conf_pdata_reduced[23:16] ;
1760
                                        if (~w_byte_en[1])
1761
                                                pci_ba2_bit31_12[15:12] <= w_conf_pdata_reduced[15:12] ;
1762
        `ifdef  HOST
1763
                                        if (~w_byte_en[0])
1764
                                                pci_ba2_bit0 <= w_conf_data_in[0] ;
1765
        `endif
1766
                                end
1767
                    if (w_reg_select_dec[13]) // case (w_conf_address_in[7:2]) = `P_AM2_ADDR:
1768
                                begin
1769
                                        if (~w_byte_en[3])
1770
                                                pci_am2[31:24] <= w_conf_pdata_reduced[31:24] ;
1771
                                        if (~w_byte_en[2])
1772
                                                pci_am2[23:16] <= w_conf_pdata_reduced[23:16] ;
1773
                                        if (~w_byte_en[1])
1774
                                                pci_am2[15:12] <= w_conf_pdata_reduced[15:12] ;
1775
                                end
1776
                    if (w_reg_select_dec[14]) // case (w_conf_address_in[7:2]) = `P_TA2_ADDR:
1777
                                begin
1778
                                        if (~w_byte_en[3])
1779
                                                pci_ta2[31:24] <= w_conf_pdata_reduced[31:24] ;
1780
                                        if (~w_byte_en[2])
1781
                                                pci_ta2[23:16] <= w_conf_pdata_reduced[23:16] ;
1782
                                        if (~w_byte_en[1])
1783
                                                pci_ta2[15:12] <= w_conf_pdata_reduced[15:12] ;
1784
                                end
1785
`endif
1786
`ifdef          PCI_IMAGE3
1787
                    if (w_reg_select_dec[15]) // case (w_conf_address_in[7:2]) = `P_IMG_CTRL3_ADDR:
1788
                                begin
1789
                                        if (~w_byte_en[0])
1790
                                                pci_img_ctrl3_bit2_1 <= w_conf_data_in[2:1] ;
1791
                                end
1792
                    if (w_reg_select_dec[16]) // case (w_conf_address_in[7:2]) = `P_BA3_ADDR:
1793
                                begin
1794
                                        if (~w_byte_en[3])
1795
                                                pci_ba3_bit31_12[31:24] <= w_conf_pdata_reduced[31:24] ;
1796
                                        if (~w_byte_en[2])
1797
                                                pci_ba3_bit31_12[23:16] <= w_conf_pdata_reduced[23:16] ;
1798
                                        if (~w_byte_en[1])
1799
                                                pci_ba3_bit31_12[15:12] <= w_conf_pdata_reduced[15:12] ;
1800
        `ifdef  HOST
1801
                                        if (~w_byte_en[0])
1802
                                                pci_ba3_bit0 <= w_conf_data_in[0] ;
1803
        `endif
1804
                                end
1805
                    if (w_reg_select_dec[17]) // case (w_conf_address_in[7:2]) = `P_AM3_ADDR:
1806
                                begin
1807
                                        if (~w_byte_en[3])
1808
                                                pci_am3[31:24] <= w_conf_pdata_reduced[31:24] ;
1809
                                        if (~w_byte_en[2])
1810
                                                pci_am3[23:16] <= w_conf_pdata_reduced[23:16] ;
1811
                                        if (~w_byte_en[1])
1812
                                                pci_am3[15:12] <= w_conf_pdata_reduced[15:12] ;
1813
                                end
1814
                    if (w_reg_select_dec[18]) // case (w_conf_address_in[7:2]) = `P_TA3_ADDR:
1815
                                begin
1816
                                        if (~w_byte_en[3])
1817
                                                pci_ta3[31:24] <= w_conf_pdata_reduced[31:24] ;
1818
                                        if (~w_byte_en[2])
1819
                                                pci_ta3[23:16] <= w_conf_pdata_reduced[23:16] ;
1820
                                        if (~w_byte_en[1])
1821
                                                pci_ta3[15:12] <= w_conf_pdata_reduced[15:12] ;
1822
                                end
1823
`endif
1824
`ifdef          PCI_IMAGE4
1825
                    if (w_reg_select_dec[19]) // case (w_conf_address_in[7:2]) = `P_IMG_CTRL4_ADDR:
1826
                                begin
1827
                                        if (~w_byte_en[0])
1828
                                                pci_img_ctrl4_bit2_1 <= w_conf_data_in[2:1] ;
1829
                                end
1830
                    if (w_reg_select_dec[20]) // case (w_conf_address_in[7:2]) = `P_BA4_ADDR:
1831
                                begin
1832
                                        if (~w_byte_en[3])
1833
                                                pci_ba4_bit31_12[31:24] <= w_conf_pdata_reduced[31:24] ;
1834
                                        if (~w_byte_en[2])
1835
                                                pci_ba4_bit31_12[23:16] <= w_conf_pdata_reduced[23:16] ;
1836
                                        if (~w_byte_en[1])
1837
                                                pci_ba4_bit31_12[15:12] <= w_conf_pdata_reduced[15:12] ;
1838
        `ifdef  HOST
1839
                                        if (~w_byte_en[0])
1840
                                                pci_ba4_bit0 <= w_conf_data_in[0] ;
1841
        `endif
1842
                                end
1843
                    if (w_reg_select_dec[21]) // case (w_conf_address_in[7:2]) = `P_AM4_ADDR:
1844
                                begin
1845
                                        if (~w_byte_en[3])
1846
                                                pci_am4[31:24] <= w_conf_pdata_reduced[31:24] ;
1847
                                        if (~w_byte_en[2])
1848
                                                pci_am4[23:16] <= w_conf_pdata_reduced[23:16] ;
1849
                                        if (~w_byte_en[1])
1850
                                                pci_am4[15:12] <= w_conf_pdata_reduced[15:12] ;
1851
                                end
1852
                    if (w_reg_select_dec[22]) // case (w_conf_address_in[7:2]) = `P_TA4_ADDR:
1853
                                begin
1854
                                        if (~w_byte_en[3])
1855
                                                pci_ta4[31:24] <= w_conf_pdata_reduced[31:24] ;
1856
                                        if (~w_byte_en[2])
1857
                                                pci_ta4[23:16] <= w_conf_pdata_reduced[23:16] ;
1858
                                        if (~w_byte_en[1])
1859
                                                pci_ta4[15:12] <= w_conf_pdata_reduced[15:12] ;
1860
                                end
1861
`endif
1862
`ifdef          PCI_IMAGE5
1863
                    if (w_reg_select_dec[23]) // case (w_conf_address_in[7:2]) = `P_IMG_CTRL5_ADDR:
1864
                                begin
1865
                                        if (~w_byte_en[0])
1866
                                                pci_img_ctrl5_bit2_1 <= w_conf_data_in[2:1] ;
1867
                                end
1868
                    if (w_reg_select_dec[24]) // case (w_conf_address_in[7:2]) = `P_BA5_ADDR:
1869
                                begin
1870
                                        if (~w_byte_en[3])
1871
                                                pci_ba5_bit31_12[31:24] <= w_conf_pdata_reduced[31:24] ;
1872
                                        if (~w_byte_en[2])
1873
                                                pci_ba5_bit31_12[23:16] <= w_conf_pdata_reduced[23:16] ;
1874
                                        if (~w_byte_en[1])
1875
                                                pci_ba5_bit31_12[15:12] <= w_conf_pdata_reduced[15:12] ;
1876
        `ifdef  HOST
1877
                                        if (~w_byte_en[0])
1878
                                                pci_ba5_bit0 <= w_conf_data_in[0] ;
1879
        `endif
1880
                                end
1881
                    if (w_reg_select_dec[25]) // case (w_conf_address_in[7:2]) = `P_AM5_ADDR:
1882
                                begin
1883
                                        if (~w_byte_en[3])
1884
                                                pci_am5[31:24] <= w_conf_pdata_reduced[31:24] ;
1885
                                        if (~w_byte_en[2])
1886
                                                pci_am5[23:16] <= w_conf_pdata_reduced[23:16] ;
1887
                                        if (~w_byte_en[1])
1888
                                                pci_am5[15:12] <= w_conf_pdata_reduced[15:12] ;
1889
                                end
1890
                    if (w_reg_select_dec[26]) // case (w_conf_address_in[7:2]) = `P_TA5_ADDR:
1891
                                begin
1892
                                        if (~w_byte_en[3])
1893
                                                pci_ta5[31:24] <= w_conf_pdata_reduced[31:24] ;
1894
                                        if (~w_byte_en[2])
1895
                                                pci_ta5[23:16] <= w_conf_pdata_reduced[23:16] ;
1896
                                        if (~w_byte_en[1])
1897
                                                pci_ta5[15:12] <= w_conf_pdata_reduced[15:12] ;
1898
                                end
1899
`endif
1900
                    if (w_reg_select_dec[27]) // case (w_conf_address_in[7:2]) = `P_ERR_CS_ADDR:
1901
                                begin
1902
                                        if (~w_byte_en[0])
1903
                                                pci_err_cs_bit0 <= w_conf_data_in[0] ;
1904
                                end
1905
                        // WB slave - configuration space
1906
                                if (w_reg_select_dec[30]) // case (w_conf_address_in[7:2]) = `W_IMG_CTRL1_ADDR:
1907
                                begin
1908
                                        if (~w_byte_en[0])
1909
                                                wb_img_ctrl1_bit2_0 <= w_conf_data_in[2:0] ;
1910
                                end
1911
                                if (w_reg_select_dec[31]) // case (w_conf_address_in[7:2]) = `W_BA1_ADDR:
1912
                                begin
1913
                                        if (~w_byte_en[3])
1914
                                                wb_ba1_bit31_12[31:24] <= w_conf_wdata_reduced[31:24] ;
1915
                                        if (~w_byte_en[2])
1916
                                                wb_ba1_bit31_12[23:16] <= w_conf_wdata_reduced[23:16] ;
1917
                                        if (~w_byte_en[1])
1918
                                                wb_ba1_bit31_12[15:12] <= w_conf_wdata_reduced[15:12] ;
1919
                                        if (~w_byte_en[0])
1920
                                                wb_ba1_bit0 <= w_conf_data_in[0] ;
1921
                                end
1922
                                if (w_reg_select_dec[32]) // case (w_conf_address_in[7:2]) = `W_AM1_ADDR:
1923
                                begin
1924
                                        if (~w_byte_en[3])
1925
                                                wb_am1[31:24] <= w_conf_wdata_reduced[31:24] ;
1926
                                        if (~w_byte_en[2])
1927
                                                wb_am1[23:16] <= w_conf_wdata_reduced[23:16] ;
1928
                                        if (~w_byte_en[1])
1929
                                                wb_am1[15:12] <= w_conf_wdata_reduced[15:12] ;
1930
                                end
1931
                                if (w_reg_select_dec[33]) // case (w_conf_address_in[7:2]) = `W_TA1_ADDR:
1932
                                begin
1933
                                        if (~w_byte_en[3])
1934
                                                wb_ta1[31:24] <= w_conf_wdata_reduced[31:24] ;
1935
                                        if (~w_byte_en[2])
1936
                                                wb_ta1[23:16] <= w_conf_wdata_reduced[23:16] ;
1937
                                        if (~w_byte_en[1])
1938
                                                wb_ta1[15:12] <= w_conf_wdata_reduced[15:12] ;
1939
                                end
1940
`ifdef          WB_IMAGE2
1941
                                if (w_reg_select_dec[34]) // case (w_conf_address_in[7:2]) = `W_IMG_CTRL2_ADDR:
1942
                                begin
1943
                                        if (~w_byte_en[0])
1944
                                                wb_img_ctrl2_bit2_0 <= w_conf_data_in[2:0] ;
1945
                                end
1946
                                if (w_reg_select_dec[35]) // case (w_conf_address_in[7:2]) = `W_BA2_ADDR:
1947
                                begin
1948
                                        if (~w_byte_en[3])
1949
                                                wb_ba2_bit31_12[31:24] <= w_conf_wdata_reduced[31:24] ;
1950
                                        if (~w_byte_en[2])
1951
                                                wb_ba2_bit31_12[23:16] <= w_conf_wdata_reduced[23:16] ;
1952
                                        if (~w_byte_en[1])
1953
                                                wb_ba2_bit31_12[15:12] <= w_conf_wdata_reduced[15:12] ;
1954
                                        if (~w_byte_en[0])
1955
                                                wb_ba2_bit0 <= w_conf_data_in[0] ;
1956
                                end
1957
                                if (w_reg_select_dec[36]) // case (w_conf_address_in[7:2]) = `W_AM2_ADDR:
1958
                                begin
1959
                                        if (~w_byte_en[3])
1960
                                                wb_am2[31:24] <= w_conf_wdata_reduced[31:24] ;
1961
                                        if (~w_byte_en[2])
1962
                                                wb_am2[23:16] <= w_conf_wdata_reduced[23:16] ;
1963
                                        if (~w_byte_en[1])
1964
                                                wb_am2[15:12] <= w_conf_wdata_reduced[15:12] ;
1965
                                end
1966
                                if (w_reg_select_dec[37]) // case (w_conf_address_in[7:2]) = `W_TA2_ADDR:
1967
                                begin
1968
                                        if (~w_byte_en[3])
1969
                                                wb_ta2[31:24] <= w_conf_wdata_reduced[31:24] ;
1970
                                        if (~w_byte_en[2])
1971
                                                wb_ta2[23:16] <= w_conf_wdata_reduced[23:16] ;
1972
                                        if (~w_byte_en[1])
1973
                                                wb_ta2[15:12] <= w_conf_wdata_reduced[15:12] ;
1974
                                end
1975
`endif
1976
`ifdef          WB_IMAGE3
1977
                                if (w_reg_select_dec[38]) // case (w_conf_address_in[7:2]) = `W_IMG_CTRL3_ADDR:
1978
                                begin
1979
                                        if (~w_byte_en[0])
1980
                                                wb_img_ctrl3_bit2_0 <= w_conf_data_in[2:0] ;
1981
                                end
1982
                                if (w_reg_select_dec[39]) // case (w_conf_address_in[7:2]) = `W_BA3_ADDR:
1983
                                begin
1984
                                        if (~w_byte_en[3])
1985
                                                wb_ba3_bit31_12[31:24] <= w_conf_wdata_reduced[31:24] ;
1986
                                        if (~w_byte_en[2])
1987
                                                wb_ba3_bit31_12[23:16] <= w_conf_wdata_reduced[23:16] ;
1988
                                        if (~w_byte_en[1])
1989
                                                wb_ba3_bit31_12[15:12] <= w_conf_wdata_reduced[15:12] ;
1990
                                        if (~w_byte_en[0])
1991
                                                wb_ba3_bit0 <= w_conf_data_in[0] ;
1992
                                end
1993
                                if (w_reg_select_dec[40]) // case (w_conf_address_in[7:2]) = `W_AM3_ADDR:
1994
                                begin
1995
                                        if (~w_byte_en[3])
1996
                                                wb_am3[31:24] <= w_conf_wdata_reduced[31:24] ;
1997
                                        if (~w_byte_en[2])
1998
                                                wb_am3[23:16] <= w_conf_wdata_reduced[23:16] ;
1999
                                        if (~w_byte_en[1])
2000
                                                wb_am3[15:12] <= w_conf_wdata_reduced[15:12] ;
2001
                                end
2002
                                if (w_reg_select_dec[41]) // case (w_conf_address_in[7:2]) = `W_TA3_ADDR:
2003
                                begin
2004
                                        if (~w_byte_en[3])
2005
                                                wb_ta3[31:24] <= w_conf_wdata_reduced[31:24] ;
2006
                                        if (~w_byte_en[2])
2007
                                                wb_ta3[23:16] <= w_conf_wdata_reduced[23:16] ;
2008
                                        if (~w_byte_en[1])
2009
                                                wb_ta3[15:12] <= w_conf_wdata_reduced[15:12] ;
2010
                                end
2011
`endif
2012
`ifdef          WB_IMAGE4
2013
                                if (w_reg_select_dec[42]) // case (w_conf_address_in[7:2]) = `W_IMG_CTRL4_ADDR:
2014
                                begin
2015
                                        if (~w_byte_en[0])
2016
                                                wb_img_ctrl4_bit2_0 <= w_conf_data_in[2:0] ;
2017
                                end
2018
                                if (w_reg_select_dec[43]) // case (w_conf_address_in[7:2]) = `W_BA4_ADDR:
2019
                                begin
2020
                                        if (~w_byte_en[3])
2021
                                                wb_ba4_bit31_12[31:24] <= w_conf_wdata_reduced[31:24] ;
2022
                                        if (~w_byte_en[2])
2023
                                                wb_ba4_bit31_12[23:16] <= w_conf_wdata_reduced[23:16] ;
2024
                                        if (~w_byte_en[1])
2025
                                                wb_ba4_bit31_12[15:12] <= w_conf_wdata_reduced[15:12] ;
2026
                                        if (~w_byte_en[0])
2027
                                                wb_ba4_bit0 <= w_conf_data_in[0] ;
2028
                                end
2029
                                if (w_reg_select_dec[44]) // case (w_conf_address_in[7:2]) = `W_AM4_ADDR:
2030
                                begin
2031
                                        if (~w_byte_en[3])
2032
                                                wb_am4[31:24] <= w_conf_wdata_reduced[31:24] ;
2033
                                        if (~w_byte_en[2])
2034
                                                wb_am4[23:16] <= w_conf_wdata_reduced[23:16] ;
2035
                                        if (~w_byte_en[1])
2036
                                                wb_am4[15:12] <= w_conf_wdata_reduced[15:12] ;
2037
                                end
2038
                                if (w_reg_select_dec[45]) // case (w_conf_address_in[7:2]) = `W_TA4_ADDR:
2039
                                begin
2040
                                        if (~w_byte_en[3])
2041
                                                wb_ta4[31:24] <= w_conf_wdata_reduced[31:24] ;
2042
                                        if (~w_byte_en[2])
2043
                                                wb_ta4[23:16] <= w_conf_wdata_reduced[23:16] ;
2044
                                        if (~w_byte_en[1])
2045
                                                wb_ta4[15:12] <= w_conf_wdata_reduced[15:12] ;
2046
                                end
2047
`endif
2048
`ifdef          WB_IMAGE5
2049
                                if (w_reg_select_dec[46]) // case (w_conf_address_in[7:2]) = `W_IMG_CTRL5_ADDR:
2050
                                begin
2051
                                        if (~w_byte_en[0])
2052
                                                wb_img_ctrl5_bit2_0 <= w_conf_data_in[2:0] ;
2053
                                end
2054
                                if (w_reg_select_dec[47]) // case (w_conf_address_in[7:2]) = `W_BA5_ADDR:
2055
                                begin
2056
                                        if (~w_byte_en[3])
2057
                                                wb_ba5_bit31_12[31:24] <= w_conf_wdata_reduced[31:24] ;
2058
                                        if (~w_byte_en[2])
2059
                                                wb_ba5_bit31_12[23:16] <= w_conf_wdata_reduced[23:16] ;
2060
                                        if (~w_byte_en[1])
2061
                                                wb_ba5_bit31_12[15:12] <= w_conf_wdata_reduced[15:12] ;
2062
                                        if (~w_byte_en[0])
2063
                                                wb_ba5_bit0 <= w_conf_data_in[0] ;
2064
                                end
2065
                                if (w_reg_select_dec[48]) // case (w_conf_address_in[7:2]) = `W_AM5_ADDR:
2066
                                begin
2067
                                        if (~w_byte_en[3])
2068
                                                wb_am5[31:24] <= w_conf_wdata_reduced[31:24] ;
2069
                                        if (~w_byte_en[2])
2070
                                                wb_am5[23:16] <= w_conf_wdata_reduced[23:16] ;
2071
                                        if (~w_byte_en[1])
2072
                                                wb_am5[15:12] <= w_conf_wdata_reduced[15:12] ;
2073
                                end
2074
                                if (w_reg_select_dec[49]) // case (w_conf_address_in[7:2]) = `W_TA5_ADDR:
2075
                                begin
2076
                                        if (~w_byte_en[3])
2077
                                                wb_ta5[31:24] <= w_conf_wdata_reduced[31:24] ;
2078
                                        if (~w_byte_en[2])
2079
                                                wb_ta5[23:16] <= w_conf_wdata_reduced[23:16] ;
2080
                                        if (~w_byte_en[1])
2081
                                                wb_ta5[15:12] <= w_conf_wdata_reduced[15:12] ;
2082
                                end
2083
`endif
2084
                                if (w_reg_select_dec[50]) // case (w_conf_address_in[7:2]) = `W_ERR_CS_ADDR:
2085
                                begin
2086
                                        if (~w_byte_en[0])
2087
                                                wb_err_cs_bit0 <= w_conf_data_in[0] ;
2088
                                end
2089
 
2090
`ifdef  HOST
2091
                                if (w_reg_select_dec[53]) // case (w_conf_address_in[7:2]) = `CNF_ADDR_ADDR:
2092
                                begin
2093
                                        if (~w_byte_en[2])
2094
                                                cnf_addr_bit23_2[23:16] <= w_conf_data_in[23:16] ;
2095
                                        if (~w_byte_en[1])
2096
                                                cnf_addr_bit23_2[15:8] <= w_conf_data_in[15:8] ;
2097
                                        if (~w_byte_en[0])
2098
                                        begin
2099
                                                cnf_addr_bit23_2[7:2] <= w_conf_data_in[7:2] ;
2100
                                                cnf_addr_bit0 <= w_conf_data_in[0] ;
2101
                                        end
2102
                                end
2103
`endif
2104
                                // `CNF_DATA_ADDR: implemented elsewhere !!!
2105
                                // `INT_ACK_ADDR : implemented elsewhere !!!
2106
                    if (w_reg_select_dec[54]) // case (w_conf_address_in[7:2]) = `ICR_ADDR:
2107
                                begin
2108
                                        if (~w_byte_en[3])
2109
                                                icr_bit31 <= w_conf_data_in[31] ;
2110
                                        if (~w_byte_en[0])
2111
`ifdef  HOST
2112
                                                icr_bit4_3 <= w_conf_data_in[4:3] ;
2113
                                                icr_bit2_0 <= w_conf_data_in[2:0] ;
2114
`else
2115
                                                icr_bit2_0[2:0] <= w_conf_data_in[2:0] ;
2116
`endif
2117
                                end
2118
                end
2119
        end
2120
end
2121
 
2122
// This signals are synchronous resets for registers, whic occures when asynchronous RESET is '1' or
2123
// data '1' is synchronously written into them!
2124
reg                     delete_status_bit15 ;
2125
reg                     delete_status_bit14 ;
2126
reg                     delete_status_bit13 ;
2127
reg                     delete_status_bit12 ;
2128
reg                     delete_status_bit11 ;
2129
reg                     delete_status_bit8 ;
2130
reg                     delete_pci_err_cs_bit8 ;
2131
reg                     delete_wb_err_cs_bit8 ;
2132
reg                     delete_isr_bit4 ;
2133
reg                     delete_isr_bit3 ;
2134
reg                     delete_isr_bit2 ;
2135
reg                     delete_isr_bit1 ;
2136
 
2137
// This are aditional register bits, which are resets when their value is '1' !!!
2138
always@(w_we or w_reg_select_dec or w_conf_data_in or w_byte_en)
2139
begin
2140
// If '1' is written into, then it also sets signals to '1'
2141
        case ({w_we, w_reg_select_dec[0], w_reg_select_dec[27], w_reg_select_dec[50], w_reg_select_dec[55]})
2142
        {1'b1, 4'b1000} :
2143
        begin
2144
                delete_status_bit15     <= w_conf_data_in[31] & !w_byte_en[3] ;
2145
                delete_status_bit14     <= w_conf_data_in[30] & !w_byte_en[3] ;
2146
                delete_status_bit13     <= w_conf_data_in[29] & !w_byte_en[3] ;
2147
                delete_status_bit12     <= w_conf_data_in[28] & !w_byte_en[3] ;
2148
                delete_status_bit11     <= w_conf_data_in[27] & !w_byte_en[3] ;
2149
                delete_status_bit8      <= w_conf_data_in[24] & !w_byte_en[3] ;
2150
                delete_pci_err_cs_bit8  <= 1'b0 ;
2151
                delete_wb_err_cs_bit8   <= 1'b0 ;
2152
                delete_isr_bit4                 <= 1'b0 ;
2153
                delete_isr_bit3                 <= 1'b0 ;
2154
                delete_isr_bit2                 <= 1'b0 ;
2155
                delete_isr_bit1                 <= 1'b0 ;
2156
        end
2157
        {1'b1, 4'b0100} :
2158
        begin
2159
                delete_status_bit15     <= 1'b0 ;
2160
                delete_status_bit14     <= 1'b0 ;
2161
                delete_status_bit13     <= 1'b0 ;
2162
                delete_status_bit12     <= 1'b0 ;
2163
                delete_status_bit11     <= 1'b0 ;
2164
                delete_status_bit8      <= 1'b0 ;
2165
                delete_pci_err_cs_bit8  <= w_conf_data_in[8]  & !w_byte_en[1] ;
2166
                delete_wb_err_cs_bit8   <= 1'b0 ;
2167
                delete_isr_bit4                 <= 1'b0 ;
2168
                delete_isr_bit3                 <= 1'b0 ;
2169
                delete_isr_bit2                 <= 1'b0 ;
2170
                delete_isr_bit1                 <= 1'b0 ;
2171
        end
2172
        {1'b1, 4'b0010} :
2173
        begin
2174
                delete_status_bit15     <= 1'b0 ;
2175
                delete_status_bit14     <= 1'b0 ;
2176
                delete_status_bit13     <= 1'b0 ;
2177
                delete_status_bit12     <= 1'b0 ;
2178
                delete_status_bit11     <= 1'b0 ;
2179
                delete_status_bit8      <= 1'b0 ;
2180
                delete_pci_err_cs_bit8  <= 1'b0 ;
2181
                delete_wb_err_cs_bit8   <= w_conf_data_in[8]  & !w_byte_en[1] ;
2182
                delete_isr_bit4                 <= 1'b0 ;
2183
                delete_isr_bit3                 <= 1'b0 ;
2184
                delete_isr_bit2                 <= 1'b0 ;
2185
                delete_isr_bit1                 <= 1'b0 ;
2186
        end
2187
        {1'b1, 4'b0001} :
2188
        begin
2189
                delete_status_bit15     <= 1'b0 ;
2190
                delete_status_bit14     <= 1'b0 ;
2191
                delete_status_bit13     <= 1'b0 ;
2192
                delete_status_bit12     <= 1'b0 ;
2193
                delete_status_bit11     <= 1'b0 ;
2194
                delete_status_bit8      <= 1'b0 ;
2195
                delete_pci_err_cs_bit8  <= 1'b0 ;
2196
                delete_wb_err_cs_bit8   <= 1'b0 ;
2197
                delete_isr_bit4                 <= w_conf_data_in[4] & !w_byte_en[0] ;
2198
                delete_isr_bit3                 <= w_conf_data_in[3] & !w_byte_en[0] ;
2199
                delete_isr_bit2                 <= w_conf_data_in[2] & !w_byte_en[0] ;
2200
                delete_isr_bit1                 <= w_conf_data_in[1] & !w_byte_en[0] ;
2201
        end
2202
        default :
2203
        begin
2204
                delete_status_bit15     <= 1'b0 ;
2205
                delete_status_bit14     <= 1'b0 ;
2206
                delete_status_bit13     <= 1'b0 ;
2207
                delete_status_bit12     <= 1'b0 ;
2208
                delete_status_bit11     <= 1'b0 ;
2209
                delete_status_bit8      <= 1'b0 ;
2210
                delete_pci_err_cs_bit8  <= 1'b0 ;
2211
                delete_wb_err_cs_bit8   <= 1'b0 ;
2212
                delete_isr_bit4                 <= 1'b0 ;
2213
                delete_isr_bit3                 <= 1'b0 ;
2214
                delete_isr_bit2                 <= 1'b0 ;
2215
                delete_isr_bit1                 <= 1'b0 ;
2216
        end
2217
        endcase
2218
end
2219
 
2220
// STATUS BITS of PCI Header status register
2221
`ifdef SYNCHRONEOUS_CLOCK_DOMAINS
2222
        // Set and clear FF
2223
        always@(posedge pci_clk or posedge reset)
2224
        begin
2225
                if (reset) // Asynchronous reset
2226
                        status_bit15_11[15] <= 1'b0 ;
2227
                else
2228
                begin
2229
                        if (perr_in) // Synchronous set
2230
                                status_bit15_11[15] <= 1'b1 ;
2231
                        else if (delete_status_bit15) // Synchronous reset
2232
                                status_bit15_11[15] <= 1'b0 ;
2233
                end
2234
        end
2235
        // Set and clear FF
2236
        always@(posedge pci_clk or posedge reset)
2237
        begin
2238
                if (reset) // Asynchronous reset
2239
                        status_bit15_11[14] <= 1'b0 ;
2240
                else
2241
                begin
2242
                        if (serr_in) // Synchronous set
2243
                                status_bit15_11[14] <= 1'b1 ;
2244
                        else if (delete_status_bit14) // Synchronous reset
2245
                                status_bit15_11[14] <= 1'b0 ;
2246
                end
2247
        end
2248
        // Set and clear FF
2249
        always@(posedge pci_clk or posedge reset)
2250
        begin
2251
                if (reset) // Asynchronous reset
2252
                        status_bit15_11[13] <= 1'b0 ;
2253
                else
2254
                begin
2255
                        if (master_abort_recv) // Synchronous set
2256
                                status_bit15_11[13] <= 1'b1 ;
2257
                        else if (delete_status_bit13) // Synchronous reset
2258
                                status_bit15_11[13] <= 1'b0 ;
2259
                end
2260
        end
2261
        // Set and clear FF
2262
        always@(posedge pci_clk or posedge reset)
2263
        begin
2264
                if (reset) // Asynchronous reset
2265
                        status_bit15_11[12] <= 1'b0 ;
2266
                else
2267
                begin
2268
                        if (target_abort_recv) // Synchronous set
2269
                                status_bit15_11[12] <= 1'b1 ;
2270
                        else if (delete_status_bit12) // Synchronous reset
2271
                                status_bit15_11[12] <= 1'b0 ;
2272
                end
2273
        end
2274
        // Set and clear FF
2275
        always@(posedge pci_clk or posedge reset)
2276
        begin
2277
                if (reset) // Asynchronous reset
2278
                        status_bit15_11[11] <= 1'b0 ;
2279
                else
2280
                begin
2281
                        if (target_abort_set) // Synchronous set
2282
                                status_bit15_11[11] <= 1'b1 ;
2283
                        else if (delete_status_bit11) // Synchronous reset
2284
                                status_bit15_11[11] <= 1'b0 ;
2285
                end
2286
        end
2287
        // Set and clear FF
2288
        always@(posedge pci_clk or posedge reset)
2289
        begin
2290
                if (reset) // Asynchronous reset
2291
                        status_bit8 <= 1'b0 ;
2292
                else
2293
                begin
2294
                        if (master_data_par_err) // Synchronous set
2295
                                status_bit8 <= 1'b1 ;
2296
                        else if (delete_status_bit8) // Synchronous reset
2297
                                status_bit8 <= 1'b0 ;
2298
                end
2299
        end
2300
`else // not SYNCHRONEOUS_CLOCK_DOMAINS
2301
  `ifdef HOST
2302
        reg             [15:11] set_status_bit15_11;
2303
        reg             set_status_bit8;
2304
        wire    delete_set_status_bit15;
2305
        wire    delete_set_status_bit14;
2306
        wire    delete_set_status_bit13;
2307
        wire    delete_set_status_bit12;
2308
        wire    delete_set_status_bit11;
2309
        wire    delete_set_status_bit8;
2310
        wire    block_set_status_bit15;
2311
        wire    block_set_status_bit14;
2312
        wire    block_set_status_bit13;
2313
        wire    block_set_status_bit12;
2314
        wire    block_set_status_bit11;
2315
        wire    block_set_status_bit8;
2316
        // Synchronization module for clearing FF between two clock domains
2317
        pci_sync_module                 sync_status_15
2318
        (
2319
                .set_clk_in             (pci_clk),
2320
                .delete_clk_in  (wb_clk),
2321
                .reset_in               (reset),
2322
                .delete_set_out (delete_set_status_bit15),
2323
                .block_set_out  (block_set_status_bit15),
2324
                .delete_in              (delete_status_bit15)
2325
        );
2326
        // Setting FF
2327
        always@(posedge pci_clk or posedge reset)
2328
        begin
2329
                if (reset) // Asynchronous reset
2330
                        set_status_bit15_11[15] <= 1'b0 ;
2331
                else
2332
                begin
2333
                        if (perr_in) // Synchronous set
2334
                                set_status_bit15_11[15] <= 1'b1 ;
2335
                        else if (delete_set_status_bit15) // Synchronous reset
2336
                                set_status_bit15_11[15] <= 1'b0 ;
2337
                end
2338
        end
2339
        // Synchronization module for clearing FF between two clock domains
2340
        pci_sync_module                 sync_status_14
2341
        (
2342
                .set_clk_in             (pci_clk),
2343
                .delete_clk_in  (wb_clk),
2344
                .reset_in               (reset),
2345
                .delete_set_out (delete_set_status_bit14),
2346
                .block_set_out  (block_set_status_bit14),
2347
                .delete_in              (delete_status_bit14)
2348
        );
2349
        // Setting FF
2350
        always@(posedge pci_clk or posedge reset)
2351
        begin
2352
                if (reset) // Asynchronous reset
2353
                        set_status_bit15_11[14] <= 1'b0 ;
2354
                else
2355
                begin
2356
                        if (serr_in) // Synchronous set
2357
                                set_status_bit15_11[14] <= 1'b1 ;
2358
                        else if (delete_set_status_bit14) // Synchronous reset
2359
                                set_status_bit15_11[14] <= 1'b0 ;
2360
                end
2361
        end
2362
        // Synchronization module for clearing FF between two clock domains
2363
        pci_sync_module                 sync_status_13
2364
        (
2365
                .set_clk_in             (pci_clk),
2366
                .delete_clk_in  (wb_clk),
2367
                .reset_in               (reset),
2368
                .delete_set_out (delete_set_status_bit13),
2369
                .block_set_out  (block_set_status_bit13),
2370
                .delete_in              (delete_status_bit13)
2371
        );
2372
        // Setting FF
2373
        always@(posedge pci_clk or posedge reset)
2374
        begin
2375
                if (reset) // Asynchronous reset
2376
                        set_status_bit15_11[13] <= 1'b0 ;
2377
                else
2378
                begin
2379
                        if (master_abort_recv) // Synchronous set
2380
                                set_status_bit15_11[13] <= 1'b1 ;
2381
                        else if (delete_set_status_bit13) // Synchronous reset
2382
                                set_status_bit15_11[13] <= 1'b0 ;
2383
                end
2384
        end
2385
        // Synchronization module for clearing FF between two clock domains
2386
        pci_sync_module                 sync_status_12
2387
        (
2388
                .set_clk_in             (pci_clk),
2389
                .delete_clk_in  (wb_clk),
2390
                .reset_in               (reset),
2391
                .delete_set_out (delete_set_status_bit12),
2392
                .block_set_out  (block_set_status_bit12),
2393
                .delete_in              (delete_status_bit12)
2394
        );
2395
        // Setting FF
2396
        always@(posedge pci_clk or posedge reset)
2397
        begin
2398
                if (reset) // Asynchronous reset
2399
                        set_status_bit15_11[12] <= 1'b0 ;
2400
                else
2401
                begin
2402
                        if (target_abort_recv) // Synchronous set
2403
                                set_status_bit15_11[12] <= 1'b1 ;
2404
                        else if (delete_set_status_bit12) // Synchronous reset
2405
                                set_status_bit15_11[12] <= 1'b0 ;
2406
                end
2407
        end
2408
        // Synchronization module for clearing FF between two clock domains
2409
        pci_sync_module                 sync_status_11
2410
        (
2411
                .set_clk_in             (pci_clk),
2412
                .delete_clk_in  (wb_clk),
2413
                .reset_in               (reset),
2414
                .delete_set_out (delete_set_status_bit11),
2415
                .block_set_out  (block_set_status_bit11),
2416
                .delete_in              (delete_status_bit11)
2417
        );
2418
        // Setting FF
2419
        always@(posedge pci_clk or posedge reset)
2420
        begin
2421
                if (reset) // Asynchronous reset
2422
                        set_status_bit15_11[11] <= 1'b0 ;
2423
                else
2424
                begin
2425
                        if (target_abort_set) // Synchronous set
2426
                                set_status_bit15_11[11] <= 1'b1 ;
2427
                        else if (delete_set_status_bit11) // Synchronous reset
2428
                                set_status_bit15_11[11] <= 1'b0 ;
2429
                end
2430
        end
2431
        // Synchronization module for clearing FF between two clock domains
2432
        pci_sync_module                 sync_status_8
2433
        (
2434
                .set_clk_in             (pci_clk),
2435
                .delete_clk_in  (wb_clk),
2436
                .reset_in               (reset),
2437
                .delete_set_out (delete_set_status_bit8),
2438
                .block_set_out  (block_set_status_bit8),
2439
                .delete_in              (delete_status_bit8)
2440
        );
2441
        // Setting FF
2442
        always@(posedge pci_clk or posedge reset)
2443
        begin
2444
                if (reset) // Asynchronous reset
2445
                        set_status_bit8 <= 1'b0 ;
2446
                else
2447
                begin
2448
                        if (master_data_par_err) // Synchronous set
2449
                                set_status_bit8 <= 1'b1 ;
2450
                        else if (delete_set_status_bit8) // Synchronous reset
2451
                                set_status_bit8 <= 1'b0 ;
2452
                end
2453
        end
2454
        wire [5:0] status_bits   =       {set_status_bit15_11[15] && !block_set_status_bit15,
2455
                                                                 set_status_bit15_11[14] && !block_set_status_bit14,
2456
                                                                 set_status_bit15_11[13] && !block_set_status_bit13,
2457
                                                                 set_status_bit15_11[12] && !block_set_status_bit12,
2458
                                                                 set_status_bit15_11[11] && !block_set_status_bit11,
2459
                                                                 set_status_bit8                 && !block_set_status_bit8      } ;
2460
        wire [5:0] meta_status_bits ;
2461
        // interemediate stage to clk synchronization flip - flops - this ones are prone to metastability
2462
        synchronizer_flop   #(6) status_bits_sync
2463
        (
2464
            .data_in        (status_bits),
2465
            .clk_out        (wb_clk),
2466
            .sync_data_out  (meta_status_bits),
2467
            .async_reset    (reset)
2468
        ) ;
2469
        always@(posedge wb_clk or posedge reset)
2470
        begin
2471
            if (reset)
2472
            begin
2473
                status_bit15_11[15:11]  <= 5'b0 ;
2474
                status_bit8                             <= 1'b0 ;
2475
            end
2476
            else
2477
            begin
2478
                status_bit15_11[15:11]  <= meta_status_bits[5:1] ;
2479
                status_bit8                             <= meta_status_bits[0] ;
2480
            end
2481
        end
2482
  `else // GUEST
2483
        // Set and clear FF
2484
        always@(posedge pci_clk or posedge reset)
2485
        begin
2486
                if (reset) // Asynchronous reset
2487
                        status_bit15_11[15] <= 1'b0 ;
2488
                else
2489
                begin
2490
                        if (perr_in) // Synchronous set
2491
                                status_bit15_11[15] <= 1'b1 ;
2492
                        else if (delete_status_bit15) // Synchronous reset
2493
                                status_bit15_11[15] <= 1'b0 ;
2494
                end
2495
        end
2496
        // Set and clear FF
2497
        always@(posedge pci_clk or posedge reset)
2498
        begin
2499
                if (reset) // Asynchronous reset
2500
                        status_bit15_11[14] <= 1'b0 ;
2501
                else
2502
                begin
2503
                        if (serr_in) // Synchronous set
2504
                                status_bit15_11[14] <= 1'b1 ;
2505
                        else if (delete_status_bit14) // Synchronous reset
2506
                                status_bit15_11[14] <= 1'b0 ;
2507
                end
2508
        end
2509
        // Set and clear FF
2510
        always@(posedge pci_clk or posedge reset)
2511
        begin
2512
                if (reset) // Asynchronous reset
2513
                        status_bit15_11[13] <= 1'b0 ;
2514
                else
2515
                begin
2516
                        if (master_abort_recv) // Synchronous set
2517
                                status_bit15_11[13] <= 1'b1 ;
2518
                        else if (delete_status_bit13) // Synchronous reset
2519
                                status_bit15_11[13] <= 1'b0 ;
2520
                end
2521
        end
2522
        // Set and clear FF
2523
        always@(posedge pci_clk or posedge reset)
2524
        begin
2525
                if (reset) // Asynchronous reset
2526
                        status_bit15_11[12] <= 1'b0 ;
2527
                else
2528
                begin
2529
                        if (target_abort_recv) // Synchronous set
2530
                                status_bit15_11[12] <= 1'b1 ;
2531
                        else if (delete_status_bit12) // Synchronous reset
2532
                                status_bit15_11[12] <= 1'b0 ;
2533
                end
2534
        end
2535
        // Set and clear FF
2536
        always@(posedge pci_clk or posedge reset)
2537
        begin
2538
                if (reset) // Asynchronous reset
2539
                        status_bit15_11[11] <= 1'b0 ;
2540
                else
2541
                begin
2542
                        if (target_abort_set) // Synchronous set
2543
                                status_bit15_11[11] <= 1'b1 ;
2544
                        else if (delete_status_bit11) // Synchronous reset
2545
                                status_bit15_11[11] <= 1'b0 ;
2546
                end
2547
        end
2548
        // Set and clear FF
2549
        always@(posedge pci_clk or posedge reset)
2550
        begin
2551
                if (reset) // Asynchronous reset
2552
                        status_bit8 <= 1'b0 ;
2553
                else
2554
                begin
2555
                        if (master_data_par_err) // Synchronous set
2556
                                status_bit8 <= 1'b1 ;
2557
                        else if (delete_status_bit8) // Synchronous reset
2558
                                status_bit8 <= 1'b0 ;
2559
                end
2560
        end
2561
  `endif
2562
`endif
2563
 
2564
// STATUS BITS of P_ERR_CS - PCI error control and status register
2565
`ifdef SYNCHRONEOUS_CLOCK_DOMAINS
2566
        // Set and clear FF
2567
        always@(posedge pci_clk or posedge reset)
2568
        begin
2569
                if (reset) // Asynchronous reset
2570
                        pci_err_cs_bit8 <= 1'b0 ;
2571
                else
2572
                begin
2573
                        if (pci_error_sig && pci_err_cs_bit0) // Synchronous set
2574
                                pci_err_cs_bit8 <= 1'b1 ;
2575
                        else if (delete_pci_err_cs_bit8) // Synchronous reset
2576
                                pci_err_cs_bit8 <= 1'b0 ;
2577
                end
2578
        end
2579
`else // not SYNCHRONEOUS_CLOCK_DOMAINS
2580
  `ifdef HOST
2581
        // Set and clear FF
2582
        always@(posedge wb_clk or posedge reset)
2583
        begin
2584
                if (reset) // Asynchronous reset
2585
                        pci_err_cs_bit8 <= 1'b0 ;
2586
                else
2587
                begin
2588
                        if (pci_error_sig && pci_err_cs_bit0) // Synchronous set
2589
                                pci_err_cs_bit8 <= 1'b1 ;
2590
                        else if (delete_pci_err_cs_bit8) // Synchronous reset
2591
                                pci_err_cs_bit8 <= 1'b0 ;
2592
                end
2593
        end
2594
  `else // GUEST
2595
        reg             set_pci_err_cs_bit8;
2596
        wire    delete_set_pci_err_cs_bit8;
2597
        wire    block_set_pci_err_cs_bit8;
2598
        // Synchronization module for clearing FF between two clock domains
2599
        pci_sync_module                 sync_pci_err_cs_8
2600
        (
2601
                .set_clk_in             (wb_clk),
2602
                .delete_clk_in  (pci_clk),
2603
                .reset_in               (reset),
2604
                .delete_set_out (delete_set_pci_err_cs_bit8),
2605
                .block_set_out  (block_set_pci_err_cs_bit8),
2606
                .delete_in              (delete_pci_err_cs_bit8)
2607
        );
2608
        // Setting FF
2609
        always@(posedge wb_clk or posedge reset)
2610
        begin
2611
                if (reset) // Asynchronous reset
2612
                        set_pci_err_cs_bit8 <= 1'b0 ;
2613
                else
2614
                begin
2615
                        if (pci_error_sig && pci_err_cs_bit0) // Synchronous set
2616
                                set_pci_err_cs_bit8 <= 1'b1 ;
2617
                        else if (delete_set_pci_err_cs_bit8) // Synchronous reset
2618
                                set_pci_err_cs_bit8 <= 1'b0 ;
2619
                end
2620
        end
2621
        wire    pci_err_cs_bits = set_pci_err_cs_bit8 && !block_set_pci_err_cs_bit8 ;
2622
        wire    meta_pci_err_cs_bits ;
2623
        // interemediate stage to clk synchronization flip - flops - this ones are prone to metastability
2624
        synchronizer_flop   pci_err_cs_bits_sync
2625
        (
2626
            .data_in        (pci_err_cs_bits),
2627
            .clk_out        (pci_clk),
2628
            .sync_data_out  (meta_pci_err_cs_bits),
2629
            .async_reset    (reset)
2630
        ) ;
2631
        always@(posedge pci_clk or posedge reset)
2632
        begin
2633
            if (reset)
2634
                pci_err_cs_bit8 <= 1'b0 ;
2635
            else
2636
                pci_err_cs_bit8 <= meta_pci_err_cs_bits ;
2637
        end
2638
  `endif
2639
`endif
2640
        // Set and clear FF
2641
        always@(posedge wb_clk or posedge reset)
2642
        begin
2643
                if (reset) // Asynchronous reset
2644
                        pci_err_cs_bit10 <= 1'b0 ;
2645
                else
2646
                begin
2647
                        if (pci_error_sig) // Synchronous report
2648
                                pci_err_cs_bit10 <= pci_error_rty_exp ;
2649
                end
2650
        end
2651
        // Set and clear FF
2652
        always@(posedge wb_clk or posedge reset)
2653
        begin
2654
                if (reset) // Asynchronous reset
2655
                        pci_err_cs_bit9 <= 1'b0 ;
2656
                else
2657
                begin
2658
                        if (pci_error_sig) // Synchronous report
2659
                                pci_err_cs_bit9 <= pci_error_es ;
2660
                end
2661
        end
2662
        // Set and clear FF
2663
        always@(posedge wb_clk or posedge reset)
2664
        begin
2665
                if (reset) // Asynchronous reset
2666
            begin
2667
                        pci_err_cs_bit31_24 <= 8'h00 ;
2668
                        pci_err_addr <= 32'h0000_0000 ;
2669
                        pci_err_data <= 32'h0000_0000 ;
2670
            end
2671
                else
2672
                        if (pci_error_sig) // Synchronous report
2673
                        begin
2674
                                pci_err_cs_bit31_24 <= { pci_error_be, pci_error_bc } ;
2675
                                pci_err_addr <= pci_error_addr ;
2676
                                pci_err_data <= pci_error_data ;
2677
                        end
2678
        end
2679
 
2680
// STATUS BITS of W_ERR_CS - WB error control and status register
2681
`ifdef SYNCHRONEOUS_CLOCK_DOMAINS
2682
        // Set and clear FF
2683
        always@(posedge pci_clk or posedge reset)
2684
        begin
2685
                if (reset) // Asynchronous reset
2686
                        wb_err_cs_bit8 <= 1'b0 ;
2687
                else
2688
                begin
2689
                        if (wb_error_sig && wb_err_cs_bit0) // Synchronous set
2690
                                wb_err_cs_bit8 <= 1'b1 ;
2691
                        else if (delete_wb_err_cs_bit8) // Synchronous reset
2692
                                wb_err_cs_bit8 <= 1'b0 ;
2693
                end
2694
        end
2695
`else // not SYNCHRONEOUS_CLOCK_DOMAINS
2696
  `ifdef HOST
2697
        reg             set_wb_err_cs_bit8;
2698
        wire    delete_set_wb_err_cs_bit8;
2699
        wire    block_set_wb_err_cs_bit8;
2700
        // Synchronization module for clearing FF between two clock domains
2701
        pci_sync_module                 sync_wb_err_cs_8
2702
        (
2703
                .set_clk_in             (pci_clk),
2704
                .delete_clk_in  (wb_clk),
2705
                .reset_in               (reset),
2706
                .delete_set_out (delete_set_wb_err_cs_bit8),
2707
                .block_set_out  (block_set_wb_err_cs_bit8),
2708
                .delete_in              (delete_wb_err_cs_bit8)
2709
        );
2710
        // Setting FF
2711
        always@(posedge pci_clk or posedge reset)
2712
        begin
2713
                if (reset) // Asynchronous reset
2714
                        set_wb_err_cs_bit8 <= 1'b0 ;
2715
                else
2716
                begin
2717
                        if (wb_error_sig && wb_err_cs_bit0) // Synchronous set
2718
                                set_wb_err_cs_bit8 <= 1'b1 ;
2719
                        else if (delete_set_wb_err_cs_bit8) // Synchronous reset
2720
                                set_wb_err_cs_bit8 <= 1'b0 ;
2721
                end
2722
        end
2723
        wire    wb_err_cs_bits = set_wb_err_cs_bit8 && !block_set_wb_err_cs_bit8 ;
2724
        wire    meta_wb_err_cs_bits ;
2725
        // interemediate stage to clk synchronization flip - flops - this ones are prone to metastability
2726
        synchronizer_flop   wb_err_cs_bits_sync
2727
        (
2728
            .data_in        (wb_err_cs_bits),
2729
            .clk_out        (wb_clk),
2730
            .sync_data_out  (meta_wb_err_cs_bits),
2731
            .async_reset    (reset)
2732
        ) ;
2733
        always@(posedge wb_clk or posedge reset)
2734
        begin
2735
            if (reset)
2736
                wb_err_cs_bit8  <= 1'b0 ;
2737
            else
2738
                wb_err_cs_bit8  <= meta_wb_err_cs_bits ;
2739
        end
2740
  `else // GUEST
2741
        // Set and clear FF
2742
        always@(posedge pci_clk or posedge reset)
2743
        begin
2744
                if (reset) // Asynchronous reset
2745
                        wb_err_cs_bit8 <= 1'b0 ;
2746
                else
2747
                begin
2748
                        if (wb_error_sig && wb_err_cs_bit0) // Synchronous set
2749
                                wb_err_cs_bit8 <= 1'b1 ;
2750
                        else if (delete_wb_err_cs_bit8) // Synchronous reset
2751
                                wb_err_cs_bit8 <= 1'b0 ;
2752
                end
2753
        end
2754
  `endif
2755
`endif
2756
/*      // Set and clear FF
2757
        always@(posedge pci_clk or posedge reset)
2758
        begin
2759
                if (reset) // Asynchronous reset
2760
                        wb_err_cs_bit10 <= 1'b0 ;
2761
                else
2762
                begin
2763
                        if (wb_error_sig) // Synchronous report
2764
                                wb_err_cs_bit10 <= wb_error_rty_exp ;
2765
                end
2766
        end */
2767
        // Set and clear FF
2768
        always@(posedge pci_clk or posedge reset)
2769
        begin
2770
                if (reset) // Asynchronous reset
2771
                        wb_err_cs_bit9 <= 1'b0 ;
2772
                else
2773
                begin
2774
                        if (wb_error_sig) // Synchronous report
2775
                                wb_err_cs_bit9 <= wb_error_es ;
2776
                end
2777
        end
2778
        // Set and clear FF
2779
        always@(posedge pci_clk or posedge reset)
2780
        begin
2781
                if (reset) // Asynchronous reset
2782
            begin
2783
                        wb_err_cs_bit31_24 <= 8'h00 ;
2784
                        wb_err_addr <= 32'h0000_0000 ;
2785
                        wb_err_data <= 32'h0000_0000 ;
2786
            end
2787
                else
2788
                        if (wb_error_sig)
2789
                        begin
2790
                                wb_err_cs_bit31_24 <= { wb_error_be, wb_error_bc } ;
2791
                                wb_err_addr <= wb_error_addr ;
2792
                                wb_err_data <= wb_error_data ;
2793
                        end
2794
        end
2795
 
2796
// SERR_INT and PERR_INT STATUS BITS of ISR - interrupt status register
2797
`ifdef SYNCHRONEOUS_CLOCK_DOMAINS
2798
  `ifdef HOST
2799
        // Set and clear FF
2800
        always@(posedge pci_clk or posedge reset)
2801
        begin
2802
                if (reset) // Asynchronous reset
2803
                        isr_bit4_3[4] <= 1'b0 ;
2804
                else
2805
                begin
2806
                        if (isr_sys_err_int && icr_bit4_3[4]) // Synchronous set
2807
                                isr_bit4_3[4] <= 1'b1 ;
2808
                        else if (delete_isr_bit4) // Synchronous reset
2809
                                isr_bit4_3[4] <= 1'b0 ;
2810
                end
2811
        end
2812
        // Set and clear FF
2813
        always@(posedge pci_clk or posedge reset)
2814
        begin
2815
                if (reset) // Asynchronous reset
2816
                        isr_bit4_3[3] <= 1'b0 ;
2817
                else
2818
                begin
2819
                        if (isr_par_err_int && icr_bit4_3[3]) // Synchronous set
2820
                                isr_bit4_3[3] <= 1'b1 ;
2821
                        else if (delete_isr_bit3) // Synchronous reset
2822
                                isr_bit4_3[3] <= 1'b0 ;
2823
                end
2824
        end
2825
  `endif
2826
`else // not SYNCHRONEOUS_CLOCK_DOMAINS
2827
  `ifdef HOST
2828
        reg             [4:3]   set_isr_bit4_3;
2829
        wire    delete_set_isr_bit4;
2830
        wire    delete_set_isr_bit3;
2831
        wire    block_set_isr_bit4;
2832
        wire    block_set_isr_bit3;
2833
        // Synchronization module for clearing FF between two clock domains
2834
        pci_sync_module                 sync_isr_4
2835
        (
2836
                .set_clk_in             (pci_clk),
2837
                .delete_clk_in  (wb_clk),
2838
                .reset_in               (reset),
2839
                .delete_set_out (delete_set_isr_bit4),
2840
                .block_set_out  (block_set_isr_bit4),
2841
                .delete_in              (delete_isr_bit4)
2842
        );
2843
        // Setting FF
2844
        always@(posedge pci_clk or posedge reset)
2845
        begin
2846
                if (reset) // Asynchronous reset
2847
                        set_isr_bit4_3[4] <= 1'b0 ;
2848
                else
2849
                begin
2850
                        if (isr_sys_err_int && icr_bit4_3[4]) // Synchronous set
2851
                                set_isr_bit4_3[4] <= 1'b1 ;
2852
                        else if (delete_set_isr_bit4) // Synchronous reset
2853
                                set_isr_bit4_3[4] <= 1'b0 ;
2854
                end
2855
        end
2856
        // Synchronization module for clearing FF between two clock domains
2857
        pci_sync_module                 sync_isr_3
2858
        (
2859
                .set_clk_in             (pci_clk),
2860
                .delete_clk_in  (wb_clk),
2861
                .reset_in               (reset),
2862
                .delete_set_out (delete_set_isr_bit3),
2863
                .block_set_out  (block_set_isr_bit3),
2864
                .delete_in              (delete_isr_bit3)
2865
        );
2866
        // Setting FF
2867
        always@(posedge pci_clk or posedge reset)
2868
        begin
2869
                if (reset) // Asynchronous reset
2870
                        set_isr_bit4_3[3] <= 1'b0 ;
2871
                else
2872
                begin
2873
                        if (isr_par_err_int && icr_bit4_3[3]) // Synchronous set
2874
                                set_isr_bit4_3[3] <= 1'b1 ;
2875
                        else if (delete_set_isr_bit3) // Synchronous reset
2876
                                set_isr_bit4_3[3] <= 1'b0 ;
2877
                end
2878
        end
2879
        wire [4:3] isr_bits4_3  =       {set_isr_bit4_3[4] && !block_set_isr_bit4,
2880
                                                                 set_isr_bit4_3[3] && !block_set_isr_bit3       } ;
2881
        wire [4:3] meta_isr_bits4_3 ;
2882
        // interemediate stage to clk synchronization flip - flops - this ones are prone to metastability
2883
        synchronizer_flop   #(2) isr_bits_sync
2884
        (
2885
            .data_in        (isr_bits4_3),
2886
            .clk_out        (wb_clk),
2887
            .sync_data_out  (meta_isr_bits4_3),
2888
            .async_reset    (reset)
2889
        ) ;
2890
        always@(posedge wb_clk or posedge reset)
2891
        begin
2892
            if (reset)
2893
                isr_bit4_3[4:3] <= 2'b0 ;
2894
            else
2895
                isr_bit4_3[4:3] <= meta_isr_bits4_3[4:3] ;
2896
        end
2897
  `endif
2898
`endif
2899
 
2900
// PCI_EINT and WB_EINT STATUS BITS of ISR - interrupt status register
2901
`ifdef SYNCHRONEOUS_CLOCK_DOMAINS
2902
  // WB_EINT STATUS BIT
2903
        // Set and clear FF
2904
        always@(posedge pci_clk or posedge reset)
2905
        begin
2906
                if (reset) // Asynchronous reset
2907
                        isr_bit2_0[1] <= 1'b0 ;
2908
                else
2909
                begin
2910
                        if (wb_error_sig && icr_bit2_0[1] && wb_err_cs_bit0) // Synchronous set
2911
                                isr_bit2_0[1] <= 1'b1 ;
2912
                        else if (delete_isr_bit1) // Synchronous reset
2913
                                isr_bit2_0[1] <= 1'b0 ;
2914
                end
2915
        end
2916
  // PCI_EINT STATUS BIT
2917
        // Set and clear FF
2918
        always@(posedge pci_clk or posedge reset)
2919
        begin
2920
                if (reset) // Asynchronous reset
2921
                        isr_bit2_0[2] <= 1'b0 ;
2922
                else
2923
                begin
2924
                        if (pci_error_sig && icr_bit2_0[2] && pci_err_cs_bit0) // Synchronous set
2925
                                isr_bit2_0[2] <= 1'b1 ;
2926
                        else if (delete_isr_bit2) // Synchronous reset
2927
                                isr_bit2_0[2] <= 1'b0 ;
2928
                end
2929
        end
2930
`else // not SYNCHRONEOUS_CLOCK_DOMAINS
2931
  `ifdef HOST
2932
  // WB_EINT STATUS BIT
2933
        reg             set_isr_bit1;
2934
        wire    delete_set_isr_bit1;
2935
        wire    block_set_isr_bit1;
2936
        // Synchronization module for clearing FF between two clock domains
2937
        pci_sync_module                 sync_isr_1
2938
        (
2939
                .set_clk_in             (pci_clk),
2940
                .delete_clk_in  (wb_clk),
2941
                .reset_in               (reset),
2942
                .delete_set_out (delete_set_isr_bit1),
2943
                .block_set_out  (block_set_isr_bit1),
2944
                .delete_in              (delete_isr_bit1)
2945
        );
2946
        // Setting FF
2947
        always@(posedge pci_clk or posedge reset)
2948
        begin
2949
                if (reset) // Asynchronous reset
2950
                        set_isr_bit1 <= 1'b0 ;
2951
                else
2952
                begin
2953
                        if (wb_error_sig && icr_bit2_0[1] && wb_err_cs_bit0) // Synchronous set
2954
                                set_isr_bit1 <= 1'b1 ;
2955
                        else if (delete_set_isr_bit1) // Synchronous reset
2956
                                set_isr_bit1 <= 1'b0 ;
2957
                end
2958
        end
2959
        wire    isr_bit1        = set_isr_bit1 && !block_set_isr_bit1 ;
2960
        wire    meta_isr_bit1 ;
2961
        // interemediate stage to clk synchronization flip - flops - this ones are prone to metastability
2962
        synchronizer_flop   isr_bit1_sync
2963
        (
2964
            .data_in        (isr_bit1),
2965
            .clk_out        (wb_clk),
2966
            .sync_data_out  (meta_isr_bit1),
2967
            .async_reset    (reset)
2968
        ) ;
2969
        always@(posedge wb_clk or posedge reset)
2970
        begin
2971
            if (reset)
2972
                isr_bit2_0[1]   <= 1'b0 ;
2973
            else
2974
                isr_bit2_0[1]   <= meta_isr_bit1 ;
2975
        end
2976
  // PCI_EINT STATUS BIT
2977
        // Set and clear FF
2978
        always@(posedge wb_clk or posedge reset)
2979
        begin
2980
                if (reset) // Asynchronous reset
2981
                        isr_bit2_0[2] <= 1'b0 ;
2982
                else
2983
                begin
2984
                        if (pci_error_sig && icr_bit2_0[2] && pci_err_cs_bit0) // Synchronous set
2985
                                isr_bit2_0[2] <= 1'b1 ;
2986
                        else if (delete_isr_bit2) // Synchronous reset
2987
                                isr_bit2_0[2] <= 1'b0 ;
2988
                end
2989
        end
2990
  `else // GUEST
2991
  // WB_EINT STATUS BIT
2992
        // Set and clear FF
2993
        always@(posedge pci_clk or posedge reset)
2994
        begin
2995
                if (reset) // Asynchronous reset
2996
                        isr_bit2_0[1] <= 1'b0 ;
2997
                else
2998
                begin
2999
                        if (wb_error_sig && icr_bit2_0[1] && wb_err_cs_bit0) // Synchronous set
3000
                                isr_bit2_0[1] <= 1'b1 ;
3001
                        else if (delete_isr_bit1) // Synchronous reset
3002
                                isr_bit2_0[1] <= 1'b0 ;
3003
                end
3004
        end
3005
  // PCI_EINT STATUS BIT
3006
        reg             set_isr_bit2;
3007
        wire    delete_set_isr_bit2;
3008
        wire    block_set_isr_bit2;
3009
        // Synchronization module for clearing FF between two clock domains
3010
        pci_sync_module                 sync_isr_2
3011
        (
3012
                .set_clk_in             (wb_clk),
3013
                .delete_clk_in  (pci_clk),
3014
                .reset_in               (reset),
3015
                .delete_set_out (delete_set_isr_bit2),
3016
                .block_set_out  (block_set_isr_bit2),
3017
                .delete_in              (delete_isr_bit2)
3018
        );
3019
        // Setting FF
3020
        always@(posedge wb_clk or posedge reset)
3021
        begin
3022
                if (reset) // Asynchronous reset
3023
                        set_isr_bit2 <= 1'b0 ;
3024
                else
3025
                begin
3026
                        if (pci_error_sig && icr_bit2_0[2] && pci_err_cs_bit0) // Synchronous set
3027
                                set_isr_bit2 <= 1'b1 ;
3028
                        else if (delete_set_isr_bit2) // Synchronous reset
3029
                                set_isr_bit2 <= 1'b0 ;
3030
                end
3031
        end
3032
        wire    isr_bit2        = set_isr_bit2 && !block_set_isr_bit2 ;
3033
        wire    meta_isr_bit2 ;
3034
        // interemediate stage to clk synchronization flip - flops - this ones are prone to metastability
3035
        synchronizer_flop   isr_bit2_sync
3036
        (
3037
            .data_in        (isr_bit2),
3038
            .clk_out        (pci_clk),
3039
            .sync_data_out  (meta_isr_bit2),
3040
            .async_reset    (reset)
3041
        ) ;
3042
        always@(posedge pci_clk or posedge reset)
3043
        begin
3044
            if (reset)
3045
                isr_bit2_0[2]   <= 1'b0 ;
3046
            else
3047
                isr_bit2_0[2]   <= meta_isr_bit2 ;
3048
        end
3049
  `endif
3050
`endif
3051
 
3052
// INT BIT of ISR - interrupt status register
3053
`ifdef HOST
3054
        wire    isr_int_prop_bit = isr_int_prop && icr_bit2_0[0] ;
3055
        wire    meta_isr_int_prop_bit ;
3056
        // interemediate stage to clk synchronization flip - flops - this ones are prone to metastability
3057
        synchronizer_flop   isr_bit0_sync
3058
        (
3059
            .data_in        (isr_int_prop_bit),
3060
            .clk_out        (wb_clk),
3061
            .sync_data_out  (meta_isr_int_prop_bit),
3062
            .async_reset    (reset)
3063
        ) ;
3064
        always@(posedge wb_clk or posedge reset)
3065
        begin
3066
            if (reset)
3067
                isr_bit2_0[0]    <= 1'b0 ;
3068
            else
3069
                isr_bit2_0[0]    <= meta_isr_int_prop_bit ;
3070
        end
3071
`else // GUEST
3072
  `ifdef SYNCHRONEOUS_CLOCK_DOMAINS
3073
        wire    isr_int_prop_bit = isr_int_prop && icr_bit2_0[0] ;
3074
        always@(posedge pci_clk or posedge reset)
3075
        begin
3076
            if (reset)
3077
                isr_bit2_0[0]    <= 1'b0 ;
3078
            else
3079
                isr_bit2_0[0]    <= isr_int_prop_bit ;
3080
        end
3081
  `else // not SYNCHRONEOUS_CLOCK_DOMAINS
3082
        wire    isr_int_prop_bit = isr_int_prop && icr_bit2_0[0] ;
3083
        wire    meta_isr_int_prop_bit ;
3084
        // interemediate stage to clk synchronization flip - flops - this ones are prone to metastability
3085
        synchronizer_flop   isr_bit0_sync
3086
        (
3087
            .data_in        (isr_int_prop_bit),
3088
            .clk_out        (pci_clk),
3089
            .sync_data_out  (meta_isr_int_prop_bit),
3090
            .async_reset    (reset)
3091
        ) ;
3092
        always@(posedge pci_clk or posedge reset)
3093
        begin
3094
            if (reset)
3095
                isr_bit2_0[0]    <= 1'b0 ;
3096
            else
3097
                isr_bit2_0[0]    <= meta_isr_int_prop_bit ;
3098
        end
3099
  `endif
3100
`endif
3101
 
3102
// INT PIN
3103
wire    int_in;
3104
wire    int_meta;
3105
reg             interrupt_out;
3106
`ifdef HOST
3107
 `ifdef SYNCHRONEOUS_CLOCK_DOMAINS
3108
        assign  int_in = isr_int_prop_bit || isr_bit2_0[1] || isr_bit2_0[2] || isr_bit4_3[3]  || isr_bit4_3[4];
3109
 `else // not SYNCHRONEOUS_CLOCK_DOMAINS
3110
        assign  int_in = isr_int_prop_bit || isr_bit1      || isr_bit2_0[2] || isr_bits4_3[3] || isr_bits4_3[4];
3111
 `endif
3112
        // interemediate stage to clk synchronization flip - flops - this ones are prone to metastability
3113
        synchronizer_flop   int_pin_sync
3114
        (
3115
            .data_in        (int_in),
3116
            .clk_out        (wb_clk),
3117
            .sync_data_out  (int_meta),
3118
            .async_reset    (reset)
3119
        ) ;
3120
        always@(posedge wb_clk or posedge reset)
3121
        begin
3122
            if (reset)
3123
                interrupt_out   <= 1'b0 ;
3124
            else
3125
                interrupt_out   <= int_meta ;
3126
        end
3127
`else // GUEST
3128
 `ifdef SYNCHRONEOUS_CLOCK_DOMAINS
3129
        assign  int_in = isr_int_prop_bit || isr_bit2_0[1] || isr_bit2_0[2];
3130
 `else // not SYNCHRONEOUS_CLOCK_DOMAINS
3131
        assign  int_in = isr_int_prop_bit || isr_bit2_0[1] || isr_bit2;
3132
 `endif
3133
        // interemediate stage to clk synchronization flip - flops - this ones are prone to metastability
3134
        synchronizer_flop   int_pin_sync
3135
        (
3136
            .data_in        (int_in),
3137
            .clk_out        (pci_clk),
3138
            .sync_data_out  (int_meta),
3139
            .async_reset    (reset)
3140
        ) ;
3141
        always@(posedge pci_clk or posedge reset)
3142
        begin
3143
            if (reset)
3144
                interrupt_out   <= 1'b0 ;
3145
            else
3146
                interrupt_out   <= int_meta ;
3147
        end
3148
`endif
3149
 
3150
/*-----------------------------------------------------------------------------------------------------------
3151
        OUTPUTs from registers !!!
3152
-----------------------------------------------------------------------------------------------------------*/
3153
 
3154
// if bridge is HOST then write clock is equal to WB clock, and synchronization of outputs has to be done
3155
`ifdef  HOST
3156
  wire [3:0] command_bits = {command_bit8, command_bit6, command_bit2_0[1:0]} ;
3157
  wire [3:0] meta_command_bits ;
3158
  reg  [3:0] sync_command_bits ;
3159
  synchronizer_flop   #(4)  command_bits_sync
3160
  (
3161
      .data_in        (command_bits),
3162
      .clk_out        (pci_clk),
3163
      .sync_data_out  (meta_command_bits),
3164
      .async_reset    (reset)
3165
  ) ;
3166
  always@(posedge pci_clk or posedge reset)
3167
  begin
3168
      if (reset)
3169
          sync_command_bits <= 4'b0 ;
3170
      else
3171
          sync_command_bits <= meta_command_bits ;
3172
  end
3173
  wire  sync_command_bit8 = sync_command_bits[3] ;
3174
  wire  sync_command_bit6 = sync_command_bits[2] ;
3175
  wire  sync_command_bit1 = sync_command_bits[1] ;
3176
  wire  sync_command_bit0 = sync_command_bits[0] ;
3177
  wire  sync_command_bit2 = command_bit2_0[2] ;
3178
`else   // GUEST
3179
  wire       command_bit = command_bit2_0[2] ;
3180
  wire       meta_command_bit ;
3181
  reg        sync_command_bit ;
3182
  synchronizer_flop   command_bit_sync
3183
  (
3184
      .data_in        (command_bit),
3185
      .clk_out        (pci_clk),
3186
      .sync_data_out  (meta_command_bit),
3187
      .async_reset    (reset)
3188
  ) ;
3189
  always@(posedge pci_clk or posedge reset)
3190
  begin
3191
      if (reset)
3192
          sync_command_bit <= 1'b0 ;
3193
      else
3194
          sync_command_bit <= meta_command_bit ;
3195
  end
3196
  wire  sync_command_bit8 = command_bit8 ;
3197
  wire  sync_command_bit6 = command_bit6 ;
3198
  wire  sync_command_bit1 = command_bit2_0[1] ;
3199
  wire  sync_command_bit0 = command_bit2_0[0] ;
3200
  wire  sync_command_bit2 = sync_command_bit ;
3201
`endif
3202
// PCI header outputs from command register
3203
assign          serr_enable = sync_command_bit8 ;                                       // to PCI clock
3204
assign          perr_response = sync_command_bit6 ;                     // to PCI clock
3205
assign          pci_master_enable = sync_command_bit2 ;                 // to WB clock
3206
assign          memory_space_enable = sync_command_bit1 ;                       // to PCI clock
3207
assign          io_space_enable = sync_command_bit0 ;                           // to PCI clock
3208
 
3209
// if bridge is HOST then write clock is equal to WB clock, and synchronization of outputs has to be done
3210
        // We don't support cache line sizes smaller that 4 and it must have last two bits zero!!!
3211
wire    cache_lsize_not_zero = ((cache_line_size_reg[7] || cache_line_size_reg[6] || cache_line_size_reg[5] ||
3212
                                                                 cache_line_size_reg[4] || cache_line_size_reg[3] || cache_line_size_reg[2]) &&
3213
                                                                (!cache_line_size_reg[1] && !cache_line_size_reg[0]) );
3214
`ifdef  HOST
3215
  wire [7:2] cache_lsize_to_pci_bits = { cache_line_size_reg[7:2] } ;
3216
  wire [7:2] meta_cache_lsize_to_pci_bits ;
3217
  reg  [7:2] sync_cache_lsize_to_pci_bits ;
3218
  synchronizer_flop   #(6)  cache_lsize_to_pci_bits_sync
3219
  (
3220
      .data_in        (cache_lsize_to_pci_bits),
3221
      .clk_out        (pci_clk),
3222
      .sync_data_out  (meta_cache_lsize_to_pci_bits),
3223
      .async_reset    (reset)
3224
  ) ;
3225
  always@(posedge pci_clk or posedge reset)
3226
  begin
3227
      if (reset)
3228
          sync_cache_lsize_to_pci_bits <= 6'b0 ;
3229
      else
3230
          sync_cache_lsize_to_pci_bits <= meta_cache_lsize_to_pci_bits ;
3231
  end
3232
  wire [7:2] sync_cache_line_size_to_pci_reg    = sync_cache_lsize_to_pci_bits[7:2] ;
3233
  wire [7:2] sync_cache_line_size_to_wb_reg             = cache_line_size_reg[7:2] ;
3234
  wire           sync_cache_lsize_not_zero_to_wb        = cache_lsize_not_zero ;
3235
// Latency timer is sinchronized only to PCI clock when bridge implementation is HOST
3236
  wire [7:0] latency_timer_bits = latency_timer ;
3237
  wire [7:0] meta_latency_timer_bits ;
3238
  reg  [7:0] sync_latency_timer_bits ;
3239
  synchronizer_flop   #(8)  latency_timer_bits_sync
3240
  (
3241
      .data_in        (latency_timer_bits),
3242
      .clk_out        (pci_clk),
3243
      .sync_data_out  (meta_latency_timer_bits),
3244
      .async_reset    (reset)
3245
  ) ;
3246
  always@(posedge pci_clk or posedge reset)
3247
  begin
3248
      if (reset)
3249
          sync_latency_timer_bits <= 8'b0 ;
3250
      else
3251
          sync_latency_timer_bits <= meta_latency_timer_bits ;
3252
  end
3253
  wire [7:0] sync_latency_timer = sync_latency_timer_bits ;
3254
`else   // GUEST
3255
  wire [8:2] cache_lsize_to_wb_bits = { cache_lsize_not_zero, cache_line_size_reg[7:2] } ;
3256
  wire [8:2] meta_cache_lsize_to_wb_bits ;
3257
  reg  [8:2] sync_cache_lsize_to_wb_bits ;
3258
  synchronizer_flop   #(7)  cache_lsize_to_wb_bits_sync
3259
  (
3260
      .data_in        (cache_lsize_to_wb_bits),
3261
      .clk_out        (wb_clk),
3262
      .sync_data_out  (meta_cache_lsize_to_wb_bits),
3263
      .async_reset    (reset)
3264
  ) ;
3265
  always@(posedge wb_clk or posedge reset)
3266
  begin
3267
      if (reset)
3268
          sync_cache_lsize_to_wb_bits <= 7'b0 ;
3269
      else
3270
          sync_cache_lsize_to_wb_bits <= meta_cache_lsize_to_wb_bits ;
3271
  end
3272
  wire [7:2] sync_cache_line_size_to_pci_reg    = cache_line_size_reg[7:2] ;
3273
  wire [7:2] sync_cache_line_size_to_wb_reg             = sync_cache_lsize_to_wb_bits[7:2] ;
3274
  wire           sync_cache_lsize_not_zero_to_wb        = sync_cache_lsize_to_wb_bits[8] ;
3275
// Latency timer
3276
  wire [7:0] sync_latency_timer = latency_timer ;
3277
`endif
3278
// PCI header output from cache_line_size, latency timer and interrupt pin
3279
assign          cache_line_size_to_pci          = {sync_cache_line_size_to_pci_reg, 2'h0} ;  // [7 : 0] to PCI clock
3280
assign          cache_line_size_to_wb           = {sync_cache_line_size_to_wb_reg, 2'h0} ;   // [7 : 0] to WB clock
3281
assign          cache_lsize_not_zero_to_wb      = sync_cache_lsize_not_zero_to_wb ;
3282
 
3283
assign          latency_tim[7 : 0]     = sync_latency_timer ;                    // to PCI clock
3284
//assign                int_pin[2 : 0]         = r_interrupt_pin ;
3285
assign          int_out                            = interrupt_out ;
3286
// PCI output from image registers
3287
//   base address, address mask, translation address and control registers are sinchronized in PCI_DECODER.V module
3288
assign          pci_base_addr0 = pci_ba0_bit31_12[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
3289
assign          pci_base_addr1 = pci_ba1_bit31_12[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
3290
assign          pci_base_addr2 = pci_ba2_bit31_12[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
3291
assign          pci_base_addr3 = pci_ba3_bit31_12[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
3292
assign          pci_base_addr4 = pci_ba4_bit31_12[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
3293
assign          pci_base_addr5 = pci_ba5_bit31_12[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
3294
assign          pci_memory_io0 = pci_ba0_bit0 ;
3295
assign          pci_memory_io1 = pci_ba1_bit0 ;
3296
assign          pci_memory_io2 = pci_ba2_bit0 ;
3297
assign          pci_memory_io3 = pci_ba3_bit0 ;
3298
assign          pci_memory_io4 = pci_ba4_bit0 ;
3299
assign          pci_memory_io5 = pci_ba5_bit0 ;
3300
assign          pci_addr_mask0 = pci_am0[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
3301
assign          pci_addr_mask1 = pci_am1[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
3302
assign          pci_addr_mask2 = pci_am2[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
3303
assign          pci_addr_mask3 = pci_am3[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
3304
assign          pci_addr_mask4 = pci_am4[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
3305
assign          pci_addr_mask5 = pci_am5[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
3306
assign          pci_tran_addr0 = pci_ta0[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
3307
assign          pci_tran_addr1 = pci_ta1[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
3308
assign          pci_tran_addr2 = pci_ta2[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
3309
assign          pci_tran_addr3 = pci_ta3[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
3310
assign          pci_tran_addr4 = pci_ta4[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
3311
assign          pci_tran_addr5 = pci_ta5[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
3312
assign          pci_img_ctrl0[2 : 1] = pci_img_ctrl0_bit2_1 ;
3313
assign          pci_img_ctrl1[2 : 1] = pci_img_ctrl1_bit2_1 ;
3314
assign          pci_img_ctrl2[2 : 1] = pci_img_ctrl2_bit2_1 ;
3315
assign          pci_img_ctrl3[2 : 1] = pci_img_ctrl3_bit2_1 ;
3316
assign          pci_img_ctrl4[2 : 1] = pci_img_ctrl4_bit2_1 ;
3317
assign          pci_img_ctrl5[2 : 1] = pci_img_ctrl5_bit2_1 ;
3318
// WISHBONE output from image registers
3319
//   base address, address mask, translation address and control registers are sinchronized in DECODER.V module
3320
assign          wb_base_addr0 = wb_ba0_bit31_12[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
3321
assign          wb_base_addr1 = wb_ba1_bit31_12[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
3322
assign          wb_base_addr2 = wb_ba2_bit31_12[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
3323
assign          wb_base_addr3 = wb_ba3_bit31_12[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
3324
assign          wb_base_addr4 = wb_ba4_bit31_12[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
3325
assign          wb_base_addr5 = wb_ba5_bit31_12[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
3326
assign          wb_memory_io0 = wb_ba0_bit0 ;
3327
assign          wb_memory_io1 = wb_ba1_bit0 ;
3328
assign          wb_memory_io2 = wb_ba2_bit0 ;
3329
assign          wb_memory_io3 = wb_ba3_bit0 ;
3330
assign          wb_memory_io4 = wb_ba4_bit0 ;
3331
assign          wb_memory_io5 = wb_ba5_bit0 ;
3332
assign          wb_addr_mask0 = wb_am0[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
3333
assign          wb_addr_mask1 = wb_am1[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
3334
assign          wb_addr_mask2 = wb_am2[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
3335
assign          wb_addr_mask3 = wb_am3[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
3336
assign          wb_addr_mask4 = wb_am4[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
3337
assign          wb_addr_mask5 = wb_am5[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
3338
assign          wb_tran_addr0 = wb_ta0[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
3339
assign          wb_tran_addr1 = wb_ta1[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
3340
assign          wb_tran_addr2 = wb_ta2[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
3341
assign          wb_tran_addr3 = wb_ta3[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
3342
assign          wb_tran_addr4 = wb_ta4[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
3343
assign          wb_tran_addr5 = wb_ta5[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
3344
assign          wb_img_ctrl0[2 : 0] = wb_img_ctrl0_bit2_0 ;
3345
assign          wb_img_ctrl1[2 : 0] = wb_img_ctrl1_bit2_0 ;
3346
assign          wb_img_ctrl2[2 : 0] = wb_img_ctrl2_bit2_0 ;
3347
assign          wb_img_ctrl3[2 : 0] = wb_img_ctrl3_bit2_0 ;
3348
assign          wb_img_ctrl4[2 : 0] = wb_img_ctrl4_bit2_0 ;
3349
assign          wb_img_ctrl5[2 : 0] = wb_img_ctrl5_bit2_0 ;
3350
// GENERAL output from conf. cycle generation register & int. control register
3351
assign          config_addr[23 : 0] = { cnf_addr_bit23_2, 1'b0, cnf_addr_bit0 } ;
3352
assign          icr_soft_res = icr_bit31 ;
3353
 
3354
 
3355
endmodule
3356
 

powered by: WebSVN 2.1.0

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