Class SDFDirector

    • 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 class Director
        Returns:
        The fire function code.
        Throws:
        IllegalActionException - If thrown while generating fire code.
      • 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 class StaticSchedulingDirector
        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 class NamedProgramCodeGeneratorAdapter
        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.
      • _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 class StaticSchedulingDirector
        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.