Skip to content
Tutorials Center
My learning

Topics

Lesson 32 of 36 ยท Testing and Verification

Requirements Traceability and Formal Verification in Simulink

Link requirements to models and tests with Requirements Toolbox, write formal requirements tables, and use Simulink Design Verifier for property proving, test generation and error detection.

Good engineering starts with requirements: statements of what the system must do. Testing shows that some cases satisfy them; traceability shows which design element and which test belongs to each requirement; formal verification uses mathematics to prove that a property holds for all inputs, or to produce a counterexample. This lesson covers Requirements Toolbox and Simulink Design Verifier. Neither product runs on this site, so the stand-ins here are small Python tools that demonstrate the same ideas (traceability reports and a tiny exhaustive property checker).

Writing a good requirement

A requirement should be atomic (one thing), unambiguous, testable and numbered. Compare:

  • Poor: "The controller shall respond quickly and safely."
  • Better: "REQ-12: When the brake pedal signal is above 5 percent, the controller shall set the throttle command to 0 within 100 ms."

Typical categories: functional, performance, safety, interface, and data (ranges, units). Keep a source for each (stakeholder, standard, hazard analysis).

Requirements Toolbox

Requirements Toolbox (the product that replaced Simulink Requirements) lets you author, import and link requirements without leaving Simulink.

  • Requirements Editor (Apps > Requirements Manager or slreq.editor): a spreadsheet-like view of requirement sets (.slreqx files). Each requirement has an ID, Summary, Description, Type (Functional, Container, Informational), Rationale and custom attributes.
  • Import requirements from Word, Excel, ReqIF, or IBM DOORS (Import button); you can keep them linked to the original document so that changes show up as differences.
  • Links: select a block or Stateflow state and a requirement, then right-click > Requirements > Link to selected requirement. Link types: Implement (a design element implements the requirement), Verify (a test case verifies it), Derive, Relate, Refine, Confirm.
  • In the model, small badges show that a block has requirement links, and the Requirements perspective (Apps > Requirements) shows requirements next to the model.
  • Test cases in Simulink Test can be linked to requirements, so the Test Manager reports pass or fail per requirement.
  • Reports and the Model Metrics Dashboard show requirement coverage: which requirements lack an implementation link or a verification link, and which links are broken or outdated.
flowchart LR
    Q["Requirement REQ-12"] -->|"implemented by"| B["Block or chart<br/>Brake logic"]
    Q -->|"verified by"| T["Test case TC-12"]
    T --> R["Result: pass / fail"]
    B --> C["Generated code<br/>traceability"]

Bidirectional links give an audit trail from requirement to design, test and code.

A stand-in: traceability matrix

The stand-in builds a trace table from lists of links and reports requirements that are not implemented or not verified, the most common review finding.

Python Stand-in: finding requirements without implementation or tests

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Requirements Table block

A Requirements Table block turns natural-language requirements into formal ones that Simulink can simulate and verify. You describe, in a table, conditions and expected outputs:

Row Precondition Postcondition Duration
1 brake > 5 throttle == 0 within 0.1 s
2 speed > limit warning == true

The block checks the postcondition whenever the precondition becomes true. You can run it as a monitor next to your model in simulations and tests, as an assertion that stops on violation, and Simulink Design Verifier can prove it. It also supports assumptions for inputs (for example, 0 <= brake <= 100).

Simulink Design Verifier (SLDV) uses a formal analysis engine (SAT/SMT solvers and abstract interpretation) on the model. Three tasks:

  1. Design error detection: finds dead logic (blocks that can never execute), integer overflow, division by zero, array index out of bounds, out-of-range signal (against specified min/max) and Stateflow problems (unreachable states, transitions that can never fire). Run Analysis > Design Verifier > Detect Design Errors.
  2. Test case generation: automatically creates test cases that satisfy model coverage objectives (decision, condition, MC/DC), so you can reach coverage that manual tests missed. Run Generate Tests (Design Verifier > Generate Tests) and save the result as a Simulink Test case or a Signal Builder group. It also tells you when an objective is unsatisfiable (dead logic).
  3. Property proving: proves that a property holds for all inputs and states (within assumptions) or gives a counterexample. You express a property with Proof Objective blocks, Assertion blocks (check assertion is enabled) or Requirements Table rows, and constraints with Proof Assumption/Test Condition blocks. Run Prove Properties.

Results for each objective: Valid (proven), Falsified (a counterexample test case is generated that you can simulate), Undecided (timeout or too complex), or Falsified/Valid within bound (for bounded analysis). Counterexamples are a gift: you can replay them in the Simulation Data Inspector to see exactly what went wrong.

Limitations: not all blocks are supported (the documentation lists support; unsupported blocks are stubbed conservatively), floating-point math is handled with approximations, and large models may time out, so you apply SLDV to components and use the Model Metrics Dashboard to select them.

A stand-in: exhaustive property check with a counterexample

A model with small input ranges can be verified exhaustively. The stand-in explores all input sequences up to a bound for a tiny throttle limiter and either proves a property or prints a counterexample, the idea behind bounded model checking.

Python Stand-in: bounded exhaustive check of a safety property

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The check finds a sequence in which the throttle stays positive while braking, because the state machine ignores the brake when it is not in armed mode. In SLDV you would see the same finding as a Falsified property with a counterexample that you can run in Simulink. Fix the logic (set the throttle to zero in every mode) and rerun: the property is then valid within the bound, and SLDV would give a proof for all depths.

Where verification fits in the process

flowchart TD
    A["Requirements (Requirements Toolbox)"] --> B["Design: model and charts"]
    B --> C["Static checks: Model Advisor"]
    B --> D["Formal analysis: Design Verifier"]
    B --> E["Tests: Simulink Test"]
    E --> F["Coverage: Simulink Coverage"]
    D -->|"generated tests"| F
    F --> G["SIL/PIL equivalence on the code"]

Several techniques cover different risks: tests sample behavior, formal methods cover all behavior of the properties you state.

Common mistakes

  • Vague requirements that cannot be verified; rewrite them with numbers and conditions.
  • Too-weak assumptions (unconstrained inputs) causing counterexamples that cannot occur, or too-strong assumptions hiding real problems; document each assumption.
  • Treating "Undecided" as "Valid". Reduce the model, add constraints or test instead.
  • Links without review: broken or outdated links give false confidence.
  • Proving properties of the plant model instead of the controller.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does a verify link between a requirement and a test case express?

    Implement links connect design elements; Verify links connect tests.
  2. 2. Which Simulink Design Verifier task creates tests to reach coverage objectives automatically?

    SLDV generates test cases for coverage objectives and reports unsatisfiable ones, which indicate dead logic.
  3. 3. What does a Falsified property result give you?

    Counterexamples can be replayed in simulation to understand the failure.
  4. 4. Why are well-defined assumptions important in formal verification?

    Without assumptions you get counterexamples that cannot occur; with wrong ones you prove nothing useful.

Summary

  • Write atomic, testable requirements and link them to design elements (Implement) and tests (Verify) with Requirements Toolbox.
  • Requirements Tables make requirements formal so that Simulink can monitor and prove them.
  • Simulink Design Verifier detects design errors, generates tests for coverage and proves properties or returns counterexamples.
  • Combine static checks, tests, coverage and formal analysis: each covers a different risk.
  • The Python tools above are stand-ins for the concepts; the Simulink products are not available on this site.

Next: Project: cruise control