
ULX3S: Hackable FPGA that runs Linux on RISC-V - herogreen
https://ulx3s.github.io/
======
herogreen
Also newsworthy: Lattice drops recent EULA clause forbidding fpga bitstream
reverse engineering [https://hackaday.com/2020/06/06/lattice-drops-eula-
clause-fo...](https://hackaday.com/2020/06/06/lattice-drops-eula-clause-
forbidding-fpga-bitstream-reverse-engineering/) therefore 2020 could be a
milestone for open FPGA toolchains!

~~~
dmos62
I initially misunderstood this headline to mean the opposite: I took "drops"
to mean "introduces", which is the opposite of the intended meaning --
"withdraws". Not sure where I got this non-mainstream meaning of "to drop".

~~~
pmiller2
People do talk about “dropping” an album to indicate it’s being released. Your
confusion is somewhat understandable. English is hard. :(

~~~
shoo
similarly, dropping off supplies or deliveries -- maybe where they are dropped
from a great height via parachute out of a plane. Or dropped off by a delivery
truck.

"Lattice drops recent EULA clause" would be easier to interpret if the initial
and final altitude of the clause was specified. If the initial altitude was
unusually high, it might indicate that the clause was being introduced via
parachute. If the initial altitude was comparable to the altitude of an object
being held in a person's hands, and the final altitude ground level, this
would suggest the clause being discarded or removed.

~~~
dmos62
Haha, that made me laugh out loud. "Lattice drops recent EULA clause from 1.5
meter height".

------
haberman
Is there any published rationale for the RISC-V instruction encoding?

A few months back I set out to write a software emulator of RISC-V for fun. I
expected the instruction set encoding to lend itself well to a very simple
implementation, eg. something you could decode in 5-10 lines of C plus some
tables.

But the instruction encoding is much more irregular than I expected:
[https://github.com/ucb-bar/riscv-
sodor/blob/master/src/commo...](https://github.com/ucb-bar/riscv-
sodor/blob/master/src/common/instructions.scala)

In particular:

    
    
        - The bit patterns allocated to the simplest instructions
          (eg. rv32i) seem random. Why not allocate starting from zero
          to allow dense jump tables?
        - I can't make any sense of the groupings. A bunch of instructions
          have 0b1100011 in the lowest bits, do these instructions have
          something in common?
    

I assume there is some rhyme and reason to all this? Where is this explained?

~~~
phkahler
I spent some time defining an alternate encoding of the base instruction set.
I dont think they did a good job, but it's also not easy to do better. I
started from an assumption of variable length - 16 bit or 32 bit opcodes plus
immediate data in 16 bit chunks. It's not easy. Remember all those strange bit
positions are irrelevant in hardware. But they are a bitch for things like
linkers.

~~~
zozbot234
It has to encode 32 GPR's and three-operand instructions so instruction
encoding is a bit cramped, even in 32 bits. 16-bit encodings are reserved for
"compressed" special-case forms of existing 32-bit instructions.

~~~
phkahler
Right, so I made 16bit opcodes only have 4 bits for register indexes. 32bit
ones would provide the 5th bit for each register. That means a compiler should
prefer the first 16 registers in order to reduce code size, but they are all
still available. It also meant a reduced size chip with half the registers
would not need different instruction encodings.

Compressed was an afterthought on Risc-V. A well thought out afterthought, but
you do things differently when you know in advance.

~~~
zozbot234
Compressed was very explicitly made optional so that implementers would have
the choice of recycling that encoding space for something else. It was not
just an "afterthought".

------
q3k
The ULX3S is great! I built myself an early prototype a year ago, and have
used it every so often for occasional hacks. It has since evolved to be a
first-class citizen in a number of projects and frameworks (LiteX, including
LiteDRAM), which makes it great to get started with.

Also worth noting, that you can use a fully open source flow (Yoys + nextpnr +
prjtrellis) for this FPGA family. Here's a repository I made that shows a
basic blinky for an ULX3S: [https://github.com/q3k/ulx3s-foss-
blinky/](https://github.com/q3k/ulx3s-foss-blinky/)

~~~
TD-Linux
Yeah I also DIY'd one and it makes an excellent dev kit - the right combo of
peripherals in a small footprint. It also has a lot of IO's on normal 0.1"
headers so it's a good starting point if you want to stack it on top of
another prototype PCB. Your blinky was actually the first code I ran on it.

------
tyingq
Where's the article? I see mostly a bunch of loosely related bullet points.

Edit: After a lot of back and forth, perhaps this is a good intro:
[https://hackaday.com/2019/01/14/ulx3s-an-open-source-
lattice...](https://hackaday.com/2019/01/14/ulx3s-an-open-source-lattice-
ecp5-fpga-pcb/)

------
bloopernova
Layman question: how many years before we get RISC-V desktops or Raspberry Pi
like computers?

~~~
mhh__
Desktops, perhaps never - 10 years? Alibaba seem to be funding some R&D in
this direction, but I'm not too familiar (and I can't speak Chinese). It's
certainly possible, but desktop processors aren't simple in any way.
Regardless of absolute technical excellence, RISC-V only has to be better than
ARM (in both specification and implementation, and cost, of course) which will
be a moving target as RISC-V improves.

Single Board Computers - [https://www.sifive.com/boards/hifive-
unleashed](https://www.sifive.com/boards/hifive-unleashed) this seems to fit
the bill. However, they don't seem to be selling those yet - the development
kit for that particular CPU seems to be an FPGA soft-core.

I am currently working on an open-hardware project that requires a fair amount
of grunt (or FPGA); in an effort to keep is open I was looking into RISC-V
processor's. You can actually buy RISC-V hardware today as a guy on the street
(i.e. Digikey etc.) but the offerings I could find were generally fast
microcontrollers rather than general purpose processors.

If RISC-V is to be adopted it's probably more of a question of engineering
knowledge and training than solely hardware: One of the chips I found in my
search above is an interesting Chinese system on module that has a RISC-V at
400MHz, Wi-Fi, _and_ a hardware NN coprocessor - it's a cool chip but even in
Chinese the documentation is unusable and awful.

If a big western company like ST or Cypress etc. picks up RISC-V and starts
making it easy and safe to actually use (for example, the section of the
manual for the serial peripherals on most NXP microcontrollers is longer than
all the documentation I could find for the aforementioned SoM).

~~~
justinclift
> ... [https://www.sifive.com/boards/hifive-
> unleashed](https://www.sifive.com/boards/hifive-unleashed) this seems to fit
> the bill. However, they don't seem to be selling those yet ...

The HiFive Unleashed was released (and for sale) back in 2018. From memory,
there was a limited run (priced at US$1k each), as it was targeted to specific
types of developers looking to do further work improving the platform.

For example, Red Hat bought some and used them for improving the RISC-V
support in Fedora. From memory, Richard Jones (@rwmj here on HN) was involved
with it.

~~~
drmpeg
[https://www.crowdsupply.com/sifive/hifive-
unleashed](https://www.crowdsupply.com/sifive/hifive-unleashed)

------
ngcc_hk
Remember there is a lecture by a guy who demo on a game emulation program.
Wait for it since.

Just placed an order :
[https://www.crowdsupply.com/radiona/ulx3s](https://www.crowdsupply.com/radiona/ulx3s)

------
wolrah
Can anyone comment on how this compares to the popular Terasic DE10-Nano used
for the MiSTer project? The price point is around the same and I see they note
running video game cores as a market for this device, but I have absolutely no
clue how to reasonably compare FPGAs.

From my rudimentary understanding it looks like this doesn't have a hard CPU
and has a smaller FPGA, so I'm guessing we have a fair bit of "open hardware
tax" at play here too.

~~~
lnsru
“Open hardware tax” is huge here, your impression is correct. Real 800MHz
Dual-core ARM Cortex-A9 processor is on Terasic board while this has a soft
core processor. In my experience soft core can run at ~200 MHz best case. Then
comes slower RAM and this limits overall possible applications. Unless
somebody wants RISC-V badly.

------
pjmlp
Cool! It also does Oberon, MicroPython and Basic.

~~~
herogreen
And DOS, NES, Amiga, Apple I, Apple II, Z80 ! I am new to FPGAs so it is a bit
difficult to know what to expect from a given number of LUTs, but you can
compare between models: the big version of ECP5 in ULX3S has 85k LUTs while
the previous well open-source supported FPGA (iCE40) had only up to 7.7 k
LUTs, so more than a 10x jump :)

------
b1ackb0x
Is it any better than Artix-7 XC7A100T or XC7A35T boards from
Aliexpress(search QMTECH, they sell 100K board for ~$100)?

~~~
rwmj
Probably not in terms of hardware. But the open source development chain is so
much easier to get started with than Vivado.

------
sitzkrieg
very impressive project, its a good time to get into fpga projects

~~~
mhh__
It's much better than before, but it's still surprisingly difficult to buy a
cheap (good) FPGA board. For example, the cheapest ECP5 on _digikey_ (FPGA's
go for a lot less than list if you're buying more than a few) is about $10 yet
the cheapest proper development board is a lot more.

The FPGA manufacturers like the margins, fine, but I'm surprised people who
make boards like this one but for other things don't just chuck an FPGA on
them (for some definition of "just")

~~~
jope12
Qmtech on Aliexpress have the best price/performance when it comes to FPGA
boards.

~~~
cinquemb
Prob not bad for some applications, but if you are trying to have cost of a
overall system low in order to make it more available to more people… id
rather go with the ice40LP's

------
gre
How does it compare to the Arty A7 for $129?

~~~
jope12
The question is rather, How does it compare to the Qmtech Wukong board? And
the answer is: you get way more bang for your buck with the Wukong board. No
Symbiflow, though, if that's what you're after.

Link to board:
[https://aliexpress.com/item/4000170042795.html](https://aliexpress.com/item/4000170042795.html)

~~~
madushan1000
I think prjxray + nextpnr has support for at least some of Artix7. Checkout
[https://github.com/daveshah1/nextpnr-
xilinx/](https://github.com/daveshah1/nextpnr-xilinx/)

------
lihaciudaniel
Theoretically every fpga is hackable

------
johan_larson
The dollar sign comes before the number, not after it.

$150

~~~
craftinator
Truly, a pedant's pedant.

------
rasz
2x more resources compared to $30
[https://github.com/q3k/chubby75](https://github.com/q3k/chubby75) at 5x the
price

~~~
aspenmayer
What is your pick for the best FPGA for the money or if money is no object? I
just don’t know much about this area outside the MiSTer project.

[https://github.com/MiSTer-devel/Main_MiSTer/wiki](https://github.com/MiSTer-
devel/Main_MiSTer/wiki)

[https://www.retrorgb.com/mister.html](https://www.retrorgb.com/mister.html)

~~~
classics2
Intel Stratix 10

~~~
aspenmayer
Can you say more about why this one is the one? Is it better in quantitative
ways or ease of use than competitors? Cheaper or more reliable? Etc

~~~
mhh__
Stratix 10 is an absolutely enormous FPGA (10FLOPS) so I'm guessing wow-factor
rather than ease of use.

~~~
aspenmayer
Oh wow, I had no idea they were that advanced. How much do these go for
secondhand?

~~~
pjc50
There is no sensible secondhand market for things like this; it will be
embedded in someone's board. And there aren't many about to start with.

Sometimes people are lucky enough to find decent FPGAs in scrap, but it's like
panning for gold.

~~~
lukego
I've recently bought second-hand Xilinx FPGAs on Ebay for $250 each with list
price of $3500. They come on boards that have an unidentified manufacturing
fault. Salvaging and reusing the chips seems realistic using a budget vapor
phase soldering setup (not attempted yet) but the challenge for me is
designing or otherwise acquiring suitable PCBs to put them onto. I'm told that
you can potentially find suitable PCBs on Aliexpress but I haven't looked into
this in detail yet.

In other words, there doesn't seem to be much demand in the secondhand market,
and you can potentially use that in your favor to take advantage of supply
selling at steep discounts.

