Defining Blocks

You can define a block by specifying its inputs/outputs called ports, local signals, and block instances. You can also declare parameters to be defined when the block is instantiated.

The block type can be SFC+, Dataflow or State Chart (with the appropriate license).

The definition of ports, signals and instances are similar whatever the block type.

This task shows you how to:


Before you begin: A logic workspace must be opened:
  • Open a State Logic library in Module & Block for Library.
  • Or edit a Simulation Logic in System and Device Designer.

Also, verify that the options set in the Tools > Options > Automation > General tab meet your needs.

Create Block

You can create a block in the current logic.

  1. Click New Block and a logic element in the specification tree.

    The Block Properties dialog box appears.

  2. Click OK.

    Result for a Simulation Logic

    Result for a State Logic Library

  3. In the contextual menu of the block, do one of the following:

    • Select [Block Name] object > Block Properties
    • Double-click either the Ports, Signals or Instances nodes in the specification tree.

    The Block Properties dialog box appears.



    The Block Properties dialog box has two sections:

    • Properties allows you to define the block name, its kind and a comment.
    • Block allows you to define the components of the block: there are specific tabs for defining Parameters, Ports, Local Signals and Instances.

Define Block Properties

You can modify the default block name, add comments and select the block kind: SFC+ or Dataflow.

  1. Change the block name.

  2. Add a comment.

  3. Select SFC+ from the Kind list.



  4. Click OK.

  5. Scroll over the block in the specification tree.

    The tool tip displays the signature and the comment of the block.

  6. Reopen the Block Properties dialog box by double-clicking the Ports node in the specification tree.

  7. In the Kind list, select Dataflow.

    A Warning box appears:

  8. Click Yes to validate the change.

  9. Click OK. The Behavior node is deleted and the block icon is modified.



Define Ports

You can define the block ports, constrain their type and direction.

  1. Click Add Port .



  2. To define the name, type, direction, and comment of a new port, fill the port data as defined below:

    1. Click in the Tree column to redefine the port name.

    2. Click the Type column to constrain the port type. The drop-down combo box displays the list of the predefined types and the user-defined types defined above the current node in the tree.

      The predefined types are defined in the @@pervasives library. For more information, see General.

      Note: In most cases, typing a port is optional, because the inference mechanism determines the port type from its usage. However, a port's structure does not always reflect its type. A leaf port can have a structured type either because a type constraint has been given on the port with a structured type or because the LCM type system automatically infers record fields.

    3. Click the Direction to define the port direction. By default, no direction is set. You can select In, Out or nothing. Select In. The icon in the Tree column displays the selected direction.

      Note: If no direction is defined, the inference mechanism determines the port direction from its usage.

    4. Fill the Comment column to add a comment to this port.



      Note: The comment is displayed in the tool tip of the port. The tool tip appears when you move the mouse over the port in the tree or the Block editor.

  3. Click Add Input to add a new port. A new port is created with a constrained direction.

  4. Select the port and click Add Port twice. The port is converted to a structure, each new port is added as a structure item.



    The items direction is determined by the direction set at the structure level. If no direction is defined at that level, the direction can be set individually at the item level.

    The items names are defined in the Tree column. In the Name column, you can define their aliases.

  5. If needed, you can redefine the structure using the contextual menu:

  6. Click OK. The block ports are defined.

Define Local Signals

You can define the block local signals.

  1. Right-click the block in the tree and select Block > Block Properties to edit it again.

  2. Select the tab Local Signals.

  3. Click Add Signal .

  4. To define the name, type and comment of the new signal, fill the signal data as defined below:

    1. Click in the Name column to redefine the signal name.

    2. Click the Type column to constrain the signal type. The drop-down combo box displays the list of the predefined types and the user-defined types defined above the current node in the tree.

      The predefined types are defined in the @@pervasives library. For more information, see General.

      Note: If no type is defined, the inference mechanism determines the signal type from its usage.

    3. Show/Hide cannot be checked. This option is only available for items of a structure or a tuple. Items will be shown or hidden in the block editor.

    4. Fill the Comment column to add a comment to this port.



      Note: The comment is displayed in the tool tip of the port. The tool tip appears when you move the mouse over the signal in the tree or the Block editor.

  5. Click Add Structure to create a new structure and select it.

  6. Click Add Signal to add signals as defined below.



    The name of the structure items are defined in the Tree column. In the Name column, you can define their alias.

  7. Click OK. The block signals are defined.



Define Block Instances

You can define block instances to be run in the current block.

An instance is a block instantiated in the current block. For this task, a block must be already defined in the specification tree above the current block.

  1. Double-click Instances in the specification tree.

  2. Click Add Block to add a block instance.



  3. Click the Block column and select the block to instantiate in the drop-down combo-box.

    Note: All the blocks contained in any libraries positioned above the block in the tree are available.

  4. Change the instance name.



  5. Click OK. The block instance is defined.



    Note: Via this tab, you cannot create the block instance defined as parameter (see next section). The instance of a parameter has to be created in the Block Editor workbench.

  6. Double-click A new Block in the specification tree.

    The Block Editor workbench is opened. You can check that all the elements defined in the Block Properties dialog box are visible in the editor.



Define Parameters

Parameters can be constants, functions or blocks to be used in the block behavior. Their difference with regular constants, functions or blocks is that they are parameters of the block and they can be redefined at each instantiation of this block.

These parameters are useful if the block behavior depends on its context. Thus, the block behavior can be modified for each instance.

  1. In the block contextual menu, select [Block Name] object > Block Properties.

    The Block Properties dialog box is opened.

  2. Click the tab Parameters.



  3. Click Add a block parameter.

    A new parameter is added to the list.


    • Name: This is the only mandatory field.
    • Default Value: You can enter the default implementation of the parameter. For constants, the easy way is to fill the value. For blocks and functions, you can enter the name of a block or a function already defined.
    • Type: In this field, you can enter the constant type or the signatures of the functions and blocks.
    • Comment: You can add a comment to any parameters.

  4. Double-click Param_0 to redefine the parameters name.

    Tip: At this stage, you can click OK. The parameter is created. As no type or default value is defined, you need to instantiate the block to build it or to debug it.

    See below some typical examples of constant declarations.

    Note: Default_Constant is a predefined constant accessible in the scope of the block.

  5. Click OK.

    The defined parameters are available in the specification tree.

  6. Double-click a parameter in the specification tree to open the Block Properties dialog box.

  7. You can enter new parameters to create blocks and functions parameters. See below typical examples.



    Note: Default_Function and Default_Block are a predefined function and a predefined block accessible in the scope of the block.

    Tip: To define types of blocks and functions, refer to Logic Control Modeler Language > Signature

Once the parameters are defined, they can be used in the block behavior like any regular constants, functions or blocks.