Hi guys!!Well I've got a questions for you. I've setup a PCIe interface and Qsys make me a memory BAR. It has a size 2mb - 21 bits. I'm confuse with 21 bits because I've setup a 32 bit non prefectchable memory. My question is: What meaning those 21 bits?? I think of the 32 bits I only have to use 21 bits....... Am I correct, or don't? :confused: Thank for reply!!
32bit/64bit BARs are referring to the address used by the PCIe bus. Every device on the bus will have memory BARs which are all programmed to have a 32 bit address by the PCIe Root Complex. It can then use the 32bit address to refer to the specific BAR in a specific device without having to know the bus-dev-func id of the device.In your device your address range will be smaller - just enough to access the required BAR size (in your case 21bits). You don't need the full 32bit address because you only have 21bit worth of memory to access, and to you it is irrelevant the address of your memory in the system as a whole. To make translation between bus addresses (32bit or 64bit) into local addresses (in your case 21bit) easier, the design of PCIe mandates that all BAR addresses are aligned to the size of the memory that they refer to. In practice what this means is that you can simply truncate the MSBs of the bus address to get your local address. That is what the PCIe core is doing for you - it is discarding the upper 11 bits leaving you with just the lower 21 bits that you need.