Creating the Assembler Lookup Files - Creating the output data through Matlab functions (e.g. hamming(n))
- Saving the output in an assembler lookup table format
- Referencing the lookup table with a name that will be called from the C source code in the DSP project (as a function)
hamming = fopen('hamming.asm', 'wt', 'l');
fprintf(hamming, '; hamming.asm - single precision floating point table generated from MATLAB\n');
fprintf(hamming, '\t.def\t_hamming\n');
fprintf(hamming, '\t.sym\t_hamming, _hamming, 54, 2, %d,, %d\n', size, n);
fprintf(hamming, '\t.data\n');
fprintf(hamming, '_hamming:\n');
fprintf(hamming, '\t.word\t%tXh, %tXh, %tXh, %tXh\n', h);
fprintf(hamming, '\n');
fclose(hamming);
- Importing the file as an asm file (adding a file to the project) to the DSP project
; hamming.asm - single precision floating point table generated from MATLAB
.def _hamming
.sym _hamming, _hamming, 54, 2, 8192,, 256
.data
_hamming:
.word 3DA3D70Ah, 3DA4203Fh, 3DA4FBD3h, 3DA669A4h
.word 3DA86978h, 3DAAFB01h, 3DAE1DD8h, 3DB1D180h
.word 3DB61567h, 3DBAE8E1h, 3DC04B30h, 3DC63B7Dh
.word 3DCCB8DCh, 3DD3C24Bh, 3DDB56B1h, 3DE374E1h
.word 3DEC1B99h, 3DF5497Fh, 3DFEFD27h, 3E049A87h
.word 3E09F7D0h, 3E0F9597h, 3E1572FFh, 3E1B8F1Ch
h = hamming(n);
- Using the lookup table in the C source code
// ----- Windowing the filtered frame with Hamming ----
for (k=0 ; k < N ; k++){
for (j=0 ; j < N ; j++){
if (k - j < 0) break;
frame[k] += hamming[j]*filtered_frame[k-j];
}
}