Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
The Intel sign-in experience has changed to support enhanced security controls. If you sign in, click here for more information.
19984 Discussions

Length of Memory BAR

Honored Contributor II

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!!
0 Kudos
2 Replies
Honored Contributor II

21 bits of address are required to cover the address range needed for 2Mb of memory. 



Honored Contributor II

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.