Class ConvolutionalCoder
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.InstantiableNamedObj
-
- ptolemy.kernel.Entity<T>
-
- ptolemy.kernel.ComponentEntity<T>
-
- ptolemy.actor.AtomicActor<TypedIOPort>
-
- ptolemy.actor.TypedAtomicActor
-
- ptolemy.actor.lib.Transformer
-
- ptolemy.actor.lib.comm.ConvolutionalCoder
-
- All Implemented Interfaces:
java.lang.Cloneable
,Actor
,Executable
,FiringsRecordable
,Initializable
,TypedActor
,Changeable
,Debuggable
,DebugListener
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
public class ConvolutionalCoder extends Transformer
Encode an input sequence with a convolutional code. The inputs and outputs are booleans.The input sequence enters a shift register, and the contents of the shift register are combined using boolean functions given by the polynomialArray parameter. The initial state of the shift register is given by the initialState parameter, which should be a non-negative integer. The uncodedRate parameter, often denoted by k in the coding literature, is the number of bits per firing that are shifted into the shift register. The polynomialArray parameter is an array of positive integers. Each integer indicates one polynomial used for computing output bits. To get a k/n convolutional code, set uncodedRate to k and provide n integers in polynomialArray.
The integers in polynomialArray are usually most conveniently given as octal numbers. A leading zero indicates an octal number. The i-th bit of the integer indicates whether the i-th tap of the delay line should be used. All bits that are used are exclusive-ored, thus yielding the parity of the selected bits. See more details in Scrambler actor on using an integer to define a polynomial. The n parity results are produced on the output in a sequence.
A good convolutional code should have large Hamming distance between any two of its codewords. This is not easily checked, but there are some simple rules that all "good" codes should satisfy:
- k should be strictly smaller than n, otherwise the code is not uniquely decodable. Thus, uncodedRate should be less than the length of polynomialArray.
- k should not be higher than the highest order of all polynomials, otherwise, some input bits never get involved in computing parities.
If these rules are violated, the actor will throw an exception. However, these rules do not guarantee the codeword can be decoded successfully, and it is not always true that larger polynomials yield better codes. Users should check tables for convolutional codes from professional references. For convenience, we list here some convolutional codes that have large distance property.
Rate = 1/2 polynomialArray {05, 07} {013, 017} {031, 027} {065, 057} {0155, 0117} Rate = 1/3 polynomialArray {05, 07, 07} {015, 013, 017} {025, 033, 037} {071, 065, 057} {0155, 0123, 0137} Rate = 1/4 polynomialArray {05, 07, 07, 07} {015, 013, 013, 017} {025, 035, 033, 037} {065, 073, 047, 057} {0135, 0135, 0163, 0147} Rate = 1/5 polynomialArray {07, 07, 07, 05, 05} {017, 017, 015, 013, 013} {037, 035, 033, 025, 027} {057, 047, 067, 053, 075} Rate = 1/6 polynomialArray {07, 07, 07, 07, 05, 05} {017, 017, 015, 015, 013, 013} {037, 027, 035, 033, 025, 027} {067, 057, 055, 053, 071, 075} Rate = 2/3 polynomialArray {017, 06, 013} {072, 057, 027} {0171, 0166, 0273} Rate = k/5 k polynomialArray 2 {017, 016, 011, 05, 02} 2 {072, 047, 025, 053, 075} 3 {056, 062, 057, 043, 071} Rate = k/7 k polynomialArray 2 {012, 06, 05, 013, 013, 015, 017} 2 {066, 055, 027, 071, 052, 056, 057} 3 {051, 042, 036, 023, 075, 061, 047} Rate polynomialArray 3/4 {064, 052, 043, 071} 3/8 {054, 021, 062, 043, 045, 036, 057, 071}
Note that this implementation is limited to a shift register length of 32 because of the specification of the polynomials and initial shift register state as 32-bit integers.
For more information on convolutional codes, see Proakis, Digital Communications, Fourth Edition, McGraw-Hill, 2001, pp. 471-477, or Barry, Lee and Messerschmitt, Digital Communication, Third Edition, Kluwer, 2004.
- Since:
- Ptolemy II 3.0
- Version:
- $Id$
- Author:
- Ye Zhou, contributor: Edward A. Lee
- See Also:
Scrambler
,ViterbiDecoder
- Pt.AcceptedRating:
- Red (cxh)
- Pt.ProposedRating:
- Yellow (eal)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description Parameter
initialState
Integer defining the initial state of the shift register.Parameter
polynomialArray
An array of integers defining an array of polynomials with binary coefficients.Parameter
uncodedRate
Integer defining the number of bits that the shift register takes in each firing.-
Fields inherited from class ptolemy.actor.lib.Transformer
input, output
-
Fields inherited from class ptolemy.actor.TypedAtomicActor
_typesValid
-
Fields inherited from class ptolemy.actor.AtomicActor
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
-
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
-
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
-
-
Constructor Summary
Constructors Constructor Description ConvolutionalCoder(CompositeEntity container, java.lang.String name)
Construct an actor with the given container and name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
attributeChanged(Attribute attribute)
If the attribute being changed is uncodedRate, then verify that it is a positive integer; if it is polynomialArray, then verify that each of its elements is a positive integer and find the maximum value among them, which is used to compute the highest order among all polynomials.java.lang.Object
clone(Workspace workspace)
Clone the actor into the specified workspace.void
fire()
Read uncodedRate bits from the input port and shift them into the shift register.void
initialize()
Initialize the actor by resetting the shift register state equal to the value of initialState.boolean
postfire()
Record the most recent shift register state as the new state for the next iteration.-
Methods inherited from class ptolemy.actor.TypedAtomicActor
_containedTypeConstraints, _customTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints
-
Methods inherited from class ptolemy.actor.AtomicActor
_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, prefire, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate, wrapup
-
Methods inherited from class ptolemy.kernel.ComponentEntity
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
-
Methods inherited from class ptolemy.kernel.Entity
_addPort, _description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName
-
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ptolemy.actor.Actor
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
-
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
-
Methods inherited from interface ptolemy.actor.Executable
isFireFunctional, isStrict, iterate, prefire, stop, stopFire, terminate
-
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, preinitialize, removeInitializable, wrapup
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Field Detail
-
polynomialArray
public Parameter polynomialArray
An array of integers defining an array of polynomials with binary coefficients. The coefficients indicate the presence (1) or absence (0) of a tap in the shift register. Each element of this array parameter should be a positive integer. The default value is {05, 07}.
-
initialState
public Parameter initialState
Integer defining the initial state of the shift register. The i-th bit of the integer indicates the value of the i-th register. This parameter should be a non-negative integer. Its default value is the integer 0.
-
uncodedRate
public Parameter uncodedRate
Integer defining the number of bits that the shift register takes in each firing. It should be a positive integer. Its default value is the integer 1.
-
-
Constructor Detail
-
ConvolutionalCoder
public ConvolutionalCoder(CompositeEntity container, java.lang.String name) throws NameDuplicationException, 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:
IllegalActionException
- If the entity cannot be contained by the proposed container.NameDuplicationException
- If the container already has an actor with this name.
-
-
Method Detail
-
attributeChanged
public void attributeChanged(Attribute attribute) throws IllegalActionException
If the attribute being changed is uncodedRate, then verify that it is a positive integer; if it is polynomialArray, then verify that each of its elements is a positive integer and find the maximum value among them, which is used to compute the highest order among all polynomials.- Overrides:
attributeChanged
in classNamedObj
- Parameters:
attribute
- The attribute that changed.- Throws:
IllegalActionException
- If uncodedRate is non-positive or any element of polynomialArray is non-positive.
-
clone
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
Clone the actor into the specified workspace.- Overrides:
clone
in classTypedAtomicActor
- Parameters:
workspace
- The workspace for the new object.- Returns:
- A new actor.
- Throws:
java.lang.CloneNotSupportedException
- If a derived class contains an attribute that cannot be cloned.- See Also:
NamedObj.exportMoML(Writer, int, String)
,NamedObj.setDeferringChangeRequests(boolean)
-
fire
public void fire() throws IllegalActionException
Read uncodedRate bits from the input port and shift them into the shift register. Compute the parity for each polynomial specified in polynomialArray. Send the results in sequence to the output. The i-th bit in the output corresponds to the parity computed using the i-th polynomial.- Specified by:
fire
in interfaceExecutable
- Overrides:
fire
in classAtomicActor<TypedIOPort>
- Throws:
IllegalActionException
- Not thrown in this base class.
-
initialize
public void initialize() throws IllegalActionException
Initialize the actor by resetting the shift register state equal to the value of initialState.- Specified by:
initialize
in interfaceInitializable
- Overrides:
initialize
in classAtomicActor<TypedIOPort>
- Throws:
IllegalActionException
- If the parent class throws it.
-
postfire
public boolean postfire() throws IllegalActionException
Record the most recent shift register state as the new state for the next iteration.- Specified by:
postfire
in interfaceExecutable
- Overrides:
postfire
in classAtomicActor<TypedIOPort>
- Returns:
- True if execution can continue into the next iteration.
- Throws:
IllegalActionException
- If the base class throws it
-
-