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.

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 are connected to the requirement SID (Session Independent Identifier) and not to its Custom ID.

Linkable Items

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

  • Simulink Requirements objects:

    • slreq.Requirement objects

    • slreq.Reference objects

    • slreq.Justification objects

  • Simulink entities

    • Blocks

    • Subsystems

    • Data dictionaries

  • Stateflow objects:

    • States

    • Charts and subcharts

    • Transitions

  • Simulink Test objects:

    • Test files

    • Test suites

    • Test cases

    • Iterations

    • Assessments

  • MATLAB code lines

  • System Composer™ architecture models

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

  1. Create a link destination structure.

    myLinkDest = struct('domain', 'linktype_rmi_url', 'artifact', ...
     'www.mathworks.com', 'id', '')
    
    myLinkDest = 
    
      struct with fields:
    
          domain: 'linktype_rmi_url'
        artifact: 'www.mathworks.com'
              id: ''
    
    % Create a link between requirement myReq and mylinkDest
    slreq.createLink(myReq, myLinkDest);
  2. Create a requirement links data structure using rmi('createempty'). See rmi.

Link Types

To track how the elements of your design are associated with your requirements, you can specify link types for your requirement links. Link types also describe the nature of requirement-to-requirement links, such as where a requirement is derived from a higher-level requirement.

Simulink Requirements provides these link types.

TypeDescription
Related toGeneral relationship between a requirement and a model element. This link is bidirectional.
Implemented bySpecifies which model elements implement this requirement. These link types contribute to the Implementation Status metric.
Implements
Verified bySpecifies which verification model elements or test cases verify that this requirement is satisfied. These link types contribute to the Verification Status metric.
Verifies
Derived fromSpecifies which destination artifacts are derived from this source artifact.
Derives
RefinesSpecifies which destination artifacts add additional detail for the functionality specified by the source artifact.
Refined by
ConfirmsSpecifies relationship between a requirement set and an external result source. These link types contribute to the Verification Status metric.
Confirmed by

To set the link type, open the Requirements Editor click Show Links. Select a link and, in the Details pane, under Properties, select the desired link type from the Type menu.

You can also create custom link types. For more information, see Define Custom Requirement and Link Types.

Requirement links have a source artifact and a destination artifact. Most of the link types are defined relative to the link direction. The Related to link type denotes a general relationship between two entities.

The Implements/Implemented by and Verifies/Verified by link types describe requirement-model relationships. Specify the source and the destination artifacts correctly for requirements with these link types because the Implementation Status and Verification Status summary metrics are derived from these link types. For more information on the Implementation Status and Verification Status summary metrics, see Review Requirements Implementation Status and Review Requirements Verification Status.

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, Simulink Requirements does not preserve the CommentedBy, CommentedOn, or SID for the link.

Resolve Links

A resolved link has an available source and destination. If a link source or destination is not available, the link is unresolved. For example:

  • A link becomes unresolved if you delete a linked block from a model.

  • A link is unresolved if a source or destination file, such as a Simulink Test test file, is not loaded in memory.

In the Links View, unresolved links are denoted by . Use the setSource and setDestination methods to resolve links.

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 necessary 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