HOME       UP       PREV       FURTHER NOTES       NEXT (Inertial and Transport Delay)  

Event Driven Simulation

The following ML fragment demonstrates the main datastructure for an EDS kernel. »EDS ML fragments
// A net has a string name and a width.
// A net may be high z, dont know or contain an integer from 0 up to 2**width - 1.
// A net has a list of driving and reading models.

type value_t = V_n of int | V_z | V_x;

type net_t = {
   net_name:      string;           // Unique name for this net.
   width:         int;              // Width in bits if a bus.
   current_value: value_t ref;      // Current value as read by others
   net_inertia:   int;              // Delay before changing (commonly zero).
   sensitives:    model_t list ref; // Models that must be notified if changed.
};

// An event has a time, a net to change, the new value for that net and an
// optional link to the next on the event queue:
type event_t = EVENT of int * net_t * value_t * event_t option ref

This reference implementation of an event-driven simulation (EDS) kernel maintains an ordered queue of events commonly called the event list . The current simulation time, tnow, is defined as the time of the event at the head of this queue.

An event is a change in value of a net at some time in the future. Operation takes the next event from the head of the queue and dispatches it. Dispatch means changing the net to that value and chaining to the next event. All component models that are sensitive to changes on that net then run, potentially generating new events that are inserted into the event queue.

We will cover two variations on the basic EDS algorithm: intertial delay and delta cycles.


23: (C) 2008-11, DJ Greaves, University of Cambridge, Computer Laboratory.