% FSM_out( x, f) - produce FSM output for input vector x
%
function y = FSM_out( x, f)

global zstate;
global zstate_0;
global states;

m = length(f);
n = length(x);
k = min(m,n);

if( zstate_0)		% initial 0's in the channel
  z = zeros(1,m-1);
else
  z = fliplr(states(:,zstate)');
end

y = f(1) * x;

for i = 1:k-1
  xx = [z(m-i:m-1), x(1:n-i)];
  y = y + f(i+1) * xx;
end
