User manual
PAL tutorial
5. Place and route the files (using Xilinx or Altera tools as appropriate).
6. Download the resulting
.bit file onto the Spartan II FPGA on the RC100.
1.3 PAL Tutorial Part 1
The Part1 project in the PAL tutorial describes how to use PAL resources. The application created
bounces a square around a VGA screen.
1.3.1 Compile-time configuration
Checking the resource is available
When building generic code, you need to have a mechanism for checking that you have the required
resources available on the platform to be targeted, and that the API you’re compiling against is
compatible with the API you’ve written your code to. PAL provides a set of utility macros for this purpose.
For example:
PalVersionRequire (1, 0);
PalVideoOutRequire (1);
This pair of statements asserts at compile time that the API being linked against is v1.0 (or is compatible
with v1.0) and that at least 1
VideoOut resource is available. These statements build no hardware and
consume no clock cycles of execution time.
Selecting the resource to use
Once you have ensured that a particular type of resource is available, you can get a handle to the
specific resource that you want to use. A handle to a PAL resource is used to identify to the PAL
methods the specific resource that you want to use. A resource handle can be returned at compile-time
by the macro expression
PalXCT(), where X is the resource type.
PAL typically provides many different video output resolution resources for each physical video
resource. A resource handle to the first video resource can be defined as a macro expression to be used
throughout the code as follows:
macro expr VideoOut = PalVideoOutCT (0);
PAL also supplies a macro
PalVideoOutOptimalCT (ClockRate), which selects the optimal video
output resolution and refresh rate for the specified target clock rate. The tutorial source code uses this
macro as follows:
macro expr VideoOut = PalVideoOutOptimalCT (ClockRate);
Checking the data width of the resource
PAL resources have interfaces with specific widths. The width of an interface should be tested at
compile time to ensure that it matches the required width for the application.
This can be done using
PalXGetYWidthCT (PalHandle), where X is the type of resource, Y is the
attribute to query and
PalHandle is the handle to the PAL resource to be queried.
The tutorial application is written to output 24-bit video data. Different platforms may have different data
widths on their video interfaces, so the application needs to check that the target platform uses 24-bit
video data, which can be done using a compile-time assert:
assert (PalVideoOutGetColorWidthCT (VideoOut) == 24, 0,
"Video output does not support 24-bit data");
www.celoxica.com
Page 8