Class HammingCoder

  • All Implemented Interfaces:
    java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

    public class HammingCoder
    extends Transformer
    Encode the information symbols into Hamming code. Let k denotes parameter uncodedRate and n denotes parameter codedRate. During each firing, the actor consumes k bits and encode them into a block of code with length n. The rate of the code is k/n.

    For a Hamming code, k and n must satisfy the following: n = 2m - 1 k = 2m - 1 - m; where m is any positive integer. Note m = n - k. It is called the order of the Hamming code. The lowest order is m = 2, and (n, k) = (3, 1).

    The generator matrix G is defined as: Gk*n = [Ik | Pk*(n-k) ] where P is called the parity matrix. The subscript of a matrix indicates its dimension.

    The parity check matrix H is defined as: H(n-k)*n = [PT | In-k ] Each column of H must be one of the non-zero n = 2m - 1 combinations of m bits.

    To generate a Hamming code, the k information bits is considered as a row vector X. Its Hamming code is Y = X * G. Hence Y is a row vector of length n. The result is then sent to the output port in sequence.

    For more information on Hamming codes, see Proakis, Digital Communications, Fourth Edition, McGraw-Hill, 2001, pp. 416-424.

    Since:
    Ptolemy II 3.0
    Version:
    $Id$
    Author:
    Ye Zhou
    Pt.AcceptedRating:
    Red (cxh)
    Pt.ProposedRating:
    Red (eal)
    • Field Detail

      • uncodedRate

        public Parameter uncodedRate
        Integer defining the uncode block size. It should be a positive integer. Its default value is the integer 4.
      • codedRate

        public Parameter codedRate
        Integer defining the Hamming code block size. This parameter should be a non-negative integer. Its default value is the integer 7.
    • Method Detail

      • attributeChanged

        public void attributeChanged​(Attribute attribute)
                              throws IllegalActionException
        If the attribute being changed is uncodedRate or uncodedRate, then verify that it is a positive integer. Set the tokenConsumptionRate and tokenProductionRate.
        Overrides:
        attributeChanged in class NamedObj
        Parameters:
        attribute - The attribute that changed.
        Throws:
        IllegalActionException - If codedRate or uncodedRate is not positive.
      • fire

        public void fire()
                  throws IllegalActionException
        If the attributes has changed, check the validity of uncodedRate and codedRate. Generate the parity matrix. Read "uncodedRate" number of tokens from the input port and compute the parities. Send the parities in sequence to the output port.
        Specified by:
        fire in interface Executable
        Overrides:
        fire in class AtomicActor<TypedIOPort>
        Throws:
        IllegalActionException - Not thrown in this base class.