@Override
public void propagate(InstanceState state) {
// First we retrieve the value being fed into the input. Note that in
// the setPorts invocation above, the component's input was included at
// index 0 in the parameter array, so we use 0 as the parameter below.
Value in = state.getPort(0);
// Now compute the output. We've farmed this out to a helper method,
// since the same logic is needed for the library's other components.
Value out = nextGray(in);
// Finally we propagate the output into the circuit. The first parameter
// is 1 because in our list of ports (configured by invocation of
// setPorts above) the output is at index 1. The second parameter is the
// value we want to send on that port. And the last parameter is its
// "delay" - the number of steps it will take for the output to update
// after its input.
state.setPort(1, out, out.getWidth() + 1);
}