WAL Programmer Manual

0.8.2

2. Waveform Handling

This section describes functions for loading and handling waveforms.
(load file id?) ↦ ()
   file : string?
     id : symbol?
Loads waveform from file and registers it in the WAL kernel with id. The id argument is optional. If no id is given, WAL automatically selects ids using the scheme t0, t1, ...
(unload id) ↦ ()
  id : symbol?
Removes the waveform specified by id from the WAL kernel.
(step id amount) ↦ (boolean?)
      id : symbol?
  amount : int?
Step trace id by amount. Both arguments are optional. If no id is provided all traces will be stepped by amount. Returns #f if the end of any loaded trace is reached.
(alias name signal) ↦ ()
    name : symbol?
  signal : symbol?
Introduces an alias for signal such that it can be also referenced using name. Aliases are compatible with groups and scopes. This means, that if an alias is resolved the current group or scope is appended to its name.
(unalias name) ↦ ()
    name : symbol?
Removes the alias name.
(whenever cond body+)
    cond : WAL expression
    body : WAL expression
Evaluates the body expressions on each waveform index at which cond evaluates to true. Returns the value of the last body expression evaluated at the last index at which cond evaluates to true.
(find cond) ↦ (list?)
    cond : WAL expression
Returns a list containing all indices at which cond evaluates to true.
(count cond) ↦ (list?)
    cond : WAL expression
Returns the number of indices at which cond evaluates to true.
(timeframe body+)
    body: WAL expression
Stores the current INDEX of every loaded trace before the evaluation of body and restores those indices after body is evaluated. Returns the result of the last expression in body. This allows performing local time operations (e.g., stepping) without losing the location inside the trace. One example for this are overlapping transactions. E.g., when a transaction starts, step to the end of transaction and Afterwards resume from the start of transaction.
Example
The example below showcases using cond in a recursive function implementing the Fibonacci sequence. If the argument n is either 1 or 2 the result of the function is 1 otherwise the last default case (clauses with #t always match) is evaluated which recursively calls fib.
(print INDEX)
(timeframe
  (while (! ready) (step))
	(print INDEX))
(print INDEX)