Reputation: 129
I am learning memory-mapped IOs. I have learned so far that the CPU reads and writes to the specific memory addr to write or read to a certain IO device. In the traditional way, the IO devices used to generate the interrupt and that's how CPU used to know that an IO device is done processing and it has results to be consumed by the CPU.
But in the memory-mapped IO there is no such provision, right? So, according to my knowledge (which doesn't make sense) to read if an IO device has provided any result to CPU or not the CPU needs to go and read the memory every time. Isn't that bad? It is worse than polling, right? because it adds the cycles for reading from the memory.
What am I missing here? Please help.
Upvotes: 1
Views: 133
Reputation: 972
Take and example of my device:
MEMORY {
IRAM : origin = 0x0, len = 0x30000
CACHE_L2 : origin = 0x30000, len = 0x10000
SDRAM : origin = 0x80000000, len = 0x1000000
FPGA_A1 : origin = 0x90000000, len = 0x1000
FPGA_A2 : origin = 0xA0000000, len = 0x1000
WATCHDOG : origin = 0xB0000000, len = 0x1
}
This is for my C6713 DSP. It shares memory with two FPGA's FPGA_1 and FPGA_2 and it share memory with a PowerPC CPU the SDRAM section. This is what can be called an example of memory mapped device. The two FPGA basically handles the ADC conversion, pulsing, digital IO and protections. Lets stick to an ADC.
So by offloading it on a memory mapped device. We have
So now to have your CPU read back the value you can either schedule a read operation on your CPU making sure it always gets a new value or you can configure your FPGA, in this particular case generate an interrupt every 50 usec making you CPU interrupt driven.
So in short no it is not bad as you gain a lot by offloading such tasks from CPU and free up lot of computing power. In process of doing so you also simplify your system.
Hope this helps.
Upvotes: 1