Main Content

Detect Read-Before-Write Issues

Since R2022a

If you have Simulink® Design Verifier™, you can analyze the table to identify read-before-write issues in the requirements in a Requirements Table block. Read-before-write issues occur when a requirement attempts to read data that has not yet been defined. For more information on table analysis and the types of issues it detects, see Analyze Requirements Table Blocks for Modeling Problems.

Analyze the Block for Read-Before-Write Issues

To analyze the block, in the Table tab of the toolstrip, click Analyze Table. If there are issues in the block, the Analysis Results pane displays additional information. For example, in this table, the first requirement reads the output data y2 before y2 has an assigned value.

Requirements Table with two requirements. The action for the first requirement reads y2 before it is written.

When you analyze the example table, the Analysis Results pane displays additional information on the read-before-write issue.

Analysis results pane showing information about read-before-write issue detected in the first requirement

Resolve Read-Before-Write Issues

You can resolve read-before-write issues by modifying the table to not call output data in preconditions and postconditions. In the example table, you can modify the first action for requirement 1 so that it does not read the value of y2. Alternatively, you can create requirement preconditions that rely on output data if you list the requirements in order and enable the Enable outputs in preconditions property in the block. See Enable outputs in preconditions. For example, the model used in Example Using Requirement Order does not produce requirement issues because the requirement order specifies the local data before the other requirements need it. If you change the order of the requirements so that Requirements 3 and 4 are listed first, then analyze the requirements, the analysis finds two read-before-write issues. For more information on specifying requirement order to prevent or resolve issues, see Leverage Evaluation Order of Formal Requirements

Note

If you write more than two requirements that read the same data before the data is written, the analysis detects the issue in only the first listed requirement with the issue. After resolving the issue, rerun the analysis to detect the next read-before-write issue.

Related Topics