Decompose and Reuse Components

Every component in an architecture model can have its own design, or even several design alternatives. These designs can be architectures modeled in System Composer™ or behaviors modeled in Simulink®. Engineering systems often use the same component design in multiple places. A common component, such as power switch, can be part of all electrical components; You can reuse a component in System Composer within the same model as well as across architecture models.

Decompose a Component

A component can have its own architecture. Double-click a component to view or edit its architecture. The ports of a component appear as architecture ports when you view it at this level. You can use the navigation arrows on the toolbar to move through the hierarchy. Use the Model Browser to view component hierarchy.

You can add components, ports, and connections at this level to define the architecture.

You can also make a new component from a group of components.

  1. Select the components. Either click and drag a rectangle, or select multiple components by holding the Shift button down.

  2. Create a component from the selected elements using Architecture > Create Component

As a result, the new component has the selected components, their ports, and connections as part of its architecture. Any unconnected ports and connections to components outside of the selection become ports on the new component.

Any component that has its own architecture displays a preview of its contents.

Create a Reference Architecture

Some projects use the same, detailed component in multiple places, and require the design of such a component to be tightly managed. You can create a reference architecture to reuse the architectural definition of a component in the same architecture model or across several architecture models. Create such a reference architecture using this procedure:

  1. Right-click the component and select Save as Architecture Model.

  2. Provide a name for the model. By default, the reference architecture is saved in the same folder as the architecture model. Browse for or type the full path if you want to save it in a different folder.

System Composer creates an architecture model with the provided name, and links the component to the new model. The linked model is indicated in the name of the component between <> signs.

All architecture models can reference this new architecture model through linked components.

Use a Reference Architecture

You can use a reference architecture, saved in a separate file, by linking to it from a component. Right-click the component and select Link to Model. You can also use the Create Reference option in the element palette directly to create a component that uses a reference architecture.

To link a selected component to an existing architecture model, use Architecture > Component > Link to Model or right-click and select Link to Model.

Provide the full path to the reference architecture. If the linked component has its own ports and components, this content gets deleted during linking and are replaced by that of the reference architecture. The ports of the linked component become the architecture ports in the reference architecture.

Any change made in a reference architecture is immediately reflected in the models that link to it. If you move or rename the reference architecture the link becomes invalid and the linked component shows an error. Link the component to a valid reference architecture to fix this.

Inline a Reference Architecture

Sometimes it is necessary to deviate from a reference architecture for a single component. For example, a comprehensive sensor model, referenced from a local component, may include too many features for the motion control architecture at hand and require simplification for that architecture only. In this case, you can inline the reference architecture to make local changes possible. Right-click a linked component and select Inline Model.

This operation provides two options:

  • Inline only interfaces: The ports and designated interfaces of the reference architecture are reflected on the component, but the composition is blank.

  • Inline both interfaces and contents: Ports, interfaces, and subcomponents of the reference architecture are copied to the component.

Once the reference architecture is inlined, you can start making changes without affecting other architectures. However, you cannot propagate local changes to the reference architecture. If you link to the reference architecture again, local changes are lost.

Create Variants

A component can have multiple design alternatives, or variants. You can model variations for any component in a single architecture model. You can define a mix of behaviors (defined in a Simulink model) and architectures (defined in a System Composer architecture model) as variant choices. For example, a component may have two variant options that represent two alternate structural decompositions.

Add variation to a component from the context menu or the Architecture > Component menu with the Add Variant Choice option.

The badge on the component indicates that it is a variant and a variant choice is added to the existing composition. Double-click the component to see variant choices.

You can add more variant choices to a variant component using the Add Variant Choice option.

Open and edit the variant by selecting Variant > Open > <variant_name> from the component context menu.

You can also designate a component as a variant upon creation using the object in the element palette. This creates two variant choices by default.

Activate a specific variant choice using the context menu of the block. Select The active choice is displayed in the header of the block.

Related Topics