Requirement Links
Track how your requirements relate to your model design by using Requirements Toolbox™ 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:
Requirements Toolbox objects:
slreq.Requirement
objectsslreq.Reference
objectsslreq.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:
MATLAB
.m
files.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).
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')
. Seermi
.
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, Requirements Toolbox 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, Requirements Toolbox 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 Requirements Toolbox 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.
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 |
---|---|---|---|---|
Relate |
| Requirement to requirement | The first requirement is related to the second requirement. | The second requirement is related to the first requirement. |
Implement |
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 |
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 |
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:
Close all the Simulink models and requirement sets before opening the project.
Load the
slreqCCProjectStart
in the MATLAB:slreqCCProjectStart
Scenario 1:
Open the model
crs_controller.slx
:open_system('crs_controller.slx');
Open Requirements Editor:
slreq.editor
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 setscrs_req.slmx
,crs_controllerdic.slmx
,DriverSWRequest_Tests.slmx
, andcrs_plant.slmx
are loaded according to Rule 2.Close the model and the Requirements Editor.
Scenario 2:
Open the requirement set
crs_req_func_spec.slreqx
:slreq.open('crs_req_func_spec.slreqx');
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.
Close the Requirements Editor.
Scenario 3:
Open the model
crs_plant.slx
:open_system('crs_plant.slx');
Open Requirements Editor:
slreq.editor
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
andcrs_req.slreqx
and all link sets which contain incoming link information for these requirements are loaded according to Rule 2.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:
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.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.
At the MATLAB command line, clear loaded links by entering:
slreq.clear
Delete the
.slmx
file.
After deleting the link set file, you can re-open artifacts as needed.
See Also
setSource
| setDestination
| slreq.refreshLinkDependencies