Run a Sample Model

Overview of the Model

One way to become familiar with the basics of SimEvents® models and the way they work is to examine and run a previously built model. This section describes a SimEvents example model. The model simulates a technique for dynamically adjusting the energy consumption of a microcontroller based on the workload, without compromising quality of service. Changes in the workload can occur as discrete events.

Accessing the Model

To read about this example, enter showdemo('sedemo_DVS_model') in the MATLAB® Command Window.

Click Open This Example to open the model.

Examining Entities and Signals in the Model

This section describes the different kinds of ports and lines that appear in the sedemo_DVS_model model. Compared to signal ports, entity ports look different and represent a different concept.

Entity Ports and Connections

Some blocks in this model can process entities, which the What Is an Entity? section discusses.

The FIFO Queue block and the Start Timer block, which are part of the SimEvents library set, process entities in this model. Each of these blocks has an entity input port and an entity output port. The following figure shows the entity output port of the FIFO Queue block and the entity input port of the Start Timer block.

Entity connection lines represent relationships among two blocks (or among their entity ports) by indicating a path by which an entity can:

  • Depart from one block

  • Arrive simultaneously at a subsequent block

The preceding figure shows the connection line:

  • From OUT, the entity output port of the FIFO Queue block

  • To IN, the entity input port of the Start Timer block

When you run the simulation, entities that depart from the OUT port arrive simultaneously at the IN port.

By convention, entity ports use labels with words in uppercase letters, such as IN and OUT.

You cannot branch an entity connection line. If your application requires an entity to arrive at multiple blocks, use the Replicate block to create copies of the entity.

Signals and Signal Ports

Some blocks in this model can process signals. Signals represent numerical quantities defined at all times during a simulation, not only at a discrete set of times. Signals appear as connection lines between signal ports of two blocks. The following figure shows that the Start Timer block has not only an entity output port but also a signal output port. The signal output port connects to the Random Service Time subsystem.

In a discrete-event system, the signal input port coming into a block changes to an empty arrow when you perform update diagram:

Key Components of the Model

The sedemo_DVS_model model uses event-based blocks to simulate the workload of the microcontroller:

  • At random times, the Time-Based Entity Generator block generates an entity that represents a job for the microcontroller.

  • The FIFO Queue block stores jobs that the microcontroller cannot process immediately.

  • The Single Server block models the processing of a job by the microcontroller.

    This block can process at most one job at a time and thus limits the availability of the microcontroller to process new jobs. While a job is in this block, other jobs remain in the FIFO Queue block.

  • The Start Timer and Read Timer blocks work together to compute the time that each job spends in the server. The result of the computation is the et output signal from the Read Timer block.

  • The Entity Sink block absorbs jobs that have completed their processing.

  • Between the blocks where event-based signals transition to signal-based signals, Event to Timed Signal block performs the conversion.

Important discrete events in this model are the generation of a new job and the completion of processing of a job.

The model also includes blocks that simulate a dynamic voltage scaling (DVS) controller that adjusts the input voltage depending on the workload of the microcontroller. The idea is to minimize the average cost per job, where the cost takes into account both energy consumption and quality of service. For more information about the cost and the optimization technique, see Modeling Load Within a Dynamic Voltage Scaling Application.

Appearance of Entities

Entities do not appear explicitly in the model window. However, you can gather information about entities using plots, signals, and entity-related features in the debugger. See these sections for more information:

Running the Simulation

To run the sedemo_DVS_model simulation, choose Simulation > Run from the model window. A Figure window opens with a dynamic plot showing how the DVS controller varies the voltage during the simulation to reduce the average cost per job. A triangle marker moves to indicate the current voltage and corresponding cost.

Was this topic helpful?