A PCIe device can have a configuration space of type 0 (endpoints) or type 1 (RC or switches or bridges).
- A device of type 0 can have a total of 6 measures, and type 1 can only have 2 measures.
--BAR provides information about the address space required for the device.
--Each BAR - 32 bits, of which the first 4 bits 3: 0 are always read-only.
- 2 ^ (position of the last R / W bits of the least significant bit) = address window required by a particular BAR.
How to find the address window or the size of the region represented by any BAR:
1) Initially, having read any BAR (suppose BAR0 in our case), we got the value 32'h0000_000F. (Remember: the last 4 bits are read only !!).
2) Write all 1 to BAR0.
3) Read BAR0 again and suppose we get the value 32'hFFFF_000F. Thus, bit position 16 is the least significant bit of R / W. Thus, the address space required for BAR0 will be 2 ^ 16.
source share