PS2 Linux Programming
VectorUnit Command Line Pre-Processor (VCL)
Introduction
The program in this tutorial performs exactly the
same rendering task as in the previous tutorial “A simple VU1 Micro Program
(PATH 1)”. In this tutorial however, the VectorUnit Command Line Pre-Processor
(VCL) is used to develop the micro code for VU1. The use of VCL greatly
simplifies the development of VU1 microcode.
The VCL pre-processor is an application that was
developed to simplify some of the complex and tedious tasks associated with assembly
level programming of the VU processors. These tasks include:
·
Dual pipeline
processing
·
Loop unrolling
·
Register allocation
·
Instruction scheduling
VCL outputs a standard vector unit assembly program
(VSM) which can then be compiled with the vu assembler (ee-dvp-as).
VCL simplifies VU programming by merging the upper
and lower instructions into a single instruction stream so that the programmer
no longer needs to be concerned with the pairing of instructions. VCL also
simplifies the instruction syntax in that in some cases it is possible for VCL
to deduce the proper register assignment from the parameters attached to the instruction.
Assembly language programming for high performance
applications requires intimate knowledge of the instruction timing and scheduling
and is therefore prone to error. VCL removes many of these problems. VCL is an
optimising compiler, therefore it will generally produce faster code that many
programmers (apart from the very advanced) will be able to produce with hand
coded assembler.
The VCL pre-processor is very verbal and produces
large output listings warning about stalls, unnecessary instructions and lots
of other information. Note that these say INFO: next to them, not WARNING or
ERROR. This means that they can generally be ignored or used as hints for
restructuring and improving the code.
It is worth noting that stalls are expected in a VU
program. It is almost impossible to make a non-trivial VU1 micro program
without any stalls.
A version of VCL comes on the DVDs supplied with
the PS2 Linux Development Kit but this is an older version which also does not
have much in the way of documentation. The current version at the time of writing
is version 1.3.2 and this can be downloaded from http://www.playstation2-linux.com/projects/vcl.
This example renders a static sprite using PATH 1
in exactly the same was as in the previous tutorial with the exception that VCL
is used to generate the vsm file. The VCL code is contained within the file vu1code.vcl
which is repeated below for clarity.
.init_vf_all
.init_vi_all
.syntax new
.vu
--enter
--endenter
iaddiu iGIFData, vi00,
0
xgkick iGIFData
--exit
--endexit
.END
The same instructions that were used in the
previous example are shown in the body of the code. There is no need to worry
about placing the [E] bit, using two instruction streams or putting in NOPs - VCL
now deals with all of these complications.
Once the example is complied, VCL will generate the
file vu1code.vsm which is the assembly listing for the VU. The code generated by
VCL is identical to the one that was hand coded in the previous sample and is
reproduced below for clarity.
; flowMon::Emit() vcl 1.3.2 produced this code:
.vu
.align 4
__v_vu1code_vcl_4:
; [0,3) size=3 nU=0 nL=2 ic=2 [lin=2 lp=0]
cycles?=3
NOP iaddiu VI01,VI00,0
NOP[E] xgkick VI01
NOP NOP
.align 4
;iCount=3
;register stats:
;1 VU User integer registers
;0 VU User floating point registers
In this tutorial probably the simplest PATH1 render
using VU1 has again been illustrated. In the example code the use of the VCL
pre-processor for generating the VU micro-program has been introduced.
Dr Henry S Fortuna
University of Abertay
Dundee