% global variables for Viterbi
%
global HUGE_VAL; % 1e99
global DEBUG;    % for debugging
global V;        % state array
global Vw;       % cost array
global Vparam;   % parameters

HUGE_VAL = 1e99;

DEBUG = 0;

% global variables for ISI
%
global FIR;     % channel response
global Memory;  % channel memory
global states;  % trellis states
global M;       % number of states
global trans;   % state transition cost matrix
global z;       % received data
global N;       % number of received data values

% data setup for symbol values (0,1) with f(D) = 1 + 0.5D
% KB ECE 8770 Fall 2000 section 3.2
%
FIR = [1 0.5]';

Memory = size(FIR,1) - 1;

states = FSM( [0 1], Memory);

M = size(states,2);

trans = FSM_trans( states, FIR);

z = [0.2 0.6 0.9 0.1]; % received data

N = length(z);

% run the Viterbi algorithm
%
vit1_init( M, N);

for t=1:N
  vit1_update;
  t, Vw % check Vw for debugging
end

path = vit1_paths;

ex = get_ex( path)
