Virtual Expo 2024

BUILDING A SIMPLE 2D GPU

Year Long Project Diode

AIM
To build a GPU with basic functions like line, circle, rectangle drawing and displaying it on a single buffered 320x240 resolution. 

INTRODUCTION
Building a GPU (Graphics Processing Unit) is a complex endeavor that involves a deep understanding of computer graphics principles, hardware architecture, and programming. GPUs are specialized hardware designed to efficiently process and render graphics data for display on a screen. Implementing drawing and displaying functionality on a custom-built GPU requires careful planning, design, and implementation. 
This project realizes a simple graphics processing unit (GPU) using Verilog which can be used as a GPU to output. Final output of the graphics will be displayed on the monitor.
The GPU supports multiple drawing functions such as text writing, line drawing, and rectangular fills. It also provides a 320x240, as well as capability for single buffered graphics. The end product allows a simple method for one to use a microcontroller or other host device to create a high quality graphical program without sacrificing memory, speed, or timing constraints of said microcontroller. We will be rendering the shapes at approximately 1 frame per second with a frame buffer of one.

METHODOLOGY
We will be implementing the various algorithms, like Bresenham line drawing, Bresenham Circle drawing and Rectangle fill on Verilog.

Line drawing[2]
We have used the Bresenhem’s line drawing algorithm. The two endpoints of the line (x0,y0) and (x1,y1) are taken as input from instruction. We define the instantaneous coordinates of the line as (x,y). We define dx and dy to determine the remaining pixels required for plotting, calculated as dx = x1 - x and dy = y1 - y. If either dx or dy is less than 0, we decrement the current coordinates by 1 unit, resulting in pixels being plotted with the desired width. Conversely, if dx or dy is greater than 0, we increment the current coordinates by 1 unit, continuing this process until reaching the final coordinates.

Rectangle drawing
We draw a rectangle by implementing the line drawing algorithm four times. We will acquire the starting point (left bottom corner) as (x0, y0) along with the width and height for the complete rectangle implementation as (WIDTH,0) and (0,HEIGHT). The first line is drawn with the left bottom corner as the starting point and the right lower corner as the end point. Subsequently, this becomes the starting point for the next line, which iterates along the y coordinates. We repeat this procedure for the remaining sides until we end back at the initial point, thereby completing the rectangle.

Circle drawing[3]
We have used the Bresenhem’s circle drawing algorithm which leverages the inherent symmetry of a circle. The whole 360 degree is divided into 8-parts with each octant of 45 degrees. We calculate the locations of the pixels in the first octant of 45 degrees. For every pixel (x, y) calculated using this algorithm, we plot pixels in all eight octants of the circle.
The circle is characterized by its center point (xc, yc) and radius (r), and we track the instantaneous coordinates of the line as (x, y). A decision parameter (p) plays a crucial role in determining the position of the next pixel to be plotted. During each iteration, the decision parameter guides whether to move horizontally or diagonally. After plotting pixels in one octant, mirror them to plot pixels in other octants, maintaining symmetry around the circle's center.

RESULTS
Successfully designed a microprocessor with 36 bit Instruction Set Architecture that decodes and executes algorithms for Line Drawing, Rectangle Drawing and Circle Drawing.

CONCLUSIONS:
The designed GPU has achieved most of the objectives outlined in the initial proposal and has made notable progress.
Through the process, we gained proficiency in structuring modules for diverse applications using Verilog
We were introduced to the various Computer Organization concepts like types of processor architectures, RISC vs CISC, Endianness, Memory Hierarchy, Register organization, Pipelining and Hazards.
Future scope includes designing and hardware implementation using FPGA

REFERENCES
[1] https://people.ece.cornell.edu/land/courses/eceprojectsland/STUDENTPROJ/2009to2010/pag42/Greczner_Meng_Final.pdf

[2] https://www.geeksforgeeks.org/bresenhams-line-generation-algorithm/
[3] https://www.geeksforgeeks.org/bresenhams-circle-drawing-algorithm/
 

Report Information

Explore More Projects

View All 2024 Projects