Chapter 8
AutoCode Sim Cdelay Scheduler
©
National Instruments Corporation
8-13
DataStore Priority Problem
As mentioned, you must find some way to enforce the priority of writers to
DataStores in the generated code. Each DataStore register can be written to
independently, so each one needs to be independently subjected to the
priority constraint. In the default scheduler, there is no need to actively
enforce the constraint, as it is automatically preserved by the order in which
outputs are posted in the single output stage. However, in the new
scheduler, there are two output posting stages, and the same technique will
not work.
An efficient solution—the one implemented—involves noticing that only
the registers in DataStores written to by both ANC and ATR tasks need be
actively monitored. For example, if a register is written to only by ANC
tasks, it is written entirely in the first stage and ordering the writes from
lowest to highest priority would enforce the constraint as in the default
scheduler. So you only need to create a priority array with just enough
space to hold priorities of registers in DataStores written to by both types
of tasks. Furthermore, observe that the problem is caused by the need to
preserve information across the gap between the first and second output
posting stages. You do not care about the regime before the first stage or
after the second.
Thus, if you call the set of registers in DataStores written to by both ANC
and ATR tasks Alpha,
it would suffice to record the priority
of each writer
to a member of Alpha only in the first output stage, because within the
second stage repeated writes do not matter because of the order in which
the write loop is executed. Likewise, guards are
not
needed in the first
output stage because of the write loop order. All you need to do is
record
the priority
of the writers to members of Alpha in the first stage, and wrap
writes to members of Alpha with guards in the second stage.
Some pseudocode for this, assuming a single DataStore register in Alpha,
is shown in Example 8-1.
Example 8-1
Pseudocode for Single DataStore Register in Alpha
for tsk <- low_prio_tsk..high_prio_tsk do {
/* loop from low to high priority */
if tsk.ready_to_post_outputs() {
write_register(tsk.output()); /*write to datastore register*/
reg_prio = tsk.prio(); /*save priority of writer*/
}
}
/* Queue Tasks */