Next Previous Contents

3. Generated code

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).

3.1 C++ code

Interface file of PHD consists of the following definitions:

Class `OKA_chip'.

Object of the class describes current state of processor. The class has the following public members:

  1. Function
                 `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.
  2. Function
                 `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.
  3. Function
                 `void OKA_reset (void)'
    
    The function sets up the object (processor) in initial state. No any processor unit is busy in the state.
  4. Constructor
                 `OKA_chip (void)'
    
    The constructor simply calls function `OKA_reset'.

Macros or enumeration (see option `-enum')

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.

3.2 C code

Interface file of PHD consists of the following definitions of generated type and functions:

  1. Structure `OKA_chip' which describes state of the processor.
  2. Type definition `OKA_chip' which is simply structure `OKA_chip'.
  3. Function
              `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.
  4. Function
              `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.
  5. Function
              `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.
  6. Macros or enumeration (see option `-enum') 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.


Next Previous Contents