Though real time is desirable for many practical applications, virtual time is still necessary in other cases.
There are two kinds of virtual time simulation:
Scaled real-time simulation can be easily simulated by a real-time simulation. This is done by multiplying all the time variables in a model with the scale factor. Macro redefinition discussed in later chapters allows for flexible change of the scale factor.
As-fast-as-possible simulation can be simulated by a real-time simulation. For a stand-alone model (a model that does not communicate with other models via ports), a clock component is designed and discussed later with examples (section 9.2). By importing the clock component as a top-level orthogonal component in the model, as-fast-as-possible simulation is enabled. The clock component maintains the time variable. To retrieve time, the model sends an event, which triggers a transition in the clock. That transition outputs another event with the value of the time variable as a parameter. The latter event tells other parts of the model the current time.
To schedule an event, the model sends an event with the scheduled time as a parameter. The event triggers another transition in the clock component, which adds the scheduled time to its schedule list (a variable). The clock component also keeps track of the activity of the model. It broadcasts the time advance event with the smallest scheduled time in the schedule list as a parameter, when the model becomes idle.
To simulate as-fast-as-possible simulation for distributed models (models that communicate via ports), the idea of a clock component is similar. However, the clock component must tolerate network delay, if some or all of the connections are established via a network. Because of this delay, a model may receive a message from another model, which is sent at a time in the past (in terms of the local virtual time of the receiver). In that case, the receiver must be rolled back to the message time. This timewarp issue is discussed in [31]. It is not in the scope of this thesis.