A specification as described in the previous section is translated by OKA (pipeline hazards description translator) into interface and implementation files having the same names as one of specification file and correspondingly suffixes `.h' and `.c' (C code) or `.cpp' (C++ code).
Interface file of PHD consists of the following definitions:
Object of the class describes current state of processor. The class has the following public members:
`int OKA_transition (int OKA_instruction)'
The function has one parameter: instruction code. If
corresponding instruction can be started by the processor in
its current state, the function returns 1 and the object
(processor) changes own state which reflects starting the
execution of given instruction. In the opposite case, when
the instruction can not be started, the function returns 0
and the object (processor) does not change own state.
`int OKA_is_dead_lock (void)'
The function returns 1 (TRUE) when transition from the
corresponding processor state is not possible on any
instruction. The single way to change object (processor)
state is to advance time (on one cycle) with the aid of
special pseudo-instruction code `OKA__ADVANCE_CYCLE'. For
example, dead lock state for dual-issue processor can be
state reflecting starting two instructions on a cycle.
`void OKA_reset (void)'
The function sets up the object (processor) in initial
state. No any processor unit is busy in the state.
`OKA_chip (void)'
The constructor simply calls function `OKA_reset'.which declare instruction codes. Macros or enumeration constants have the same name as one in PHD and prefix `OKA_' (see also option `-p'). OKA always generates additional code `OKA__ADVANCE_CYCLE'. If such pseudo-instruction starts, the processor make transition into the state reflecting advancing time on one cycle. It is guaranteed that there is always transition from any processor state on given pseudo-instruction. Macros or enumeration are generated in interface file only if option `-export' is present on OKA command line. By default, the macros or the enumeration are generated in the implementation file. Usually, the last case means that the scheduler code is placed PHD in additional C/C++ code.
Interface file of PHD consists of the following definitions of generated type and functions:
`int OKA_transition (OKA_chip *OKA_chip,
int OKA_instruction)'
The function has two parameter: pointer to structure
describing the processor state and instruction code. If
corresponding instruction can be started by the processor in
its current state, the function returns 1 and the structure is
changed in order to reflects starting the execution of given
instruction. In the opposite case, when the instruction can
not be started, the function returns 0 and the structure is
not changed.
`int OKA_is_dead_lock (OKA_chip *OKA_chip)'
The function returns 1 (TRUE) when transition from the
processor state given by the structure is not possible on any
instruction. The single way to change processor state is to
advance time (on one cycle) with the aid of special
pseudo-instruction code `OKA__ADVANCE_CYCLE'. For example,
dead lock state for dual-issue processor can be state
reflecting starting two instructions on a cycle.
`void OKA_reset (OKA_chip *OKA_chip)'
The function sets up the structure (processor) in initial
state. No any processor unit is busy in the state.