PCIe Device can have either Type-0 (Endpoints) or Type-1( RC or Switches or Bridges) Configuration Space.
--Type-0 device can have total of 6 BARs while Type-1 can have only 2 BARs.
--BAR gives the information about address space needed by the device.
--Each BAR is 32 bit , out of which first 4 bit 3:0 are always Read Only.
-- 2^(Position of last R/W bits from least significant bit) = Address window required by particular BAR.
How to know the address window or size of the region represneted by any BAR :
1) Initially Read any BAR( Suppose BAR0 in our case) , we got value 32'h0000_000F. (Remember : last 4 bits read only!! ).
2) Write all 1's to BAR0.
3) Read again BAR0 and Suppose we got value 32'hFFFF_000F. So bit position 16 is the least significant R/W bit. So address space required by BAR0 will be 2^16.