Silicon Chip – April 2019

(Ben Green) #1

siliconchip.com.au Australia’s electronics magazine April 2019 33


The advantage that this arrangement
has over a microcontroller is that eve-
rything happens at the same time in
an FPGA.
Rather than having to wait for things
to process in a sequence, determined
by the list of instructions which form
the program, everything happens prac-
tically instantly in an FPGA.
This makes them ideal for tasks
where many different calculations can
be made in parallel.
While some microcontroller pro-
cessors have multiple cores, allowing
several instructions to be executed si-
multaneously, in an FPGA, practically
everything happens simultaneously.
So it’s a bit like having a processor
with thousands (or even millions) of
cores; even though each of those cores
may have fairly limited capabilities,
overall it is a much more powerful and
capable device.
A good example of a task which is
quite easy to do with an FPGA but vir-
tually impossible with a regular mi-
crocontroller, as demonstrated by the
Arduino MKR Vidor 4000, is the gen-
eration of an HDMI digital video signal.
The FPGA can produce the HMDI
data (which is typically clocked at the
hundreds of megahertz) far quicker
than any microcontroller could man-
age.
And it can do this while perform-
ing whatever other tasks are required
simultaneously, without any concerns
that the different tasks may interfere
with the time-critical video genera-
tion process.
Rather than software code (eg, BA-
SIC, C, assembly language etc), the
FPGA configuration is described in a
hardware description language (HDL).
There are two main HDLs in wide-
spread use: Verilog and VHDL.
We will mostly be dealing with Ver-
ilog, which as stated earlier, borrows
some of its syntax from the C language;
but due to the nature of FPGAs, it has


some important and significant dif-
ferences.
The HDL is synthesised into a ‘bit-
stream’ (basically, a blob of binary
data), which is what is actually loaded
into the FPGA chip to configure it. In
the case of the iCE40HX-1k FPGA on
the iCEstick, this is up to 34kB in size.
The bitstream is roughly the equivalent
of machine code to a microcontroller
or microprocessor.
There is a lot more to this process
than this simple description suggests,
and much of how FPGAs and FPGA
development tools work has been hid-
den by the manufacturers until the ad-
vent of the open source tools we are
now using.

ICE40HX chip and
iCEstick board capabilities
While touted as having a USB thumb
drive form factor, it actually measures
95 x 25mm. But when you consider that
a large portion of this board is taken
up by the sizeable FPGA chip, its size
seems reasonable.
This IC is a Lattice iCE40HX-1k
FPGA which comes in a 144-lead TQFP
package. While not all the input/out-
put pins are broken out (the chip has
96 I/O pins in total), an ample number
are available.
The iCE40HX-1k contains 1280 flip-

flops, 1280 lookup tables, 160 program-
mable logic blocks and 16 RAM blocks.
Each RAM block holds four kilobits
(512 bytes), for a total of 8 kilobytes.
For comparison, its larger sibling, the
iCE40HX-8k, can emulate a 32-bit RISC
processor, but this is a bit beyond the
iCE40HX-1k’s capabilities.
The core of the chip runs at 1.2V,
but external I/O on the iCEstick is
3.3V. There are four I/O banks on the
iCE40HX-1k which can (in a different
implementation) be set to other I/O
voltages.
Also on the iCEstick board are sev-
eral other components for communica-
tions and programming. The second-
largest IC, nearest the USB plug, pro-
vides the USB interface.
This is an FTDI 2232H dual UART
with USB 2.0 Hi-Speed. Typically, one
of the UARTs is used in SPI mode for
programming, and the second UART is
available for communication with the
bitstream that is ‘running’ on the FPGA.
The two 8-pin SOIC devices are a
flash IC and an EEPROM IC. The flash
IC is 32Mbit and is used to store the
configuration bitstream in a non-vol-
atile fashion. The FPGA is configured
using internal RAM, the contents of
which is lost on power-down, so it must
be loaded from the flash chip each time

The iCEstick, slightly under life
size. The huge (144-pin TQFP)
IC in the middle of the iCEstick
is the iCE40HX-1k. To the
right of it are the various
I/O headers and
five user LEDs.
To the left are the
flash and EEPROM
ICs, an FTDI 2232H
dual UART and a 12MHz
oscillator.

Screen1: ensure that the correct device is selected in the Zadig application, and
that libusbK is selected before clicking “Replace” and closing the window. If you
do change the wrong driver, you can uninstall it via device manager.

Pin Function
No.
21 12MHz Osc.
8 UART TX
9 UART RX
78 PMOD 1
79 PMOD 2
80 PMOD 3
81 PMOD 4
87 PMOD 7
88 PMOD 8
Table1: iCEstick physical pin to
I/O pin mapping

Pin Function
No.
90 PMOD 9
91 PMOD 10
95 LED5 (GREEN)
96 LED4 (RED)
97 LED3 (RED)
98 LED2 (RED)
99 LED1 (RED)
105 IR TX
106 IR RX
Free download pdf