Carpe Diem

Whilst motoring gently along the River Wey, there is plenty of opportunity for reflection. As the narrowboat travels at a maximum of 4mph, it’s not unusual to step off the boat and walk along the towpath for a mile or so, rejoining the boat at the next lock. These towpath walks allow a break from the tiller and a time to think, figuratively, where we are going.

The exceptional warm weather in mid-September was a welcome surprise after the unsettled August. I have a birthday in mid-August, and over the years I have memories of torrential downpours, thunder and lightning, and in 1979 I was under canvas during the storm that led to the Fastnet Disaster.  Equally, I remember that September has often brought fine weather, usually just around the time the school year was starting. A school trip to Stratford upon Avon in 1980 to pick up some Shakespearean culture, coincided with a week of fine weather – an Indian Summer.

As Brits, we always have something to say about the weather. Often you start a conversation with a stranger with a comment about the weather. Britain gets most of its weather from the west, and is subject to the vaguaries of Atlantic fronts. As such, we seldom get two days alike – apart for the exceptions, such as last week, when we do. We are a nation that has become obsessed with the ever changing weather: “Will I need an umbrella?” “Will the outdoor event at the weekend be cancelled?” “Will it clear up this evening so we can have a barbeque?”  These clearly are short term concerns – because we all know that tomorrow normally the weather will be different.

Perhaps the conversation that we should be having is that of Climate Change, its imminent arrival and its long term consequences. It will take more than an umbrella to save us from the effects of global change.

As I walked the towpath, bright and sunny, but still with the early morning chill, the last wisps of mist hanging over the river, I was reminded that we will soon be into Autumn, and the requirement to turn the home heating on. Not a worry, we have gas central heating, backed up with a wood-burning stove – we will be warm and comfortable. What will happen over the next 20 years as we aim for decarbonisation of our power sector and running our economy for carbon-neutrality?

Britain has some of the poorest-built housing stock in Western Europe.  New houses are being built that are still woefully below the insulation requirements, demanded by decarbonisation of the energy sector. 60% of our housing stock was built before 1960 – about 14 million dwellings. Many of these are terraced or semi-detached and are difficult and costly to effectively insulate. The country would need to spend seven hundred billion on a national program of building improvement, just to bring the older housing stock up to an acceptable standard of insulation and energy efficiency.

The global automotive industry has finally woken up to the need to replace the world’s vehicle population with those powered by electricity, instead of perpetuating the internal combustion engine. New models have been announced from several manufacturers including Mini, BMW, VW and Renault. The Mini Electric, recently featured on “Fully Charged” begins at £25000 with Government discount. Hopefully within a few years these vehicles will become truly affordable, as it is anticipated that all new vehicles sold by 2040 will be electric. The UK currently has about 32 million cars on its roads, of which only 212,000 are plug-in hybrid or pure electric – since sales took off with the Nissan Leaf in 2011. However, with fewer than 1 in 150 vehicles running on electricity, we clearly have a long way to go.

It will take much more than better insulated homes and electric cars to fix the multiple-crises on the horizon. Climate Change, sea levels rising, loss of rainforest and bio-diversity and food-security to mention just a few.  Our current politicians are incapable or unwilling to make the decisions needed. Left to the “free market” we will achieve nothing. What is needed is needed is a Government that can seize the day, formulate a long term plan and unite the country – so we can all work together to fix this mess. When the Thames starts lapping around the Houses of Parliament and flooding the City of London – we will know its all too little, too late.


Posted in Uncategorized | Leave a comment

Thoughts from the Towpath

Part 1 – The Adventure Begins……

There are few opportunities in our busy lives, to take some time off the day job and spend the time relaxing with friends.  Even more infrequently do those days align perfectly with a period of several days of perfect weather in mid-September.

My friends, from California were about mid-way through their European Grand Tour – that would encompass Ireland, UK and France. My role was to choose a uniquely English leisure activity that would keep us all busy for five days in Surrey, before they departed by channel ferry and train to visit friends and relations in Paris.

By chance, the September edition of Canal Boat magazine, featured an article about cruising on the River Wey between Godalming and Pyrford, and so over a meal with another couple of mutual friends, we decided to rent a narrowboat for four nights and see where it would take us.

The River Wey was one of the first rivers to undergo significant man-made improvements to allow the easier passage of cargo carrying boats, between Guildford and Weybridge, where it meets the River Thames. This work was completed in 1653 – a full 100 years before much of the canal network was constructed.  Barges carried milled flour, corn, iron and timber from Surrey and Sussex up to the ever expanding London, and brought coal and other heavy goods back to market town of Guildford – which at that time was a settlement of only 1500 people.

There is nothing fast about narrowboating. If you have to do something fast, then your are probably inexperienced and doing it wrong. The speed limit on our waterways is set at 4mph – equivalent to a brisk walking pace. But you will never cover four miles in one hour, there are locks to pass through, and these at worst case may take 20 minutes, sometimes longer if there are fellow boaters ahead of you, and you need to wait your turn.  So, at best, you may travel 2 miles in any hour, and you will have all that extra time to take stock of all around you and think about where you are going.

We had a rough plan to leave the boathouse at Farncombe on the Monday afternoon, travel about 10 miles down stream to Pyrford lock, which we hoped to reach by Wednesday lunchtime. Then we would turn the boat around and sail back with the aim of handing the boat back by 9am on Friday morning.  The course of the River Wey is conveniently punctuated by riverside pubs, and these would serve as way-points and refreshment stops.

On route we encountered a couple of locks, that fortunately were already full from the last passing vessel and so we could sail right in. With locks set in one’s favour, the process is quite simple. If you have to wait to refill a lock, or you are accompanying another vessel through the lock, the process needs a bit more co-ordination and co-operation.  You very soon learn the rudiments of lock-etiquette

By Monday evening we had reached The Olde Ship Inn which is just to the south of Guildford, close to St Catherine’s Hill. It’s a short walk up a steep lane, Ferry Lane, which leads up from the towpath close to the footbridge that carries the Pilgrim’s Way across the river. Here we met up with our other two friends who would be joining us for a couple of nights, and part of the voyage – as work commitments would allow for.  We found a genuinely old fashioned pub with exposed timber beams and timber panels neatly dividing the interior into a few small rooms. The five of us grabbed a large table in the corner and studied the menus. They served an excellent home made pizza, and after eating more than our fill, we rollicked down the hill, contented with good food, wine and beer.

St Catherines Hill is a low sandy mound on the bank of the Wey.  A ruined chapel, St. Catherines dates from the early 14th century, and is depicted in a painting by Turner from 1808 which is now in the Tate Gallery. (Wikipedia)

Tuesday morning began early, as I had forgotten to cancel my 6:15 weekday alarm on my mobile.  An eerie mist had descended upon the river, and highlighted the sunbeams as the sun rose through the trees around 7am.   First up, and also because I was sleeping in the galley area meant that I was on tea duty, and with the first rays on sun bursting through the boat windows – I felt it would be forgiven if I started clanking around with gas rings and kettles, and the abrupt whir of the fresh water electric pump.

As we breakfasted we were passed by several rowers in their individual rowing sculls, friendly dogs and their walkers and various brisk commuters either on foot or cycling the towpath.

Suitably revitalised with tea and toast, and with the sun fully up over the river, we set off and covered the last mile into Guildford, passing water meadows on the starboard side and expensive waterside properties on the steep riverbank to our port side.

