FSD123: Function block development procedure

Header

Title

FSD123: Function block development procedure

Products

Safety Simplifier

Requirements

61508-2 and 61508-3

Purpose

Procedure for function block development

Input

FSD120

Output

Approved procedure for function block development


Table of contents


Introduction

This document specifies the procedure to follow to develop new GUI and compiler function blocks.

Terms and Definitions

  • GUI: Graphical User Interface

  • GUI block: A GUI element in Simplifier Manager that represents a function and allows users to use the function in logic.

  • SL3: Ssp logic format version 3. The format used to describe logic to the compiler.

  • Compiler block: A lower level function in the compiler SRC002-104-CompilerIII that translates sl3 code to C code.

Procedure

Below follows the procedures for developing all function blocks.

Specification: Function block development procedure FSD123_SPEC1
status: PASS

To develop a function block, the following steps shall be performed and documented:

  1. Identify the need for a function block and specify it as a market requirement.

  2. Perform a hazard and risk analysis to identify the risks of the function block, as specified in 61508-1 clause 7.4.2.

    Note especially reasonably forseeable misuse.

    Note that since function blocks are part of an environment which is already verified for safety, only the aspects of the function block itself should be considered in the risk analysis.

    Note

    For example, effects of the power supply (low voltage, unstable voltage) should be disregarded if the block is only for digital logic (ie, not input or output related). Effects of the power supply are considered in FSD150: Validation tests of modes, power supply, and configuration.

    The following risks and hazards are applicable to all blocks and can, for brevity, be omitted from the risk analysis of each block. These risks shall however be covered by the integration tests (specified later in this procedure):

    • Incorrect Function: The function block may not correctly perfrom its intended operation, leading to incorrect behavior.

      Mitigation: Thorough testing and validation of the function blocks to ensure correct functionality.

    • Signal Propagation Delay: The function block may introduce unexpected delays.

      Mitigation: Measure the propagation delay of the block using an oscilloscope or logic analyzer, or similar.

    • Misuse: Users may misuse the function block, which may lead to unsafe function.

      Mitigation:

      • Limit the usage of the function so it can only be used in the intended way by limiting parameters and what can be connected to inputs and outputs,

      • provide clear documentation and guidelines on the correct usage of the function in the safety manual,

      • warn the user if the function is not used in the intended way.

  3. From the hazard and risk analysis, specify any special safety requirements of the block and safety manual.

  4. Specify the function block specification that fulfils the safety requirements, and including at least:

    • a function description (with text and state- and timing-diagrams if helpful),

    • list of all inputs,

    • list of all outputs,

    • list of all parameters including all possible values, for example a range [1,1000], or a list of values [“a”, “b”, “c”]).

  5. From the function specified in (4), identify and specify the underlying compiler functions that are required.

  6. For any compiler function block identified in (5) that is not already implemented, specify the compiler function block specification, including at least:

    • a function description (with text and state- and timing-diagrams if helpful),

    • list of all inputs,

    • list of all outputs,

    • list of all parameters (including all possible values, for example a range [1,1000], or a list of values [“a”, “b”, “c”]),

  7. Specify integration tests to validate all aspects of the function block, and all aspects of any new compiler blocks, taking the risk analysis and safety requirements into account. Preexisting underlying compiler blocks are already covered by other integration tests and do not need to be retested. However, the combination of the functions shall be tested.

    All possible values of parameters shall be tested, unless a suitable subset is specified with an explanation of why that is enough.

    Note

    In general, it is not feasible to test all possible values of a parameter which has a valid range of thousands of values. For such parameters, usually a minimum, a maximum, and some other intermediate values are enough to test.

    If timing is critical, it should be verified with an oscilloscope, logic analyzer or similar.

    How to prepare the test shall be clearly specified.

    Note

    Example (from an examlpe SR-latch function):

    Compile two single input blocks connected to the S and R inputs of an SR Latch block, and the output connected to a single output block. Download to a single unit and measure all inputs and outputs with an oscilloscope or logic analyzer.

    The test procedure shall be clearly specified as a list of steps, where each step may have a single easily verifiable pass critera.

    Note

    An example of a test procedure with easily verifyable pass criteria (from an examlpe SR-latch function):

    1. Verify that the output is LOW/OFF/0V.

    2. Apply a high signal pulse to the S input and verify that the output turns on within X ms of the high flank on the S input.

    3. Apply a high signal pulse to the R input and verify that the output turns off within X ms of the high flank on the R input.

    4. Apply a high signal to both the S and R inputs and verify that the output is off.

  8. Specify module tests to verify the GUI function block. Module tests for GUI blocks are in general “code review” tests, where the generated sl3 code is verified against the GUI defined logic, but may also incude other types of tests if applicable for the block. The logic to be used shall be clearly specified, as a picture or as a file.

    The test pass criteria shall be clearly specified as a list of easily verifyable conditions, and shall include at least the following:

    • All input signals to the block are in the correct place in the sl3 output,

    • all attributes (constant values) are named correctly and have the correct value in the sl3 output,

    • any other block specific logic is correct (such as inputs/outputs, memories, or other sl3 parameters).

    Test results shall contain at least:

    • The date when the test was performed,

    • who performed the test,

    • the git commit hash and/or version number of the version of Simplifier Manager that was used to generate the sl3 code,

    • all the relevant generated sl3 code as plain text,

    • arguments how the generated sl3 code fulfills all the pass criteria.

  9. Specify module tests for compiler blocks that test all aspects and parameters of the compiler function block. Module tests for compiler blocks are in general “code review” tests, where the generated C code is verified against the sl3 defined logic, but may also incude other types of tests if applicable. If the test does not cover all variants of parameters, a suitable subset with explanation why that is enough shall be included in the test specification.

    Module tests shall clearly specify the sl3-code to be compiled as plain text, or how to generate that code.

    The pass criteria shall be clearly specified, and shall include at least the following:

    • All aspects of the compiler block specification are implemented in the generated C code,

    • All attributes (constant values) are named correctly and have the correct value in the generated C code,

    • all input signals to the block are in the correct place in the generated C code,

    • any other block specific logic is correct (such as inputs/outputs, memories, defines, etc).

    Test results shall contain at least:

    • The date when the test was performed,

    • who performed the test,

    • the git commit hash and/or version number of the compiler used to generate the C code,

    • all the relevant generated C code as plain text,

    • arguments how the generated C code fulfills all the pass criteria.

  10. Develop the GUI block in Simplifier Manager

  11. Develop the compiler block or blocks in the compiler

  12. Integrate the safety aspects of the function block in the safety manual.

  13. Verify the module tests.

  14. Validate the integration tests.

