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.
- Change the path to the output.txt on line 19 of ppm_file_writer.v
- Select which shape you want generated in vga_controller_tb.v (line 76, 78, 80)
- Color values can be changed as explained thoroughly in the testbench.
- (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.
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.
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
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
The following circle was generated with these values:
- rad = 100
- x0 = 320
- y0 = 240
- R = 100
- G = 255
- B = 150
The following rectangle was generated with these values:
- width = 200
- height = 100
- x0 = 200
- y0 = 140
- R = 0
- G = 255
- B = 0
Full sim:
Zoomed in: