Edwin Jan Klein - Universiteit Twente
Edwin Jan Klein - Universiteit Twente
Edwin Jan Klein - Universiteit Twente
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Chapter 4<br />
Listing 4.4. Pseudo code implementation of the execution engine.<br />
AddCall(dT, V, C)<br />
{<br />
Create the call with value V and port target C to the call list at time TCurr+dT;<br />
}<br />
Simulate()<br />
{<br />
Set the current time TCurr to 0;<br />
Initialize all the primitives;<br />
Find the first call in the call list;<br />
TCurr is now equal to the time in this call;<br />
}<br />
loop //Simulation loop<br />
{<br />
Execute all the calls that have time TCurr by<br />
First placing the forwarded signal values V in these calls on their<br />
target nodes C;<br />
Then calling the Calculate() functions of the parent primitives of these nodes;<br />
Find the first call that has a time> TCurr in the call list;<br />
TCurr is now equal to the time in this call;<br />
} until TCurr>TMax or until there are no more calls;<br />
With these first calls, however, the core loop of the algorithm becomes self<br />
sustaining: If the algorithm executes the calculate functions of the primitives that<br />
these first calls refer to, these in turn will either generate one or more new calls<br />
themselves or, if they are instantaneous, call another primitives that do so. When the<br />
core loop has finished executing all the calls placed at TCurr=0 it can then simply<br />
continue with the newly created calls that are next on the time line. These calls in turn<br />
will then generate their own new calls and so forth and so on.<br />
Once the core loop has started itself there are only two ways in which the simulation<br />
can be ended. In optical circuits that have no feedback loops, like the fictitious circuit<br />
shown in Figure 4.13, the signals and calls will simply propagate from the point<br />
where the change in signal originated (the wave source) to where they can propagate<br />
no further (the right coupler in this example). After these last calls have been executed<br />
the call list will be empty and the core loop will terminate by itself.<br />
Figure 4.13. Self terminating optical circuit. (Image created from an Aurora screenshot). Unused<br />
ports in the simulation do not participate in the simulation.<br />
In circuits with feedback loops, however, like the one shown in Figure 4.14 new calls<br />
are continuously generated, allowing the inner loop to continue forever. In such cases<br />
90