public class Scrambler extends Transformer
With a proper choice of polynomial, the resulting output appears highly random even if the input is highly non-random. If the polynomial is a primitive polynomial, then the feedback shift register is a so-called maximal length feedback shift register. This means that with a constant input (or no input, which is equivalent to a constant false input) the output will be a sequence with period 2N-1, where N is the order of the polynomial (the length of the shift register). This is the longest possible sequence. Moreover, within this period, the sequence will appear to be white, in that a computed autocorrelation will be very nearly an impulse. Thus, the scrambler with a constant input can be very effectively used to generate a pseudo-random bit sequence.
The maximal-length feedback shift register with constant input will pass through 2N-1 states before returning to a state it has been in before. This is one short of the 2N states that a register with N bits can take on. This one missing state, in fact, is a lock-up state, in that if the input is an appropriate constant, the scrambler will cease to produce random-looking output, and will output a constant. For example, if the input is all zeros, and the initial state of the scrambler is zero, then the outputs will be all zero, hardly random. This is easily avoided by initializing the scrambler to some non-zero state. The default value for the shiftReg is set to 1.
The polynomial must be carefully chosen. It must represent a primitive polynomial, which is one that cannot be factored into two (nontrivial) polynomials with binary coefficients. See Lee and Messerschmitt (Kluwer, 1994) for more details. For convenience, we give here a set of primitive polynomials (expressed as octal numbers so that they are easily translated into taps on shift register). All of these will result in maximal-length pseudo-random sequences if the input is constant and lock-up is avoided:
order polynomial 2 07 3 013 4 023 5 045 6 0103 7 0211 8 0435 9 01021 10 02011 11 04005 12 010123 13 020033 14 042103 15 0100003 16 0210013 17 0400011 18 01000201 19 02000047 20 04000011 21 010000005 22 020000003 23 040000041 24 0100000207 25 0200000011 26 0400000107 27 01000000047 28 02000000011 29 04000000005 30 010040000007
The leading zero in the polynomial indicates an octal number. Note also that reversing the order of the bits in any of these numbers will also result in a primitive polynomial. Thus, the default value for the polynomial parameter is 0440001 in octal, or "100 100 000 000 000 001" in binary. Reversing these bits we get "100 000 000 000 001 001" in binary, or 0400011 in octal. This latter number is the one listed above as the primitive polynomial of order 17. The order is simply the index of the highest-order non-zero in the polynomial, where the low-order bit has index zero.
Since the polynomial and the feedback shift register are both implemented using type "int", the order of the polynomial is limited by the size of the "int" data type. For simplicity and portability, the polynomial is not allowed to be interpreted as a negative integer, so the sign bit cannot be used. Thus, if "int" is a 32-bit word, then the highest order polynomial allowed is 30 (recall that indexing for the order starts at zero, and we cannot use the sign bit). Java has 32-bit integers, so we give the primitive polynomials above only up to order 30.
For more information on scrambler, see Lee and Messerschmitt, Digital Communication, Second Edition, Kluwer Academic Publishers, 1994, pp. 595-603.
|Modifier and Type||Field and Description|
Integer defining the initial state of the shift register.
Integer defining a polynomial with binary coefficients.
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
|Constructor and Description|
Construct an actor with the given container and name.
|Modifier and Type||Method and Description|
If the attribute being changed is polynomial, then verify that is a positive integer and the lower-order bit is 1.
Read a bit from the input port and shift it into the shift register to scramble.
Initialize the actor by resetting the shift register state equal to the value of initialState.
Record the most recent shift register state as the new initial state for the next iteration.
_containedTypeConstraints, _customTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints
_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
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
_addPort, _description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
_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
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
isFireFunctional, isStrict, iterate, prefire, stop, stopFire, terminate
addInitializable, preinitialize, removeInitializable, wrapup
description, getContainer, getDisplayName, getFullName, getName, getName, setName
public Parameter polynomial
public Parameter initialState
public Scrambler(CompositeEntity container, java.lang.String name) throws NameDuplicationException, IllegalActionException
public void attributeChanged(Attribute attribute) throws IllegalActionException
public void fire() throws IllegalActionException
public void initialize() throws IllegalActionException
public boolean postfire() throws IllegalActionException