03-05-2012, 04:20 PM
Sprites in Block ROM
Sprites in Block ROM.pdf (Size: 87.71 KB / Downloads: 107)
In Example 36 we made a sprite by storing the bit map of three initials in a VHDL
ROM. To make a larger sprite we could use the Core Generator to store the sprite image
in either distributed or block RAM/ROM. Block ROM will allow larger images to be
stored and in this example we will use a block ROM to store the image of the two loons
shown in Fig. 6.11. The size of this image is 240 x 160 pixels and is available at
www.lbebooks.com as the image file loons240x160.jpg.
In Example 30 we showed how to create a block ROM using the Core Generator
where the initial data is stored in a .coe file. We can convert the JPEG image in the file
loons240x160.jpg to a corresponding .coe file called loons240x160.coe by using the
Matlab function IMG2coe8(imgfile, outfile) shown in Listing 6.7. This function will
work with other standard image formats other than JPEG such as bmp, gif, and tif. Note
that the .coe file produced by this function contains an 8-bit byte for each image pixel
with the format
color byte = [R2,R1,R0,G2,G1,G0,B1,B0] (6-3)
The original image read into the Matlab function in Listing 6.7 will contain 8-bits
of red, 8-bits of green, and 8-bits of blue. The 8-bit color byte stored in the .coe file will
contain only the upper 3 bits of red, the upper 3 bits of green, and the upper 2 bits of blue.
We need to do this because as we have seen the Nexys-2 board supports only 8-bit VGA
colors. The resulting 8-bit color image is called img2 in Listing 6.7 and will be of
reduced quality from the original image as can be seen in Fig. 6.12.