Soon we were entering Guildford with the rowing club on the right and the Millmead lock approaching us. Millmead lock was empty, and not set in our favour, so we had to tie-up just upstream and refill the lock.  Unfortunately there is a weir to the side of the lock, and the river current flowing over the weir made manouvering difficult. Regardless of engine or tiller, our bow was being pulled towards the weir.  I resorted to the large boat-pole and somewhat awkwardly punted the bow back towards the jetty so that the bow-line could be secured.

Millmead Lock was our first challenge – not only did we have to go through the whole cycle of fill and empty, but we had a few onlookers including ducks and inquisitive (or hungry) swans.

We pottered into the centre of Guildford and moored up alongside a row of converted old warehouses. A suitable mooring whilst we went shopping for supplies including the essential coffee that my American friends were already twitching for.  We dived into a Wetherspoons for a quick caffeine fix, before exploring the High Street and then reprovisioning at the conveniently located Tesco Express.


Posted in Uncategorized | Leave a comment

Back to BASICS

In March of 2017, I began to follow a project on for a microcomputer constructed entirely out of common TTL integrated circuits.  TTL stands for transistor-transistor logic, and appeared first in the very late 1960s.  Several of the iconic minicomputers of the early 1970s were constructed from TTL integrated circuits – including the Data General Nova and the DEC PDP-11. Remarkably the descendants of this family of logic devices are still available today, using modern high speed CMOS process so that they are much faster yet consume a lot less power.  In real terms they are also a lot cheaper than they were –  with typical devices costing between $0.50 and $1.00.

The Gigatron TTL Microcomputer has evolved from the breadboard computer featured in Hackaday.  It was released as a DIY soldering kit last March and could play simple video games – typical of the late 1970s and early 1980s.  It has 64 colour graphics and sound similar to the Acorn Electron or Sinclair Spectrum which appeared at that time. However, all of these features are done completely without a microprocessor – all of the control logic, arithmetic and input – output is done using readily available TTL chips.

Gigatron uses just 35 TTL chips – and these ate simple logic functions such as counters, multiplexers, decoders, registers and adders. There is nothing used here that would not have been available back in 1975.  However Gigatron does take advantage of decades of memory evolution, and uses modern ROM and RAM chips- which would have been very expensive – but now available for just a couple of dollars each.

Gigatron produces a 64 colour video signal that can be displayed on any  VGA compatible monitor.

The Gigatron kit contains all the components you need to make a fully fledged computer – and sells for under $200.  Full details are available on the website. There is a User forum – linked from the Gigatron website.

In the last year,  the Gigatron has benefited from both hardware and software upgrades. Today I received by post the new V3 ROM which includes a BASIC interpreter and a small adaptor pcb, which allows you to use a PS/2 keyboard with the Gigatron.

Writing in BASIC takes me back about 40 years to when I first encountered microcomputers at high-school.  It’s an easy language to learn and opens up the architecture of the Gigatron for further exploration.

Whilst relatively simple in hardware terms, there is considerable sophistication in the software which allows it to perform the colour graphics and sound. Fundamentally it is an 8-bit Harvard architecture, executing native machine language out of ROM, but on top of this is built a 16-bit Von Neuman virtual machine – which executes code out of RAM – whilst seamlessly taking care of all of the critical video timings.

The virtual cpu – or vCPU has just 34 core instructions which allow 16-bit operations to be performed.  These operations execute in typically 14 to 28 clock cycles (6.25MHz clock) – but nevertheless are still about 5 times the performance of a 6502 or Z80 – which were the usual choice of microprocessor in the late 1970s and early 1980s.  Indeed the Gigatron is even faster than the first IBM PC of 1981 – although it cannot address as much memory.

There is scope to increase the clock speed of the Gigatron possibly to 16 or 20MHz- and I am currently doing some experimentation  – which will become the subject of a future post.

I am also intrigued with the possibility of developing a Forth-like language based on the 34 instructions of the vCPU. Like the old days of BASIC – the interpreted language would be self-hosted on the Gigatron – and not rely on modern PCs, python or sophisticated tools for its development.









Posted in Uncategorized | Leave a comment

When all you have is a hammer…….

Last weekend I attended a retro-computing fair at the Centre of Computing History in Cambridge.  This was my first visit to this popuar museum and I was impressed by the range of exhibits that they had on show.

35 years ago – Cambridge was buzzing with computer activity – and it was home to at least two of the prominent home computer companies in the early 1980s – Acorn and Sinclair.  Machines of this era were on prominent display throughout the museum.

I got my first computer around this same time – a ZX81 which I built up from a kit – following a price reduction – in the Spring of 1983, the ZX81 was very much being superseded by more sophisticated hardware such as the Spectrum, the BBC Micro and a plethora of other 8-bit machines.  It cost me £39.99, at a time when £40 was a week’s wage in a summer job, to a sixth former.  I still have it – or most of it, a surviving keepsake, when many other bits of more sophisticated electronic hardware have long since been junked.

When all you have is a Z80 – everything needs to be solved with Z80 code……….

The early 1980s machines were relatively unsophisticated and we learned how to get the most out of them with clever coding and a bit of ingenuity.   Slowly the IBM PC and it’s clones became the dominant machine in the office, and computing changed forever.

In the early 1990s, my job involved designing pcbs using ORCAD.  For Autumn 1990 to Spring 1991, I pushed tracks around the screen using a ‘286 machine clocked at 25 or 33MHz.  I don’t remember the job being particularly arduous or slow – but then we barely had Windows – and the PCs would really only run a single application at a time. There was no Internet, no distractions and no social media interrupting your thought processes every 20 seconds.

Now we are surrounded by microcontrollers of all sizes, and electronic hardware has never been cheaper – our daily lives revolve around staring into LCD screens – both big and small – we have become addicted to checking our phones and our social media apps – in the hope that something interesting is happening elsewhere.

But I digress….. I’m here to write about a revolution in open source hardware.

Last year, Alan Wood and I, designed an FPGA dev board around the Lattice ICE40 device.  This was our first venture into open source FPGA hardware – very much triggered by Clifford Wolf’s open source FPGA toolchain “Project IceStorm”.

We put together the combination of a low cost ARM microcontroller and an easily programmable FPGA.  We wanted to create a platform that was interesting from a hardware perspective  and one that could readily be expanded. And so “BlackIce” was created.

Returning to the retro-computing fair,  I was fortunate enough to be able to demonstrate some retro machines, created by community member David Banks running on our BlackIce hardware.

The following designs are now available from David’s github repository:

  1. Acorn Atom (6502)
  2. BBC Micro Model B (6502) with BBC BASIC
  3. Jupiter ACE (Z80A with FORTH)
  4. CP/M Platform – Z80A with either serial terminal connection or colour VGA /PS/2 Keyboard

David has included binary files for each of these designs that need to be programmed into the STM32L433 using DFU-UTIL. These binary files contain the ROM data and make the design file “sticky” – i.e. resident in the STM32 flash – so on power on the FPGA boots to whichever retro computer you have chosen.

