Home > Net >  If I build a new CPU, what should the BIOS contain?(Read details)
If I build a new CPU, what should the BIOS contain?(Read details)

Time:05-23

I am trying to build a CPU from scratch (from Nor gates) in an emulator first, then on breadboard.

Just trying to understand how things work.

Now, as my CPU will be new, how would I instruct an OS, say arch linux to work with it?

What role the BIOS will play? Will I have to write a BIOS which contains an assembler in it?

Do I need to write some program on the OS too?

So that, it starts to communicate to with my CPU.

[P.S]: I am a programmer, so pretty much have idea on how things move till assembly level.

Just want to know how the hardware level works beyond Assembly.

Or in other words, what was written on BIOS for the first ever computer?

How did it bootstrap?

CodePudding user response:

Just trying to understand how things work.

How things work is that a CPU is just one piece of a system. Without RAM it's useless, without some form of persistent storage it's useless, and without some kind of IO to talk to the outside world (e.g. a serial port maybe) it's useless.

What role the BIOS will play?

"BIOS" (or more correctly, some kind of ROM used when the system is turned on) plays the role of "storage" - a way for the CPU to obtain executable code that's needed to initialize other storage devices and load more executable code.

For your "NOR gates spread across hundreds of breadboards" you'll probably end up putting a very minimal "OS" directly in the ROM so that you don't have to worry about providing additional persistent storage; and with about 10 years of dedication you might eventually see your minimal OS work 3 times (before getting tired of "which wire is having a bad connection this week?" continual breakage).

For some perspective; 1 bit of RAM will cost you 4 NOR gates, so a measly 512 bytes of RAM will cost you 16384 NOR gates (more for row/column select logic, etc). That works out to over 4000 "74LS02 Quadruple Two Input NOR Gate" chips. If you can pack 40 of these chips on a breadboard then you're looking at about 100 breadboards just to end up with not enough RAM to run any OS.

CodePudding user response:

I can recommend you "The Fabric of Computing" article series: https://jeelabs.org/202x/tfoc/

There will be some initial code in every computer, but what it does is entirely up to you! In embedded, the "bios" is the complete application.

Going straight from soldering gates is a long and arduous way. I am doing CPU design on FPGAs, and I am contributor in a course that takes you from the first steps in logic to a full RISC-V CPU with compiled C programs:

https://github.com/BrunoLevy/learn-fpga

Good luck! With FPGAs, it is actually possible to reach booting Linux with a custom design:

https://github.com/enjoy-digital/litex

CodePudding user response:

Operating systems can be very very simple — if you just want the system to boot and do a few things like devices and threads but don't want all the protections and features of a full-fledged operating system.

All you really need is the ability to respond to interrupts and signal the user level software that data is ready (buffering input) or the device is ready, and, sort of the reverse, that user level software can indicate (e.g. via syscalls) data it wants to send to devices (buffered output) or obtain from them.  That can be had with a few hundred lines of assembly for an interrupt handler, a mini os.

But there are many systems that don't even have that level of sophistication.  Some program micro controllers to simply run one program, without interrupts, they have one main event loop that continuously checks for button presses or other.

  • Related