Main Content

Requirement Links

Track how your requirements relate to your model design by using Simulink® Requirements™ to create links between your requirements and various Simulink model elements, including blocks, Stateflow® objects, Simulink Test™ test objects, Simulink data dictionary entries, MATLAB® code lines, and other requirements.

Each link has a corresponding slreq.Link object. The link points from a source item to a destination item.

You can create links to blocks and Stateflow objects from the Simulink Editor by dragging requirements from the Requirements Browser in the Requirements Perspective View. You can create links to Simulink Test test objects from the Test Manager or from the Requirements Editor. For more information on linking Simulink model elements to requirements, see Link Blocks and Requirements and Link to Test Cases from Requirements.

Requirement links identify the requirement by the Session Independent Identifier (SID) instead of the Custom ID, such that the link remains functional if the Custom ID is modified.

Linkable Items

You can create links between these requirements items, model entities, test artifacts, and code:

  • Simulink Requirements objects:

    • slreq.Requirement objects

    • slreq.Reference objects

    • slreq.Justification objects

  • Simulink entities:

    • Blocks

    • Subsystems

  • Simulink data dictionary entries

  • Stateflow objects:

    • States

    • Charts and subcharts

    • Transitions

  • System Composer™ architecture entities:

    • Components

    • Ports

    • Views

  • Simulink Test objects:

    • Test files

    • Test suites

    • Test cases

    • Iterations

    • Assessments

  • Lines of MATLAB code in:

You can set external artifacts like URLs as link destinations by creating MATLAB structures. There are two approaches available:

  • Create a link destination structure, then create a link between the requirement and the destination.

    myLinkDest = struct('domain', 'linktype_rmi_url', 'artifact', ...
     'https://www.mathworks.com', 'id', '')
    
    myLinkDest = 
    
      struct with fields:
    
          domain: 'linktype_rmi_url'
        artifact: 'www.mathworks.com'
              id: ''
    slreq.createLink(myReq, myLinkDest);
  • Create a requirement links data structure using rmi('createempty'). See rmi.

Link Types

Each link has a type that describes the relationship between the source and destination items. The link type refers to the slreq.Link object's Type property value.

Each link type has an intended use case. For example, the Implement link type indicates a relationship between a requirement and a design item that implements the requirement. When you create a link between two items, Simulink Requirements sets the link type and designates the items as source or destination depending on the type of artifact that they belong to. For example, if you create a link between a requirement and a Simulink model element, Simulink Requirements assumes that the model element implements the requirement. It sets the link type to Implement and designates the model element as the source and the requirement as the destination.

If there is no assumed link type for a link created between two items, then Simulink Requirements sets the link type to Relate.

After you create the link, you can edit the link type in the Requirements Editor, the Requirements Perspective, or at the MATLAB command line. In the Requirements Editor, click Show Links. Select a link and, in the Details pane, under Properties, select the desired link type from the Type list.

Simulink Requirements provides six built-in link types.

The forward direction indicates how the source relates to the destination. Similarly, the backward direction indicates how the destination relates to the source.

TypeDescriptionSource-to-Destination ExampleForward DirectionBackward Direction
Relate
  • General relationship between items for most use cases

  • Bi-directional link

Requirement to requirement

The first requirement is related to the second requirement.

The second requirement is related to the first requirement.

Implement
  • Specifies the source item that implements the requirement

  • Contributes to the implementation status

For more information, see Review Requirements Implementation Status.

Simulink model element to requirement

The Simulink model element implements the requirement.

The requirement is implemented by the Simulink model element.

Verify
  • Specifies which source item verifies the requirement

  • Contributes to the verification status if the source item is one of the accepted item types

For more information, see Review Requirements Verification Status.

Simulink test case to requirement

The Simulink test case verifies the requirement.

The requirement is verified by the Simulink test case.

Derive

Specifies which source item derives the destination item

Imported referenced requirement to requirement

The imported referenced requirement derives the requirement.

The requirement is derived from the imported referenced requirement.

Refine

Specifies which source item adds detail for the functionality specified by the destination item

Low-level requirement to high-level requirement

The low-level requirement refines the high-level requirement.

The high-level requirement is refined by the low-level requirement.

Confirm
  • Specifies a relationship between a requirement and an external test result source

  • Can contribute to the verification status in certain cases

For more information, see Include Results from External Sources in Verification Status.

Requirement to external test result

The requirement is confirmed by the external test result.

The external test result confirms the requirement.

The Implement and Verify link types describe requirement-to-model and requirement-to-test relationships. Specify the source and the destination artifacts carefully because these links affect the implementation status and verification status. For more information, see Review Requirements Implementation Status and Review Requirements Verification Status.

The link type also affects the impact direction in the Traceability Diagram window. For more information, see Visualize Links with a Traceability Diagram.

Custom Link Types

In addition to the built-in types, you can define custom link types. Custom link types must be a subtype of one of the built-in types. The custom link type inherits some functionality from the built-in type, including how the link type contributes to the implementation and verification statuses. For more information, see Define Custom Requirement and Link Types.

