Tuesday, October 10, 2023

VHDL Character Generator

The bitmap was saved to 80x60 at 8bpp, allowing the pixel values to index character tiles from a character generator ROM in VHDL. This design slightly improves on my previous project by accounting for the clock delay incurred with the registered address into the BRAM. 

It's not a very good picture, using an old USB capture device which actually goes from VGA through a converter to analog video before it hits the USB device. Cell phone camera will take a better picture.

The tile calculation formula maps an 80x60 tile display of 8x8 character tiles to a 640x480 VGA display. The present design is far from optimized and uses integer math to convert the pixel scan location to a tile address in the simulated VRAM. The synthesis tool infers a DSP to implement a multiplier. The Vivado DRC (design rule checker) flags this DSP implementation with warnings which I would like to eliminate. 



Monday, September 4, 2023

VHDL Bitmap Rendering


This is a brief overview of using VHDL to render bitmap images on a VGA display. It is far from being a complete tutorial on working with VHDL. The presentation was developed using the Xilinx Vivado suite, targeting the Arctix A7 FPGA on the Digilent Basys 3 development board.
 

My first experiment with rendering a bitmap image from an FPGA device was based on using the builtin file I/O operations available in VHDL. In VHDL it is possible to read the content of a bitmap image from a file, parse the bitmap header to obtain the layout of the image (height, width, color encoding etc.), and then populate a ROM entity in VHDL with the bitmap data, and of course build a VHDL circuit around that ROM to render the image to a VGA display. Turns out that this method really slows down the synthesis operation, and even the small image shown above requires several minutes to generate a bitstream for programming the FPGA. However it is quite interesting to see the capability of VHDL code being used not just to describe digital logic circuits, but for "mundane" operations such as file I/O!

For the purpose of designing microprocessor based systems in VHDL, one will no doubt want to write a program for the target CPU, and then have a means to infer a ROM in the VHDL design containing the image of the compiled code. For example, the t80 distribution has a utility program provided by the author called hex2rom that can take a source hex or binary image and generate a suitable VHDL entity. hex2rom works just as well to convert a bitmap file to VHDL and provides options to specify the basic necessary attributes such as endianness, address width and so on. 

First significant problem encountered has to do with using hex2rom to generate ROM in synchronized mode. In many cases, the sync ROM is more desirable as it is more likely to infer a Block RAM. However, hex2rom registers the ROM address internally, which causes the ROM to output a pixel data that is 1 clock behind the screen row/column address from which the pixel address input to the ROM was calculated. Before:


After many days, finally realized from running the simulation what was going on. The fix is to add 1 to the allowed column range of the image enable signal in each scan-line, forcing the image display logic to sync with the actual pixel data coming out of the ROM.  


Hard to explain in words, more details to come. And that's not the last problem to be solved. We also find that Vivado is spewing a lot of warnings related to the BRAM that the synthesis tool has inferred.


In relatively small and simple circuits these warnings can possibly be ignored and the circuit ends up working as intended, but the cause should be understood and corrected. In this case, the tool doesn't think that the address inputs to the inferred BRAM are properly synchronized (the Xilinx Synthesis Tool guide or similar documentation provide a lot of information on how to setup your design to infer properly working BRAMs, without incurring a bunch of DRC warnings!).

Friday, January 24, 2020

pgge: new animation controller

The new animation capability is just kind of hacked in right now. The important part is that the physics body of the rigs now provided by btCompoundShape. This allows me to manipulate the mesh of individual model nodes within the model instance, and then they are magically synced up with bullet so that the collision detection is true to the dynamically changing mesh body. See video!



Wednesday, December 18, 2019

Pretty Good Game Engine is 2 Years Old!

Has a few more features since then ...

  • Pause menu
  • Loading screen
  • Gamepad on Android
  • Bad actors
  • Player can  shoot at and kill some things and even get some points for doing it
  • Prize pickups


Monday, November 11, 2019

Before and after adjust internal edge contacts filtering edge collisions of btvhTriangleMesh


Wednesday, December 26, 2018

Fixed memory leak in pgge

Nasty memory leak has been present for the last 10 months! It was found by running on the Android device, after about 10 minutes the fireworks start:

D/dalvikvm: GC_FOR_ALLOC freed 3603K, 14% free 31246K/36280K, paused 176ms, total 176ms
D/dalvikvm: GC_FOR_ALLOC freed 3585K, 14% free 31666K/36684K, paused 183ms, total 183ms
W/Adreno-GSL: : sharedmem_gpumem_alloc: mmap failed errno 12 Out of memory
E/Adreno-GSL: : GSL MEM ERROR: kgsl_sharedmem_alloc ioctl failed.
W/Adreno-GSL: : sharedmem_gpumem_alloc: mmap failed errno 12 Out of memory
E/Adreno-GSL: : GSL MEM ERROR: kgsl_sharedmem_alloc ioctl failed.
A/libc: Fatal signal 11 (SIGSEGV) at 0x61860398 (code=2), thread 25200 (Thread-2710)
Application terminated.


If one had been paying any attention to the Android console log, it would have been evident that the GC is staying WAY too busy! Creating new instances at every render will definitely leak away the memory! Several hours to find the issue, only a minute to fix it

Tuesday, December 18, 2018

Pretty Good Game Engine is 1 Year Old!

One year ago I started a new github repo, a new programming project using libGDX.

The purpose of the pgge project is to demonstrate the libGDX 3D API and Bullet physics integration in a 3D game engine.

The project is developed using Android Studio for Java development, and Blender to create 3D models. Thanks to libGDX multiplatform capability, the program can be run on an Android device or on PC desktop.

Hope someone has a chance to check it out!