Compose Architectures Visually
You can create and edit visual diagrams to represent architectures in System Composer™. Use architectural elements including components, ports, and connections in the system composition. Model hierarchy in architecture by decomposing components. Navigate through the hierarchy.
With MATLAB® code and the functions
exportModel, you can import external architecture descriptions into System Composer. For more information, see Import and Export Architecture Models.
Alternatively, you can use MATLAB programming to create and customize the various architectural elements. For details, see Build Architecture Models Programmatically.
Create Architecture Model
A System Composer architecture represents a system of components and how they interface with each other structurally and behaviorally.
Different types of architectures describe different aspects of systems. You can use views to visualize a subset of components in an architecture. You can define parameters on the architecture level using the Parameter Editor.
A System Composer model is the file that contains architectural information, including components, ports, connectors, interfaces, and behaviors.
An architecture model includes a top-level architecture that holds the composition of the system. This top-level architecture also allows definition of interfaces of this system with other systems.
Start with a blank architecture model to model the physical and logical architecture of a system. Use one of these three methods to create an architecture model:
At the MATLAB Command Window, enter:
Select Architecture Model.
Use a System Composer Architecture Model to describe systems as a combination of structural elements with underlying behavioral descriptions. Use a Software Architecture Model to easily define the execution order of your functions from your components, simulate your design in the architecture level, and generate code by linking your Simulink® export-function, rate-based, or JMAAB models to components.
For more information about software architecture models, see Author Software Architectures.
From a Simulink model or a System Composer architecture model. On the Simulation tab, select New , and then select Architecture .
At the MATLAB Command Window, enter:
archModel = systemcomposer.createModel("ModelName"); systemcomposer.openModel(archModel);
ModelNameis the name of the new model.
Save the architecture model. On the Simulation tab, select
. The architecture model is saved as an
The architecture model includes a top-level architecture that holds the composition of the system. This top-level architecture also allows definition of interfaces of this system with other systems. The composition represents a structured parts list — a hierarchy of components with their interfaces and interconnections. Edit the composition in the Composition Editor.
This example shows a motion control architecture, where a sensor obtains information from a motor, feeds that information to a controller, which in turn processes this information to send a control signal to the motor so that it moves in a certain way. You can start with this rough description and add component properties, interface definitions, and requirements as the design progresses.
A component is a nontrivial, nearly independent, and replaceable part of a system that fulfills a clear function in the context of an architecture. A component defines an architectural element, such as a function, a system, hardware, software, or other conceptual entity. A component can also be a subsystem or subfunction.
The Component element in System Composer can represent a component at any level of the system hierarchy, whether it is a major system component that encompasses many subsystems, such as a controller with its hardware and software, or a component at the lowest level of hierarchy, such as a software module for messaging.
Represented as a block, a component is a part of an architecture model that can be separated into reusable artifacts. Transfer information between components with:
Port interfaces using the Interface Editor
Parameters using the Parameter Editor
Use one of these methods to add components to the architecture:
Draw a component — In the canvas, left-click and drag the mouse to create a rectangle. Release the mouse button to see the component outline. Select the Component block option to commit.
Create a single component from the palette —
Create multiple components from the palette —
Each component must have a name that is unique within the same architecture level. The name of the component is highlighted upon creation so you can directly type the name. To change the name of a component, click the component and then click its name.
Move a component simply by clicking and dragging it. Blue guidelines may appear to help align the component with other components.
Resize a component by dragging corners.
Pause the pointer over a corner to see the double arrow.
Click the corner and drag while holding the mouse button down. If you want to resize the component proportionally, hold the Shift button as well.
Release the mouse button when the component reaches the size you want.
Click a component and press Delete to delete it. To delete multiple components, select them while holding the Shift key down, then press Delete.
A port is a node on a component or architecture that represents a point of interaction with its environment. A port permits the flow of information to and from other components or systems.
There are different types of ports:
Component ports are interaction points on the component to other components.
Architecture ports are ports on the boundary of the system, whether the boundary is within a component or the overall architecture model.
For example, a sensor might have data ports to communicate with a motor and a controller. Its input port takes data from the motor, and the output port delivers data to the controller. You can specify data properties by defining an interface as described in Define Port Interfaces Between Components.
Add Component Port
Represent the relationship between components by defining directional interface ports. You can organize the diagram by positioning ports on any edge of the component, in any position.
Pause over the side of a component. A + sign and a port outline appear.
Click the port outline. A set of options appear for an
Outputto commit the port. You can also name the port at this point.
An output port is shown with the icon, an input port is shown with the icon, and a physical port is shown with the icon and is nondirectional.
You can move any port to any component edge after creation.
Add Architecture Port
You can also create a port for the architecture that contains components. These system ports carry the interface of the system with other systems. Pause on any edge of the system box and click when the + sign appears. Click the left side to create input ports and click the right side to create output ports.
Every port is created with a name. To change the name, click it and edit.
Ports of a component must have unique names.
You can move a port to any side of a component. Select the port and use arrow keys.
|Arrow Key||Original Port Edge||Port Movement|
|Up||Left or right||If below other ports on the same edge, move up, if not, move to the top edge|
|Top or bottom||No action|
|Right||Top or bottom||If to the left of other ports on the same edge, move right, if not, move to the right edge|
|Left or right||No action|
|Down||Left or right||If above other ports on the same edge, move down, if not, move to the bottom edge|
|Top or bottom||No action|
|Left||Top or bottom||If to the right of other ports on the same edge, move left, if not, move to the left edge|
|Left or right||No action|
The spacing of the ports on one side is automatic. There can be a combination of input and output ports on the same edge.
Delete a port by selecting it and pressing the Delete button.
Change Port Type
To change a port type, right-click a port and select Change port action, then select either Input, Output, or Physical. You can also change port types in the Property Inspector. In the Interface section, from the Action list, select the appropriate port action.
systemcomposer.arch.PortDirection enumeration to change port
action. In this example,
compPort represents a
systemcomposer.arch.ComponentPort object, and
systemcomposer.arch.ArchitecturePort object. Each object uses a
Direction property to identify port action.
compPort.Direction = systemcomposer.arch.PortDirection.Input compPort.Direction = systemcomposer.arch.PortDirection.Physical archPort.Direction = systemcomposer.arch.PortDirection.Output archPort.Direction = systemcomposer.arch.PortDirection.Physical
Input port or an
Output port, you can
change a port type to its conjugate after right-clicking a port and selecting
Conjugate port from the context menu. An
Input port is converted into an
Output port, and
Output port is converted into an
Connectors are lines that provide connections between ports. Connectors describe how information flows between components or architectures.
A connector allows two components to interact without defining the nature of the interaction. Set an interface on a port to define how the components interact.
Connections are visual representations of data flow from an output port to an input port. For example, a connection from a motor to a sensor carries positional information.
Connect Existing Ports
Connect two ports by dragging a line:
Click one of the ports.
Keep the mouse button down while dragging a line to the other port.
Release the mouse button at the destination port. A black line indicates the connection is complete. A red-dotted line appears if the connection is incomplete.
You can take these steps in both directions — input port to output port, or output port to input port. You cannot connect ports that have the same direction.
A connection between an architecture port and a component port is shown with tags instead of lines.
Connect Components Without Ports
To quickly create ports and connections at the same time, drag a line from one component edge to another. The direction of this connection depends on which edges of the components are used - left and top edges are considered inputs, right and bottom edges are considered outputs. You can also perform this operation from an existing port to a component edge.
You can create a connection between an edge that is assumed to be an input only with an edge that is assumed to be an output. For example, you cannot connect a top edge, which is assumed to be an input, with another top edge, unless one of them already has an output port.
Connect an output port to multiple input ports by branching a connection. To branch, right-click an existing connection and drag to an input port while holding the mouse button down. Release the button to commit the new connection.
Create New Components Through Connections
If you start a connection from an output port and release the mouse button without a destination port, a new component tentatively appears. Accept the new component by clicking it.
Change Line Crossing Style for Overlapping Connections
In complex architectural diagrams, connectors can overlap. You can improve the
readability of your diagram by choosing another line crossing style. Navigate to Modeling > Environment > Simulink Preferences. In Simulink Preferences, select
Editor, then select a Line crossing
style. The default line crossing style,
Line Hop, is shown below.
For more information on line crossing style parameters, see Line crossing style.