Forum Discussion
Altera_Forum
Honored Contributor
15 years agoI think, what you are trying to do is not possible in this way.
First, your periphereal is memory mapped, so you are correct using the DMA. But DMA only makes sense when transferring multiple data in one run. Let me give you an example: For a serial interface, you could have the DMA transferring the contents of a buffer to the periphereal. For the opposite direction, you could use the DMA too, but not at the same time. (You could use a second DMA, if you wanted to send and receive parallel, allthough I don't think that would be neccessary). As a DMA is typically much faster than the periphereal, the DMA had to wait until the periphereal finished processing a value, before delivering the next one. Therefore, periphereals usually employ a buffer (e.g. a FIFO), so the DMA can write or read an amount of data in one run. The more data you can transfer at once, the more efficient it gets to use a DMA. Your code seems to use the DMA to deliver one value at a time. It does not make sense to setup the DMA to transfer 1 value of x, one value of y and one value of z. It would make more sense to add a fifo to your periphereal, and transmit the whole array of number[] for x, then for y, then have your periphereal calulate the result, and then again fetch the whole result[] via DMA. So you'd have to add 3 FIFOs to your periphereal, and some control to start a calculation once you have all data transmitted.