This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Work with Requirements in the Simulink Editor

Simulink® Requirements™ enables you to author, organize, and edit requirements in the Simulink Editor. A specialized view, the Requirements Perspective, helps you to visualize the links between requirements and the parts of a model. Using an integrated environment simplifies linking requirements to the parts of your model that implement them.

This integrated environment has other advantages. For details, see Introduction to Simulink Requirements.

Author Requirements in Simulink

In Simulink Requirements, you organize your requirements in groups called requirement sets. In each requirement set, you can create additional levels of hierarchy for when you need more requirements to describe the details of a requirement.

In this tutorial, you use the Requirements Editor to create a requirement set to organize related requirements and add requirements to the set.

Suppose that you are writing requirements for a controller model of an automobile cruise control system. You develop these requirements, using your company’s numbering standard for requirements (R1, R2, and so on).

ID and DescriptionRationale
R1: The maximum input throttle is 100%The maximum value of the throttle from the acceleration pedal can be no greater than 100%.
R2: Cruise control has a speed operation rangeCruise control has a minimum and maximum operating speed.
R2.1: The vehicle speed must be at least 40 km/hThe speed of the vehicle must be at least 40 km/h for the cruise control system to engage.
R2.2: The vehicle speed cannot be greater than 100 km/hThe maximum operational speed of the cruise control system for the vehicle is 100 km/h.

Add these requirements to a model called crs_controller.

  1. The model and supporting files are in a project. Open the project. At the MATLAB® command prompt, enter:

    slreqCCProjectStart
  2. Open the model. At the command prompt, enter:

    open_system('models/crs_controller')
  3. Open the Requirements Editor. In the Simulink Editor, select Analysis > Requirements > Requirements Editor.

    The Requirements Editor opens with the requirements in view in the requirements browser, arranged by requirement set. The crs_controller model has two requirements sets that you can see in the browser: crs_req_func_spec and crs_req.

  4. Add a requirement set in the requirements browser. From the Requirements Editor toolbar, click New Requirement Set .

  5. You save requirement sets to external files. Save your requirement set to a writable location and name it cruise_control_reqset.slreqx.

  6. When you save requirement sets to external files, you can share requirements with other models.

  7. Add a requirement to your requirement set. Select the requirement set and click Add Requirement .

  8. In the Properties pane, enter details for the requirement. You can copy and paste or drag requirements from another source to the Properties pane.

    • Custom ID: R1

    • Summary: Max input throttle %

    • Description: The maximum input throttle is 100%.

    If you do not specify a custom ID, the Requirements Editor numbers requirements in order. Custom IDs let you use your company standards for labeling requirements and set the numeric order. (Custom IDs cannot contain a # character.) You can also use an ID to help locate a requirement by searching. Keywords also aid in searching for a requirement.

  9. Create the requirement R2. Right-click R1 and select Add Requirement After. Enter details for the requirement:

    • Custom ID: R2

    • Summary: Cruise control speed operation range

    • Description: Cruise control has a minimum and maximum operating speed.

  10. Create the child requirement of R2. Right-click R2 and select Add Child Requirement. Enter details for the requirement:

    • Custom ID: R2.1

    • Summary: Minimum vehicle speed

    • Description: The speed of the vehicle must be at least 40 km/h for the cruise control system to engage.

    Add the other child to requirement R2 if you want.

Tip

You can rearrange the hierarchy by using the or by dragging requirements.

Author and Edit Requirements Content by Using Microsoft Word

To author and edit the Description and Rationale fields of your requirements, open Microsoft® Word from within the Requirements Editor or the Requirements Perspective View.

Note

This functionality is available only on Microsoft Windows® platforms.

Using Microsoft Word to edit rich text requirements enables you to:

  • Spell-check requirements content.

  • Resize images.

  • Insert and edit equations.

  • Insert and edit tables.

To open Microsoft Word, click in the toolbar of the Edit field of the Description or Rationale. Save the changes to your requirements content within Microsoft Word to see them reflected in Simulink Requirements.

You cannot edit requirements in the built-in editor when you use Microsoft Word to edit requirements content.

View or Hide Columns in the Requirements Editor

You can change the view configuration of the Requirements Editor. Right-click the header row and click Select Columns. Add, remove, and reorder columns through the Column Selector dialog box. The view configuration is saved across sessions. You can export view settings to a MAT-File by using the slreq.exportViewSettings function and import them by using the slreq.importViewSettings function.

You can reset saved view configurations by using the slreq.resetViewSettings function.

Link Blocks and Requirements

You can create links between your requirements and the Simulink blocks or Stateflow® objects that implement them. By linking between the model elements that implement requirements, you can track whether all your requirements have been implemented. You can also keep requirements and implementation in sync, for example, if a requirement changed or if the implementation causes you to revise your requirements.

In this tutorial, you use the Requirements Perspective View to work with your requirements in the cruise control model. As in the Requirements Editor, you can add requirement sets and requirements in the Requirements Perspective View. In both views, you can link requirements with blocks. In the Requirements Perspective View, visual elements help you to see the links between requirements and blocks. The Requirements Perspective View displays requirement and link information only for the model that is currently open in the Simulink editor.

  1. In the crs_controller model, to preview the perspectives associated with the model, click the perspectives control in the lower-right corner.

  2. To open the Requirements Perspective View, click the Requirements image.

    The Requirements Perspective View includes the Requirements Browser, docked at the bottom of the Simulink editor. When you select a requirement, the Property Inspector displays the Simulink Requirements Properties pane.

  3. Link a requirement to the model element that implements it. Search for the requirement that you want to link from. In the Requirements Browser search box, enter Enable Switch Detection. As you type, matches are highlighted.

  4. To create a link, select the matching requirement and drag it onto the enbl inport block. A markup guide appears on the canvas as a preview of the requirement annotation. Click the markup guide to place the requirement annotation on the canvas. You can also click anywhere else to create the link but not have the annotation display on the canvas.

  5. A badge appears on the block to show that a link was created. You see badges only in the Requirements Perspective View. To see more information about the requirement, click the badge and select Show.

    Clicking Show displays a requirement annotation on the model canvas.

    The annotation displays the ID, the summary, and the relationship between the block and the requirement. In this example, the block implements the requirement. For other possible relationships, see Requirement Links.

    • To see the requirement description, double-click the annotation.

    • To edit the requirement, right-click the annotation and select Select in Requirements Browser. The requirement properties appear in the Property Inspector, where you can edit them.

  6. Exit the Requirements Perspective View. Click the perspectives control and click the requirements image.

Work with Simulink Annotations

Convert Simulink Annotations to Requirements.  You can convert the annotations in your Simulink models to requirements by using the context menu in the Requirements Perspective View and by using the API. See slreq.convertAnnotation for more information on converting annotations to requirements by using the API.

To convert annotations to requirements by using the context menu in the Requirements Perspective View:

  1. Open the Simulink model and enter the Requirements Perspective View.

  2. Select a requirement set from the Requirements Browser. This is the destination requirement set for the new requirement.

  3. Right click the annotation you want to convert to a requirement and click Convert to Requirement.

  4. The annotation is converted to a requirement and is linked to the system or subsystem at which the annotation was present.

Link Requirements to Simulink Annotations.  Use the Requirements Perspective View to link requirements to text and area annotations on the Simulink Editor. To create a link, select a requirement and drag it onto the annotation. If you link requirements to an area annotation, a badge appears on the annotation to show that the link was created. You see badges only in the Requirements Perspective View. To see more information about the requirement, click the badge and select Show.

Related Topics