-
Not Synced
It's my very great pleasure to introduce
to you Clifford
-
Not Synced
who is going to talk about a very complex
topic I know very little about, but that's
-
Not Synced
probably gonna change now.
-
Not Synced
So please give a warm round of applause
for "A Free and Open Source
-
Not Synced
Verilog-to-Bitstream Flow for iCE40
FPGAs".
-
Not Synced
applause
-
Not Synced
Thank you.
-
Not Synced
I'm talking about a Free and Open Source
Verilog-to-bitstream flow for iCE40 FPGAs
-
Not Synced
and in particular that means I'm going to
talk about three projects,
-
Not Synced
because these three projects together form
this Free and Open Source Verilog to
-
Not Synced
bitstream flow for this kind of FPGA.
-
Not Synced
The project I'm gonna talk about,
Project IceStorm, is an effort
-
Not Synced
to reverse engineer and document the
bitstream format for iCE40 FPGAs
-
Not Synced
and in particular right now we support the
HX1K and HX8K FPGAs.
-
Not Synced
In theory we should also support the LP1K
and LP8K--
-
Not Synced
if there is such a one, I don't know--
FPGAs because they just have different
-
Not Synced
timings but the bitstream format is
absolutely identical.
-
Not Synced
From the IceStorm project we get the
documentation for the bitstreams
-
Not Synced
documentation in human-readable form as
well as in machine-readable form
-
Not Synced
so we can write other tools that do useful
things with this kind of devices
-
Not Synced
and also from Project IceStorm we have a
couple of tools that we can use to read
-
Not Synced
bitstream files for those FPGAs and
convert those bitstream files into
-
Not Synced
different formats and vice-versa.
-
Not Synced
The second project I'm going to talk about
is arachne-pnr. arachne-pnr is a
-
Not Synced
place-and-route tool for the iCE40 FPGAs
and it's based on the IceStorm
-
Not Synced
documentation, so I wrote the IceStorm
documentation and then I was lucky enough
-
Not Synced
to find someone, Cotton Seed is his name,
to write this arachne-pnr place-and-route
-
Not Synced
tool, based on the documentation I wrote.
-
Not Synced
The third project I'm going to talk about
is Yosys, and Yosys actually is kind of my
-
Not Synced
main project that I'm working on now for
a little bit over three years
-
Not Synced
Yosys is a huge project but simply said
it's a Verilog synthesis suite so when you
-
Not Synced
have hardware designs that are written in
Verilog you can use Yosys to synthesize
-
Not Synced
those designs to netlists for a variety of
different architectures and one of those
-
Not Synced
architectures is the iCE40 FPGA
architecture, but I also have support for
-
Not Synced
other FPGA series, there is support for
ASIC synthesis and there is also support
-
Not Synced
for various forms of verification flows
in Yosys and
-
Not Synced
I'm going to talk about this a little bit,
not very much, just a little bit.
-
Not Synced
And last but not least I'm going to talk
about the icoBOARD
-
Not Synced
the icoBOARD is a development board
featuring the iCE40 FPGA
-
Not Synced
and I'm also showing you a little demo and
that's this contraption here we are going
-
Not Synced
to use this at the end of the talk.
-
Not Synced
So this is the flow, the big overview for
the flow
-
Not Synced
you see, you start with Verilog sources
and the synthesis script
-
Not Synced
usually the synthesis script just reads
the Verilog files and then executes a few
-
Not Synced
macro commands that do everything that is
necessary to synthesize for the specified
-
Not Synced
target, and of course we are looking at
the iCE40 FPGA here in particular.
-
Not Synced
The output of Yosys in this case is a BLIF
file
-
Not Synced
BLIF is a very easy, very simple netlist
format, and it's one of many format that
-
Not Synced
Yosys supports as backends.
-
Not Synced
We've made some extensions to the BLIF
file format to enable the use of
-
Not Synced
additional attributes on cells and
parameters, which is quite useful when you
-
Not Synced
do for example FPGA synthesis and would
like to have the LUT configuration as part
-
Not Synced
of a cell instantiation with a kind of
parameter.
-
Not Synced
The we take this netlist in the BLIF file
and we pass it on to arachne-pnr, the
-
Not Synced
place-and-route tool written by Cotton
Seed
-
Not Synced
and we also give arachne-pnr a few
additional files, namely we give it a
-
Not Synced
physical constraints file that specifies
where each pin should go, where each input
-
Not Synced
or output of the design should go on the
device, to which pin it should map.
-
Not Synced
Optionally, you can also specify a place-
and-route script that tells arachne-pnr
-
Not Synced
what strategy it should follow and which
of its internal passes it should execute
-
Not Synced
and in what order.
-
Not Synced
The output of that is what I call an
IceStorm text file
-
Not Synced
this is already a very very low-level file
format, you will see a short example of
-
Not Synced
that, where you can see for each
individual tile, just an ASCII block of
-
Not Synced
zeros and ones and then, you know, in line
8, column 13, this bit has this or that
-
Not Synced
function.
-
Not Synced
And lastly, we pass this IceStorm text
file to icepack, and icepack is a very
-
Not Synced
simple tool that can convert this easy to
read text file into the binary
-
Not Synced
representation that must be passed to the
FPGA in order to use this design.
-
Not Synced
Yeah, so, let's look at the first of those
four projects at the first part of my talk
-
Not Synced
Project IceStorm.
-
Not Synced
First I think I should give you a little
overview over the iCE40 FPGA series
-
Not Synced
because the iCE40 FPGAs are not very
widely used, I mean, a lot of people use
-
Not Synced
these Xilinx devices or Altera devices,
but Lattice iCE40 is kind of niche.
-
Not Synced
So it's a family of small FPGAs, the
largest one has a little bit under
-
Not Synced
8000 LUTs, and the LUTs are small
4-input LUTs.
-
Not Synced
The FPGA itself is of course a kind of
grid of tiles and different kinds of tiles
-
Not Synced
there are logic tiles and those logic
tiles have 8 look-up tables and for
-
Not Synced
each of those look-up tables an optional
flip-flop and carry chain logic that you
-
Not Synced
can use optionally.
-
Not Synced
There are also RAM tiles for block memory.
They always come in pairs, there is always
-
Not Synced
the RAM bottom tile and the RAM top tile
and the bottom tile and the top tile
-
Not Synced
together, they form a 4 kilobit SRAM.
-
Not Synced
And of course there are I/O tiles of the
edges of this grid that connect to the
-
Not Synced
programmable I/O pins, but also provide
the infrastructure necessary to connect
-
Not Synced
the FPGA logic with other resources on
the chip like PLLs and global nets.
-
Not Synced
A nice thing about iCE40 FPGAs is that
they come in quite reasonable packages
-
Not Synced
so when you would like to make your own
boards, it can be quite a hassle to work
-
Not Synced
with ball grid arrays and stuff like that,
but the iCE40 FPGAs come in packages like
-
Not Synced
144-pin TQFP that you can even solder by
hand if you have to.
-
Not Synced
And all of their very cheap development
boards, available from Lattice directly
-
Not Synced
for this kind of FPGAs, the Lattice
iCEstick costs less than $25, so it's
-
Not Synced
really affordable for someone who just
would like to experiment with it and have
-
Not Synced
a quick go with it.
-
Not Synced
Also, if you would like to do some
low-level stuff and are afraid of maybe
-
Not Synced
breaking your dev board by fiddling with
the configuration bits manually, then it's
-
Not Synced
quite nice to have a dev board in this
price range where nothing is, yeah, where
-
Not Synced
you can simply replace it.
-
Not Synced
So in summary the FPGA looks a little bit
like that. We have this grid of PLBs,
-
Not Synced
Programmable Logic Blocks, these are the
logic tiles, we have some memory tiles
-
Not Synced
that span two rows, and we have the I/O
tiles on the edges, and then in the middle
-
Not Synced
of that slide, we have a more detailed
look into one of these logic tiles, that
-
Not Synced
we see, we have these 8 flip-flops, 8
carry chain elements, and 8 look-up tables
-
Not Synced
this is all blown up here so we can see it
in more detail, however this is still just
-
Not Synced
it's still missing stuff, for example,
there is a connection that goes directly
-
Not Synced
from one LUT output to the second LUT
input of the next look-up table in this
-
Not Synced
chain, bypassing the flip-flop.
-
Not Synced
At the bottom right you see this is the
iCEstick dev board that you can buy from
-
Not Synced
Lattice for under $25. I think it costs
$25 from Lattice, but on Mouser it's
-
Not Synced
under $25.
-
Not Synced
Good, so with Project IceStorm we had a
detailed look at these FPGAs and we
-
Not Synced
documented the bitstream format and we
wrote these low-level tools that can be
-
Not Synced
used to work with bitstreams, and we also
defined a very simple text file that can
-
Not Synced
be used to just specify each and every
individual bit in the configuration, and
-
Not Synced
on the right on this slide you see a
little excerpt of what this text file
-
Not Synced
looks like, so you have here logic tile
9 9 and these are of course the
-
Not Synced
coordinates and then you just have this
block of ones and zeros and then you can,
-
Not Synced
when you look up the documentation online
that we provided, then you can decipher
-
Not Synced
that and say, ok, this bit is set because
that's this function and this kind of
-
Not Synced
makes sense for what this configuration
does.
-
Not Synced
So with the IceStorm tools we can convert
between the text files
-
Not Synced
and the binary files and we can also do a
lot of other interesting stuff.
-
Not Synced
For example, we can take one of those text
files and convert it back into
-
Not Synced
a behavioral Verilog model and actually
when I released this feature
-
Not Synced
the first time I got quite some hate mail
from people who thought I'm want to steal
-
Not Synced
their IP or something.
-
Not Synced
You can also create timing netlists from
these bitstreams directly, however this
-
Not Synced
is under construction. It's almost done
but not quite yet.
-
Not Synced
The reason why we are doing things like
that always on this low level bitstream
-
Not Synced
format is because we can create these
files from our own flow but we can also
-
Not Synced
create it for the bitstream files
generated by Lattice's flow, so it's very
-
Not Synced
easy to verify if our interpretation of
the bitstream is correct, we just create
-
Not Synced
random Verilog designs, pass it through
the Lattice flow, then convert the output
-
Not Synced
back into something that is behavioral
Verilog, and then use something like the
-
Not Synced
formal verification features in Yosys to
check if the Verilog we started with and
-
Not Synced
the Verilog we got out at the end are
formally equivalent.
-
Not Synced
So, you can go to clifford.at/icestorm
and browse the documentation I wrote.
-
Not Synced
A little bit of warning here, it's a
reference, it's not like an
-
Not Synced
introductionary textbook, so if you don't
know anything about how FPGAs work
-
Not Synced
internally, it might be a hard read. Also
it's actually not very very structured,
-
Not Synced
unfortunately, but it's not very long,
it's just a few pages,
-
Not Synced
so my recommendation if you really would
like to know how these FPGAs work and what
-
Not Synced
each individual bit means, is to just read
the entire thing once and then you have
-
Not Synced
an overview, and for example, most of the
interconnect is explained on the page for
-
Not Synced
the logic tiles, and things like PLLss and
global nets are explained on the page that
-
Not Synced
cover the I/O tiles. But it's really small
and you can read it in maybe an hour
-
Not Synced
or two, so it's I think not so bad.
-
Not Synced
So, the things provided by project
IceStorm, besides the actual tool,
-
Not Synced
the documentation provided is written
documentation that gives you an overview,
-
Not Synced
then there is an auto-generated HTML
documentation that gives you the reference
-
Not Synced
what each bit exactly means, and there
is also and auto-generated ASCII that can
-
Not Synced
be used in other tools, like arachne-pnr,
to do something with these kinds of FPGAs.
-
Not Synced
We have a couple of screenshots from this
documentation
-
Not Synced
so on the lower left you have some of the
written documentation that covers
-
Not Synced
this is actually from the I/O tile and you
see the column buffer control bits that
-
Not Synced
are used for the global nets and stuff
like that is documented here.
-
Not Synced
Then the two screenshots with these
wonderfully colored tables, these are
-
Not Synced
the auto-generated HTML documentation
where we document the function of each
-
Not Synced
and every individual bit and most of them
in more than just one way so we have
-
Not Synced
in this case some matrices that can tell
us which nets can be connected to which
-
Not Synced
other nets and what bits are used for
that.
-
Not Synced
And here on the upper right you actually
see for one logic tile the entire
-
Not Synced
collection of bits we have reverse
engineered, so you see there are some
-
Not Synced
grey areas, and as far as I can tell it's
not the things that I have missed but
-
Not Synced
these bits are just not used.
-
Not Synced
I can't be sure, of course, but I didn't
manage to create any Verilog design that
-
Not Synced
would use those bits so I think it's a
pretty fair guess that they are
-
Not Synced
actually unused. And on the bottom right
you see a part of the interconnect
-
Not Synced
documentation and you can see things like
these interconnect lines are pairwise
-
Not Synced
crossed-out and stuff like that, so it
took us quite a while to figure out all
-
Not Synced
these details.
-
Not Synced
So that's Project IceStorm, that's the
low-level stuff and of course it's very
-
Not Synced
interesting to just see how the FPGA works
and to know what each and every individual
-
Not Synced
bit does, but this doesn't really give us
something that we can use for everyday
-
Not Synced
design work with FPGAs.
-
Not Synced
Part two, arachne-pnr, this is the
place-and-route tool that Cotton Seed
-
Not Synced
wrote. This now takes this BLIF netlist
and converts it into one of those
-
Not Synced
text files, so it performs essentially
these operations here, it instantiates
-
Not Synced
I/O cells and clock buffers, this is more
like a convenience feature, but it's
-
Not Synced
something that is quite useful for
place-and-route, low-level implementation
-
Not Synced
tools to do something like that. It packs
LUTs and carry logic and flip-flop
-
Not Synced
instances into iCE40 logic cells because
the architecture netlist has individual
-
Not Synced
lookup tables and carry logic blocks and
flip-flops and we need to figure out how
-
Not Synced
we can fit them in these logic cells.