Specification: Compiler function block implementation guidelines FSD123_SPEC2
status: PASS

Compiler blocks are implemented as python classes which generate C code, (usually simple text replacement of input parameters in a predefined function), which is then compiled by a C compiler. Module tests for compiler blocks are in large part code review tests, i.e., compiling sl3 logic and verifying the generated C code. To ensure that the generated C code is easily verifyable, the following guidelines shall be followed:

  • Always specify minimum and maximum values for parameters.

  • Prefer naming inputs with full names and not abbreviations.

    For example “data” instead of “d”.

  • Prefer naming outputs if there are more than one safe outputs. If a block has a single safe output, prefer having it unnamed (name = “”).

    For example an AND block which has only one output, the result.

  • If feasible, extract inputs (signals from other functions) and parameters (constant values supplied as arguments to the block) to const C stack variables with a defined size at the beginning of the function, and use them by referencing those variables by name in the function.

    This ensures that the code that performs the function doesn’t change when changing inputs and parameters, only the values of the variable assignments in the beginning of the function change, which makes it easier to verify that the function is correct. It also improves readability when values are used by name.

    It also ensures that the expected size of the parameter fits in the variable. If the parameter is too large, the compiler will give an error.


Revision History

Date

By

Version

Description

2017-10-02

Mats Linger

V1

Initial Version

2017-10-17

Mats Linger

V2

Completed the procedure

2024-10-31

William Forsdal

V3

  • Moved to new documentation structure,

  • Updated procedure to more closely follow 61508.

  • Added compiler block implementation guidelines spec.