Decisions in Flows with IFJOB

Another way to add conditionals into the flows consists of adding the decision code directly into the FDL. This can be done with the procedure IFJOB, as illustrated by the following example.

The example is of course contrived. We assume that we do some design jobs (e.g. copying files) and then we check some properties of the results, e.g. the size of the output file, to determine whether we have met some attribute of the design or not. In this example, we pretend that the attribute is "timing", which is a property of a digital circuit. If the timing is met, we do something, otherwise we do something completely different.
# Do some design activity...
N "standinDesignActivity"
J vw cp aa bb

# Now add the decision node.
IFJOB -label checkTiming {
    puts "Hello: we are inside checkTiming"
    set timingOk [expr [file size bb] & 1] 
    puts "TimingOk = $timingOk Size = [file size bb]"

    set sId [S "Result:decision:checkTiming" {
        if { $timingOk } {
            N "TIMING_OK"
            J vw cp bb cc
            J vw cp cc dd 
            J vw cp dd ee 
            J vw cp ee final
        } else {
            N "FIX_TIMING"
            J vw cp bb cc1 
            J vw cp bb cc2
            J vw cp bb cc3
            J vw cp bb cc4
            J vw cat cc1 cc2 cc3 cc4 > final
    AD $env(VOV_JOBID) $sId
    # after 5000; START $sId

This flow initially creates two jobs, the cp aa bb and another job called vovdecision, which depends on the first job based on the sequence of the code (or we could have used the option -jobid ID in IFJOB to specify a dependency with another job). The code fragment provided as last argument to IFJOB is attached to the decision node as an annotation.

When the decision node is executed, it executes the code fragment. In this case, the code consists of a measurement (pretend that the size of the file bb is an expression of the timing of a circuit), and then decides: if the timing is ok, it creates a flow, otherwise it creates a different flow.

The utility vovdecision is essentially an invocation of vovbuild with a small flow file that can be embedded right into the top-level flow.

The limit for the length of the script is about 30kB, but we expect the code fragments used in decision nodes to be much simpler. For more complex decisions, you may want to write a separate flow file and execute it normally with vovbuild. You can add the vovbuild job to the trace by using the option -T, as in the following example:
% vovbuild -T -f anotherDecisionFlow.tcl