- Axis-Aligned Bounding Boxes: https://developer.mozilla.org/en-US/docs/Games/Techniques/3D_collision_detection
- Pillow Library - https://pillow.readthedocs.io/en/stable/
ChatGPT:
- When prompted with “I want to load a sprite image of a player into the Pmod OLED that uses the Basys 3 FPGA board”. The ChatGPT-generated text indicated “To load a sprite image of a player onto the Pmod OLED using the Basys 3 FPGA, you'll need to convert your sprite into a monochrome bitmap (1-bit per pixel) and then write a Verilog module to send the pixel data to the OLED. The Pmod OLED (SSD1306) communicates via SPI or I²C, but since the Basys 3 does not have direct SPI support in Verilog, it’s common to implement a bit-banged SPI protocol”
- When prompted with “How can I write a Python file that helps convert a PNG file into the RGB565 format?”. The ChatGPT-generated text indicated that:
from PIL import Image
img = Image.open('input.png').convert('RGB').resize((96,64))
with open('output.mem', 'w') as f:
for y in range(64):
for x in range(96):
r, g, b = img.getpixel((x, y))
rgb565 = ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3)
f.write(f"{rgb565:04X}\n")
ChatGPT generated the OpenCV Python code did not work. The code above worked better using the Pillow Library. In addition, I also noticed that JPG files worked better, so the white background gets generated as well. I handled this issue in the Verilog code. I also modified the Python script to cater to different-sized image files.
- When prompted with “My pmod oled is configured that way. i need to load this sprint mem file into the display how do I do that“. The ChatGPT-generated text indicated You need to convert the sprite (stickman, ball, etc.) into a memory file (MIF/HEX) that can be loaded into FPGA Block RAM (BRAM). Now, load the sprite.hex file into Block RAM. Verilog ROM Module for Loading Sprite Data
module sprite_rom (
input clk,
input [12:0] addr, // Address range (96x64 pixels / 8 = 768 bytes)
output reg [7:0] data
);
reg [7:0] memory [0:767]; // 768 bytes for 96x64 pixels
initial begin
$readmemh("sprite.hex", memory); // Load sprite into BRAM
end
always @(posedge clk) begin
data <= memory[addr]; // Read 8 pixels at a time
end
endmodule
ChatGPT generated the module I had to use to load a single memfile into the Verilog project. I figured out how to use this module in my TopStudent module. Using this, and a bit of tweaking. I managed to generate the various static elements required for this project. The original idea of just using circles and squares would have made the graphics look less appealing.
- When prompted with “Is my collision logic between ball and player wrong?”. The ChatGPT-generated text indicated that “Yes — your collision logic for ball_hits_left_player and ball_hits_right_player currently uses || (OR), which will trigger even when only one side of the ball overlaps with a player's bounding box. This can lead to false positives for a "hit." To check if the ball actually intersects the paddle, you should use AND (&&) logic to check that both the X and Y bounds overlap.”
- When prompted with “why do players sometimes still overlap mid-air?”, Chat-GPT indicated “Right now, your logic allows each player to independently update their Y position, based on the current state. But here's the catch: These updates happen simultaneously in the same clock cycle. So both players might decide they’re not overlapping before they move. But after they both move together, they end up overlapping, because each one assumed the other wouldn't move. This is a classic race condition in discrete-time simulations.” This inspired me to look for solutions to check if players will collide in the next positive edge given that they both move, instead of with the assumption that they are stationary.