Skip to content

LudoProvost/VGA-controller-basic-shape-rendering

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

VGA controller with basic shape rendering

Simple VGA controller made in verilog which writes to an output.txt file in PPM format which can later be opened with the VGA_px_gen_debug.py python scrypt as a PNG.

Without having access to an FPGA to test the VGA controller with, I decided to use $fwrite() in verilog to transform the R,G,B values from the pixel generation and the vsync and hsync values from the VGA_controller into an image in PPM format. The images generated below are generated from the outputs which would have been fed to a monitor through a VGA connection.

image

How to run

  1. Change the path to the output.txt on line 19 of ppm_file_writer.v
  2. Select which shape you want generated in vga_controller_tb.v (line 76, 78, 80)
  3. Color values can be changed as explained thoroughly in the testbench.
  4. (OPTIONAL) To use the python scrypt to get the PNG from the PPM, change the path on line 4 of VGA_px_gen_debug.py to point to the same output.txt of the ppm_file_writer.

Using different precision for gradient circle

The precision parameter should be set between 0 and 8. The number of different shades will be given by 2^precision. Shown below is the same gradient circle but with different precision levels.

Precision = 8:

gradient_circle_LUT_prec8

Precision = 5:

gradient_circle_LUT_prec5

Precision = 2:

gradient_circle_LUT_prec2

Render examples

Outwards gradient circle

The following gradient circle was generated with these values:

  • rad = 200
  • x0 = 320
  • y0 = 240
  • outwardGradient = 0
  • precision = 8
  • R = mid_i
  • G = mid_i
  • B = 255

gradient_circle_LUT_prec8 (2)

Inwards gradient circle

The following gradient circle was generated with these values:

  • rad = 100
  • x0 = 320
  • y0 = 240
  • outwardGradient = 1
  • precision = 8
  • R = mid_i
  • G = 0
  • B = 0

gradient_circle_LUT_prec8

Circle

The following circle was generated with these values:

  • rad = 100
  • x0 = 320
  • y0 = 240
  • R = 100
  • G = 255
  • B = 150

image

Rectangle

The following rectangle was generated with these values:

  • width = 200
  • height = 100
  • x0 = 200
  • y0 = 140
  • R = 0
  • G = 255
  • B = 0

rectangle

Simulation wave form example

Full sim:

sim_wf

Zoomed in:

sim_wf_zoomed

Sources

  1. Pixel generation lecture
  2. 8-bit VGA Controller detailed reference information by Altium

About

basic shape rendering from a VGA controller in PPM format

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published