A
Artist
In an ADSP-BF547 I will have a buffer of data from an AD7606 A to D Converter. There will be 200k samples from each of eight channels for a total of 1..6M samples. On this data I need to do one DFT for each channel in real time. It is essential the DFT be as efficient as possible and so arises the question about the most efficient way to address the data in a channel.
For this many samples in a channel I do not have a choice about the sequence the DMA will put the data in the memory. The sequence is defined by the below equation which maps a sample row and a channel number to an index in the dynamically allocated linear array that data is stored in:
i = s*8 + c eq 1
Where:
i is the index number of an A to D data element in the linear array
s is the sample row number, 0 <= s < 200e3
c is the A to D channel number (column). There are eight of them. 0 <= c< 8
I could use the above equation 1 which would require one multiplication andone addition.
Since the number of channels is a convenient power of two I could instead shift and OR:
i = s<<3 | c eq 2
I could also dynamically allocate a linear array of pointers to each row:
u16 ** D2 = (u16 **)malloc( 200e3 * sizeof( u16 ** ) );
for( j=0; j<200e3; j++ ){
D2[j] = &D[ J*8 ];
}
Where:
D is the array DMA stored the A to D data in.
D2 is an array of pointers.
This way the data in D can be accessed by
Dadc = D2[c] eq 3
I expect the above for loop to be executed only once per buffer at initialization because the DMA alternates between two buffers. While it is filling one, the DFT will be done on the other. A DFT for a buffer has to be completed before DMA has finished filling the other buffer.
I need to know which of the above equations, 1, 2, or 3, will access the data quickest.
For this many samples in a channel I do not have a choice about the sequence the DMA will put the data in the memory. The sequence is defined by the below equation which maps a sample row and a channel number to an index in the dynamically allocated linear array that data is stored in:
i = s*8 + c eq 1
Where:
i is the index number of an A to D data element in the linear array
s is the sample row number, 0 <= s < 200e3
c is the A to D channel number (column). There are eight of them. 0 <= c< 8
I could use the above equation 1 which would require one multiplication andone addition.
Since the number of channels is a convenient power of two I could instead shift and OR:
i = s<<3 | c eq 2
I could also dynamically allocate a linear array of pointers to each row:
u16 ** D2 = (u16 **)malloc( 200e3 * sizeof( u16 ** ) );
for( j=0; j<200e3; j++ ){
D2[j] = &D[ J*8 ];
}
Where:
D is the array DMA stored the A to D data in.
D2 is an array of pointers.
This way the data in D can be accessed by
Dadc = D2
I expect the above for loop to be executed only once per buffer at initialization because the DMA alternates between two buffers. While it is filling one, the DFT will be done on the other. A DFT for a buffer has to be completed before DMA has finished filling the other buffer.
I need to know which of the above equations, 1, 2, or 3, will access the data quickest.