ptolemy.actor.lib.comm
Class HammingCoder

java.lang.Object
  extended byptolemy.kernel.util.NamedObj
      extended byptolemy.kernel.InstantiableNamedObj
          extended byptolemy.kernel.Entity
              extended byptolemy.kernel.ComponentEntity
                  extended byptolemy.actor.AtomicActor
                      extended byptolemy.actor.TypedAtomicActor
                          extended byptolemy.actor.lib.Transformer
                              extended byptolemy.actor.lib.comm.HammingCoder
All Implemented Interfaces:
ptolemy.actor.Actor, ptolemy.kernel.util.Changeable, java.lang.Cloneable, ptolemy.kernel.util.Debuggable, ptolemy.kernel.util.DebugListener, ptolemy.kernel.util.Derivable, ptolemy.actor.Executable, ptolemy.kernel.util.Instantiable, ptolemy.kernel.util.ModelErrorHandler, ptolemy.kernel.util.MoMLExportable, ptolemy.kernel.util.Nameable, java.io.Serializable, ptolemy.actor.TypedActor

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: HammingCoder.java,v 1.15 2004/04/13 03:01:37 cxh Exp $
Author:
Rachel Zhou
See Also:
Serialized Form
Accepted Rating:
Red (cxh)
Proposed Rating:
Red (eal)

Nested Class Summary
 
Nested classes inherited from class ptolemy.kernel.Entity
ptolemy.kernel.Entity.ContainedObjectsIterator
 
Field Summary
 ptolemy.data.expr.Parameter codedRate
          Integer defining the Hamming code block size.
 ptolemy.data.expr.Parameter uncodedRate
          Integer defining the uncode block size.
 
Fields inherited from class ptolemy.actor.lib.Transformer
input, output
 
Fields inherited from class ptolemy.actor.AtomicActor
_stopRequested
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
 
Constructor Summary
HammingCoder(ptolemy.kernel.CompositeEntity container, java.lang.String name)
          Construct an actor with the given container and name.
 
Method Summary
 void attributeChanged(ptolemy.kernel.util.Attribute attribute)
          If the attribute being changed is uncodedRate or uncodedRate, then verify that it is a positive integer.
 void fire()
          If the attributes has changed, check the validity of uncodedRate and codedRate.
 
Methods inherited from class ptolemy.actor.TypedAtomicActor
_addPort, attributeTypeChanged, clone, newPort, typeConstraintList
 
Methods inherited from class ptolemy.actor.AtomicActor
_createReceivers, clone, connectionsChanged, getDirector, getExecutiveDirector, getFunctionDependency, getManager, initialize, inputPortList, iterate, newReceiver, outputPortList, postfire, prefire, preinitialize, pruneDependencies, removeDependency, setContainer, stop, stopFire, terminate, wrapup
 
Methods inherited from class ptolemy.kernel.ComponentEntity
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, propagateExistence, setName
 
Methods inherited from class ptolemy.kernel.Entity
_description, _exportMoMLContents, _removePort, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName, validateSettables
 
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeList, attributeList, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, getAttribute, getAttributes, getChangeListeners, getClassName, getDerivedLevel, getDerivedList, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, message, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setModelErrorHandler, setPersistent, setSource, toplevel, toString, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ptolemy.actor.Actor
getDirector, getExecutiveDirector, getFunctionDependency, getManager, inputPortList, newReceiver, outputPortList
 
Methods inherited from interface ptolemy.actor.Executable
initialize, iterate, postfire, prefire, preinitialize, stop, stopFire, terminate, wrapup
 
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
 
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getFullName, getName, getName
 

Field Detail

uncodedRate

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


codedRate

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

Constructor Detail

HammingCoder

public HammingCoder(ptolemy.kernel.CompositeEntity container,
                    java.lang.String name)
             throws ptolemy.kernel.util.NameDuplicationException,
                    ptolemy.kernel.util.IllegalActionException
Construct an actor with the given container and name. The output and trigger ports are also constructed.

Parameters:
container - The container.
name - The name of this actor.
Throws:
ptolemy.kernel.util.IllegalActionException - If the entity cannot be contained by the proposed container.
ptolemy.kernel.util.NameDuplicationException - If the container already has an actor with this name.
Method Detail

attributeChanged

public void attributeChanged(ptolemy.kernel.util.Attribute attribute)
                      throws ptolemy.kernel.util.IllegalActionException
If the attribute being changed is uncodedRate or uncodedRate, then verify that it is a positive integer. Set the tokenConsumptionRate and tokenProductionRate.

Throws:
ptolemy.kernel.util.IllegalActionException - If codedRate or uncodedRate is not positive.

fire

public void fire()
          throws ptolemy.kernel.util.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.

Throws:
ptolemy.kernel.util.IllegalActionException