Create and Store Links
You can use links and link sets to trace requirements to the design and test items that implement and verify them. Each link and link set has a corresponding API object. You can use the Requirements Editor, Requirements Perspective, a traceability matrix, or the MATLAB® command line to create links between requirements, MATLAB code, Simulink® blocks, Simulink Test™ test cases, and other items. You can also view and edit the links.
Link Objects, Sources, and Destinations
Each link has a corresponding
object. You can provide additional traceability information by using link properties, custom
attributes, and stereotypes. For more information, see:
Links point from source items to destination items, which are contained in source artifacts and destination artifacts, respectively. For example, consider a link that points from a Simulink block to a requirement. The Simulink model is the source artifact and the block is the source item. The requirement set is the destination artifact and it contains the requirement, which is the destination item.
A linked item has an outgoing link if it is the source of a link. Conversely, an item has an incoming link if it is the destination of a link. For example, if a link points from a Simulink block to a requirement, the Simulink block has an outgoing link and the requirement has an incoming link.
Link sets contain links. Each link set you load has a corresponding
slreq.LinkSet object. When you create a link, Requirements Toolbox™ creates a link set and saves it as an SLMX file in the same folder as the source
artifact. The link set name is the source artifact base name and the source artifact
extension, separated by a tilde. For example, Requirements Toolbox stores outgoing links from a MATLAB function called
myFunction.m in a link set file called
Link sets that contain links from Simulink models combine the model base name and
~mdl to prevent link
resolution issues if the model file extension changes between
.slx. For example, Requirements Toolbox stores outgoing links from
vdp.slx in a link set file
When you create links from artifacts such as Simulink models or Simulink Test files, you can save the changes to the link set by saving the artifact.
To save the changes to a link set when you create or edit links to lines of MATLAB code or plain-text external code, use one of these approaches:
In the MATLAB Editor, right-click and select Requirements > Save Links.
In the Requirements Editor, click Show Links. Select the link set, and click Save.
At the MATLAB command line, use
You can create links between these requirements items, model entities, test artifacts, and code:
Requirements Toolbox objects:
Simulink data dictionary entries
Charts and subcharts
System Composer™ architecture entities:
Simulink Test objects:
Lines of MATLAB code in:
MATLAB code files (
.mextension). For more information, see Requirements Traceability for MATLAB Code.
MATLAB Function blocks. For more information, see Integrate Basic Algorithms Using MATLAB Function Block (Simulink).
MATLAB-based Simulink tests. For more information, see Test Models Using MATLAB-Based Simulink Tests (Simulink Test).
Lines of code in plain-text external code files, such as C and H files. You can also link to HTML files, but not XML or JSON.
To create links to lines of plain-text external code, you must open the code in the MATLAB Editor. For more information, see Link Requirements to MATLAB or Plain Text Code.
You can use the Requirements Editor, Requirements Perspective, a traceablity matrix, or the MATLAB command line to create links.
To create a link from a design or test item to a requirement by using the Requirements Editor:
Select one of these items:
Simulink or Stateflow model element
System Composer architecture element
Simulink Test test case
Code range in the MATLAB Editor
Simulink data dictionary entry
To link to MATLAB functions and enable change tracking for the entire body of the function, create the link to the line that contains the
In the Requirements Editor, select the requirement.
Click Add Link, then select the menu option that contains the selection that you want to link to.
To create a requirement-to-requirement link:
Select the requirement that you want to link as the source item.
Click Add Link > Select for Linking with Requirement.
Select the requirement that you want to link as the destination item.
Create the link by selecting Add Link > Create a link from.
You can create links without leaving the Simulink Editor by using the Requirements Perspective. For more information, see Link Blocks and Requirements.
You can create links between multiple artifacts in a single window by using a traceability matrix. For more information, see Track Requirement Links with a Traceability Matrix.
Create Links Programmatically
To create links at the MATLAB command line:
Get the object or handle for the link source. For example:
open_system("vdp") src = get_param("vdp/Mu","Handle");
Get the object or handle for the link destination. For example:
dest = slreq.find(Type="Requirement",Summary="My requirement");
slreq.createLinkfunction to create the link.
newLink = slreq.createLink(src,dest);
Assigned Link Types
Each link type has an intended use case. For example, the
link type indicates a relationship between a requirement and a design item that implements
the requirement. When you create a link between two items, Requirements Toolbox sets the link type and designates the items as the 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, Requirements Toolbox assumes that the model element implements the requirement, sets the link type
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 Requirements Toolbox sets the link type to
Relate. For example,
requirement-to-requirement links and links from plain-text external code default to
Edit the Link Type
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 right pane, under Properties, select the desired link type from the Type list.
Built-in Link Types
Requirements Toolbox 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.
|Type||Description||Source-to-Destination Example||Forward Direction||Backward Direction|
||Requirement to requirement|
The first requirement is related to the second requirement.
The second requirement is related to the first requirement.
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.
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.
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.
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.
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.
Verify link types
describe requirement-to-model and requirement-to-test relationships. 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 use one of the built-in types as the base behavior. 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 Choose a Built-in Type as a Base Behavior.
You can define custom link types by using stereotypes or by using
sl_customization files. For more information, see Define Custom Requirement and Link Types and Properties.
View and Edit Links
To view the loaded link sets and the links they contain, in the Requirements Editor, click View Links. You can then select a link and view or edit its properties or custom attributes. For more information, see Set Link Properties, Custom Attributes, or Stereotype Properties.
You can also view the links for a particular requirement in the Requirements Editor when you select a requirement. In the right pane, under Links, the outgoing links icon indicates outgoing links and the incoming links icon indicates incoming links.
To view links in the Simulink Editor by using the Requirements Perspective:
Open the Requirements Perspective in a Simulink model by clicking the Show Perspectives views icon in the lower-right corner of the model canvas and select Requirements.
In the Requirements tab, ensure that Layout > Requirements Browser is selected.
In the Requirements pane, in the View menu, select
To visualize links, create a traceability matrix or traceability diagram. For more information, see Track Requirement Links with a Traceability Matrix and Visualize Links with a Traceability Diagram.
Delete Links and Link Sets
To delete a link, in the Requirements Editor, click Show Links. Select a link and, in the Links section, click .
To delete a link set:
Locate the SLMX file that contains the link set. By default, link set files are in the same folder as the source artifact.
Close the linked artifacts before deleting a link set, including requirement sets, Simulink Test files, MATLAB code, Simulink data dictionaries, and Simulink, Stateflow or System Composer models.
At the MATLAB command line, clear the loaded requirements and links by entering:
Delete the SLMX file.
If you want to delete a link set file associated with a Simulink model, ensure that the links are stored externally. For more information about how to store links externally, see Requirements Link Storage.