For each of these designs you will need a Digilent VGA pmod (£8.99 from Farnell


Connecting VGA and PS/2 Keyboard using standard Digilent pmods

This plugs into Pmods 7/8 and 9/10.

You will also need a PS/2 keyboard – which requires a trivial adaptor (4 resistors) plugged into Pmod 11/12 or can be bought from Digilent here:

You will see from the datasheet for the PS/2 connector – that it is a very simple circuit.

Below is our display at the Centre for Computing History – with the BlackIce board hosting a BBC B running a sphere demo in BBC basic.BBC_retro_sphere








Posted in Uncategorized | Leave a comment

Arduino meets open FPGA


BlackIce Open FPGA – Includes an 80MHz “Arduino”

Arduino is the Marmite of embedded programming – you either love it or hate it.

Regardless of how you feel about it – Arduino in the last 12 years probably has introduced more people to embedded programming of microcontrollers than any other organisation. What started with the humble AVR ATmega8 in 2005 has grown to include a multitude of different microcontrollers. and devices.

Initially the Arduino IDE handled only Atmel AVR microcontrollers – but with the addition of the Arduino Due board, it has opened up to include ARM devices – including parts by Atmel and ST Microelectronics.  To allow this to work the GCC toolchain for ARM has been integrated into the Arduino IDE along with the necessary “board files” and hooks to the various programmer devices.

In late August I noted that the STM32L4 parts had been brought into the fold – by way of the “Butterfly” boards which use the STM32L433.  This is the same microcontroller that we use on the current generation of myStrom BlackIce FPGA boards – and to have this part readily programmable from within the Arduino ecosystem will open up a whole new set of possibilities for the BlackIce board.

The STM32L433 brief specification:

64 pin low power ARM M4 Cortex microcontroller
256Kbytes of flash memory, 64Kbytes of SRAM
80MHz clock
USB 2.0 Full speed interface
11 timers
Capacitive touch interface
12 bit 5 MSPs ADC
2 x 12 bit DACs
SPI and Quad SPI

The full datasheet

Whilst my initial efforts in late August allowed me to program the STM32L433 from within the Arduino IDE using the “Butterfly” board file, it was going to take further work to create a custom board file for our BlackIce pcb.

Following on from the Hebden Bridge “Wuthering Bytes” festival in early September, our programmer friend Richard Miller has now created the necessary board file and Arduino platform support for BlackIce – and so all of the peripheral features and GPIO are now accessible via Arduino library functions.

Instructions for configuring the Arduino IDE and more details of the accessible GPIO signals are included on Richard’s Github repository.

This framework includes the DFU-UTIL program – which allows you to bootload the STM32 from within the Arduino IDE. Here are a few helpful hints:

  1. First remove the programming jumper from pins 14 and 16 of the Pi connector
  2. Plug the USB cable into the centre microUSB connector
  3. Always press the reset switch before you recompile and program.
  4. Replace the jumper if you want the code to be permanent
  5. If you want to access the UART – use “” in any functions that use the Serial code.

It was not long before I had Blink running, so I decided to load my old favourite – SIMPL. This is a small interactive toolkit that allows you to exercise the hardware via a series of serial commands. You can read about it and find the code on my Github repository .

All appeared to work and soon I had the STM32L433 executing my interactive code.

Finally, as the STM32 is cocked at 80MHz – which is 5 times faster than the standard Arduino, plus it is a 32 bit processor rather than an 8-bit device, out of curiosity, I decided to run the standard dhrystone benchmark test to see how it compares to the regular 16MHz Arduino.

The results were interesting, clearly showing that the 32 bit ARM architecture scores over the 8-bit AVR:

Arduino Uno

Microseconds for one run through Dhrystone: 78.67
Dhrystones per Second: 12711.22
VAX MIPS rating = 7.23


Microseconds for one run through Dhrystone: 8.94
Dhrystones per Second: 111854.70
VAX MIPS rating = 63.66

So on the Dhrystone benchmark – BlackIce is about 8.8 times faster than the regular Arduino R3.

Arduino GPIO Headers

One of the features of BlackIce is that most of the spare GPIO signals from the STM32L433 microcontroller have been brought to Arduino-style female headers.  These allow connection to the analogue ADC, PWM, UART, SPI and I2C lines.  All apart from the six ADC inputs are 5V tolerant. For simple extensions to the BlackIce board – Arduino style shields may be fitted – but preferable if they are of the 3V3 type to avoid 5V reaching the FPGA pins and potentially causing damage.

Serial Terminal connection

BlackIce has a UART to USB converter IC which appears as a CH340 COM port.  It is available on the micro USB connector closest to the bottom left corner of the pcb.  This may be utilised from within Arduino provided that it is referenced as “Serial1”

STM32 – FPGA Interface

The STM32L433 shares a total of 20 signal lines with the ICE40 FPGA.  Some are used to provide the FPGA configuration interface (for FPGA programming) but may be re-used at runtime.

The signals are arranged into the following groups.

SPI Interface:    MOSI, MISO, SCLK, SS

Quad SPI Interface:  QD0,  QD1, QD2, QD3, QCS and QCK

GPIO Interface:    Dig 16, Dig 17,  Dig 18, Dig 19 (Slide switches)  B1, B2 (Buttons)

UART Interface:   TX , RX

Misc Controls:      RESET, DONE

All of these with the exception of RESET and DONE appear on the FPGA as GPIO and may be repurposed as required.

Posted in Uncategorized | Leave a comment

Splitting the Atom

It’s not everyday that you meet someone with the talent and tenacity of Dave Banks (@hoglet67 on Twitter).  In less than three days, Dave ported his FPGA based Acorn Atom from Xilinx and VHDL across to Lattice ICE40 and verilog. The result is a fully functioning Acorn Atom – running on our latest open source FPGA board, BlackIce.

The Atom was a forerunner of the Acorn Electron and the BBC Micro. It used a 6502 microprocessor an provided a chunky colour display – which was virtually unknown back in 1980 when the Atom first appeared.

On Friday, Dave emailed me to say that he was going to begin to port his Atom design to the BlackIce board – and was looking at the VGA implementation using the recreated Motorola 6847 graphics controller as used in the Atom. However, the 6847 module was written in VHDL and would have to be ported to verilog first – so that it could take advantage of the open source “IceStorm” FPGA toolcain.

Then without warning, on Saturday evening the following two images appeared:


With the help of a few carefully chosen resistors and a hacked VGA cable, Dave had fashioned a VGA output – driving the resistor arrays direct from the FPGA pins. The result was the characteristic Atom “pre-boot” screen – when the video RAM is full of random data.


Within a couple of hours, Dave had achieved the boot screen, connected a PS/2 keyboard and written “Hello World” in Acorn BASIC.

To any casual observer – all of this happened within the short space of Saturday afternoon.



By late Saturday night – and a few tweets on my part – interest was gaining rapidly – and eagerly awaiting part 2 of Dave’s installments.


Dave put up an original Atom schematic – to illustrate the extent of the digital logic that had been implemented within the ICE40 FPGA – and by Sunday evening we faced some Alien Invaders – a port of the famous “Galaxians” game:




It was now Sunday evening and Dave mentioned that he had work out a way to get ROM data into the large external SRAM (256K words) that is closely coupled to the FPGA.  This involved some neat coding tricks – and taking advantage of the flexibility of the BlackIce loading mechanism.

Dave’s progress was soon appreciated by the “stardot” forum – a group devoted  to Acorn retro computers – and very soon, a fellow forum member, Ed Brindley, had implemented a similar Atom – using the BlackIce board and some Digilent pmods  – for the VGA and keyboard.



This all looks like excellent progress – but Dave was like a dog with a bone – he had to solve the issue of using the microSD socket on the underside of the BlackIce board to allow a full repertoire of Atom software to be loaded via SD card.

This latest triumph appeared on Tuesday morning – just 3 days after commencing this mammoth project.

Dave’s write-up of this project appears on the myStorm forum with full technical details – which you may find here




Thanks to Dave for his tireless work in making this happen in such a short space of time.

BackIce will be featuring at @WutheringBytes in Hebden Bridge between September 1st and 10th.

Throughout the week we have talks, workshop sessions and general FPGA geekery goodness.

If you’d like to obtain a BlackIce open source FPGA board – please follow this link – or contact me at ken dot boak at gmail dot com


Posted in Uncategorized | Leave a comment

A Minimum Interactive Language Toolkit

In previous posts I began to describe a minimum interactive language toolkit which could work standalone in virtually any small microcontroller. Here are the following prerequisites I stated in the previous post:

  1.  Interactive – commands may be typed at the keyboard for immediate execution
  2.  Commands can be combined into programs then compiled for later execution
  3.  Extensible – from a small kernel of commands, a whole application can be built
  4.  No external tools required other than a serial terminal – all tools run on chip.

This may appear to be a huge break from conventional wisdom, as virtually all embedded microcontroller development is done in high level C – compiled using a package of tools hosted on a more powerful machine – such as laptop.

Microcontrollers have evolved to have a fairly large proportion of their memory as flash-ROM, and modest quantities of  RAM – so it’s not unusual to find a micro with 32K bytes of flash but only 2k bytes of RAM. Whilst this partition of memory resources is not ideal for interactive languages (more RAM would be nice) – it’s enough to get started.

In the early days of microprocessors – it was commonplace to have a “Monitor” program – which consisted of a few simple commands to allow hexadecimal opcodes to be entered directly into memory and then executed from a given address. Some of these monitor programs also allowed a hex-dump to be sent to a terminal, to examine the contents of memory, plus primitive editing commands.

Typically the monitor would take a few hundred bytes of ROM, but it provided the absolute basics of being able to write machine code. Assemblers seldom existed, given the meager resources of the early home computers, and so a lot of coding was done by hand assembly – using pencil and paper – or by copying hexadecimal listings out of magazines.

What I am proposing here is a program that offers the same low level support as a monitor, but rather than programming in raw Hex or machine language, the User has access to a small instruction set of highly mnemonic commands.  These are executed out of memory by a  generic virtual machine, hosted on the MSP430 microcontroller.

This can be coded in about 562 bytes of assembly language, of which 128 bytes are a 64 entry look-up table. The MSP430 generally dos not have a good code density with an average of around 2.95 bytes being required for each instruction.

The mechanics of this virtual machine are as follows:

  1. Take in a string of serial characters and place in a buffer until the newline character is detected.
  2. Parse through the characters one at a time creating a jump address into a look-up table based on the ascii value of the character.
  3. Numerical character strings are handled by the number routine, forming them into a 16-bit integer which is placed on the stack.
  4. All other characters cause program flow to jump to a table-selected address from where code is executed. Numerical parameters may be used from the stack.
  5. Where appropriate putchar is used to provide serial output of numbers and strings
  6. Jump back to the parser in (1).

The prototype has been coded up in MSP430 assembly language – and is available at the following github repository.

A More Efficient Instruction Set?

Most MSP430 instructions are two bytes,  but moving byte or word constants into registers, byte comparisons and byte subtractions require a further two bytes to hold the constant.  Calls also require the second pair of bytes to hold the call address.

As much of the interpreter is based on the testing and handling of characters and the manipulation of ascii values – it would appear prudent to have a class of instruction that could efficiently handle 8-bit values.  This could be done by allowing an 8-bit immediate value to be coded into the instruction, with a 4-bit field for the source/destination register and a 4 bit instruction.

This becomes a balancing act between a processor that can efficiently handle 16-bit maths operations via registers and still efficiently handle 8-bit immediates. It becomes quite a challenge to shoe-horn this into a 16-bit instruction wordlength, but it’s no different to the challenge that the 8-bit ISA designers had when the immediate was the byte following the opcode.

Last year I reviewed the 8080/Z80 common instruction set based on how they were decoded – and I produced the following image.  Whilst the 8080 and Z80 were 8-bit micros, they did have a small capability to handle 16-bit numbers by way of their register pairs plus a very few 16-bit instructions.  perhaps there could be some inspiration from the 8080 instruction set – for a processor that could handle 8-bit immediates and short jumps – whilst being predominantly a 16-bit machine.


When expressed in octal – and a bit of colour added  – it’s clear to see how the instructions were grouped with the most significant 2 bits defining the class, the next 3 bits defining the operation, and the bottom 3 bits defining the operand(s). It’s a clever bit of encoding – that ensured that almost all of the 256 opcodes did something useful.

If we take the top two bits to define the instruction Group – a very rough description is as follow – where only Group 01 and 10 are entirely regular and defined by the bit fields. Groups 00 and 11 need further decoding to derive their classification.

00  xxx   yyy     – INC, DEC, double ADD, relative jumps etc

01  DST   SRC     – regular source to destination register moves

10  ALU  SRC    – register-accumulator ALU operations ADD ADC SUB SBC AND XOR OR CMP

11  FLG  JMP    – conditional CALL, RET, JMP operations

With Groups 00 and 11 being a bit of a mash-up — it might be possible to re-hash them into something a bit more logical.

A Hybrid CPU.  – Neither Fish- Nor Fowl

The 8080 was based on a modest set of 8 registers that could be combined to form 16-bit pairs  bc, de, hl.  Limited arithmetic was permitted within these pairs – in that they could be added to hl as an accumulator, incremented or decremented.  They could be loaded with immediate 16-bit constants and could be used as indirect pointers for load and store operations to memory.  The hl pair had special preference in that it was used as a memory pointer and any of the other registers could load or deposit through (hl). Push and Pop operations were done on the register pairs.

With 8 registers we have the possibility of creating a small stack – and with a rich, orthogonal set of register to register moves (Group 01), there is little or no requirement to have the usual stack manipulation instructions.  Group 10 instructions allow any register to have math or logical operations done using the accumulator as the destination.  So in theory if the register file were considered to be a pseudo-stack – any of the members could interact with the accumulator – or top of stack.

A machine capable of executing Group 01 and 10 instructions would be fairly versatile – so lets keep these in place.  That leaves manipulating Groups 00 and 11 to provide the other necessary instructions.






Posted in Uncategorized | Leave a comment

Minimal Computing – some more thoughts

This post is concerned with minimal computing – a subject that is close to my heart. I write this on the day that my Employers have suffered a major ransom-ware cyber attack on their servers and IT systems, bringing the companies activities to a virtual standstill.  To me this proves the fragility of the technology that we entrust for our day to day lives. There has to be a better, much simpler way……..

In the 1960s, the world of computing was evolving quickly as many new machines came on the market.  For code developers at that time, this presented a problem in that every new machine had a different assembly language, and this, and other quirks of the machine had to be mastered before efficient coding could be done.

High level languages such as Fortran, Algol and Cobol first appeared in the late 1950s, and whilst these eliminated the need for the developer to handle the machine language directly, the languages brought their own problems and abstracted control of the machine from the programmer.

The young developers of that age wanted something better, and both Ken Thompson of Bell Labs and C fame, and Charles H. Moore – inventor of Forth,  came up with their own solutions – to create a comfortable programming environment where they could code efficiently.

Thompson was part of the team including Brian Kernighan and Dennis Richie, working a Bell Labs who brought us the C programming language and the UNIX operating system – which is the basis of Linux and the foundation layer of almost all open source software.

Moore decided that he preferred a language that was closer to the “metal”,  and interactive in nature – so as to avoid the edit, compile, debug cycle – typical of a compiled language such as C.  Moore also believed that the target processor should be able to host it’s own toolchain – and not rely on external resources from a more powerful machine. Key to this was the dual capabilities of Forth – summarised (from Wikipedia) “Forth features both interactive execution of commands  and the ability to compile sequences of commands for later execution.” It is also extensible, in that it has the means for the programmer to create new commands.

Inspired by Chuck Moore’s Forth, and the minimum instruction set computing (MISC) ICs that he subsequently developed, I decided to get to the heart of minimum interactive computing and devise a computing environment that could be applied to the smallest, resource limited microcontrollers and offer the four main features of Forth that I felt were most important

  1.  Interactive – commands may be typed at the keyboard for immediate execution
  2.  Commands can be combined into programs then compiled for later execution
  3.  Extensible – from a small kernel of commands a whole application can be built
  4.  No external tools required other than a serial terminal

These I believe are the minimum requirements for computing – an interactive computing environment that can accessed with nothing more than a serial terminal.

Now some versions of Forth can be very comprehensive and run to about 16Kbytes, though most are between 4K and 6K.  My quest was for a much-reduced “Forth-Like” environment, that was so small, that it could almost become part of the bootloader, and be always present at start-up.  My initial experimentation was with Arduino – as it was so widely available,  but I then progressed to ARM and MSP430 – because of their larger wordsizes.  I settled on the MSP430 as my “model processor”  – because of it’s 16-bit wordsize (ideal for Forth) and the fact that it had a very “clean, orthogonal” instruction set, with a rich set of registers. I found coding in MSP430 assembly language relatively straightforward and thus I use it to test out new ideas.

As a bare minimum, the interactive environment needs to be able to do the following:

  1. Read consecutive serial characters from a UART and place them into an input buffer.
  2. Identify numerical strings from this buffer and convert them into integers to store in RAM.
  3. Use non-numerical characters as the index for a jump table, allowing the processor to branch to blocks of code on the basis of the ascii value of the character.
  4. Execute code at the jump address, then return to fetch the next character from the input buffer.

These actions are best performed by an inner interpreter  running within a loop, which co-ordinates the actions and ensures that the characters from the buffer are interpreted in sequence until the buffer end is reached with a newline character. This is all that is required to form the basis of an interactive character interpreter framework – and in MSP430 assembly language may be achieved in about 300bytes – including the initialisation of peripherals (UART, GPIO etc) and the get_char and put_char UART routines.

The other main aspect of a Forth-like language is that ability to store sequences of commands from the input buffer to memory,  and “compile” them, so that they are available to be run later.

Forth uses the process of giving these sequences a name or “word” and uses a process called the “colon definition” to commit the sequences to memory in an orderly arrangement – such that they may be retrieved and executed later.  Forth uses a dictionary structure to do this which it scans to find the word just typed.  Whilst convenient, this offered more sophistication than I needed so I adopted a much more basic approach.

In order to keep this process extremely simple, I decided that  naming a sequence would just really mean allocating a known character to it, such that it can be executed upon receipt of that character.  Then finding a fixed address to store the sequence could also be based on the value of that character, so that it may be located by a jump table.

So with this simple approach, for example  we can type a sequence  100L   The number decode routine will put 100 (decimal) onto the stack and then jump to the code that is addressed by decoding ascii L. This might be for example a routine that sends a number to a parallel 8-bit port which has LEDs attached.  The routine picks up the value of 100 from the stack and lights the LEDs to give a binary representation of 100.

This was how the programming toolkit started – just the means to decode a single integer number and use it within a given routine to perform some I/O action.

It was decided that capital letters would be used for the user routines, allowing a full 26 different actions, initially passing a single numerical parameter to the routine via the stack.  This was deemed a little limited, so a mechanism was derived to put more parameters onto the stack – so that arithmetical operations could be done.

Forth uses whitespace to separate words, but I thought that the space character could be used to separate sequences of numbers and place them on the stack one after another:

14 29    put 14 on the stack then put 29 on the stack

We can then introduce code that provides the basic maths operators + – * /

14 29+     Adds 14 and 29 leaving 43 on the top of the stack

14 29-     Subtracts 14 from 29 leaving 15 on the top of the stack

Following on from the above example we can then add in the “L”   LEDS command

14 29+L      Illuminates the LEDs with binary pattern for 43

14 29-L       Illuminates the LEDs with binary pattern for 15

So the fledgling language began – a means to perform a series of operations expressed as a string of serial characters. As the language evolved, the following conventions emerged:

Language primitives:   All ascii symbols and punctuation marks ! ” % ^ & *  ( ) _ +  etc

Built in functions:          Lower case characters a to z

User “Words”:                  Upper Case characters A to Z

Assembly Language Implememtation

Tiny-Forths had been explored before – notably on the AVR, a register rich 8 -bit processor but these resulted in about a 2K bytes implementation. My aim was to reduce the core of the language to less than 1024 bytes.

In the winter and spring of 2017, I decided to code up the language in MSP430 assembly language.  This served two purposes, I got to learn a little MSP430 assembly language, and it illustrated what sort of resources were required of a processor in order to implement a compact version of this language.

The MSP430 was chosen because it was a 16 bit processor – and it had a very orthogonal instruction set and a rich set of 16 registers. To me, it represented a blank canvas on which to paint the essence of the language.

The MSP430 code was quite compact with the kernel of the language fitting into some 300 bytes and a full implementation in under 900 bytes.

In the next part I will take the ideas around a self contained 1K byte interactive language toolkit further.












Posted in Uncategorized | 2 Comments

Minimal CPUs – “One Page Computing”

As I continue to explore the boundaries between computing hardware, firmware and software as part of an effort to reduce the perceived complexity to something that I can understand, the idea arose for a computing platform with an artificially imposed simplicity.

Hackaday has run competitions for the best code application written in fewer that 1024 bytes of code, so this led me to think about what sort of computing machine could be constructed in fewer than 1024, 2-input NAND gates. Memory would not be counted.

It was whilst pondering this when I received a comment to a past blog post from “BigEd” – who is a participant and moderator in the anyCPU forum

As a result of his comment,  I visited the anyCPU forum, and this showed that hardware constrained cpus were nothing new.

anyCPU is a spin-off from to address the interests of those actively developing new cpu designs using FPGAs.  Several of these cpus were designed  with influences from the 6502, using the 6502 as a benchmark for the performance of the new designs. This has led to some interesting challenges within the forum – such as to create an 8-bit design with similar or better performance to the 6502, and the “One Page Computing” challenge  – which deserves special mention.

“One Page Computing”

The “OPC” project is to create a fully functioning, useful cpu, who’s design can be captured in just 1 page of verilog code – where a page is defined as 66 lines of 132 characters – or the old green and white, fan-fold, tractor feed line-printer paper.

This artificial design constraint,  puts some interesting challenges on the design – and in remarkable short time – has led to an interesting evolution of cpu designs – that meet this criteria. With each generation of the design, the instruction set has improved, as has the performance.

The OPC challenge was conceived in mid-April and in barely 4 months the OPC design has gone through 6 major iterations as outlined in this github project   This shows that FPGAs can be used to quickly prototype new cpu designs with minimum of expenditure.

The clever folks on the OPC Project now have written an assembler, and there is a C compiler currently being adapted to cater for the OPC6 instruction set.  Another enthusiast is porting PLASMA, a high level bytecoded language to the OPC6.

OPC6 was design constrained by the need for it’s verilog description to fit onto 1 page of printer paper – but this has shown that quite sophisticated cpus can be designed from very little resources.

“BigEd” has done a quick port of the OPC6 onto a Lattice ICE40 – merely to look at the resources used:

After packing: 
IOs 57 / 206 
GBs 0 / 8 
GB_IOs 0 / 8 
LCs 598 / 7680 
DFF 106 
BRAMs 2 / 32 
WARMBOOTs 0 / 1 
PLLs 0 / 2 

After placement: 
PIOs 33 / 206 
PLBs 108 / 960 
BRAMs 2 / 32

The after placement figures show that the logic has used about 1/8th of the programmable logic blocks (PLBs) and one sixteenth of the available Block RAM, on the 8k Lattice Ice40.

For comparison – a soft core 6502 uses the following:

After placement: 
PIOs 27 / 206 
PLBs 144 / 960 
BRAMs 0 / 32

With low cost FPGA boards now available, for as little as £40,  supported by an open-source tool chain, there has never been a better time to get started with “One Page Computing”.

The OPC6 is the latest cpu to evolve from the OPC experiment.

It has 16 registers and provides a fairly comprehensive instruction set allowing register to register operations, not dissimilar to the MSP430, but lacking in several of the addressing modes. The conditional predicate bits allow the instruction to be conditionally executed according to the status of the ALU flag bits.

The OPC6 Instruction set is as follows   (See for full size):






Posted in Uncategorized | 4 Comments

Getting started with myStorm BlackIce



Getting Started with myStorm BlackIce


myStorm BlackIce is a unique combination of low power FPGA and ARM microcontroller designed and manufactured specifically to bring affordable FPGA open source  hardware and software to Hobbyists, Makers and Students.

Working in conjunction with Clifford Wolf’s innovative open source FPGA development toolchain, known as “Project IceStorm”  it allows new digital designs to be written in verilog, synthesised and programmed into the FPGA.

The features found on BlackIce offer the user access to the widest variety of devices and expansion interfaces including PMODs, microSD, SRAM, LEDs switches and buttons.

External circuits connect via the PMOD connectors – and these are available from a variety of sources or for the experienced hobbyist some of these expansion devices may be created at home – using readily available hardware.

Few FPGA development boards feature a powerful 32-bit ARM microcontroller on board , such as the STM32L433 – but it was found at the development stage of the myStorm project that including a microcontroller greatly widened the scope for experimentation, and provided a powerful, versatile, support chip to the FPGA.

The STM32 provides the programming interface for the FPGA, so that it may be programmed over USB using little more than a serial terminal program.

For Windows Users  – TeraTerm is Recommended.

For MAC OS X  Users   – CoolTerm

For Linux Users –  see notes below

Alternatively the FPGA may be programmed via a Raspberry Pi – particularly useful if the Raspberry Pi is being used to host the FPGA development toolchain.


Project Icestorm

Project IceStorm was written by Clifford Wolf with contributions from others – and it is used to program a range of FPGAs entirely using open source software.  It is a viable alternative to the proprietary toolchains provided by FPGA vendors which often consume tens of gigabytes on the hard drive. Project IceStorm is tiny by comparison.

Project IceStorm aims at reverse engineering and documenting the bitstream format of Lattice iCE40 FPGAs and providing simple tools for analyzing and creating bitstream files. The IceStorm flow (YosysArachne-pnr, and IceStorm) is a fully open source Verilog-to-Bitstream flow for iCE40 FPGAs.

The focus of the project is on the iCE40 LP/HX 1K/4K/8K chips.   BlackIce uses the iCE40HX4K-TQ144 part

The typical workflow involved in creating a working FPGA design

  1.  Create your design using the verilog hardware description language using a text editor.
  2.  Submit the verilog file (eg design.v) to the YoSys Logic Synthesiser
  3. Invoke the Arachne Place and Route to act on the YoSys output file
  4. Use the IceStorm toolchain  (icepack, icebox, iceprog, icetime, chip databases) to create the bitstream file
  5. Program the Bitstream file into the FPGA

Whilst this set of operations may seem quite complex – it can be automated either from the command line,  or by using the APIO IDE – which is a cross-platform IDE tailored to the requirements of FPGA design projects.


The STM32L433 Microcontroller

On the left hand side of the BlackIce pcb is the 64 pin microcontroller which acts as the support device for the FPGA – primarily handling the programming function.

The STM32L433 has 256K of flash memory and 64K of SRAM clocked at a maximum of 80MHz.  It is a powerful microcontroller in its own right – similar in capability to an Arduino Due.

20 of its GPIO lines are brought out to Arduino style headers for maximum flexibility and access to analogue and digital interfaces.

When not being used for programming, the microcontroller can be used for the User’s own application firmware – in a choice of languages including C/C++, Forth or JavaScript (Espruino and MicroPython (

The STM32 may be programmed with Arduino (1.8.3 or later) or using the mbed online compiler.  Forth enthusiasts can use Mecrisp Ice V0.9 – which has been specifically tailored to support the STM32 and the ICE40 FPGA.

The STM32 is used to buffer the bitstream file – that is the binary format file that is used to program the FPGA with its logical design.  This bitstream file is created using an open source toolchain called Project IceStorm.

Why a Microcontroller?

The STM32L433 microcontroller is a powerful 32-bit ARM Cortex M4 device clocked at 80MHz and offering 100DMIPS. It is however one of the ultra-low power series – so perfectly complements the iCE40 – which is also a low power part.

Every FPGA needs some supporting hardware to allow the Bitstream file to be programmed into it’s internal RAM – and this is very often done by an FTDI device – the FT2232.  However this FT2232 is an expensive part, costing about $4.50, and it still needs a $0.30 Flash memory to hold the bitfile.  Once the FT2232 has programmed the Flash chip, it can then serve as a UART to USB interface for the FPGA.

When we designed myStorm, we decided that the cost of the FTDI device was prohibitive – and we could get a lot more value from the board by spending that part of the budget on a high spec microcontroller – and using that to provide the FPGA programming function.   When not actually in programming mode – it can be used to host the User’s application – which can be written in a variety of languages.  The result is that you get a general purpose microcontroller development board, with access to 20 lines of digital and analogue I/O – capable of working with some of the currently most popular microcontroller environments.

The microcontroller adds support and versatility to the FPGA, and for some designs the combination of FPGA and ARM will give rise to some unique projects.

The mcu and the FPGA are connected via a Quad SPI bus – capable of running at 60MHz – or 240Mbit/s.

The mcu provides analogue peripherals including a multi-channel 5MSPs 12bit ADC and two 12-bit DAC channels

BlackIce offers features not found in other comparably priced FPGA boards

More PMODS – a total of 6 double and 2 single PMODS   = 56 GPIO lines appear on PMODS including differential LVDS lines

For compatibility – further GPIOs have been routed to an Olimex expansion board header

STM32 ARM Cortex co-processor acts as a complete support system for the FPGA – offering a convenient means of programming the FPGA

The STM32 mcu adds 20off  5V tolerant analogue and digital I/O routed to Arduino style headers – including  6 analogue to digital converter inputs and 2 DAC outputs with 12 bit resolution

STM32  can be used as a slave set of standard peripherals to the outside world – including timers, ADC DAC, SPI, I2C and USB

It can be programmed using STM32Duino, mBed Nucleo, MeCrisp Forth.

BlackIce includes a 256Kx16 SRAM closely coupled to the FPGA

microSD card socket on underside of pcb – which may be accessed either by the FPGA or ARM mcu

Using APIO to manage the ToolChain and Development Process

The APIO package is a plug-in for the open source Atom Editor environment. It was written specifically to manage projects involving the Project Icestorm toolchain and Lattice ICE40 FPGAs.

Project Icestorm consists of several stages which are conveniently managed by the APIO IDE which is a derivative of PlatformIO – specifically tailored to meet the needs of the Project  IceStorm toolchain.  APIO runs as a module within the Atom Editor Environment.

The advantage of using an IDE such as APIO, is that it works across all platforms, and provides a convenient way of managing the toolchain and the various modules (files) that make up the design project.

The design is coded in verilog, and it’s then just a case of building the project.

This invokes the YoSys “Logic Synthesiser” and the Arachne “Place and Route” tools. It then takes the p&r file and converts it into a binary “Bitfile”  which is used to program the FPGA.

On BlackIce, an STM32L433 ARM  M4 Cortex microcontroller is used to manage the programming of the ICE40 FPGA.

The STM32 device runs an application firmware called “Iceboot”  – and this allows the binary bitstream file to be loaded via the STM32 and then into the FPGA.

This is done via the native USB device port on the STM32 microcontroller using a terminal program such as Teraterm, using it’s “Send File” option from the File menu tab. Ensure that the Binary option is checked on the file selection dialogue box. FPGA loading takes only about 2 or 3 seconds.


Programming the STM32

In our application the STM32 runs the programming firmware “Iceboot”. However it can be programmed to permanently retain the FPGA bitstream image – so that this is automatically loaded on power-up. This may be useful for demonstration purposes where you want the FPGA image to be non-volatile.

Additionally, the STM32 may be programmed with application firmware, provided that this does not interfere with the FPGA loading mechanism.

20 lines of GPIO, including six ADC channels are brought out to Arduino-style expansion connectors, and these are available for User experimentation.

The STM32 is readily programmed using mbed – as it can be made to look like a Nucleo device – using a ST-Link to program it.  Later versions of the Arduino IDE now support the M4 Cortex microcontroller – so this may also be used.

Alternatively it can be put into DFU  (Device Firmware Upgrade) mode by removing the jumper link connected across the 7th and 8th pin of the right hand row of header pins. Reflashing the firmware using DFU is an advanced topic, and is covered in the Appendix.

Arduino Headers

These headers allow access to many of the interfaces on the microcontroller including ADC inputs,  DAC outputs, SPI, I2C and UART interfaces and timer inputs and outputs.  They also access the four  “slide switch” inputs that connect to both FPGA and ARM.

The headers run east-west across the centre of the board, and break out many of the ARM microcontroller GPIO signal to a set of connectors that are compatible with Arduino shields.  Note that whist these GPIO lines are 5V tolerant – the rest of the board is 3V3 only – so extreme care should be exercised when working with mixed supply rail designs.


The Arduino Shield headers can be used to access up to 20 digital lines and 6 analogue lines.

50mm x 50mm square pcbs may be conveniently mounted  – or an extended shield 60mm x 50mm will pick up all  14 LVDS pairs from the Olimex connector.  Care should be taken however because the FPGA lines are not 5V tolerant.


There are to user push button switches which connect to both the microcontroller and the FPGA. These are useful for when a logic design requires momentary intervention.

They are connected to pins  PC8 and PC9 of the microcontroller and pins 63 and 64 of the FPGA.

In addition to the push switches on the left, there are four DIP slide switches arranged in two banks of two. These also connect to both the mcu and the FPGA and are also exposed to the outside world via pins on the “Digital 3” connector of the Arduino Headers.  They are useful for setting up a mode of operation or connecting to external stimuli.

To the right of the mode switches is a Reset Button which provides a momentary active low reset signal to the microcontroller.  This is independent of the high going reset signal that the microcontroller sends to the FPGA at the time of programming.


System connector – sometimes called the “Pi Header”

This is a 2 x13 male header on the left hand edge of the pcb which carries certain signals that allow the FPGA to be programmed from an external device such as a Raspberry Pi. It has a mix of programming pins, control pins and power.

The UART RX and TX signal  lines from the FPGA also appear on pins – compatible with the position of the corresponding UART pins on the Raspberry Pi expansion header. Full details of these signals are in the appendix.

Programming Jumper Link.

This is a 2.54mm jumper link which normally bridges across pins 14 and 16 of the system connector.  When removed, it forces the microcontroller into DFU boot mode (Device Firmware Upgrade), which allows it to be programmed with new system firmware. Occasionally there may be a firmware upgrade posted in the myStorm repository to provide new features.

The microcontroller may additionally be programmed using a low cost “ST Link”  – a small system programming device – which may be sourced cheaply from ebay. This plugs into the programming pins of the system header.

For normal operation, the jumper link must remain across pins 14 and 16.


These are an industry standard interface connector originally devised by Digilent – a major manufacturer of FPGA development boards.

They come in 6 pin or 12 pin (2 rows of 6 pin) right angled female headers, organised on a specific pitch spacing between connectors.

The connect directly to the FPGA GPIO pins and also carry 3V3 and 0V power.   Small external circuit boards, carrying a variety of expansion circuitry or devices may be plugged directly into these headers – picking up 4 I/O pins for a single PMOD, and 8 I/O pins on a double PMOD.

On BlackIce there are two single PMOD connectors and 6 double PMOD connectors.   The double PMODs on the right hand edge of the pcb carry the fast LVDS (low voltage differential signalling) pairs of signals – and these may be used for driving the most demanding of high speed hardware.

A total of 56 GPIO lines  (including 14 pairs of LVDS lines) are brought out via the PMOD connectors.

There are a whole range of third party PMODs available from a variety of suppliers – such as ADCs, 7 segment displays, audio codecs etc, etc.  See here for further information plus a selection of what is available:

The small size of PMOD circuit boards makes them a convenient size for home construction – taking advantage of low cost pcb manufacturing services.

Olimex Expansion Connector

This is a 2 x 17  2.54mm connector that accesses 28 of the FPGA GPIO signals and is compatible with the range of expansion modules supplied by Olimex.   These low cost  modules include ADC, DAC, VGA & PS/2, and buffered digital I/O.

To take advantage of this – a 2 x 17 pin male header should be fitted in this position, or a 2×17 right angled box header fitted from the underside of the board.  More details in the appendix.

MicroSD Card

On the rear of the pcb is a microSD card socket which may be accessed from the FPGA or the microcontroller.


Also on the rear of the pcb is a 256Kx16 fast (10nS) asynchronous SRAM – directly connected and closely coupled to the FPGA. This can be used in FPGA designs where additional external storage is required.

Other Features

BlackIce is provides with a 100MHz oscillator module from which internal clock signals for the FPGA may be derived via the internal PLL (phase locked loop) module.


A small 2 way multiplexer chip allows selection between external programming of the FPGA from the system connector, or onboard programming from the ARM device.  When onboard programming is selected it routes the output of the FPGA signals P52, P53,P54 and P55 to the SPI bus of the microcontroller, whilst ordinarily these are used for driving the LEDs.

User LEDs

There are four coloured LEDs available to the user Blue, Green, Amber and Red.  These can be used to indicate certain status within the FPGA, or to create for example a traffic light display.

An additional STATUS LED is connected to port PC13 of the microcontroller – and can be used for user purposes if the user is developing code for the microcontroller using Arduino, mbed or similar.

A further red LED indicates that the FPGA programming has been DONE.

The power white LED shows when 5V power is connected.

Powering the Unit

The board may be powered from either microUSB socket or from the 5V power and 0V ground pins on the 2x13way connector.

There are two microUSB connectors:



This one closest to the ARM chip, just below the 2×13 pin system connector is the direct USB connection to the STM32 microcontroller – and is used primarily for sending the programming bitfile to the mcu.

The lower of the two microUSB sockets connects to a USB-UART converter IC, and is used to communicate serially with the FPGA – assuming that your logic design contains a suitable UART module. It may also be used to convey serial data from the ARM mictocontroller, and on first power-up or following a reset it sends the message showing the firmware revision.  The firmware running on STM32 connects to this com port at 115,200 baud.

Sending a Bitstream file to the BlackIce Board

There are two USB sockets:

  1. Programming Port

The one closer to the middle of the board is connected to the USB interface on the microcontroller – and if you plug into this one  – it will appear as a virtual com port, capable of running at more than 1 Mbit/second.

This is the one that is primarily used to transfer the large bitstream file from the laptop, through the microcontroller and into the FPGA – very quickly – in a couple of seconds.

After you have sent the bitstream file and it is correctly loaded – the message should then say

Config done

 Waiting for UART or USB serial


2. UART Port

The microUSB port nearer the corner of the board is connected via a CH340 USB converter to the UART lines of both the microcontroller and the FPGA.

This port is normally used for getting serial input/output from the FPGA  – provided that your logic design included a suitable UART connected to the correct pins.

However, at start-up or following a reset of the STM32 it is used to send a start-up message. Following this message, the STM32 switches it’s Tx line to a high impedance input – allowing the FPGA UART access to the com port adaptor.

If you plug into the lower port – set up a 115,200 baud terminal and press the  reset button (top right) you should get this message on the terminal screen

Mystorm Version 0.3
Setup Done

Note that the version is now 0.3 –  you may previously have been using version 0.2

DFU Programming.

This is an alternative programming method that uses “Device Firmware Upgrade” – which is a factory built in bootloader within the STM32 microcontroller.   DFU is used for 2 specific purposes:

  1. To put new firmware onto the STM32
  2. To load an image of the FPGA design into the flash memory – so it loads this on power-up.

Putting new firmware on the STM32 is covered in Appendix 1.

The other thing to note is that you must keep the jumper link fitted across pins 14 and 16 of the “system” connector.    This is only removed when you want to update the firmware that runs on the microcontroller.


The myStorm BlackIce boards are now available in production quantities – and priced as follows:

For Customers in UK £40 + £2 postage
For Customers in EU 45 Euros + 4 Euros shipping
For Customers in US $52.50 + $7.00 shipping

For world wide customers – please contact me and ask about shipping costs.

You can PayPal me at ken dot boak at gmail dot com to place an order or discuss volume discounts.


Appendix 1.

How to Update the STM32 Firmware using DFU Mode

BlackIce uses an STM32L433 ARM M4 Cortex microcontroller to act as the FPGA  programming and support chip. It allows the upload of the bitstream binary file using the native USB port of the STM32.  This is done using the microUSB connector closest to the ARM processor and using a terminal emulator program such as Teraterm or CoolTerm.
Occasionally the support firmware “IceBoot” will need to be updated – and this is done using the dfu mode – or Device Firmware Upgrade mode of the STM32.  This is a factory installed bootloader which allows the firmwate on the STM32 to be upgraded via USB.
In order to invoke DFU mode – the shorting link fitted between pins 14 and 16 of the “Pi Header” needs to be removed.  This allows a pin to be released from being held low and this forces the STM32 into dfu mode.
Once in dfu mode, it is possible to use the STMicroelectronics Dfuse application (for Windows) or the dfu-util program with Linux to load the new firmware into the STM32.
If you are using the Windows application, the firmware has to be first converted into “dfu format” and this is done with another application called “DFU File Manager” which is bundled with the STM software tools. This can be used to convert a binary or HEX format file into the required dfu format, before using the dfuse programmer application.
How to update the Firmware – for Linux Users


For Linux users this process is a little easier as this file conversion is handled automatically by the dfu-util.  Here’s Matthew Venn’s description of how to do this
Here’s how on Linux (works for Ubuntu 14).

Unplug blue jumper on pin7&8.

Plug USB cable into socket closest to ARM chip.

Use lsusb to find the device:

  Bus 001 Device 026: ID 0483:df11 STMicroelectronics STM Device in DFU Mode

Use dfu-util (sudo apt-get install dfu-util) to list DFUs:

  sudo dfu-util -d 0483:df11 -l
  dfu-util 0.5

  (C) 2005-2008 by Weston Schmidt, Harald Welte and OpenMoko Inc.
  (C) 2010-2011 Tormod Volden (DfuSe support)
  This program is Free Software and has ABSOLUTELY NO WARRANTY

  dfu-util does currently only support DFU version 1.0

  Filter on vendor = 0x0483 product = 0xdf11
  Found Runtime: [05ac:828f] devnum=0, cfg=1, intf=3, alt=0, name="UNDEFINED"
  Found DFU: [0483:df11] devnum=0, cfg=1, intf=0, alt=0, name="@Internal Flash  /0x08000000/0128*0002Kg"
  Found DFU: [0483:df11] devnum=0, cfg=1, intf=0, alt=1, name="@Option Bytes  /0x1FFF7800/01*040 e"
  Found DFU: [0483:df11] devnum=0, cfg=1, intf=0, alt=2, name="@OTP Memory /0x1FFF7000/01*0001Ke"
  Found DFU: [0483:df11] devnum=0, cfg=1, intf=0, alt=3, name="@Device Feature/0xFFFF0000/01*004 e"

We want the internal flash (alt=0), so now with the iceboot.dfu:

  sudo dfu-util -d 0483:df11 -D ~/Downloads/iceboot.dfu --alt 0
  dfu-util 0.5

  (C) 2005-2008 by Weston Schmidt, Harald Welte and OpenMoko Inc.
  (C) 2010-2011 Tormod Volden (DfuSe support)
  This program is Free Software and has ABSOLUTELY NO WARRANTY

  dfu-util does currently only support DFU version 1.0

  Filter on vendor = 0x0483 product = 0xdf11
  Opening DFU USB device... ID 0483:df11
  Run-time device DFU version 011a
  Found DFU: [0483:df11] devnum=0, cfg=1, intf=0, alt=0, name="@Internal Flash  /0x08000000/0128*0002Kg"
  Claiming USB DFU Interface...
  Setting Alternate Setting #0 ...
  Determining device status: state = dfuIDLE, status = 0
  dfuIDLE, continuing
  DFU mode device DFU version 011a
  Device returned transfer size 2048
  Dfu suffix version 11a
  Warning: File product ID 0000 does not match device df11
  DfuSe interface name: "Internal Flash  "
  file contains 1 DFU images
  parsing DFU image 1
  image for alternate setting 0, (1 elements, total size = 22744)
  parsing element 1, address = 0x08000000, size = 22736
  done parsing DfuSe file

Then unplug usb, put jumper back, plug into other USB socket and check dmesg:

  [108129.748055] ch341 1- ch341-uart converter detected
  [108129.749285] usb 1- ch341-uart converter now attached to ttyUSB0

Check serial output:

  miniterm /dev/ttyUSB0 115200
  --- Miniterm on /dev/ttyUSB0  115200,8,N,1 ---
  --- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---

Press reset button:

  Mystorm version 0.2
  Setup done
  Waiting for UART

Now you should be able to flash your mystorm like this:

cat chip.bin > /dev/ttyUSB0

(takes about 10 seconds).


Appendix 2.


STM32 GPIO Pin Out

Pin Port Primary  Analogue Other 
Posted in Uncategorized | Leave a comment