[Music]
all right well good afternoon welcome
back after the break i was just uh
watching the uh the logo thinking that
um we should have a flipper sanitizer
sayo
so uh this next session is going to be
talking about the various wares for the
uh
the rocklin swag bags and the party
buttons so um
this is the uh
collection of hardware that we've been
playing with throughout developing this
project so we can see the old
last year's swag badge we've got the new
swag badge we've got um
a various various rocklin prototypes in
production and uh and there's no party
button there
um and so
uh for those who are new to fpgas i'm
going to dive in there's lots of
terminology jargon but don't but don't
let that put you off for playing of your
rocklin um
but at first they'll appear like a risk
five processor just running c code um
all the uh itc peripherals uh are
controlled by c
and uh and and all the and all the the
cpu and uh the profiles appear on a
memory map bus which you can just uh
interact with directly from your laptop
so you can basically peek and poke and
send commands to see what's going on and
as you get more gain more confidence you
can
dive in deeper into the into the world
fpga tools and write down the individual
gates
so let's let's go
so um
we
use uh use software to control hardware
and typically that hardware has got
specific functions it says it's either a
cpu or a gpu uh it could be you know
some sort of peripheral like an
accelerometer and it's pretty hard for
most of us to um create or change this
these are these ics
um
yeah you need to be a large corporation
and uh these ics may have some small
number of gates maybe a dozen or so up
to many billions of gates
uh
and uh and most of us who work we work
in software
uh
throughout the hmc projects um you know
when we're doing embedded um
devices we use some firmware which is
just a former software just takes a
little bit longer to write a little bit
longer to flash
and a little bit harder to change
so
so this year with the fpjs we're uh
we're going to be playing with gateway
and so it's going to chat a little bit
about what the gateway is
so
uh
if fpgas which uh stands for fuel
programmable gate array is a sort of the
sort of ic that's um you know is
programmable you can um you can change
change of what changes function and it
consists of a number quite a quite a few
different parts
the uh
the the first three these main things
are the uh what are called the lookup
tables which allows you to do what's
called combinational logic this is um
uh
sort of the the ands and the ors and not
gates the uh logic logic gates um and
what lookup table allows you to do is to
have a number of inputs and a and
typical single output and for any any
combination of inputs you can define
what that output is and it might use um
a ram to just maintain uh create that
lookup table
but what combinational logic gates can't
do is that they uh they don't allow you
to um
they're time independent so it doesn't
matter um
uh what any previous states are they
always produce the same result
so if you want to basically have
a
maintained state and have a different
different results
over time use a flip-flops these this is
for doing sequential logic and you can
maintain
previous state and and uh and as
you have new inputs you can your your
output can depend upon a previous state
and the other part we've got in fpga is
what's called carry logic so if you've
got a a number of cells yeah if you want
to make like a shift register or
something like that you can um
chain the output from one cell to the to
the next
and so these
logic cells are a combination of a
lookup table
flip-flop and the carry logic and on the
fpga that we're using in the rockling
you have about 5000 of those lookup
tables
the other thing a
fpga has is the routing between logic
cells
you also have a
clocks which um provide uh clocking
clock signals out to all these cells to
synchronize them
and in the case of the fpga
that's chosen is also a
fair amount of memory you've got 128
kilobytes of um of ram
uh the other thing fpgas provides don't
have to do everything um yourself in the
in
using your own the logic gates is you
can get specialized circuits for doing
um you know i2c or spi buses including
digital signal processors for doing fast
uh fast arithmetic
and so what the gateway is it's the the
it's the definition language allows you
to describe your fpga and uh and then
admin programming so this is what's
called the gate the gateway
so
this is a this is a diagram from the uh
the lattice documentation and you can
see a logic still has these uh these
components the lookup table
the output lookup table goes to the flip
flop and you also your carry logic and
so you can you can see on the left hand
side if you had eight souls in row you
might you know create a shift register
by having the carry logic trans transfer
the output from one cell to the next
so that's sort of a quick overview of
what goes on goes on inside an fpga
which i've kept track time
uh so then once so if you want to
basically uh
define define what goes on in fpga and
then and then flash or programming if
fpga there's a open source tool chains
now like for example uh symbiflow and so
you start off with uh
a uh a module description so it's like
module.v in a hybrid description
language like ferolog
and it describes um
all the combination logic and the um
and the sequential logic and so on then
how you want to use the different hard
blocks and use a
program called yosis which
turns that
high-level design into the
actual logic gates
then there's a program called next pnr
which
then places those logic gates
into the various available resources of
the fpga
and then and then it routes the uh all
those logic holes together
and uh and then you then you need to
create a what's called a bit stream
which is a
a configuration that's usually subject
to the particular fpga chosen and and
then finally
the fpga
we've chosen has a bootloader which
allows it to appear as a usb device and
there's a standard
tool called dflutool diffuser which
writes that bit stream to to the uh the
rocklin fvga
so that's the um the general
process
so so what so why have we chosen to use
fpgas and why are other people excited
about them given that most of the time
we can just use um cpus and gpus and
other other sorts of peripherals and uh
don't even need to touch an fpga
well if you're um
if you're using something like a
like an arduino um processors like that
mega three to eight sometimes just you
know just you know you run out of pwms
or you just like to have another i2c bus
or something like that and uh you don't
and uh you don't have enough choice
except to just choose another chip
or um you know be really nice to um if
there's an operation do really uh
a lot and it's um the uh it's it's just
slow to do in the uh instructions that
you should be really nice to be able to
like add another instruction or if you
want to add
uh you know a
fpga html output and these are sort of
things you can do uh quite easily in
fpga
uh and also if you can compare the
performance of the uh these small
microcontrollers
um yeah they all have like a very
similar price you know sort of like five
dollars without 5k versus a couple
dollars for that mega three two eight or
a bit more for a for an stm
32
uh
uh because the fha the choice has uh
digital single processors you can if you
have eight of those doing um 16-bit
multipliers at 48 megahertz that's so
that's a lot more horsepower than you do
you get out of an at mega so
so you've got these of um
flexibility advantages
and whilst we're we're playing it sort
of at the very low end of the spectrum
in terms of number of um
uh lookup tables so it's only about 5000
in the um in the up 5k they've chosen
uh
that's still that still allows you to do
quite quite a bit so i'm comparing it to
the
original live 6502 microprocessor which
had about three and a half thousand
transistors there's more than enough uh
lookup tables to um
uh replicate the um function over 6502
and so you can put a effectively put
like a whole app or two inside this
little up 5k or you could or even a a
32-bit risk risk processor
but just in comparison the other end of
the spectrum
a modern
process like you'd find in your mac
that's about nearly 60 billion
transistors in that um similarly with a
top-end gpu from uh from amd or even
silence it's also around 60 billion uh
transistors if you look at the um what
you can get from an fpga it's um
you know nearly a hundred hundred
billion uh transistors so
so even though we're only playing
playing with uh a small number of gates
in the uh with the rockling the same
techniques would allow to
acquire a very very large fpga and
you could
write your own
modules to um you know utilize all those
transistors for a very very custom job
so you can
apply apply the hard resources your
transistors to exactly what i need and
not waste them on anything you don't
need
so
so what
why should um we say take interest in
fpgas now given they've been out since
about 1985 so
several decades and and one of the main
reasons is that a lot of open source
developers like uh by people like tim
ansel have been pushing
pushing very hard to um develop our open
source tool chains and so
uh
it's becoming much
much easier to use now so for decades uh
the definition language like foreign log
and vhdl were roughly like you know same
sort of
i guess abstraction as a writing c code
and these were tied very close to
proprietary tools um they were
very slow sometimes with steep learning
curves and that was fine if you're
working in fpga you know day in day out
as your main job but if you just want to
you know have a bit of a play or um
occasionally use it so it wasn't very
attractive
these days you can use
high-level languages
python in particular but also scala and
others to define your fpga logic uh in
your using a higher level language so
you're not not so down
you know
at the low level the uh logic gates and
there's um also additional software like
litex which allows you to do whole
components um so like a whole
32-bit processor or um or a whole bus
and uh and you can use this to uh
connect together modular components so
your cpu your controls and so on
uh into uh into a quite high-level
design it's much easier to use and
there's um diagnosis tools like light
scope which allows you to have a logic
analyzer so it's become much more
approachable
um and even if you also find uh there's
plenty of um
uh existing verilog modules that or vhtl
in
in github or open cores you can still
integrate those those into your into
your design
and so you can now pretty much work
entirely in
open source tool chains and
for your fpga and often these tools are
do synthesis much faster than the vendor
tools
so um so additional reasons why why
perhaps you're interested is um it's uh
even though you may not you know need to
use the fpga very often very often it's
so it's still very very capable thing to
have you know to know how to do and it's
also just fun um if you're into
nostalgic
hardware or you know dark video games or
do your own cpu design
there's something you can very easily
play with uh with fpgas
and so you know why i have to have the
best of luck for all you use his asic
cpus when you need to and
and combine them with fpgas if that
helps
so so get so in terms of getting started
um the up 5k is um it's fairly expensive
it's a it's um
offers a good range of um
of capability and uh so
tim ansel and uh
uh his group his um colleagues uh
produced the fomo a few years ago back
in uh i think 2019 and there's also
things like the icebreaker and now now
this year produced the rockling
tim's um workshop's a great great place
to get started
and uh and also hopefully first
presentation give you give some more um
some more insights
so
uh so so the inspiration for the
rockling was um
was that last year when we did the swag
badge uh we didn't uh spend as much time
on on sales as we
would have liked we're hoping to
encourage more people to um produce
their own simple uh boards to add onto
the swag badge
and so we thought it'd be nice to try
and create the um
the most interesting so we could
uh
some some people have been chatting uh
for a while about doing an fpga and we
were long overdue
due to a j project
and so we start off with um
uh some foamers that tim had provided
and uh and saw that we were able to
create uh the bootloader for it and so
john
3d printed a a rig so we could um flash
our foamers with with faux boot and that
that worked that was good and uh andy
kitchen uh was
also uh working with fpjs as part of as
part of his work and so
we just sort of had had all the right
people you know bob had some some time
to design and we think well what could
we do with we um try to design our own
uh fpga board and uh doing a playing of
audio was something we hadn't done
before so that seemed a natural thing to
have with the the eight dsps and then uh
and then to say what we're going to do
of audio processing we thought well
let's make a musical instrument and um
because andy had the idea of making a
theremin
so that's so how that's how the rocklin
came about
so
we start off with um with uh some foam
moves and uh and if you want if you want
to um
get get a fl they run flash so that's
basically uh flash the spi module uh
flash memory and uh so do that initially
by soldering some eyes on which are very
very fine pitch and uh we managed to
manage to do that well it was a bit
cumbersome and so after that uh john uh
3d printed the
uh little test jig so you guys could
just place the foam in the chest you can
just flash a raspberry pi so that that
worked
uh and then if you wanted to actually
play with the phone like there was um
these four four tiny tiny pads for gpo
so we you know sort of attached wires to
that and the reset button that was a bit
also a bit cumbersome but um that sort
of gave us some confidence that
we could build the tool chains and get
going and uh and even though there's
only four pins on a
on a phone you can still create a an i2c
bust an spi bus or even drive fpga so
even though it's only a very tiny board
it's um you can still have some fun with
it
and then from there we uh
uh bob
with andrew's uh nielsen's uh layout and
bob's uh
electronics design um we produced the
the first prototype and uh it was a
challenge getting that up because
unlikely when you put a cpu down on the
board if you it usually has an internal
clock or if you're applying a clock
signal it pretty much
usually works right away or it's easy to
diagnose
um one of our first problems is uh
we mistakenly chose the wrong
uh
internal global system clock pin to use
and uh just nothing worked and it was um
it was not immediately obvious how to
you know what what the problem was but
we uh
eventually figured it out and uh managed
to clock get the fpga clocking and we
were able to um
uh flash it and and
and flashing a flashing led so that was
um encouraging
and then
one of the
key things you want to do is make it
just make it easier to um
flash and interact with the chip so
basically put a put a has a header on
the uh
on the rocklin which uh gives us both
i2c and spi so it would make it easy for
us to uh reflash the uh the bootloader
and also to interact with the device
over over a sayo from the swag badge
so you can see that's
uh there
once the prototype was done and uh we've
pretty much proven out the the
fundamental design worked we then went
on to produce production boards and it
was a pretty exciting day when they
first came back because we were able to
test uh andrew nielsen's tiling and see
if they truly did tile the plane and we
can make some some pretty patterns with
them
so so again getting down to some details
so this is the uh
sort of a block diagram what's going on
inside there at the rockling so at the
heart of it is the
fpj and towards the uh the front of the
uh the fish you know the the fish the
fish head where the fish eyes that's
that that's the analog front end for a
theremin so
a theremin has uh two inputs a uh a
volume and a pitch and tennessee
basically
you know have moved one hand for volume
another hand for pitch and i think
during bob's talk later today he'll um
he'll talk about some antenna design
but bob took the design from open open
thurman and so basically just translate
that onto the onto the board and usually
has a
an arduino at mega chip rather than fpga
but
what we what we did was i see it took
the volume and pitch uh that came from
the front end which um should be roughly
500 kilohertz uh and it just varies
slightly by uh maybe 20 or 30 kilohertz
based on your hand position
and uh have that come into the fpga
on the uh
the so the rocking has both an itc bus
for interaction with the swag badge
and an internal i2c bus for talking to
the
adac which provides um
two output folders one to act as a bias
for the volume and other to act as a
bias for the pitch
and the other things on the bus is the
uh the audio codec
so uh
so the fpgas i2c to control the
dac and codec and downstream from the
audio codec is the uh the amplifier
so the idea is that with the fpga the
dsps we'll be able to synthesize
hopefully um some sophisticated sounds
and to give that that sort of classic
thermal noise and then over the r2c bus
would send that data to the audio codec
out to the amplifier then to um you know
hit either a headphone jack or speakers
and you can also see at the top the
flash memories on the on the spi bus so
that allows the swag badge to um
initially flash
flash the
bootloader onto the flash memory so when
the fpga is powered up it'll uh
you'll
load its bitstream from from the flash
memory
uh the final piece in that diagram is
usb so there's um
pins
gpo pins from the fpga
go directly to a usb connector and the
and how that works is the
fpga has a risc-5 processor which has a
usb stack written in c and so when you
power the fpg up it appears as a dfu
device which is just a standard way of
loading um
firmware onto onto devices over over usb
so
just just to recap
we'll provide the rockling with uh
phobic already flashed on it but for any
reason we need to change or reflash it
then uh the swag badge can be used spi
to re-flash the phone re-flash uh
the flash memory on the on the rockling
uh the main primary way of interacting
between this the swag badge and the fpga
will be via the uh sayo igc bus
and allows the swag badge to provide a
user interface or uh or networking for
the rockling
the fpga um has a little bit of gateway
that measures the um counts the uh
the volume and pitch
input frequency
and then uses um we've got a
a soft r2c bus
controller for controlling the dac and
the audio codec and uh and also there's
um
an i2s
module as well
um as mentioned uh yeah the
rocklin when you plug into usb the
operating appears as a dfu device and
use dfu tool to list it and then also to
flash code
and there's uh also it's called the
wishbone bus so all the all the
peripherals on the on the rockling
appear on this 32-bit
bus and you can just use a laptop
command wishbone command on your laptop
to uh interact with all those
peripherals
uh
so the uh
the phone
normally comes with a
a wrist five soft core that's um
quite capable but it's also consumes
quite a lot of resources so
andy was able to find a
a smaller implementation of s5 called
arm femto
i think femto risk and it was which um
i gave
didn't use quite as many uh
logic cells so um yeah we're running out
of room
um yeah so
uh during the process of um
going to production um
you know we have you can see there's
lots lots of barge wires on the uh on
the on the prototypes as uh we had to um
use a a different pin for the system
clock and uh
also a ysl for testing out things like
the usb and so on and then uh
as as we bring each board you see
there's like a checklist of what you
know what things were working so to make
sure the bootloader worked and appeared
over usb that the
rgb led is working to serve as just a
this big checklist which we're still
going through now for each of the boards
right so um so looking at the
the whole project the project as whole
so the swag badge
the uh party button and the the rockling
this is um a bit of a an
overview of how these all hang together
so
the uh the party button uh can connect
operate stand alone i think as uh as
john showed earlier you can uh just put
a little uh
baseboard that has the uh the battery
and uh just basically short circuits the
uh the button to the uh the mosfet so
you just press the button and the lids
go on but if you take that little um
download adapter off you can
connect the party button up as a sayo
which then means the gpo
input from the button or the output to
the mosfet can then be controlled by the
sp32 on one of the save connectors
and uh and somebody can connect the
rockling up to
one of the so so we've got so one is not
it's got not just uh rtc but also also
the spi bus so if you put uh you can use
that uh so connector for um
flashing the uh
the the rocklin from the swag badge if
you need to otherwise would normally put
it on a say three
uh on the right hand side of the rock
rocklin of the sorry the swag badge and
that's um provides an itc bus for
interacting with the fpga and also the
gpo is used for the uh for resetting the
fpga and listening to the configuration
done
uh pin and then finally on the rocklin
also has the the usb connector for you
know
doing development from your laptop
so uh those the swag badges for sales
the swag badge provides the user
interface and uh you can also provide
additional program control monitoring
and also the networking
and
we
wanted to have the uh the party button
so as a as a server
we always like to give people the
opportunity to learn to solder and also
get a simple introduction to making sews
whereas this is the button
in a mosfet out
and some of the simple ideas
is to basically allow the uh swag badge
to provide more more complex behavior
than just a button controlling leads or
maybe just networking and connect a
couple of party buttons up together
so um
finally just to talking about the
rockling the um primary may we intend
the rock can be used with the swag
badges are using this r2c bus where the
esp32 is the rtc controller and the
rocklin is the peripheral
and we've got the two pins for our gpo
pins for resetting and checking the
configurations done
and then we've also got the other header
for the
spo pins flashing and then on on your
laptop you'd use uh
when um
we've provide instructions on how to use
um symbiflow and set up the tool chain
for the for um creating uh
an fpga bitstream you suggest you just
go you simply just type make and it uh
basically runs all the python code and
uh live text for
for creating the uh the bit stream and
you just then just use
usual just to flash that onto the fpga
um
yep still got five minutes so um
that's a quick quick run through so okay
what sort of questions do we have like
did any of that make sense i'm just
jumping back in
to pass through some questions that came
in in the chat
so um the first question and other
people can chime in with this as well is
do you have any real world problems for
when you use an fpga versus a
traditional mcu and why
um
well um
in in a situation we have uh lots of
parallel inputs uh where we need to do
signal processing as a classic a classic
use for an fpga so um
it's it's one thing to um
look after a small number of inputs
through a microcontroller but if you had
like um
you know like a 100 100 signals that you
need to look at simultaneously then an
fpga would be ideal for that
another situation people looking at is
uh
with um
uh with cmos transistors whenever you um
change state that consumes power if
you're not if the transistor is not not
not switching
um it doesn't use any power so with an
fpga you can have you know minimize the
number of transistors to just what you
need so for people who are playing with
neural networks where they only need um
a single bit they don't need eight bit
or four thirty bit numbers uh applying
an
fpga to um small neural networks to save
power is another another option
okay
next question is will fpga save us from
the component shortage apocalypse and
replace hard to buy ic ip with an
fpga well well perhaps um
uh that
uh as a bit of an aside
as uh companies like apple and i think
also tesla doing the same thing where
they they um
incomp control their complete tech stack
and so in contrast to other car
manufacturers when there was a chip
shortage tess was able to
get different chips and just rewrite
their software stack to use those
different ships whereas if
other companies like gm and so on we
were dependent upon other third parties
they were they were stuffed they if they
couldn't get the chips they needed they
couldn't change the software
so um in a situation where you could do
control your whole stack
and you can have like an fpga and you
can um
uh
change it to um to for your needs and um
then then perhaps
and this is on the um
the optimistic
side of things where the fpgas
themselves remain available yes which is
difficult as well
um but i certainly like the idea that if
you've got um
uh
you basically need a cpu and you've got
some other logic other digital logic
that um to be able to you know integrate
that onto a single chip is a nice thing
and if you do need to make some simple
changes you don't have to go and buy a
new you know a different different um
say small scale integration chips you
just simply change your fpga that's
that's a certainly a nice thing so i
think we saw that in the early days of
them
hobbyist pcs where um
the first um apples and other things
where they maybe use 20 or 30 or 40
chips and you look at something like an
apple two gs and there's only like six
chips and so
um increasing your integration is always
a good thing
also a question specifically about the
rockling is can we use the rockling to
do stuff even if we don't touch the fpga
at all
yes great question you can because the
um
the first way you can start to use the
rockling is simply as a risk five
processor that um has uh the peripherals
the
i2c control and peripherals the uh the
dac and the auto codec and and it's just
there's a c code
there's initializing these peripherals
and then i'm sending um i2c
commands to um
set the
the the dac is really used to use it's
basically a one command to
set the the the voltage for um
one channel so there are two commands
you can change the voltages on the two
channels for the front at the front end
uh the audio codec is a little bit more
complex to um
control which they're still going
through that but um it takes a series of
i2c commands to stop the inputs the
outputs the
uh
the um
the clock the clock rates for the i2c
bus sorry sorry the i2s bus and so on
and west uh but that is all just um c
code that we're changing on top of the
fpga
okay and um one final question which i
think is a very interesting one what
would it take to expose the fpga
wishbone bus as an external memory
device to the esp host processor eg
memory mapped gateway peripherals
okay
um let me think about a sec
so the um the wishbone bus allows you to
wrap
any um any peripheral as a uh in the
fpga
as a as a uh uh on a on a 32 address and
so what we could potentially do is um
and i'm really making this up on the fly
is uh we we communicate between the the
esp32 is the i2 i2c um controller of bus
zero and the fpga as the peripheral and
so
um
if we had um
uh
the uh well actually we already do have
the ability for understanding
wishbone commands that um right to the
um
the to the i2c bus
um yeah i'd say i'd say potentially
possible to
use wishbone commands to um talk talk to
the rtc bus with the esp32 so we'll take
a little bit of work but i can see it's
it's possible
um i said that was a final question but
there is actually one more that was in
the chat unfortunately we have to answer
no the question was can we have a
performance of the theremin
and unfortunately it's not quite at that
functional point there has been
validation of various parts of the
circuit but we do not have the complete
working system so things like the
oscillators in the analog front end that
read from the antennas to measure your
hand position and those sorts of things
there's been some testing done of those
and we can see on the oscilloscope that
the signal coming out of them makes
sense oh and better than that we've
actually got the fpga is actually
counting the uh the frequency so um
uh there's a couple of um diagnostic
tools uh one is one allows you to um
reference uh
the um or actually
let's say so again the rom and the ram
of the risc-5 cpu is uh mapped onto the
whisper bus and so you can actually get
the um when you compile the c code for
the risk five you can actually get the
memory map of the uh the various um c
variables and so you can actually just
on the wishbone bus look at those and so
you can actually see the c code that's
the c variable it's actually counting
the frequency so there's that way um and
so yes we've actually we've seen that
it's i'm correctly counting the um the
theorem input what we haven't got um
fully going is the
uh
there's five processor on the fpga
seeing the right i2c commands to set up
the uh the audio codec
by which we get sound out yeah and uh
we're we're pretty much out of time
we're a minute or two over time now
but there was one question which is how
many times can you reflash these things
and then i think we're gonna have to
wrap it up um
uh
the we're using a standard um flash
memory module so um
you could uh
re-flash it thousands of times yeah
anytime soon
okay okay well i hope that was useful
made sense it was a little bit a little
bit of a rush but um thank you for
listening and uh we're looking forward
to getting this some in in your hands
and and collaborating on on some
building some stuff yeah so in a couple
of minutes we will be back at 2 40 p.m
um tisha will be talking about open
hardware where the radar awesome thank
you very much and uh we'll see you soon
okay thanks