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.

Tuesday, 3 April 2018

HsQML released: Cabal Armageddon

For some years now, HsQML* has been accumulating an increasingly complex pile of Template Haskell in its Setup script in order to accommodate all the API changes since Cabal 1.14. It couldn't last forever and indeed Cabal 2.0 has finally delivered a blow to what must have at least been a contender for the title of "world's most arcane Setup.hs". Not a fatal blow mind you, but let's say that it's less complicated than it used to be.

Last September, I very quietly released version of HsQML which, among
other things, used the new setup-depends feature to try and stem the tide and force building the Setup script against Cabal 1.24. However, the even newer release made last week finally adopts the Cabal 2.0 API and does away with Template Haskell. Hurray!

There are a number of other minor fixes in these two releases, mostly adjusting for newer versions of Haskell tools and libraries.

* For the uninitiated, HsQML is a Haskell binding to the Qt Quick user interface toolkit.

release- - 2018.03.28

 * Fixed building with Semigroup/Monoid changes in base 4.11 (GHC 8.4.1).
 * Fixed crash if setDebugLogLevel called before other functions.
 * Fixed GHCi cbits library install location.
 * Changed Setup script to use Cabal 2 API only.
 * Relaxed Cabal constraint on 'QuickCheck'.

release- - 2017.09.08

 * Added facility for setting Qt application flags.
 * Fixed building GHCi objects with Cabal 1.24.
 * Relaxed Cabal constraint on 'QuickCheck' and fixed test suite.
 * Relaxed Cabal constraint on 'directory'.