1 function [ y ] = gen_sin_lut( file, length, period, bits )
2 %gen_sin_lut Generate sinus look-up-table
3 % Generates sinus look-up-table for use in 'wave_table.vhd' entity. Wave
4 % values are in range 0 .. (2^bits - 1).
6 % Length - length of the table
7 % Period - length of one wave period
8 % Bits - bit length of each value
9 % File - if not empty waveform is saved in this file for direct use in VHDL
16 y = sin(2*pi*x/period);
17 y = (y + 1) * (2^(bits-1) - 0.5);
22 fprintf(fd,'%s\n',dec2bin(i,bits));