cpld

Programmable logic devices have claimed their place in the hobbyist world, with more and more projects showing up that feature either a CPLD or their bigger sibling, the FPGA. That place is rightfully earned — creating your own, custom digital circuitry not only adds flexibility, but opens up a whole new world of opportunities. However, this new realm can be overwhelming and scary at the same time. A great way to ease into this is combining the programmable logic with a general purpose MCU system that you already know and are comfortable with. [Just4Fun] did just that with the CPLD Fun Board, a development board connecting an Arduino compatible STM32F103 Cortex-M3 controller to an Altera MAX II CPLD.

The PCB itself has some standard development board equipment routed to the CPLD: LEDs, buttons, a seven-segment display, and additional GPIO. The rest of the CPLD’s pins are going straight to the STM32 and its SPI, I2C and UART pins. Let’s say you want to create your own SPI device. With the CPLD Fun Board, you can utilize all the pre-existing libraries on the STM32 and fully focus on the programmable logic part. Better yet, every connection from MCU to CPLD has its own pin header connection to attach your favorite measurement device for debugging. And in case you’re wondering — yes, you can attach external hardware to those connectors by setting either MCU or CPLD pins to Hi-Z.

The downside of all this is the need for proprietary design software and a dedicated programmer for the CPLD, which sadly is the everyday reality with programmable logic devices. [Just4Fun] did a great job though writing up a detailed step-by-step tutorial about setting up the environment and getting started with the board, but there are also other tutorials on getting started with CPLDs out there, in case you crave more.

[EvilTim] dug deep into a classic system to finally give the Game Gear a proper video output. The Game Gear was Sega’s answer to Nintendo’s Gameboy. Rushed to market, the Game Gear reused much of the hardware from the very popular Master System Console. The hardware wasn’t quite identical though – especially the cartridge slot. You couldn’t play Game Gear games on a Master System, and the game gear lacked an AV output, which meant gamers were stuck playing on a small fluorescent backlit LCD screen.

[EvilTim] wanted to play some of those retro titles on a regular TV using the original hardware. To accomplish this he had to start digging into the signals driving the Game Gear’s LCD. The Master System lineage was immediately apparent, as Game Gear’s LCD drive signals were similar in timing to those used to drive a TV. There was even a composite sync signal, which was unused on in the Game Gear.

[EvilTim] first designed a circuit using discrete ’74 series logic which would convert the LCD drive signals to SCART RGB. Of note is the construction technique used in this circuit. A tower of three 74HC374 chips allows [EvilTim] to create R, G, and B outputs without the need for a complex circuit board.

As pretty as a three-story chip tower is, [EvilTim] knew there was a better way. He re-spun the circuit with a 32 macrocell CPLD. This version also has an NTSC and PAL video encoder so those without a SCART interface can play too. If you’re not up to building your own, [EvilTim] sells these boards on his website.

We’ve seen some incredible retro gaming hacks over the years. From a NES inside a cartridge to incredible RetroPi builds. Hit the search bar and check it out!

When it was released 20 years ago, the Sega Saturn was by far the most powerful video game console available. It was a revolutionary device, had incredible (for the time) graphics, and a huge library of IP Sega could draw from. The Saturn was quickly overshadowed by the Sony Playstation, and soon these devices found themselves unused, unloved, and fetching high prices on the collectors market.

After finding a Sega Saturn on a trip to Japan, [jhl] decided he would like to write some code for this machine. Unlike earlier consoles, where Flash cartridges are readily available, or later consoles, where writing directly to the on-board storage is easy, bringing up a development environment for the Saturn isn’t easy. The best method is installing a mod chip and working off of burned CDs. Instead of writing a game or two for the Saturn, [jhl] got distracted for a few years and developed an optical drive emulator.

According to [jhl], the design of the Sega Saturn is tremendously complicated. There’s an entire chip dedicated to controlling the CD drive, and after some serious reverse engineering work, [jhl] had it pretty much figured out. The question then was how to load data onto the Saturn. For that. [jhl] turned to the internal expansion port on the Saturn. This internal expansion port was designed to accept an MPEG decoder card for playing video CDs on the Saturn, but the connector presents the entire bus. By attaching a Game Boy Flash cartridge, [jhl] was able to dump the ROM on the CD controller.

