Forum Discussion
Altera_Forum
Honored Contributor
9 years agoHallo Tricky
Thanks for the quick reply. Here is my Matlab function for a CIC filter. I get the error on the line where i cast the x. I am not sure if the next parts of the code will also produce some error. function y = CIC4FPGA( x ) % 4th order CIC filter with 2 times oversampling % over = cast(2,'int32'); x = cast(x/8,'int32'); % this line shows the error persistent comb integrator if isempty( comb ) comb = cast(zeros(4,1),'int32'); integrator = cast(zeros(4,1),'int32'); end xx= cast(zeros(length(x)*over, 1),'int32'); y = cast(zeros(length(x)*over, 1),'int32'); a = cast(0,'int32'); b = cast(0,'int32'); % Calculate Comb stage for i = 1:length(x) a = x(i) - comb(1); comb(1) = x(i); b = a - comb(2); comb(2) = a; a = b - comb(3); comb(3) = b; b = a - comb(4); comb(4) = a; xx( 2*( i-1) + 1 ) = b; % insert (over - 1) zeros end; for i=1:length(xx) integrator(1) = integrator(1) + xx(i); integrator(2) = integrator(2) + integrator(1); integrator(3) = integrator(3) + integrator(2); integrator(4) = integrator(4) + integrator(3); y(i) = integrator(4); end;