function [next, output] = update(state, input)
% UPDATE - simple state machine update.
% The state argument should be 0 or 1.
% The input argument should be ’0’, ’1’, or ’absent’.
% The output result is ’0’, ’1’, or ’absent’.
% The next result is 0 or 1.
switch input
case '0'
next = 0;
if state output = '1';
else output = '0';
end
case '1'
next = 1;
if state output = '1';
else output = '0';
end
otherwise
next = state;
output = 'absent';
end