Documentation Center

  • Trials
  • Product Updates

Requirements Links for Library Blocks and Reference Blocks

Introduction to Library Blocks and Reference Blocks

Simulink® allows you to create your own block libraries. If you create a block library, you can reuse the functionality of a block, subsystem, or Stateflow® atomic subchart in multiple models.

When you copy a library block to a Simulink model, the new block is called a reference block. You can create several instances of this library block in one or more models.

The reference block is linked to the library block using a library link. If you change a library block, any reference block that is linked to the library block is updated with those changes when you open or update the model that contains the reference block.

    Note:   For more information about reference blocks and library links, see Libraries in the Simulink documentation.

Library Blocks and Requirements

Library blocks themselves can have links to requirements. In addition, if a library block is a subsystem or atomic subchart, the objects inside the library blocks can have library links. You use the Requirements Management Interface (RMI) to create and manage requirements links in libraries and in models.

The following sections describe how to manage requirements links on and inside library blocks and reference blocks.

Copy Library Blocks with Requirements

When you copy a library subsystem or masked block to a model, you can highlight, view and navigate requirements links on the library block and on objects inside the library block. However, those links are not associated with that model. The links are stored with the library, not with the model.

You cannot add, modify, or delete requirements links on the library block from the context of the reference block. If you disable the link from the reference block to the library block, you can modify requirements on objects that are inside library blocks just as you can for other block attributes when a library link has been disabled.

Manage Requirements on Reference Blocks

You use the RMI to manage requirements links on a reference block just like any other model object. You can view and navigate both local and library requirements on a reference block.

For example, in the following graphic, right-clicking the reference block shows that the reference block has locally created requirements links and requirements links on the library block:

  • Locally created requirements links — Can be modified or deleted without changing the library block:

    • Manifold absolute pressure sensor

    • Mass airflow estimation

  • Requirements links on the library block — Cannot be modified or deleted from the context of the reference block:

    • Speed sensor

    • Throttle sensor

    • Oxygen sensor

Manage Requirements Inside Reference Blocks

If your library block is a subsystem or a Stateflow atomic subchart, you can create requirements links on objects inside the subsystem or subchart. If you disable the link from the reference block to the library, you can add, modify, or delete requirements links on objects inside a reference block. Once you have disabled the link, the RMI treats those links as locally created links.

After you make changes to requirements links on objects inside a reference block, you can resolve the link so that those changes are pushed to the library block. The next time you create an instance of that library block, the changes you made are copied to the new instance of the library block.

The workflow for creating a requirement link on an object inside a reference block is:

  1. Within a library you have a subsystem S1. Drag S1 to a model, creating a new subsystem. This subsystem is the reference block.

  2. Disable the library link between the reference block and the library block. Keep the library loaded while you disable the link to maintain RMI data. To disable the link, select the reference block and select Diagram > Library Link > Disable Link.

  3. Create a link from the object inside the reference block to the requirements document.

      Note:   When linking to a requirement from inside a reference block, you can create links only in one direction: from the model to the requirements document. The RMI does not support inserting navigation objects into requirements documents for objects inside reference blocks.

  4. Resolve the library link between the reference block and the library block:

    1. Select the reference block.

    2. Select Diagram > Library Link > Restore Link.

    3. In the Action column, click Push.

    4. Click OK to resolve the link to the library block and push the newly added requirement to the object inside the library block.

      When you resolve the library link between the library block and the subsystem, Simulink pushes the new requirement link to the library block S1. The following graphic shows the new link from inside the library block S1 to the requirement.

      Note:   If you see a message that the library is locked, you must unlock the library before you can push the changes to the library block.

  5. If you reuse library block S1, which now has an object with a requirement link, in another model, the new subsystem contains an object that links to that requirement.

Links from Requirements to Library Blocks

If you have a requirement that links to a library block and you drag that library block to a model, the requirement does not link to the reference block; the requirement links only to the library block.

For example, consider the situation where you have established linking between a library block (B1 in the following graphic) and a requirement in both directions.

When you use library block B1 in a model, you can navigate from the reference block to the requirement. However, the link from the requirement still points only to library block B1, not to the reference block.

As discussed in the previous section, you can create requirements links on objects inside instances of library block after disabling library links. However, the RMI prohibits you from creating a link from the requirements document to such an object because that link would become invalid when you restored the library link.

Was this topic helpful?