View unanswered posts | View active topics It is currently Sat Apr 20, 2024 2:57 pm



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

Joined: Wed Jan 09, 2013 6:54 pm
Posts: 1783
.
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

Quote:
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
Profile

Joined: Mon Oct 07, 2019 2:41 am
Posts: 593
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.
Ben.


Wed Oct 07, 2020 6:24 pm
Profile

Joined: Wed Jan 09, 2013 6:54 pm
Posts: 1783
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
Profile

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

_________________
Robert Finch http://www.finitron.ca


Fri Oct 09, 2020 7:28 am
Profile 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
Profile

Joined: Wed Jan 09, 2013 6:54 pm
Posts: 1783
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
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 posts ] 

Who is online

Users browsing this forum: No registered users and 7 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

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