Monday 7 May 2018

Front Panel Components for Logisim

Over the last decade, low-cost programmable microcontrollers (e.g. Arduino) and small embedded systems (e.g. Raspberry Pi) have popularised electronics as a hobby. I think a big contributing factor is that, as components have become more integrated, designs that once would have required complex circuitry have become programs that you can just download onto a chip. While still something of a niche, programmable logic takes this even further. Circuits themselves are designed in a form of code, not unlike writing software, and downloaded into hardware wholesale.

I used to work for Altera, one of the big manufactures of Field Programmable Gate Arrays (before it got swallowed up by Intel). I've spent a lot of time working with programming logic and all this technology is undoubtedly great, but I will admit to feeling a little bit jaded about writing VHDL. As a hobbyist, some of the appeal of hardware is that it's "hard". Real, physical, and tangible. When it comes to fun, downloading stuff onto a programmable chip doesn't quite do it for me.

My personal hero is this respect is Bill Buzbee for creating the Magic-1. A computer constructed out of 74 series logic chips. As in, even the processor is constructed out of discrete logic wired together. What's even more impressive is that he re-targeted the lcc C compiler to the custom instruction set of his creation, and then ported Minix to run on it. On a good day, you can even browse a web site hosted on the machine itself. I have to admit, to me the thought of electrical impulses making their way from pin to pin in response to my HTTP requests is more marvellous to imagine than the same thing at the microscopic scale of a contemporary microprocessor.

Anyway, the above is all just background to my desire to walk in Bill's (and every other member of the Home-brew CPU Web-ring's) footsteps. I've been working on designing a somewhat more modest system in the open-source logic simulator Logisim. Rather than a fully internet connected Unix machine, I'm aiming for something more akin to an oversized Gameboy. One of the key peripherals is a 16 by 16 element RGB LED matrix, but Logisim's built-in Dot Matrix component isn't quite sophisticated enough for this.

Fortunately, Logisim allows you to extend it with new components written in Java. I've created a new component library called Logisim Front Panel to contain any additional components I need for my simulation. At the moment, this just consists of a RGB Matrix component, but I plan to at least add an RGB 7 Segment display with similar capabilities. You can download a pre-compiled JAR file here.

RGB Matrix Example 1
The above animated GIF shows the RGB Matrix in action. A counter is used to cycle through the lines while adjusting the bit-pattern at the colour inputs. A property of the human visual system called flicker fusion means that although, in real hardware, only one line is illuminated at the time, we perceive a complete image which accumulates the light received over time.

It takes 256 simulation ticks for the counter to cycle through completely and this is set as the value for the Fusion Window attribute on the RGB Matrix component. You can see the image being built up over the first cycle and it remains stable thereafter. As there are 8 lines, a given pixel can only be active for at most one 8th of that. Hence, the Maximum Duty attribute is set to 32 ticks. The variation in colour across the matrix is created by different pixels being illuminated between 1 and 32 ticks in a window.

The circuit is available in the examples directory of the distribution. More details about the actual machine to come in a future instalment.