classdef HDLRSEncoder< matlab.System
% HDLRSEncoder Encode data using a Reed-Solomon encoder
%   ENC = comm.HDLRSEncoder returns a block encoder System object, ENC,
%   that performs Reed-Solomon (RS) encoding in a streaming fashion for
%   HDL.
%
%   ENC = comm.HDLRSEncoder(Name,Value) creates an RS encoder object, ENC,
%   with the specified property Name set to the specified Value. You can
%   specify additional name-value pair arguments in any order as
%   (Name1,Value1,...,NameN,ValueN).
%
%   ENC = comm.HDLRSEncoder(N,K,Name,Value) creates an RS encoder object,
%   ENC, with the CodewordLength property set to N, the MessageLength
%   property set to K, and other specified property Names set to the
%   specified Values.
%
%   Step method syntax:
%
%   [Y,startOut,endOut,validOut] = step(ENC,X,STARTIN,ENDIN,VALIDIN)
%   encodes the input data, X, and returns the encoded data, Y. The
%   PuncturePatternSource and PuncturePattern properties affect the amount
%   of valid Y data.
%
%   System objects may be called directly like a function instead of using
%   the step method. For example, y = step(obj, x) and y = obj(x) are
%   equivalent.
%
%   HDLRSEncoder methods:
%
%   step     - Perform RS encoding (see above)
%   release  - Allow property value and input characteristics changes
%   clone    - Create RS encoder object with same property values
%   isLocked - Locked status (logical)
%
%   HDLRSEncoder properties:
%
%   CodewordLength            - Codeword length
%   MessageLength             - Message length
%   PrimitivePolynomialSource - Source of primitive polynomial
%   PrimitivePolynomial       - Primitive polynomial
%   PuncturePatternSource     - Source of puncture pattern
%   PuncturePattern           - Puncture pattern column vector
%   BSource                   - Source of B value
%   B                         - B value for polynomial generation
%
%   % Example:
%   %   RS-encoded a DVD-II standard packet of random data
%
%   hdlenc = comm.HDLRSEncoder(204,188,'BSource','Property','B',0);
%   enc  = comm.RSEncoder(204,188,...
%                            'GeneratorPolynomialSource','Property',...
%                            'GeneratorPolynomial',rsgenpoly(255,239,[],0));
%   dataIn = [randi([0,255],188,1,'uint8') ; zeros(255-188,1)];
%   for ii = 1:255
%     [dataOut(ii), startOut(ii), endOut(ii), validOut(ii)] = ...
%               hdlenc(dataIn(ii), ii==1, ii==188, ii<=188);
%   end
%   % Check the result:
%   Y = enc(dataIn(1:188));
%   assert(all(Y == dataOut(validOut)'))
%
%   See also comm.RSEncoder, comm.HDLRSDecoder.

     
    %   Copyright 2011-2018 The MathWorks, Inc.

    methods
        function out=HDLRSEncoder
        end

        function out=getExecutionSemanticsImpl(~) %#ok<STOUT>
            % works in both classic and synchronous subsystems
        end

        function out=getHeaderImpl(~) %#ok<STOUT>
            %getHeaderImpl   Return header for object display
        end

        function out=getIconImpl(~) %#ok<STOUT>
        end

        function out=getInputNamesImpl(~) %#ok<STOUT>
        end

        function out=getNumInputsImpl(~) %#ok<STOUT>
        end

        function out=getNumOutputsImpl(~) %#ok<STOUT>
        end

        function out=getOutputNamesImpl(~) %#ok<STOUT>
        end

        function out=isInactivePropertyImpl(~) %#ok<STOUT>
        end

        function out=isInputComplexityMutableImpl(~) %#ok<STOUT>
        end

        function out=isInputSizeMutableImpl(~) %#ok<STOUT>
        end

        function out=loadObjectImpl(~) %#ok<STOUT>
            % loadObjectImpl
        end

        function out=outputImpl(~) %#ok<STOUT>
            % output only, no state update
        end

        function out=resetImpl(~) %#ok<STOUT>
        end

        function out=resetStates(~) %#ok<STOUT>
        end

        function out=saveObjectImpl(~) %#ok<STOUT>
            % saveObjectImpl
        end

        function out=setupImpl(~) %#ok<STOUT>
            % Setup GF tables
            % codeSize = 2.^ceil(log2(obj.CodewordLength));
            % corrSize = obj.CodewordLength - obj.MessageLength;
            % tMultTable  = zeros(corrSize, codeSize,'uint32'); % hardcoded for now
            % tPowerTable = zeros(corrSize, codeSize,'uint32'); % hardcoded for now
            % tCorr       = uint32(0);            % hardcoded for now
            % tWordSize   = uint32(0);            % hardcoded for now
        end

        function out=showSimulateUsingImpl(~) %#ok<STOUT>
            % do not show simulate using option on mask
        end

        function out=supportsMultipleInstanceImpl(~) %#ok<STOUT>
            % Support in For Each Subsystem
        end

        function out=updateImpl(~) %#ok<STOUT>
            % no output, only update states
        end

        function out=validateInputsImpl(~) %#ok<STOUT>
        end

    end
    properties
        %B B value
        %   Specify the starting power for roots of the primitive polynomial.
        %   The default is 1. The primitive polynomial used is
        %   (X-alpha^B)*(X-alpha^(B+1))*...*(X-alpha^(B+N-K-1)), where B is an
        %   integer and alpha is a root of the primitive polynomial.
        B;

        %BSource Source of B, the starting power for roots of the primitive polynomial
        %   Specify the source of the B value as one of 'Auto' | 'Property'. The
        %   default is 'Auto'.
        BSource;

        %CodewordLength Codeword length
        %   Specify the codeword length of the RS code as a double precision,
        %   positive, integer scalar. If you set the PrimitivePolynomialSource
        %   property to 'Auto', CodewordLength must be in the range 3 <
        %   CodewordLength <= 2^16-1. If you set the PrimitivePolynomialSource
        %   property to 'Property', CodewordLength must be in the range 3 <=
        %   CodewordLength <= 2^M-1. M is the degree of the primitive polynomial
        %   that you specify with the PrimitivePolynomialSource and
        %   PrimitivePolynomial properties. M must be in the range 3<= M <= 16.
        %   The difference (CodewordLength - MessageLength) must be an even
        %   integer.
        %
        %   For a full-length RS code the value of the CodewordLength property
        %   must be of the form 2^M-1. If CodewordLength is less than 2^M-1, the
        %   object assumes a shortened RS code.
        %
        %   The default is 7.
        CodewordLength;

        %MessageLength Message length
        %   Specify the message length as a double precision, positive integer
        %   scalar. The difference (CodewordLength - MessageLength) must be an
        %   even integer. The default is 3.
        MessageLength;

        %PrimitivePolynomial Primitive polynomial
        %   Specify the primitive polynomial that defines the finite field GF(2^M)
        %   corresponding to the integers that form messages and codewords. You
        %   must set this property to a double precision, binary row vector that
        %   represents a primitive polynomial over GF(2) of degree M in descending
        %   order of powers. If CodewordLength is less than 2^M-1, the object uses
        %   a shortened RS code. The default is the result of
        %   fliplr(de2bi(primpoly(3))), which is [1 0 1 1] or the polynomial
        %   x^3+x+1. This property applies when you set the
        %   PrimitivePolynomialSource property to 'Property'.
        PrimitivePolynomial;

        %PrimitivePolynomialSource Source of primitive polynomial
        %   Specify the source of the primitive polynomial as one of 'Auto' |
        %   'Property'. The default is 'Auto'. When you set this property to
        %   'Auto', the object uses a primitive polynomial of degree M =
        %   ceil(log2(CodewordLength+1)), which is the result of
        %   fliplr(de2bi(primpoly(M))). When you set this property to 'Property',
        %   you can specify a polynomial using the PrimitivePolynomial property.
        PrimitivePolynomialSource;

        %PuncturePattern Puncture pattern vector
        %   Specify the pattern used to puncture the encoded data as a double
        %   precision, binary column vector of length
        %   (CodewordLength-MessageLength). Zeros in the puncture pattern vector
        %   indicate the position of the parity symbols that are punctured or
        %   excluded from each codeword. This property applies when you set the
        %   PuncturePatternSource property to 'Property'. The default is
        %   [ones(2,1); zeros(2,1)].
        PuncturePattern;

        %PuncturePatternSource Source of puncture pattern
        %   Specify the source of the puncture pattern as one of 'None' |
        %   'Property'. The default is 'None'. If you set this property to 'None'
        %   then the object does not apply puncturing to the code. If you set this
        %   property to 'Property' then the object punctures the code based on a
        %   puncture pattern vector specified in the PuncturePattern property.
        PuncturePatternSource;

    end
end
