PIC32 memory sizes are specified in bytes, but it stores 32bit words. Addressing is byte based, incrementing by 4 for each 32bit instruction.
PIC32’s implement two address schemes: virtual and physical.
All hardware resources (program memory, data memory and peripherals) are located at their respective physical addresses.
Virtual addresses are exclusively used by the CPU to fetch and execute instructions as well as access peripherals.
Physical addresses are used by bus master peripherals, such as DMA and the Flash controller, that access memory independently of the CPU.
KSEG0 and KSEG1 both translate to the same physical memory. They are created as separate memory segments because KSEG0 can be cached by the application whilst KSEG1 cannot:
KSEG0 is cacheable
KSEG1 is not cacheable. On chip peripherals are only accessible through this segment (SFR not present in the KSEG0 memory range)
Example – PIC32MX534F064H
Program memory:
0x1D000000 – 0x1D00FFFF
0x9D000000 – 0x9D00FFFF (virtual memory mapped)
0xBD000000 – 0xBD00FFFF (virtual memory mapped)
0x1D000000 – 0x1D00FFFF = 65536 addresses = 64KB program memory as specified in datasheet.
PIC32 memory is 32bit words, addressing is byte based and increments by 4 for each instruction, so:
64KB of program memory = 16K x 32bit instructions