With a little bit of work, a fast ARM microcontroller, and a CPLD for all the logic glue, [jhl] was built an adapter to push CD data to the Saturn through this internal expansion port. Not only is this a boon for homebrew Saturn development, but this build also completely replaces the CD drive in the Saturn – a common failure point in this 20-year-old machine.

The formal release for this ultimate Saturn crack isn’t out yet, but it’s coming shortly, allowing anyone who still has a Saturn to enjoy all those very blocky games and develop their own games. You can check out a short, amateur documentary made on [jhl]’s efforts below.

We have talked about a whole slew of logic and interconnect technologies including TTL, CMOS and assorted low voltage versions. All of these technologies have in common the fact that they are single-ended, i.e. the signal is measured as a “high” or “low” level above ground.

This is great for simple uses. But when you start talking about speed, distance, or both, the single ended solutions don’t look so good. To step in and carry the torch we have Differential Signalling. This is the “DS” in LVDS, just one of the common standards throughout industry. Let’s take a look at how differential signaling is different from single ended, and what that means for engineers and for users.

Single Ended

Single Ended: TTL, CMOS, LVTTL, Etc.

Single Ended and Sources of Noise

Collectively, standards like TTL, CMOS, and LVTTL are known as Single Ended technologies and they have in common some undesirable attributes, namely that ground noise directly affects the noise margin (the budget for how much noise is tolerable) as well as any induced noise measured to ground directly adds to the overall noise as well.

By making the voltage swing to greater voltages we can make the noise look smaller in proportion but at the expense of speed as it takes more time to make larger voltage swings, especially with the kind of capacitance and inductance we sometimes see.

Differential

Enter Differential Signaling where we use two conductor instead of one. A differential transmitter produces an inverted version of the signal and a non-inverted version and we measure the desired signal strictly between the two instead of to ground. Now ground noise doesn’t count (mostly) and noise induced onto both signal lines gets canceled as we only amplify the difference between the two, we do not amplify anything that is in common such as the noise.

If you read my first post about a simple CPLD do-it-yourself project you may remember that I seriously wiffed when I made the footprint 1” wide, which was a bit too wide for common solderless breadboards. Since then I started over, having fixed the width problem, and ended up with a module that looks decidedly… cuter.

To back up a little bit, a Complex Programmable Logic Device (CPLD) is a cool piece of hardware to have in your repertoire and it can be used to learn logic or a high level design language or replace obsolete functions or chips. But a CPLD needs a little bit of support infrastructure to become usable, and that’s what I’ll be walking you through here. So if you’re interested in learning CPLDs, or just designing boards for them, read on!

[Antti] has gained a bit of a reputation over on Hackaday.io – he has a tremendous number of FPGA projects on hackaday.io, and they’re all open source. If you’re looking for street cred with FPGAs, [Antti] has it. His Hands-on experience with FPGAs and CPLDs stretches back to the very first chips in the 70s. We’re so happy that he’s working to share this depth of knowledge, and that includes this talk he gave a few weeks ago at the Hackaday SuperConference. Take a look and then join us after the break for an overview of the FPGA terrain, then and now.

[Kodera2t] wanted to experiment with programmable logic. Instead of going with an FPGA board, he decided to build his own CPLD (complex programmable logic device) board, with a built-in programmer. The CPLD is a Xilinx 9536 which is inexpensive and, though obsolete, still readily available. The programmer for the board uses an FT232RL and the total cost is very low ([kodera2t] says it is in the price range of a Raspberry Pi Zero or about $4).

From a user’s point of view, a CPLD is just a small FPGA. Internally, there is a significant difference in how they implement your design. Although there are differences between different product families, CPLDs usually use a sea of logic gates arranged as an AND/OR chain. By feeding inputs and inverted inputs into the AND gates and then ORing the results, you can build interesting logic circuits. However, modern CPLDs use Verilog or VHDL, so you describe what you want just like with an FPGA and the software figures out how to use the underlying circuits to give you what you want.