Hardware Microarchitecture of MiniGPU
MiniGPU is a hardware-accurate 2D graphics processor designed in synthesizable Verilog HDL. It demonstrates the fundamental microarchitectural principles of hardware graphics acceleration: command streaming, FIFO decoupling, bounding-box rasterization, mathematical shape coverage evaluation, dual-port video memory (SRAM), and display timing generation.
1. Coordinate System & Memory Geometry
MiniGPU targets a 160 ร 120 display resolution with 24-bit RGB888 true color. The horizontal coordinate \(X\) spans \(0 \le X \le 159\) (8 bits), and the vertical coordinate \(Y\) spans \(0 \le Y \le 119\) (7 bits). The framebuffer consists of exactly 19,200 words:
By decomposing the multiplication \(Y \times 160\) into binary shifts \((Y \times 128) + (Y \times 32)\), the hardware avoids an expensive general-purpose multiplier in the memory addressing unit, requiring only two barrel shifts and an adder.
2. Pineda Edge-Function Triangle Rasterization
Triangle coverage is evaluated using the Juan Pineda edge-function algorithm in signed fixed-point integer arithmetic. Given three vertices \(V_0(x_0, y_0)\), \(V_1(x_1, y_1)\), and \(V_2(x_2, y_2)\), each edge defines a 2D cross-product:
\(E_{12}(x, y) = (x - x_1)(y_2 - y_1) - (y - y_1)(x_2 - x_1)\)
\(E_{20}(x, y) = (x - x_2)(y_0 - y_2) - (y - y_2)(x_0 - x_2)\)
A pixel \((x, y)\) lies inside the triangle if and only if all three edge functions share the same sign. MiniGPU supports both clockwise (CW) and counter-clockwise (CCW) triangle windings:
3. Circle Rasterization via Squared-Distance Arithmetic
Circles are rendered using the algebraic distance equation: \((x - c_x)^2 + (y - c_y)^2 \le r^2\). To eliminate the need for an expensive square root operator, the hardware computes the squared Euclidean distance directly using signed arithmetic intermediates sized to 20 bits, guaranteeing zero arithmetic overflow under all coordinates.
4. True Dual-Port Framebuffer Architecture
The video memory employs two independent, concurrent synchronous ports:
- Port A (Render Write): Driven by the rasterizer controller. Updates memory pixels asynchronously as drawing commands are processed.
- Port B (Display Read): Driven by the display controller. Continuously scans the visible display grid at real-time video rates with 1 clock cycle of synchronous pre-fetch latency compensation.