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 154

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

powered by: WebSVN 2.1.0

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