Last visit was: Fri Sep 17, 2021 9:47 pm
It is currently Fri Sep 17, 2021 9:47 pm

 [ 6 posts ] 
 Building compiler and porting an OS to a new CPU 
Author Message

Joined: Wed Jan 09, 2013 6:54 pm
Posts: 1632
A nice report from a student project:
How we ran a Unix-like OS (Xv6) on our home-built CPU with our home-built C compiler

It’s been two years since I started working as a software engineer. I sometimes tell my colleagues about a student project I did in my junior year of university, and it’s so well-received that I’m writing this post.

Now, let me ask you a question. Have you ever designed your own ISA, built a processor of that ISA on FPGA, and built a compiler for it? Furthermore, have you run an operating system on that processor? Actually, we have.

In this post, I’m going to talk about my undergraduate days in 2015, our four months of building a home-built CPU of a home-built RISC ISA, building a home-built C toolchain, and porting Xv6, a Unix-like OS, to that CPU.

It turns out Xv6 isn't very portable or especially RISC-friendly but evidently the problem could be solved.

Wed Oct 07, 2020 5:31 pm

Joined: Mon Oct 07, 2019 2:41 am
Posts: 256
Ints now have to be 64 bits? C (counting next new standard) has int as 16, 32, 64,128 bits.
How can one be portable? If in Xv6 files are only 64KB max size that I see more a problem that
int size. PDP11 had compact program size, todays machines do not.
Unix always had the got ya, the source code is free, but the compiler is closed source.

Wed Oct 07, 2020 6:24 pm

Joined: Wed Jan 09, 2013 6:54 pm
Posts: 1632
I really like the setup of this student project: the necessary set task was 'only' to make a CPU and run a particular program. Having done that, the students were free to make up their own stretch goals, and in this case the ones interested in this particular adventure took themselves out of their original teams and made a new team, with effort split over CPU, assembler/toolchain, compiler.

There's even an online emulator of the system, running the port of xv6, and with the applications: sl, as, vi, minesweeper, 2048.

Wed Oct 07, 2020 7:23 pm

Joined: Sat Feb 02, 2013 9:40 am
Posts: 1482
Location: Canada
That is a pretty amazing feat.

Robert Finch

Fri Oct 09, 2020 7:28 am WWW
User avatar

Joined: Fri Mar 22, 2019 8:03 am
Posts: 328
Location: Girona-Catalonia
Now, who fancies porting it to their own home-brew CPU?
Other than a compiler, I guess this needs at least a 32 bit CPU with an appropriate implementation of interrupts...

Mon Oct 12, 2020 11:58 am

Joined: Wed Jan 09, 2013 6:54 pm
Posts: 1632
It might be interesting to see if the C compiler is amenable to generating code for other architectures... although, I know nothing about OCaml.

I did find three repos relating to the project:
GAIA Processor
Udon C Compiler: C compiler for our original CPU (Blog post, in Japanese)
xv6 porting to GAIA architecture

Mon Oct 12, 2020 12:13 pm
 [ 6 posts ] 

Who is online

Users browsing this forum: AhrefsBot, CCBot and 0 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software