Review Requirement Links

You can review links in the Requirements Editor or the Requirements Browser. To view links in the Requirements Editor, click Show Links. To view links in the Requirements Browser, select Links from the View drop-down menu.

When working in the Simulink Editor, you can review requirement links for individual requirements. In the Requirements Browser, select Requirements from the View drop-down menu and select a requirement. The links are displayed in the Property Inspector, under Links.

By default, all the outgoing links from a source artifact are stored in a Link Set file (.slmx). See Requirements Link Storage for more information on requirements links storage.

When you delete a link, all related data is deleted including associated comments and custom attributes.

Resolve Links

For a link to be resolved, you must be able to navigate to the source item and to the destination item. If the source, destination, or both are not available, the link is unresolved. The source or destination items can be unavailable because:

  • The design artifact that contains the source or destination item is not loaded. For example, if you load a requirement set that has incoming links from a Simulink model, this also loads the link set that belongs to the model. However, if you do not load the Simulink model, the links are unresolved because the link sources are not available.

  • The design artifact loaded, but the specified ID does not exist. For example, if you delete a linked requirement, the link becomes unresolved because the stored ID no longer corresponds to a valid item.

If a link is unresolved because the specified ID does not exist, it is a broken link.

To see the unresolved links, in the Requirements Editor, click Show Links. Unresolved links are denoted by .

If a link is unresolved because the source or destination is not loaded, you can resolve the link by loading the file that contains the unloaded source or destination. If a link is broken, you can use the setSource and setDestination methods to repair the link.

Load Link Information

For artifacts such as requirement sets, Simulink models, data dictionaries, test files, and MATLAB files, all link information related to the artifacts that are on the MATLAB or Project path are automatically loaded when that artifact is loaded.

The link information loading can be summarized by the rules as follows:

  • Rule 1: Loading an artifact such as requirement sets, Simulink models, data dictionaries, test files, and MATLAB files, that are on the MATLAB or Project path loads all incoming and outgoing link sets for that artifact. Each artifact can have one outgoing link set and one or more link sets containing link information from other artifacts.

  • Rule 2: If the loaded artifact has outgoing links to a requirement set, then the requirement set is also loaded along with the link information. This loaded requirement set is also eligible to follow Rule 1 to further load link information.

The application of these rules can be illustrated using the slreqCCProjectStart project in three scenarios. Follow these steps:

  1. Close all the Simulink models and requirement sets before opening the project.

  2. Load the slreqCCProjectStart in the MATLAB:

    slreqCCProjectStart

  3. Scenario 1:

    1. Open the model crs_controller.slx:

      open_system('crs_controller.slx');

    2. Open Requirements Editor:

      slreq.editor

    3. The Requirements Editor shows following information:

      Link information from outgoing link set crs_controller.slmx is loaded according to Rule 1.

      Requirement set crs_req_func_spec.slreqx and link sets crs_req.slmx, crs_controllerdic.slmx, DriverSWRequest_Tests.slmx, and crs_plant.slmx are loaded according to Rule 2.

    4. Close the model and the Requirements Editor.

  4. Scenario 2:

    1. Open the requirement set crs_req_func_spec.slreqx:

      slreq.open('crs_req_func_spec.slreqx');

    2. The Requirements Editor opens and shows following information:

      Link sets View

      All link sets which contain incoming link information for loaded requirement set are loaded according to Rule 1.

    3. Close the Requirements Editor.

  5. Scenario 3:

    1. Open the model crs_plant.slx:

      open_system('crs_plant.slx');

    2. Open Requirements Editor:

      slreq.editor

    3. The Requirements Editor shows following information:

      Link information from outgoing link set crs_plant.slmx is loaded according to Rule 1.

      Requirement sets crs_req_func_spec.slreqx and crs_req.slreqx and all link sets which contain incoming link information for these requirements are loaded according to Rule 2.

    4. Close the model and the Requirements Editor.

Link information is not automatically loaded if you save your links with the model as an embedded link set. You can also load link information by using the slreq.refreshLinkDependencies command.

Unload Link Information

Link information is automatically unloaded when you unload all the related artifacts from memory.

Delete a Link Set

Link sets are stored in .slmx files. Deleting the .slmx file while the links are loaded in memory may lead to unexpected behavior.

Note

If you want to delete a link set file associated with a Simulink model, ensure that the links are stored externally. To read more about how to store links externally from a Simulink model, see Requirements Link Storage.

To delete a link set:

  1. Locate the .slmx file. By default, when you create a link, it is stored in a link set with the same name as the artifact that the source item belongs to. The .slmx file is stored in the same directory as the source artifact.

  2. It is best to close all loaded artifacts before deleting a link set. This includes requirement sets, Simulink Test files, MATLAB code, Simulink data dictionaries, and Simulink, Stateflow or System Composer models. Manually close all of these artifacts.

  3. At the MATLAB command line, clear loaded links by entering:

    slreq.clear

  4. Delete the .slmx file.

After deleting the link set file, you can re-open artifacts as needed.

See Also

| |

Related Topics