public static IEnumerable <StateRegister> EnumerateStates(this CodeConfig config) { for (var i = 0; i < 1 << config.NoOfStateRegisters; i++) { yield return(StateRegister.Create(i.GetBools(config.NoOfRegisters).Reverse())); } }
public static IEnumerable <Transition> EnumerateTransitions(this CodeConfig config) { return (config.EnumerateStates() .SelectMany(state => new[] { false, true } .Select(input => CalculateTransition(state, input, config)) ) .ToList()); }
private static Transition CalculateTransition(StateRegister state, bool input, CodeConfig config) { var newState = state.Shift(input); var output = newState.GetOutput(config).ToList(); return(new Transition(state.State.Values, input, output, newState.State.Values)); }
public IEnumerable <bool> GetOutput(CodeConfig config) { yield return(Mod2Add(config.GeneratorTop)); yield return(Mod2Add(config.GeneratorBottom)); }
public Encoder(CodeConfig config, bool terminateCode) { this.config = config; this.terminateCode = terminateCode; }