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