Table des matières
Bitmap VGA output
WARNING : The module has recenty been updated… some information here might be obsolete… contact me for confirmation.
Before the implementation of any of these modules, please, check if your design leaves enough memory resources for the required memory. Logic requirements are negligible and working frequency is high enough in most cases.
( figure source )
- n : number of address bits (resolution dependant)
- bpp : number of bits/pixel (configurable)
- reset is active high
instanciation
The most simple version is to be instanced with the following lines. Optional I/Os are not used, and might produce warnings, you can safely ignore them.
display_module : entity work.vga_bitmap_640x480 generic map(RAM_BPP => 4, -- number of bits per pixels INDEXED => 0, -- do not used indexed colors READBACK => 0) -- read from bitmap memory disabled port map(clk => clk, -- 100MHz system clock reset => reset, -- active high system reset VGA_hs => VGA_hs, -- VGA screen output VGA_vs => VGA_vs, VGA_color => VGA_color, pixel_x => pixel_x, -- pixel horizontal coordinate pixel_y => pixel_y, -- pixel vertical coordinate data_in => data_in, -- new color for the addressed pixel data_write => data_write); -- write order
If data readback is required, it becomes :
- warning: a 5 to 6 clock periods latency is necessary between the data_read assertion and data_rout assertion
- data read requests can be pipelined
display_module : entity work.vga_bitmap_640x480 generic map(RAM_BPP => 4, -- number of bits per pixels INDEXED => 0, -- do not used indexed colors READBACK => 1) -- read from bitmap memory enabled port map(clk => clk, -- 100MHz system clock reset => reset, -- active high system reset VGA_hs => VGA_hs, -- VGA screen output VGA_vs => VGA_vs, VGA_color => VGA_color, pixel_x => pixel_x, -- pixel horizontal coordinate pixel_y => pixel_y, -- pixel vertical coordinate data_in => data_in, -- new color for the addressed pixel data_write => data_write, -- write order data_read => data_read, -- read order data_rout => data_rout, -- data read is ready data_out => data_out): -- pixel read color
The end_of_frame output signal might also be useful to synchronize display updates with screen refresh.
addressing a pixel
Pixels are addressed by x,y coordinates from the top left (0,0) to the bottom right (xmax, ymax).
Different resolutions are available :
160×120(on request)- 320×240
- 640×480
Pixel coding
All resolutions are available from 1 bit/pixel to 12 bit/pixel. It is possible to chose between colored or greyscale for color depth of 2, 3 and 4 bits / pixel.
1 bit/pixel
The graphic memory only contains 1 bit/address to match the pixel coding. The output is then black for '0' and white for '1'. As the VGA interface is coded using 4 bits / color (or 12 bits / pixel). It is possible to modify the white value by any other with simple logic gating.
2 bits/pixel
The pixel value is encoded with 2 bits. The generic parameter grayscale makes it possible to code the screen as monochrome if set to true, if omitted, it is considered as false and display will be colored. The corresponding values are as follow :
Value (MSB:LSB) | Color | Grayscale |
---|---|---|
0:0 | Black | Black |
0:1 | Blue | Dark Grey |
1:0 | Green | Light Grey |
1:1 | Red | White |
In each case, the color is set at its maximal intensity.
3 bits/pixel
Here again, the generic parameter grayscale makes it possible to code the screen as monochrome if set to true, if omitted, it is considered as false and display will be colored. With this coding scheme, each bit represent a primary color. Each individual color is always set at its maximum. The next table lists the expected colors.
Value | r | g | b | Color |
---|---|---|---|---|
000 | 0 | 0 | 0 | Black |
001 | 0 | 0 | 1 | Blue |
010 | 0 | 1 | 0 | Green |
011 | 0 | 1 | 1 | Cyan |
100 | 1 | 0 | 0 | Red |
101 | 1 | 0 | 1 | Magenta |
110 | 1 | 1 | 0 | Yellow |
111 | 1 | 1 | 1 | White |
4 bits/pixel
The 4-bit representation is very similar to 3-bit. There is the possibility to use it to code grayscale or colored pixels. For colors, it uses the same scheme as 3-bit for the chrominance, and uses the MSB (4th) bit to code luminance. When the MSB is 0, colors are dark, when the MSB is '1', colors are bright. It is worth mentioning that dark white is a gray which is lighter than bright black.
5 bits/pixel (3 level coding)
Using this color scheme, colors are coded in RGB format where R, G and B may take three values (dark or 0, medium or 1, bright or 2). The corresponding values are then coded as an integer given by : (R*9 + G*3 + B). This representation only provides 27 different colors where 32 are actually possible, but it is a good compromise to provide RGB coding with low memory resources.
6 bits/pixel and above
Beyond this point, pixel values are coded using RGB representation. The table below shows how bits are split to provide the expected coding :
bpp | Red | Green | Blue |
---|---|---|---|
6 | 2 | 2 | 2 |
7 | 2 | 3 | 2 |
8 | 3 | 3 | 2 |
9 | 3 | 3 | 3 |
10 | 3 | 4 | 3 |
11 | 4 | 4 | 3 |
12 | 4 | 4 | 4 |
memory usage (Artix 7)
resolution | ISE synthesis | greedy Vivado (v1.1 and previous) |
---|---|---|
320×240 | 2.5 BRAM / bpp | 4 BRAM / bpp |
640×480 | 10 BRAM / bpp | 16 BRAM / bpp |