Compiling my own SPARC CPU inside a cheap FPGA
thanassis.space
thanassis.space
The Pano G2 FPGA is a monster, but prices on eBay have gone up a lot. My cheapest buy was 25 of them for $85 (including shipping!). They now go for around 1 for $30 if you’re lucky... or $200+ for many.
The Pano G1 (with VGA instead of DVI) is cheaper but has a much smaller FPGA, though still large by hobby standards.
The benefit of the G1 is that all interfaces are working now, including DRAM, USB, Ethernet.
Last week, Skip Hansen got a full CP/M system running on one: https://github.com/skiphansen/pano_z80
USB on the G2 is hard. A bunch of people have tried and failed.
(Granted, I mostly see Rev C.)
The only reliable indicator to check which one to buy is looking at the pictures: VGA is G1, DVI is G2. (Some G2 are photographed with a DVI to VGA dongle plugged in, adding to the confusion.)
There are 2 G2 versions: one with an LX100 and one with LX150. You can’t know which one you’re buying...
LX100 is still a gigantic FPGA for hobby stuff.
Found one with DVI and just bought it, @ $22.95.
Thanks for the advice!
Have fun with it!
//edit: Next thing tomorrow: Order the stuff necessary to program this (or check if I can use company equipment).
If you're willing to forgo the Xilinx special features such as ChipScope, you can also use OpenOCD and pretty much any OpenOCD compatible JTAG cable to upload a bitstream into the FPGA.
I wonder if it would be possible to retrofit an MMU onto a Z80 design and port a real UNIX to it? 25 or even 50 or even a 75 MHz UNIX server on a Z80 processor, that'd be a nice perversion...
http://dmitry.gr/?r=05.Projects&proj=07.%20Linux%20on%208bit
That is because the z80 was a (mostly) binary compatible superset of the 8080 instruction set, and the 8086 (while not binary compatible) was intentionally modeled after the 8080 such that there was a program that could take an 8080 program and do the 1:1 instruction mapping from 8080 to 8086 and get a working 8086 program.
> I wonder if it would be possible to retrofit an MMU onto a Z80 design
Zilog made a number of Z80 follow-on CPUs, and some have MMUs. It is amazing how far they took the instruction set; the Z80380 could run Z80 code as-is, but it also extended instructions to support 32b operations and had a mode with a flat 32b linear address space. I don't recall ever hearing any consumer product using it though.
None of this would have been possible without you, Tom! Thanks for everything.
I'm wondering if my Scarab code for the LX6+ will move over.
I built a frame buffer for a Cortex-M4 on it.
At first, I was extremely impressed that a 50 employee company could design their own FPGA chip.
Here are the internals of the G2: https://tomverbeure.github.io/pano/logic/2018/12/02/Pano-Log...
It seems that the Panos are only available on eBay US, any idea where to get them in Europe without all the shipping and tax hassle?
> any peripheral hardware and firmware with priveleged access.
That would be a more feasible vector. But it all still will be much more secure than your average computer with a BMC.
FOSS vulnerabilities countered the many eyeballs argument a long time ago. There's even fewer people who know how to review hardware for flaws. I'm assuming it would be a targeted attack by default. That raises the bar. However, they could also leave a trigger that looks like a hardware flaw in the I/O interface. Intel has basically been doing that subversion with their ME flaws for some time now. Then, the only targeted part is just how to aim what's already there.
"That would be a more feasible vector. But it all still will be much more secure than your average computer with a BMC. "
True. Especially if you use an architecture like crash-safe.org or Cambrige's CHERI. I already advocate secure CPU's on FPGA's with dumb-as-allowed hardware if one can't get actual silicon. Also lets you throw in extra reliability features, too.
the truth is that most of the HW designers I know are editing inside their Vendor-provided IDEs.
Maybe true for FPGA designers, but not for ASIC designers in my experience.
Another crazy difference I experienced was that builds are NOT deterministic
Yes, hardware generation (synthesis, but mostly optimizations, placement and routing) are not deterministic. SW people are starting to experience that phenomenon with ML as well: you don't fully control what you get, but it works.
The best bit is the windows-only version of the Xillinx gooware that in fact installs a Linux virtual box on windows to finally get to run the tools it needs.
Oh, and yeah : there's a lame protection in there that checks it's running on a specific virtual box with a specific MAC address.
Amazing (not in a good way).
No, they definitely aren't funny. I've worked with FPGAs and DDR controllers at college and their can be a big PITA. Even with DDR controller libraries you can still run into all sorts of timing issues.
1. You start to wonder how very, very far your code runs from the theoretical capabilities of the hardware and you start experiencing existential doubts.
2. You are overcome by a deep and immense feeling of gratitude towards whomever managed to force all that complexity to remain hidden underneath the simple memory abstraction your rely on to write day to day code.
Found this PDF from Samsung regarding the DDR4 interface itself:
https://www.samsung.com/semiconductor/global.semi/file/resou...
(The JEDEC DDR4 spec is $284 to download...)
Also, is it anything like http://www.visual6502.org/JSSim/?
The impression I got, esp by 28nm, is the hardware is inherently broken in quite a few ways. They have to correct the masks with algorithms, they do image recognition on circuits to spot patterns that act up, extra latches, variance across the chip/wafer, aging effects... list goes on. Miracle they even work at all.
These things are also why I only trust old nodes for security. Sort of.
(but this observation is generic for all FPGA-stuff really, it seems easy first, it's just another language etc.. but you need to learn timing analysis and constraints and optimization to use it for real)
Spartan-6 does not.
But Xilinx has a MIG (memory interface generator) that automatically creates the RTL for a memory controller that synthesizes to regular core logic.
In addition, it also has IO cells with posedge and negedge FFs and calibrated delay lines.
Getting the DDR DRAM to work on the Pano G2 shouldn’t be too hard. (Less hard than the G1, which has DRAM that isn’t supported by the MIG.)
I really should get the DRAM working on the G2. How hard could it be?
Just got it up and running with a 125MHz clock and the Xilinx MIG (memory interface generator.)
I used a similar DDR2 memory (MT47H64M16 I think) on a Cyclone III a few year ago. Using the ALTMEMPHY from Altera it was not to difficult to make it work. Then later we got a new batch of cards witch would randomly fail. The problem was that DDR had been switched from Micron to an equivalent from Samsung. But the timing must have been just different enough to cause random fails. So yes DDR2 memories can be tricky.
Many years ago at University I used Leon and grlib for a project. It was a nice processor and IP library. I would like to use it again.
[1] https://www.xilinx.com/support/documentation/data_sheets/ds1...
What other cheap hardware products contain FPGA's that are potentially user accessible?
I started a new message chain for this:
Ask HN: What other cheap hardware products contain FPGA's?
HDLs and FPGAs have very different principles and objectives. The best term is ‘instantiate’, because one creates an instance of a given hardware description upon the substrate of gates provided by the array.
I’m sure I’ll be told I’m nit-picking, but those who do so would probably recoil in horror at the faux pas of some n00b saying a browser “compiles HTML” and tell them the correct term is ‘render’, and they’d be right.
Please, let’s be careful and deliberate about the terms we use, can we please?
Lowering HDLs into logic that can be flushed onto LUTs does involve an intermediate compilation step, even though it does also involve placing/relocating/routing elements on the FPGA, ultimately producing a file to be flushed to the chip.
One could argue that 'compiling' is often conflated with 'linking' in producing application binaries, and in fact 'linking' also involves positioning/relocating elements in some fashion.
'compiling' is suitable and conceptually compatible enough that it clarifies rather than confuses.
It’s entirely possible that I might’ve (accidentally) redefined one or more meanings, and if I have, I apologise. It’s almost four in the morning and insomnia prevents me from sleeping but doesn’t necessarily maintain me at full alertness (tomorrow/today will be hell).
How about synthesizing the GPL-licensed OpenSPARC T2 now?
https://www.oracle.com/technetwork/systems/opensparc/openspa...
I'd love to have SmartOS backported on a FPGA-based, OpenSPARC T2, 19" 1U rack mountable server someday. Free hardware and software all the way.
Edit: no it isn't, see below.
An OpenSPARC T2 is a SPARC V9b+VIS ISA. All UltraSPARC processors with a SPARC V9 ISA are 64-bit.
It appears that I have been mislead, back in 2005 when OpenSPARC was released somebody from Sun told me that LEON is based on OpenSPARC, and I haven't bothered to check since. It seems to be a completely different design (it even uses VHDL instead of Verilog). So I was very mistaken about LEON.
However, there have been other (embedded) SPARC V8 CPUs derived from OpenSPARC. I have worked on one myself (on the software side). This one was a very strange one because it only had two register windows (and the ABI didn't use register windows) and they disabled SMT.
This type of modification is extremely easy to do on SPARC because of the way 64-bit works. There are no separate execution modes, there's simply another set of flags that's affected by instructions. The conditional instructions chose which set of flags to use.
I really like SPARC, it's my favorite architecture.
Dr Jack Whitham disagrees:
> https://www.jwhitham.org/2016/02/risc-instruction-sets-i-hav...
There are some spectacularly annoying things like the stack bias, but those are easy to hide in the assembler (and those are problems with the System V ABI, not SPARC, embedded ABIs ignore them).
The offset is chosen odd as to trivially identify 64-bit code in things like register window overflow trap handlers[2].
When I say I prefer some assembly vs. some other assembly, I speak from the perspective of a kernel/compiler writer. Realistically you will never use assembly to write general purpose code. You either target it from a compiler (in which case it better be easier to target), or write some specialized runtime/driver code, in which case it would better have easy to understand semantics and behavior. If you were to write general purpose code in assembly, say write assembly instead of C, an orthogonal CISC architecture would be way easier to write code for. But nobody does that anymore. People only use assembly when they have to (or target it from a compiler) and for that particular case the features of the ISA that matter most are quite different than what a general purpose programmer would want.
SPARC really excels for me because of how easy it is to target and how easy it is for me understand when I am writing runtime code.
I have various SPARC hardware, the most interesting (and the one eventually used for the Go port) being a single-digit serial number S7-2 system[3]
[1] https://docs.oracle.com/cd/E18752_01/html/816-5138/advanced-...
[2] http://src.illumos.org/source/xref/illumos-gate/usr/src/uts/...
50% of servers in my basement data center are SPARC based.
Ha, I remember suffering through this. MIPS has a relatively pretty instruction set but it’s just such a pain to write by hand and the arbitrary choice of forcing delays and pipeline stalls on developers in the way that it did was just really disappointing…
"Lot of 25 Pano Logic Thin / Zero Desktop Client Black w/ Power Supply
Buy now: US $170.00"
I wonder what the thinking was that lead Pano Logic to put expensive FPGAs inside these units, instead of some more typical cheap ARM SoC?
Edit: Ah, they operated in 2006-2012. I guess that was just before the rise of the very cheap/fast SoCs.
Cheap ARM SoCs were on ARM’s roadmap back then. Cortex A9 was huge innovation these days.
https://www.bizjournals.com/sanjose/blog/2012/11/pano-logic-...
"... the company had doubled or tripled its revenue every year since 2008, when it had about $1 million in sales.
...
The company was backed by about $38 million in funding from investors including Goldman Sachs, ComVentures, Foundation Capital, Fuse Capital, and Mayfield Fund."
Fpgas are often used as a stepping stone towards cheaper asic or hybrid solutions. asic requires a high volume and a working design, neither of which you have early in the project.
(The large amount of memory is not because they need so much memory, but because they needed the bandwidth of a 3x 32 bit bus)
Cloud Computing got really hot in 2006, it was perfect time to milk suckers. https://www.crunchbase.com/organization/pano-logic mo was finding bigger idiot before running out of coal.
Reminds me of another 'we will make it up in volume' dotcom scam I-Opener https://en.wikipedia.org/wiki/I-Opener selling ~$500 worth of computer and LCD monitor at $99
$250 for Xilinx Artix-7:
https://store.digilentinc.com/arty-a7-artix-7-fpga-developme...
$100 for Lattice ECP5 (85K LUT):
https://www.latticestore.com/products/tabid/417/categoryid/5...
In any case, I think ecp5 is partially supported by open source tools which should make it much more interesting to hobbyists.
I know that "#!/bin/sh" and "set -e" will work on all the BSDs, Solaris, Linux, macOS, what Unix is realistically left?
But TBH, keeping that script (that I wrote in 60 seconds) nice and clean was the least of my worries... Making the damn toolchain work had far, far higher priority :-)
And after that, booting the LEON cores of course.
Up until the latest Solaris 10 patches, /bin/sh and /sbin/sh did not implement set -e, because on Solaris /bin/sh is the real McCoy - Steven Bourne's shell from 1972 - 1977. There is a fully POSIX compliant /usr/xpg4/bin/sh, but only Solaris experts know that the /usr/xpg4 directory exists and what is in it; 99.99% of the people out there won't have it before /bin or /usr/bin in their PATH.
Portability should never be traded for convenience, because when one does that, one forces "the next guy" to waste his time fixing one's code. That's just wrong. I've had so much of my life wasted by GNU/Linux "bashisms" which were completely unnecessary. I resent that deeply. That's my life I could have spent in more productive and fulfilling ways, rather than fixing what should not have been broken to begin with.
If you want to write portable shell programs, write them in ksh and then you won't have to worry about POSIX or non-POSIX.
You speak in absolutes.
Very dated absolutes as well.
You might want to think about that.
Solaris 10 release date: January 2005.
There's been a conformant POSIX shell on Solaris since 1995.
/bin/sh has been conformant to this since 2007 or so.
It is 2019. When should we be allowed to use it?
POSIX is the standard for Unix portability and has been for the last 2 decades. System V never was.
> Portability should never be traded for convenience, because when one does that, one forces "the next guy" to waste his time fixing one's code. That's just wrong. I've had so much of my life wasted by GNU/Linux "bashisms"
"set -e" is not a bashism. The errflag was there from nearly the beginning. By the early 1979 BSD 3 development tree, it could be triggered by 'set -e'. When the POSIX standards committee decided to iron out differences between the BSD and SystemV branches of the Unix Family tree, they decided it was worth keeping, and over the next few years everyone conformed.
> Portability should never be traded for convenience, because when one does that, one forces "the next guy" to waste his time fixing one's code. That's just wrong. I've had so much of my life wasted by GNU/Linux "bashisms" which were completely unnecessary. I resent that deeply. That's my life I could have spent in more productive and fulfilling ways, rather than fixing what should not have been broken to begin with.
There's also things that are good for everyone else's productivity-- by e.g. not catering to someone who is stuck 18-40 years in the past.
Wow-- I hadn't realized just how wrong your argument was! Bourne's shell from the outset supported set -e!
From Bourne's "An Introduction to the Unix Shell", ~1977-1978 (converted to HTML at http://porkmail.org/era/unix/shell.html )
> The shell flag -e causes the shell to terminate if any error is detected.
and the document goes on to state that you can use 'set' to set shell flags.
It's in the V7 source, too:
CHAR flagchar[] = {
'x', 'n', 'v', 't', 's', 'i', 'e', 'r', 'k', 'u', 0
};
INT flagval[] = {
execpr, noexec, readpr, oneflg, stdflg, intflg, errflg, rshflg,
keyflg, setflg, 0
};
Along with a proper call to options() in the set builtin.If the basis of your whole argument is history, you're complaining about something that would have worked on V7 or 3BSD. :D Apparently they are "too new."
edit: Running V7 on a PDP-11 emulator has the anticipated results:
boot
Boot
: hp(0,0)unix
mem = 2020544
# RESTRICTED RIGHTS: USE, DUPLICATION, OR DISCLOSURE
IS SUBJECT TO RESTRICTIONS STATED IN YOUR CONTRACT WITH
WESTERN ELECTRIC COMPANY, INC.
WED DEC 31 19:15:00 EST 1969
login: root
Password:
You have mail.
#
#
# set -e
# false
login:I know this was a thing 20-25 years ago, but is it still a problem now?
We're talking about standards that were published in 1992-1994 and that the overwhelming mass of the industry followed relatively quickly. To hold back 25 years later is nuts.
If you are generating a script that has to run everywhere, yes have the backend emit the verbose or tricky or unergonomic construct. But most of time, breaking portability to have something that is easier to understand, or more regular, that uses modern facilities is almost always the correct solution.
What's "everywhere", anyways? We'll have a hard time even finding a system this won't work on.
Especially in the context of FPGA tools that will only run on modern Linux, anyways...
Right, annatar doesn't actually care that his "advice" here is completely wrong and irrelevant. His only goal is to derail any useful discussion in order to point out how smart he is and how terrible any software that isn't included with solaris 8 is.
You may need 'showdead' on.
I have sympathies for the arguments. It's kinda unfortunate that Linux has taken over everything and we don't have real portable code anymore and other Unixes find themselves on the margins. x86, even x86-64 isn't really "clean". Way too much of the software ecosystem is willing to be on the bleeding edge. I worry we're losing core bits of Unix philosophy / simplicity as things evolve. Etc.
If the arguments were completely untrue, they'd not find any purchase. But this guy is running around kicking the hornet's nest whenever possible.
A while back I even tried to encourage him to explain HOW zones are better with real examples instead of just shitting all over a how-to mentioning docker. He instead attacked me and said it wasn't his job to teach anyone anything. Awesome job, the only thing anyone learned from that thread was that SmartOS users are assholes.
What's left of solaris is dying and he is helping in every way he can.
Sad to read this after having taught so many information technology professionals over the three decades, some of them in the heart of Silicon Valley. What I probably told you is that I don't owe you anything, which is still true. You disrespected me and attacked me several times. Why should I teach you?
As for the "what's left of Solaris is dying" "argument", I would be careful to make such statements, as they reek of casual usage: SmartOS isn't Linux; one deploys it because one has understood his advanced capabilities and features Linux doesn't have, to do a job and do it reliably and easier than with Linux, not because it's a good old buddies club where we comb our Ken and Barbie dolls and drink-pretend to have tea at 4 o' clock. If you want an echo chamber, stick with Linux; if you need to do a job, read the SmartOS manual pages, then come back with concrete questions. I'm not about fanboyism and casual usage, "community" and all that "Stack Overflow" nonsense.
Now, with all of that out of the way: what do you need help with in SmartOS?
Outside Oracle, the various efforts to use OpenSolaris derived stuff are constantly fragmented and overall shrinking in size. What little effort there is to improve things is often duplicative between the three+ branches of effort. Hardware support is more marginal than ever on OpenSolaris derived stuff.
Less and less important software compiles under and works well under it, and it's getting harder and harder to run.
That's funny, because I'm on the mailing lists for illumos and SmartOS and I see that everything generally useful impemented in SmartOS ends up upstream in illumos. Do you have any evidence to support your claim?
It's true that less and less software compiles on Solaris 10. I have to spend time patching badly written software to get it to compile. I have however not noticed any performance impact, on the contrary, that same software runs faster on Solaris 10 (and by extension illumos and therefore SmartOS) than on GNU/Linux where it has been developed, which is a slap in the face of GNU/Linux crowd hacking on that trash fire.
SmartOS is a different story, completely different: they use pkgsrc and their library is 15,000+ packages. So the argument here is mis-information. Presumably, this is being done on purpose, "because Linux"?
And also, I have no fear of hornets or their sting; I've been stung enough times. I have never cowered and I'm not about to start now.
To add insult to injury, I am forced to work deep in the bowels of Linux and various GNU tools like GCC because of the current market conditions, so I get to "live the dream" every day. I want things to change, and I'm doing something about it, the best way I know how, which is by raising awareness, just like all the Linux people did back in the '90's and early 2000's.
I've loved Solaris, NetBSD, and Irix. ZFS is pretty cool.
But it'd be pretty easy based on your posts to conclude that the only people who still advocate for that stuff are wrongheaded, pedantic curmudgeons.
In the meanwhile, notice how absolutely no one could explain what's wrong with || exit 1, other than it's "ugly" (which is a personal opinion, not a fact)?
"You can't even admit your mistake."
So let me get this straight: because I was wrong about set -e making one's program instantly unportable, my entire argument that SmartOS is a good, fast product is invalid? I guess the implication here is that because I was wrong about set -e making a shell program unportable, I am wrong about everything else, is that it?
set -e is a stylistic choice, though one I'd urge anyone writing scripts in Bourne and Bourne-like shells to prefer by default.
And I'm not your "bro".
I've learnt a lot from you. The original Bourne shell didn't support set -e. set -e is a bashism. Depending on a posix shell is unreasonable. This has something to do with Linux.
Wait, none of these things are true.
> because on Solaris /bin/sh is the real McCoy - Steven Bourne's shell from 1972 - 1977.
vs. v7 Linux from 1977-1978 including set -e. You're hilarious, bro.
And I'm not your "bro". Are you in need of an older brother so badly?
Disabling XQ
boot
Boot
: hp(0,0)unix
mem = 2020544
# RESTRICTED RIGHTS: USE, DUPLICATION, OR DISCLOSURE
IS SUBJECT TO RESTRICTIONS STATED IN YOUR CONTRACT WITH
WESTERN ELECTRIC COMPANY, INC.
WED DEC 31 19:15:05 EST 1969
login: root
Password:
You have mail.
# set -e
# true
# false
login:With the exception of GNU autotools, I know of no backends which would emit shell programs. People write programs in shells.
But in this case I know of
https://github.com/BYVoid/Batsh
and
Autotools is written in M4.. M3/M4 were developed by K&R to help automate generating mostly shell programs. In 1974-1977.
For someone who purports to be so oldschool, you're sure missing a lot.
M4 would excel at this adaptation...
Which isn't even necessary, because everything posix conformant has "set -e". And if "posix" isn't good enough, the Bourne Shell back to 1978 has it (probably earlier).
You are hilarious, bro. :D
And I'm not your bro.