Diagrams

Diagrams are where most of a model’s logic resides. They are comprised of units and wire networks. Wires represent variables and show how these variables are passed between various units. Units represent logic that is performed on the variables.

This image shows some of the elements that can appear in a diagram:

ALT

Adding Units

To get a diagram to represent logic, or to simulate logic, units need to be added to the diagram.There are two broad categories of units, primitives and components. See Editing a Diagram to get more information on how to add units to a diagram.

Primitives are units whose presentation and functionality are hard coded into the system. They function as the basic building blocks of diagrams, and allow more complex pieces of logic to be made. Think of them as standard library functions in a given language. Examples of primitives include Boolean Logic Gates, the General Math Function, Summation components, and CertSAFE’s bit wise operations functions. By default, all primitives are located in the palette view and can be used by dragging them from the palette to the diagram. See the documentation about primitive units for more information on what each individual primitive does.

Components are units whose logic is defined by the user. They function as a way to reuse previously defined functionality or develop subsystems that connect to each other. Any Stitch, Table, or Diagram can be used as a component, and their presentation can be defined with the use of a component file. To use a custom component in a diagram, simply drag and drop the component from the projects tree into your diagram. For more information on Components, please see Custom components .

Almost all primitives have properties that can be modified. These properties change what the unit looks like and how the unit acts. To view the available properties for a unit, select the unit. The properties will then be displayed in the properties view (by default, located in the bottom right corner of the screen), and can be edited when in definition mode.

Producers and consumers

In a diagram, variables are produced and consumed by units. Any unit that takes a variable as an input is considered a consumer of that variable. Any unit that outputs a variable is considered a producer of that variable.

A network can only have one producer connected to it, but it can have any number of consumers. CertSAFE will generate an error on a network that has consumers but no producer, or more than one producer. CertSAFE will generate a warning on a network that has a producer but does not have at least one consumer, since this means a value is defined but is not used anywhere.

There are several special primitive units that can be used in a diagram to control how variables are produced and consumed.

  • An input/output (I/O) primitive gives an exported name to a variable so that values can be passed in and out of the diagram. An input primitive has a single pin which counts as a producer. It allows values from outside the diagram to be used within the diagram. An output primitive has a single pin which counts as a consumer. It allows values produced within the diagram to be used outside of the diagram. The pins that appear on a custom component made from a diagram are determined by the I/O primitives in the diagram.
  • A terminator primitive has a single pin which behaves specially, being neither a producer or consumer. It is designed to explicitly mark when a network’s value is not used anywhere. Adding a terminator to a network suppresses the warning if the network has a producer but no consumers.
  • Local variable primitives, described below, are used to connect and assign names to networks in different parts of a diagram. If two local variables in a diagram have the same name, the attached networks are automatically connected, as if a wire were drawn between them. (This actually works for I/Os as well, so you can use the same input name in multiple places in a diagram.) Local variables are non-directional, so you don’t have to specify whether a local variable primitive is an “input” or “output” for that variable.

For more information on producers and consumers, including how to trace signals within and between diagrams, see the article on producers and consumers .

Local variables

In a diagram, local variables can be used to give wire networks specific names. Local variables can also be used to connect two disjoint pieces of logic in a diagram. Further, when simulating a model, local variables can be dragged into a simulation and displayed as a waveform.

ALT

Local variables are useful when trying to organize logic in a diagram. Naming a wire network with a local variable gives the wire network more meaning, and provides clear meaning of what that wire network means. Connecting disjoint pieces of logic gives an easy way to separate logic in a diagram, and allows that logic to be reused within the same diagram.

Data types

Every wire has a corresponding data type. Further, pins on components have corresponding data types as well. The system will try to infer what data type a specific wire should have by basing it upon what the wire is connected to. If the system cannot resolve the data type for a given wire, either a pin primitive should have its type constraint property set or a type constraint component should be connected to the wire network and its type property should be set.

For more information on how data types work, and how the system infers data types for variables, see the article on type inference

Constants

Diagrams can also have values inside of them that are constants. The most obvious example of this is using one of CertSAFE’s primitive literal components. Input/Output primitives can also be defined as constants as well. When an Input/Output pin is defined as a constant, it encapsulates the pin inside a box to better show the user that it has been declared as a constant.

ALT

Being able to define an input or output as a constant has ramifications for the diagram. The most obvious one is in simulation. For Inputs that are defined as constants, in simulation their value can only be changed on the first frame of the simulation. For more information about constants in simulations, please see Controlled variables and IntelliPoints .

Another useful feature of constants in CertSAFE is constness propagation. In CertSAFE, the system is able to infer what variables are constant and what variables can change during simulation. A diagram shows this information to the end user by making wire networks that are constants gray instead of black. This allows any user of CertSAFE to look at a diagram and know what variables can be precomputed or simplified. For more information on constants, please see Constness inference .

ALT