| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → SimEvents |
| Contents | Index |
| Learn more about SimEvents |
| On this page… |
|---|
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 demo 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.
To open this demo, enter sedemo_DVS_model in the MATLAB Command Window.

Alternatively, you can open the MATLAB Help browser and, in the Demos tab, click the + sign next to Simulink, SimEvents, and Application Demos. In the expanded list of application demos, double-click the listing for Dynamic Voltage Scaling Using Online Gradient Estimation.
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.
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.
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.

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.
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 Dynamic Voltage Scaling Using Online Gradient Estimation.
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:
Plotting the Pending-Entity Signal, which is part of the larger example Building a Simple Discrete-Event Model
To run the sedemo_DVS_model simulation, choose Simulation > Start 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.

![]() | What Is an Event? | Building Simple Models with SimEvents Software | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |