-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Problem
Simulating FPGAs is difficult.
Tickit differs from the FPGA simulation on which was based in the following ways.
Tick Scope
Tickit does not allow cyclic graphs because it considers a tick to be a single, instantaneous propagation of the entire device from the lowest down nodes that require wakeup. The following is a valid graph showing which nodes are visited in which ticks (t0, t1 and t2):
If a cycle were inserted anywhere then t0 would never end because the tick only ends when the output propagates all the way to D.
The FPGA design allows cycles by having a reduced scope for a tick, only ticking each subsequent node:
Temporal Relevance
In tickit a tick is assumed to be instantaneous, even if it is propagating a signal through a large and complex graph, no simulation time passes. An arbitrary number of ticks can also take place in zero simulated time. In the below example, only tick 3 takes place after 0 nanoseconds:
Time is much more important to FPGA ticks, a delay is enforced between them and "event x must happen n ticks (clock cycles) later than event y" is a valid use case.
The example below shows a simple traversal with no wakeups:
The graph below shows each propagation stage (tock) of each tick. A tock is defined as a single transfer of output of one node to input of another node, or an initial trigger of a node at the beginning of a tick.
| Tick | Tock | Time (ns) | Node (Tickit) | Node (FPGA)) |
|---|---|---|---|---|
| 0 | 0 | 0 | A | A |
| 0 | 1 | 0 | B | B |
| 0 | 2 | 0 | C | _ |
| 0 | 3 | 0 | D | _ |
| 1 | 0 | 8 | _ | C |
| 1 | 1 | 8 | _ | D |
| 2 | 0 | 16 | _ | D |
This implies one more visit to D than in the tickit model, showing a fundamental difference that cannot be achieved by inserting an artificial delay.
Causality
Both of the above examples show how tickit treats causality differently to the FPGA model. It traverses the whole graph instantly to propagate the consequences of events before any time can pass that introduces new events. Thus something at one end of a graph affects something at the other end in 0 sim time.
Proposed Solutions
Hybrid Schedulers
Write a child scheduler that works like the FPGA simulation. Keep the existing master scheduler for wiring all devices outside of the FPGA simulation and reconciling the outputs. See example below:
Several issues with this approach are illustrated here:
- The two schedulers each have their own concept of ticks, which is uncontroversial and how the current
NestedSchedulerworks, but they also each have their own separate concepts of simulated time. - The FPGA takes a number of nanoseconds to complete its tasks, while the master still treats its output as instantaneous and passes it onto the detectors.
- From the FPGA's point of view the detectors should each be triggered at a different time: 16ns, 8ns and 0ns. From the master point of view they are all triggered simultaneously. There is no clear way to tell who is right or if causality is affected. To the outside world (via device adapters) all detectors are triggered simultaneously.
These are not necessarily showstoppers as long as we accept this potential inaccuracy in the simulation.
Different Master Scheduler
Write a new master scheduler to be used for all simulations involving FPGAs, which makes everything time-sensitive. In this case, all ticks are propagated in the FPGA style. All node dependencies must have a delay of at least 1ns. There is still a separate scheduler for controlling FPGA simulations for performance reasons, but it and the master share a concept of simulated time.
In this version the detectors are all triggered at different times and in the order the FPGA requires. The disadvantage is that these simulations are more restrictive and less generic. They can only accept simulated devices that have a concept of time and all causality is based around the FPGA, which makes it more difficult to simulate non-discrete-time entities such as the behaviour of the beam. That does, however, optimise tickit for the hardware triggered scanning use case.





