User manual

Tutorial: Handel-C and PSL basics
macro expr White = 0xFFFFFF;
macro expr Black = 0x000000;
macro expr Red = 0xFF0000;
macro expr Green = 0x00FF00;
macro expr Blue = 0x0000FF;
macro expr ScanX = PalVideoOutGetX (VideoOut);
macro expr ScanY = PalVideoOutGetY (VideoOut);
Having defined these simple macro expressions, it is now possible to make the
RunOutput macro
display graphics on a VGA output. The example in
GraphicsDemo1 draws a white grid on a black
background. This is achieved by taking the lowest five bits of
ScanX and ScanY, and drawing a white
pixel whenever these bits are equal to zero. All other pixels are drawn as black, resulting in a grid of
white lines one pixel wide, and spaced by 32 pixels vertically and horizontally. The code to generate this
grid is shown below, and a screenshot of the output in simulation is shown in the figure below. Note that
the code to generate the grid graphics is inside a
while(1) loop, so it will run forever, and it also
executes in a single cycle, as this is the rate at which pixels must be sent out to the VGA display.
while (1)
{
if ((ScanY <- 5 == 0) || (ScanX <- 5 == 0))
PalVideoOutWrite (VideoOut, White);
else
PalVideoOutWrite (VideoOut, Black);
}
PALSIM RUNNING GRAPHICSDEMO1
www.celoxica.com
Page 64