Class SDFDirector
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.cg.kernel.generic.CodeGeneratorAdapter
-
- ptolemy.cg.kernel.generic.program.ProgramCodeGeneratorAdapter
-
- ptolemy.cg.kernel.generic.program.NamedProgramCodeGeneratorAdapter
-
- ptolemy.cg.adapter.generic.adapters.ptolemy.actor.Director
-
- ptolemy.cg.adapter.generic.adapters.ptolemy.actor.PortDirector
-
- ptolemy.cg.adapter.generic.program.procedural.adapters.ptolemy.actor.sched.StaticSchedulingDirector
-
- ptolemy.cg.adapter.generic.program.procedural.adapters.ptolemy.domains.sdf.kernel.SDFDirector
-
- All Implemented Interfaces:
java.lang.Cloneable
,Changeable
,Debuggable
,DebugListener
,Derivable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
- Direct Known Subclasses:
SDFDirector
,SDFDirector
public class SDFDirector extends StaticSchedulingDirector
Code generator adapter associated with the SDFDirector class. This class is also associated with a code generator.- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Bert Rodiers
- Pt.AcceptedRating:
- Red (rodiers)
- Pt.ProposedRating:
- Red (rodiers)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.cg.kernel.generic.program.NamedProgramCodeGeneratorAdapter
NamedProgramCodeGeneratorAdapter.VariableScope
-
Nested classes/interfaces inherited from class ptolemy.cg.kernel.generic.program.ProgramCodeGeneratorAdapter
ProgramCodeGeneratorAdapter.Channel
-
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.HashMap<NamedProgramCodeGeneratorAdapter,java.util.HashSet<Parameter>>
_referencedParameters
A hashmap that keeps track of parameters that are referenced for the associated actor.-
Fields inherited from class ptolemy.cg.adapter.generic.program.procedural.adapters.ptolemy.actor.sched.StaticSchedulingDirector
CURRENTTIME_DECLARATION
-
Fields inherited from class ptolemy.cg.adapter.generic.adapters.ptolemy.actor.PortDirector
_sanitizedDirectorName, ports
-
Fields inherited from class ptolemy.cg.kernel.generic.program.ProgramCodeGeneratorAdapter
_component, _defaultBlocks, _eol, _templateParser
-
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
-
-
Constructor Summary
Constructors Constructor Description SDFDirector(SDFDirector sdfDirector)
Construct the code generator adapter associated with the given SDFDirector.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.String
_createDynamicOffsetVariables(IOPort port)
Create offset variables for the channels of the given port.protected void
_createInputBufferSizeAndOffsetMap()
Create the input buffer and offset map.protected java.lang.String
_createOffsetVariablesIfNeeded(IOPort port, int channelNumber, int readTokens, int writeTokens)
Check for the given channel of the given port to see if variables are needed for recording read offset and write offset.protected java.lang.String
_generateVariableInitialization(NamedProgramCodeGeneratorAdapter target)
Generate variable initialization for the referenced parameters.protected java.lang.String
_getParameter(NamedProgramCodeGeneratorAdapter target, Attribute attribute, java.lang.String[] channelAndOffset)
Return an unique label for the given attribute referenced by the given adapter.protected void
_updatePortBufferSize()
Check to see if the buffer size for the current schedule is greater than the previous size.java.lang.String
generateFireFunctionCode()
Generate The fire function code.java.lang.String
generateInitializeCode()
Generate the initialize code for the associated SDF director.java.lang.String
generatePreinitializeCode()
Generate the preinitialize code for this director.int
getBufferSize(IOPort port, int channelNumber)
Return the buffer size of a given channel (i.e, a given port and a given channel number).-
Methods inherited from class ptolemy.cg.adapter.generic.program.procedural.adapters.ptolemy.actor.sched.StaticSchedulingDirector
_generateUpdatePortOffsetCode, _updateConnectedPortsOffset, _updatePortOffset, allowDynamicMultiportReference, createDecoratorAttributes, generateFireCode, generateMainLoop, generatePortName, generateVariableDeclaration, padBuffers
-
Methods inherited from class ptolemy.cg.adapter.generic.adapters.ptolemy.actor.PortDirector
_checkLocal, _checkRemote, _generateChannelOffset, _generatePortReference, _getCastType, _getChannelAndOffset, _getRefName, _getRefType, getReference, getReference, getSanitizedDirectorName
-
Methods inherited from class ptolemy.cg.adapter.generic.adapters.ptolemy.actor.Director
_ceilToPowerOfTwo, _generateVariableDeclaration, generateCodeForGet, generateCodeForSend, generateConstructorCode, generateModeTransitionCode, generatePostfireCode, generatePreinitializeMethodBodyCode, generateTransferInputsCode, generateTransferInputsCode, generateTransferOutputsCode, generateTransferOutputsCode, generateVariableDeclaration, generateVariableInitialization, generateVariableInitialization, generateWrapupCode, getComponent, getIncludeDirectories, getLibraries, getLibraryDirectories, getModifiedVariables, getParameter
-
Methods inherited from class ptolemy.cg.kernel.generic.program.NamedProgramCodeGeneratorAdapter
_generateFireCode, _generateTypeConvertStatement, analyzeTypeConvert, copyFilesToCodeDirectory, generatePrefireCode, generateSimpleName, generateTypeConvertFireCode, generateTypeConvertFireCode, getAddTimeString, getBufferSize, getDeclareSharedCode, getDefaultBlocks, getFireFunctionParameters, getHeaderFiles, getName, getParameterValue, getReference, getReference, getSharedCode, getSinkChannels, getSourceTimeString, getTimeSourcePortName, getTypeConvertChannels, getTypeConvertReference, getTypeConvertSinkChannels, setupAdapter, targetType
-
Methods inherited from class ptolemy.cg.kernel.generic.program.ProgramCodeGeneratorAdapter
_generateBlockByName, getAdapter, getCodeGenerator, getTemplateParser, processCode, setCodeGenerator, setTemplateParser, toString
-
Methods inherited from class ptolemy.cg.kernel.generic.CodeGeneratorAdapter
generateName
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _description, _executeChangeRequests, _exportMoMLContents, _getContainedObject, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateExistence, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, addHierarchyListener, attributeChanged, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, clone, containedObjectsIterator, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getContainer, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, notifyOfNameChange, propagateExistence, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setName, setPersistent, setSource, sortContainedObjects, toplevel, uniqueName, validateSettables, workspace
-
-
-
-
Field Detail
-
_referencedParameters
protected java.util.HashMap<NamedProgramCodeGeneratorAdapter,java.util.HashSet<Parameter>> _referencedParameters
A hashmap that keeps track of parameters that are referenced for the associated actor.
-
-
Constructor Detail
-
SDFDirector
public SDFDirector(SDFDirector sdfDirector)
Construct the code generator adapter associated with the given SDFDirector.- Parameters:
sdfDirector
- The associated ptolemy.domains.sdf.kernel.SDFDirector
-
-
Method Detail
-
generateFireFunctionCode
public java.lang.String generateFireFunctionCode() throws IllegalActionException
Generate The fire function code. This method is called when the firing code of each actor is not inlined. If the inline parameter of the code generator is true, then each actor's firing code is in a function with the same name as that of the actor. If the inline parameter is false, then the firing code is grouped in inner classes.- Overrides:
generateFireFunctionCode
in classDirector
- Returns:
- The fire function code.
- Throws:
IllegalActionException
- If thrown while generating fire code.
-
generateInitializeCode
public java.lang.String generateInitializeCode() throws IllegalActionException
Generate the initialize code for the associated SDF director.- Overrides:
generateInitializeCode
in classStaticSchedulingDirector
- Returns:
- The generated initialize code.
- Throws:
IllegalActionException
- If the adapter associated with an actor throws it while generating initialize code for the actor.
-
generatePreinitializeCode
public java.lang.String generatePreinitializeCode() throws IllegalActionException
Generate the preinitialize code for this director. The preinitialize code for the director is generated by appending the preinitialize code for each actor.- Overrides:
generatePreinitializeCode
in classStaticSchedulingDirector
- Returns:
- The generated preinitialize code.
- Throws:
IllegalActionException
- If getting the adapter fails, or if generating the preinitialize code for a adapter fails, or if there is a problem getting the buffer size of a port.
-
getBufferSize
public int getBufferSize(IOPort port, int channelNumber) throws IllegalActionException
Return the buffer size of a given channel (i.e, a given port and a given channel number). The default value is 1. If the port is an output port, then the buffer size is obtained from the inside receiver. If it is an input port, then it is obtained from the specified port.- Overrides:
getBufferSize
in classNamedProgramCodeGeneratorAdapter
- Parameters:
port
- The given port.channelNumber
- The given channel number.- Returns:
- The buffer size of the given channel.
- Throws:
IllegalActionException
- If the channel number is out of range or if the port is neither an input nor an output.
-
_createDynamicOffsetVariables
protected java.lang.String _createDynamicOffsetVariables(IOPort port) throws IllegalActionException
Create offset variables for the channels of the given port. The offset variables are generated unconditionally, but this method is only called when dynamic multiport references are desired. The buffers should be padded before this method is called.- Parameters:
port
- The port whose offset variables are generated.- Returns:
- Code that declares the read and write offset variables.
- Throws:
IllegalActionException
- If getting the rate or reading parameters throws it.
-
_createInputBufferSizeAndOffsetMap
protected void _createInputBufferSizeAndOffsetMap() throws IllegalActionException
Create the input buffer and offset map.- Throws:
IllegalActionException
- If thrown while getting port information.
-
_createOffsetVariablesIfNeeded
protected java.lang.String _createOffsetVariablesIfNeeded(IOPort port, int channelNumber, int readTokens, int writeTokens) throws IllegalActionException
Check for the given channel of the given port to see if variables are needed for recording read offset and write offset. If the buffer size of a channel divides the readTokens and writeTokens given in the argument, then there is no need for the variables. Otherwise the integer offsets are replaced with variables and the code to initialize these variables are generated. If padded buffers are desired (based on the padBuffers parameter of the CodeGenerator), pad the buffers.- Parameters:
port
- The port to be checked.channelNumber
- The channel number.readTokens
- The number of tokens read.writeTokens
- The number of tokens written.- Returns:
- Code that declares the read and write offset variables.
- Throws:
IllegalActionException
- If getting the rate or reading parameters throws it.
-
_generateVariableInitialization
protected java.lang.String _generateVariableInitialization(NamedProgramCodeGeneratorAdapter target) throws IllegalActionException
Generate variable initialization for the referenced parameters.- Overrides:
_generateVariableInitialization
in classDirector
- Parameters:
target
- The ProgramCodeGeneratorAdapter for which code needs to be generated.- Returns:
- code The generated code.
- Throws:
IllegalActionException
- If the adapter class for the model director cannot be found.
-
_getParameter
protected java.lang.String _getParameter(NamedProgramCodeGeneratorAdapter target, Attribute attribute, java.lang.String[] channelAndOffset) throws IllegalActionException
Return an unique label for the given attribute referenced by the given adapter.- Overrides:
_getParameter
in classStaticSchedulingDirector
- Parameters:
target
- The ProgramCodeGeneratorAdapter for which code needs to be generated.attribute
- The given attribute.channelAndOffset
- The given channel and offset.- Returns:
- an unique label for the given attribute.
- Throws:
IllegalActionException
- If the adapter throws it while generating the label.
-
_updatePortBufferSize
protected void _updatePortBufferSize() throws IllegalActionException
Check to see if the buffer size for the current schedule is greater than the previous size. If so, set the buffer size to the current buffer size needed.- Throws:
IllegalActionException
- If thrown while getting adapter or buffer size.
-
-