📄 pci_conf_space.v
字号:
output [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_addr_mask1 ;
output [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_addr_mask2 ;
output [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_addr_mask3 ;
output [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_addr_mask4 ;
output [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_addr_mask5 ;
output [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_tran_addr0 ;
output [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_tran_addr1 ;
output [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_tran_addr2 ;
output [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_tran_addr3 ;
output [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_tran_addr4 ;
output [31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] wb_tran_addr5 ;
output [2 : 0] wb_img_ctrl0 ;
output [2 : 0] wb_img_ctrl1 ;
output [2 : 0] wb_img_ctrl2 ;
output [2 : 0] wb_img_ctrl3 ;
output [2 : 0] wb_img_ctrl4 ;
output [2 : 0] wb_img_ctrl5 ;
// WISHBONE input to wb error control and status register, error address and error data registers
input [3 : 0] wb_error_be ;
input [3 : 0] wb_error_bc ;
input wb_error_rty_exp ;
input wb_error_es ;
input wb_error_sig ;
input [31 : 0] wb_error_addr ;
input [31 : 0] wb_error_data ;
// GENERAL output from conf. cycle generation register & int. control register
output [23 : 0] config_addr ;
output icr_soft_res ;
output int_out ;
// GENERAL input to interrupt status register
input isr_sys_err_int ;
input isr_par_err_int ;
input isr_int_prop ;
output pci_init_complete_out ;
output wb_init_complete_out ;
`ifdef PCI_CPCI_HS_IMPLEMENT
output pci_cpci_hs_enum_oe_o ;
output pci_cpci_hs_led_oe_o ;
input pci_cpci_hs_es_i ;
reg pci_cpci_hs_enum_oe_o ;
reg pci_cpci_hs_led_oe_o ;
// set the hot swap ejector switch debounce counter width
// it is only 4 for simulation purposes
`ifdef PCI_CPCI_SIM
parameter hs_es_cnt_width = 4 ;
`else
`ifdef PCI33
parameter hs_es_cnt_width = 16 ;
`endif
`ifdef PCI66
parameter hs_es_cnt_width = 17 ;
`endif
`endif
`endif
`ifdef PCI_SPOCI
output spoci_scl_oe_o ;
input spoci_sda_i ;
output spoci_sda_oe_o ;
reg spoci_cs_nack,
spoci_cs_write,
spoci_cs_read;
reg [10: 0] spoci_cs_adr ;
reg [ 7: 0] spoci_cs_dat ;
`endif
/*###########################################################################################################
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
REGISTERS definition
====================
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
###########################################################################################################*/
// Decoded Register Select signals for writting (only one address decoder)
reg [56 : 0] w_reg_select_dec ;
/*###########################################################################################################
-------------------------------------------------------------------------------------------------------------
PCI CONFIGURATION SPACE HEADER (type 00h) registers
BIST and some other registers are not implemented and therefor written in correct
place with comment line. There are also some registers with NOT all bits implemented and therefor uses
_bitX or _bitX2_X1 to sign which bit or range of bits are implemented.
Some special cases and examples are described below!
-------------------------------------------------------------------------------------------------------------
###########################################################################################################*/
/*-----------------------------------------------------------------------------------------------------------
[000h-00Ch] First 4 DWORDs (32-bit) of PCI configuration header - the same regardless of the HEADER type !
r_ prefix is a sign for read only registers
Vendor_ID is an ID for a specific vendor defined by PCI_SIG - 2321h does not belong to anyone (e.g.
Xilinx's Vendor_ID is 10EEh and Altera's Vendor_ID is 1172h). Device_ID and Revision_ID should be used
together by application. Class_Code has 3 bytes to define BASE class (06h for PCI Bridge), SUB class
(00h for HOST type, 80h for Other Bridge type) and Interface type (00h for normal).
-----------------------------------------------------------------------------------------------------------*/
reg [15: 0] r_vendor_id ;
reg [15: 0] r_device_id ;
reg [15: 0] r_subsys_vendor_id ;
reg [15: 0] r_subsys_id ;
reg command_bit8 ;
reg command_bit6 ;
reg [2 : 0] command_bit2_0 ;
reg [15 : 11] status_bit15_11 ;
parameter r_status_bit10_9 = 2'b01 ; // 2'b01 means MEDIUM devsel timing !!!
reg status_bit8 ;
parameter r_status_bit7 = 1'b1 ; // fast back-to-back capable response !!!
parameter r_status_bit5 = `HEADER_66MHz ; // 1'b0 indicates 33 MHz capable !!!
`ifdef PCI_CPCI_HS_IMPLEMENT
wire r_status_bit4 = 1 ;
reg hs_ins ;
reg hs_ext ;
wire [ 1: 0] hs_pi = 2'b00 ;
reg hs_loo ;
reg hs_eim ;
wire [ 7: 0] hs_cap_id = 8'h06 ;
reg hs_ins_armed ;
reg hs_ext_armed ;
`else
wire r_status_bit4 = 0 ;
`endif
reg [ 7: 0] r_revision_id ;
`ifdef HOST
parameter r_class_code = 24'h06_00_00 ;
`else
parameter r_class_code = 24'h06_80_00 ;
`endif
reg [7 : 0] cache_line_size_reg ;
reg [7 : 0] latency_timer ;
parameter r_header_type = 8'h00 ;
// REG bist NOT implemented !!!
/*-----------------------------------------------------------------------------------------------------------
[010h-03Ch] all other DWORDs (32-bit) of PCI configuration header - only for HEADER type 00h !
r_ prefix is a sign for read only registers
BASE_ADDRESS_REGISTERS are the same as ones in the PCI Target configuration registers section. They
are duplicated and therefor defined just ones and used with the same name as written below. If
IMAGEx is NOT defined there is only parameter image_X assigned to '0' and this parameter is used
elsewhere in the code. This parameter is defined in the INTERNAL SIGNALS part !!!
Interrupt_Pin value 8'h01 is used for INT_A pin used.
MIN_GNT and MAX_LAT are used for device's desired values for Latency Timer value. The value in boath
registers specifies a period of time in units of 1/4 microsecond. ZERO indicates that there are no
major requirements for the settings of Latency Timer.
MIN_GNT specifieshow how long a burst period the device needs at 33MHz. MAX_LAT specifies how often
the device needs to gain access to the PCI bus. Values are choosen assuming that the target does not
insert any wait states. Follow the expamle of settings for simple display card.
If we use 64 (32-bit) FIFO locations for one burst then we need 8 x 1/4 microsecond periods at 33MHz
clock rate => MIN_GNT = 08h ! Resolution is 1024 x 768 (= 786432 pixels for one frame) with 16-bit
color mode. We can transfere 2 16-bit pixels in one FIFO location. From that we calculate, that for
one frame we need 6144 burst transferes in 1/25 second. So we need one burst every 6,51 microsecond
and that is 26 x 1/4 microsecond or 1Ah x 1/4 microsecond => MAX_LAT = 1Ah !
-----------------------------------------------------------------------------------------------------------*/
// REG x 6 base_address_register_X IMPLEMENTED as pci_ba_X !!!
// REG r_cardbus_cis_pointer NOT implemented !!!
// REG r_subsystem_vendor_id NOT implemented !!!
// REG r_subsystem_id NOT implemented !!!
// REG r_expansion_rom_base_address NOT implemented !!!
// REG r_cap_list_pointer NOT implemented !!!
reg [7 : 0] interrupt_line ;
parameter r_interrupt_pin = 8'h01 ;
reg [7 : 0] r_min_gnt ;
reg [7 : 0] r_max_lat ;
/*###########################################################################################################
-------------------------------------------------------------------------------------------------------------
PCI Target configuration registers
There are also some registers with NOT all bits implemented and therefor uses _bitX or _bitX2_X1 to
sign which bit or range of bits are implemented. Some special cases and examples are described below!
-------------------------------------------------------------------------------------------------------------
###########################################################################################################*/
/*-----------------------------------------------------------------------------------------------------------
[100h-168h]
Depending on defines (PCI_IMAGE1 or .. or PCI_IMAGE5 or (PCI_IMAGE0 and HOST)) in constants.v file,
there are registers corresponding to each IMAGE defined to REG and parameter pci_image_X assigned to '1'.
The maximum number of images is "6". By default there are first two images used and the first (PCI_IMAGE0)
is assigned to Configuration space! With a 'define' PCI_IMAGEx you choose the number of used PCI IMAGES
in a bridge without PCI_IMAGE0 (e.g. PCI_IMAGE3 tells, that PCI_IMAGE1, PCI_IMAGE2 and PCI_IMAGE3 are
used for mapping the space from WB to PCI. Offcourse, PCI_IMAGE0 is assigned to Configuration space).
That leave us PCI_IMAGE5 as the maximum number of images.
There is one exeption, when the core is implemented as HOST. If so, then the PCI specification allowes
the Configuration space NOT to be visible on the PCI bus. With `define PCI_IMAGE0 (and `define HOST), we
assign PCI_IMAGE0 to normal WB to PCI image and not to configuration space!
When error occurs, PCI ERR_ADDR and ERR_DATA registers stores address and data on the bus that
caused error. While ERR_CS register stores Byte Enables and Bus Command in the MSByte. In bits 10
and 8 it reports Retry Counter Expired (for posted writes), Error Source (Master Abort) and Error
Report Signal (signals that error has occured) respectively. With bit 0 we enable Error Reporting
mechanism.
-----------------------------------------------------------------------------------------------------------*/
`ifdef HOST
`ifdef NO_CNF_IMAGE
`ifdef PCI_IMAGE0 // if PCI bridge is HOST and IMAGE0 is assigned as general image space
reg [31 : 8] pci_ba0_bit31_8 ;
reg [2 : 1] pci_img_ctrl0_bit2_1 ;
reg pci_ba0_bit0 ;
reg [31 : 8] pci_am0 ;
reg [31 : 8] pci_ta0 ;
`else // if PCI bridge is HOST and IMAGE0 is not used
wire [31 : 8] pci_ba0_bit31_8 = 24'h0000_00 ; // NO base address needed
wire [2 : 1] pci_img_ctrl0_bit2_1 = 2'b00 ; // NO addr.transl. and pre-fetch
wire pci_ba0_bit0 = 0 ; // config. space is MEMORY space
wire [31 : 8] pci_am0 = 24'h0000_00 ; // NO address mask needed
wire [31 : 8] pci_ta0 = 24'h0000_00 ; // NO address translation needed
`endif
`else // if PCI bridge is HOST and IMAGE0 is assigned to PCI configuration space
reg [31 : 8] pci_ba0_bit31_8 ;
wire [2 : 1] pci_img_ctrl0_bit2_1 = 2'b00 ; // NO pre-fetch and read line support
wire pci_ba0_bit0 = 0 ; // config. space is MEMORY space
wire [31 : 8] pci_am0 = 24'hFFFF_F0 ; // address mask for configuration image always 20'hffff_f
wire [31 : 8] pci_ta0 = 24'h0000_00 ; // NO address translation needed
`endif
`endif
`ifdef GUEST // if PCI bridge is GUEST, then IMAGE0 is assigned to PCI configuration space
reg [31 : 8] pci_ba0_bit31_8 ;
wire [2 : 1] pci_img_ctrl0_bit2_1 = 2'b00 ; // NO addr.transl. and pre-fetch
wire pci_ba0_bit0 = 0 ; // config. space is MEMORY space
wire [31 : 8] pci_am0 = 24'hffff_f0 ; // address mask for configuration image always 24'hffff_f0 - 4KB mem image
wire [31 : 8] pci_ta0 = 24'h0000_00 ; // NO address translation needed
`endif
// IMAGE1 is included by default, meanwhile other IMAGEs are optional !!!
reg [2 : 1] pci_img_ctrl1_bit2_1 ;
reg [31 : 8] pci_ba1_bit31_8 ;
`ifdef HOST
reg pci_ba1_bit0 ;
`else
wire pci_ba1_bit0 = `PCI_BA1_MEM_IO ;
`endif
reg [31 : 8] pci_am1 ;
reg [31 : 8] pci_ta1 ;
`ifdef PCI_IMAGE2
reg [2 : 1] pci_img_ctrl2_bit2_1 ;
reg [31 : 8] pci_ba2_bit31_8 ;
`ifdef HOST
reg pci_ba2_bit0 ;
`else
wire pci_ba2_bit0 = `PCI_BA2_MEM_IO ;
`endif
reg [31 : 8] pci_am2 ;
reg [31 : 8] pci_ta2 ;
`else
wire [2 : 1] pci_img_ctrl2_bit2_1 = 2'b00 ;
wire [31 : 8] pci_ba2_bit31_8 = 24'h0000_00 ;
wire pci_ba2_bit0 = 1'b0 ;
wire [31 : 8] pci_am2 = 24'h0000_00 ;
wire [31 : 8] pci_ta2 = 24'h0000_00 ;
`endif
`ifdef PCI_IMAGE3
reg [2 : 1] pci_img_ctrl3_bit2_1 ;
reg [31 : 8] pci_ba3_bit31_8 ;
`ifdef HOST
reg pci_ba3_bit0 ;
`else
wire pci_ba3_bit0 = `PCI_BA3_MEM_IO ;
`endif
reg [31 : 8] pci_am3 ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -