This entry is a post to myself as to how I did this project. It’s of very limited value to anyone else unless you happen to WANT to drive a bunch of LEDs with a CPLD.
My last “learning” project was to implement a 32 bit register on the CPLD and allow various operations such as shifts/rotates/and/or, etc. I had quite a few operations implemented for the 8 bit version, but the 32 bit version was too large for the MAXII CPLD I’m using, so I pared the operations back to just shifts and rotates since they are more interesting visually.
I use a Teensy 3.1 to communicate with the CPLD. The teensy is 3.3V, so it works perfect. I use I2C to send commands from the teensy to the CPLD. The teensy can also toggle the reset line and watch the busy line to determine when the CPLD is ready for the next command.
Lastly, the teensy provides a second clock to the CPLD (the primary clock is a 50MHz clock that is on the dev board). This second clock is used to time the shifts and rotates. I read a pot and determine the secondary clock’s speed from that. This allows the user to change the speed of the secondary clock dynamically.
Here is the device in operation:
Having spent most of my life programming, it was a struggle to get my head around VHDL. It looks like Pascal and you just want to do what you would do in Pascal, but even if it works, it could generate so much hardware you can’t get it to fit on the CPLD.
Here are the VHDL files for the CPLD, the C program for the Teensy, and a connection diagram: