Main Content

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 Custom Libraries (Simulink).

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 can use Requirements Toolbox™ 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 can use Requirements Toolbox 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:

  • Locally created requirements links can be modified or deleted without changing the library block

  • Requirements links on the library block cannot be modified or deleted from the context of the reference block.

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, Requirements Toolbox 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.

    The new subsystem reference block has a library link to the library block that it references.

  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 in the Subsystem tab, click Disable Link.

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

    The reference block's library link is disabled and the reference block has a new link to a requirement in a 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. Requirements Toolbox 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. In the Subsystem tab, click 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.

    The library link between the reference block and the library block is restored. The library block now has a link to the same requirement that the reference block has.

    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.

    A second reference block was created from the library block. It has a library link to the library block that it references, and a link to the same requirements that the library block links to.

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.

Library block B1 has a bidirectional link to a requirement in a requirements document.

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.

The reference block created from the library block B1 has a link to the requirement in the requirements document and a library link to the library block. However, the requirement does not have a link 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, Requirements Toolbox 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.

Repair Unresolved Links

When library links are broken and the library is not on the path, the requirement links become unresolved. To fix unresolved requirement links, in the Requirements Editor, select Show Links. Select the link set and, in the Links section, select Resolve link issues > Repair invalid links. Use the Repair Invalid Links dialog to delete the links or update the link source or destination IDs. For more information, see Load and Resolve Links.

Alternatively, you can use the rmitag function to add a keyword to the links that are associated with the library. See Add Keywords for Direct Links to External Documents. Then, use rmitag to delete the links with the keyword. See Delete Links from a Model by Using Keywords.

Related Topics