Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
How do I make a computer
25 points by laxmymow on July 28, 2023 | hide | past | favorite | 31 comments
Hi I'm a web developer, with extreme anxiety that i don't really know how does a computer work. I want to change that and take a year off to make a computer from the george hotz "From the Transistor to the Web Browser" 12 week course. I would really appreciate if anybody has any advice, resources, tips, stories, or experiences to share for this project.


Maybe start by reading the book Code by Charles Petzold.

https://www.amazon.com/Code-Language-Computer-Hardware-Softw...


No book has done more to convince me that we are modern day wizards ala Clarke's Third Law.

The beginning chapters that work through relays and logic gates make this leap to how we create memory and do logic that made me realize we are, quite literally, harnessing electricity (think: mana) to etch arcane runes (circuitry) that perform feats that are effectively magic.

This must be why I like reading books that have software developers as magicians (see: Off to be the Wizard).

I struggled with the chapter on combinatorics but the book is amazing and I love the illustrations.


Did you read "Wizardry compiled" series by Rick Cook? :)


Going from web development to creating your own semiconductor lab to understand the solid state physics of transistors enough to make one will not only take more than a year, it's also silly.

You may as well learn C and the guts of microprocessors if you're really concerned about how a computer actually operates.

Web development really just treats the whole of the internet as one big computer, and the dev formats interesting content nicely for the screen of the user, which is ultimately about presenting useful data. There's probably little incentive to take a "year off" to try and understand the whole thing from the physics to the electronics to the logic to the anthopology and philosophy of computation - it's too big a field and something you'll be spending the rest of your life doing. Plus even in a year, starting from scratch, even with 8-bit kits or transistors, any computer you make when compared to modern machines won't really even do anything. Imo you'd be better off getting a ZX Spectrum, a cassette drive, a copy of Manic Miner, and enjoying watching the 48kb of it load into the machine, then pouring over the code. Or even Elite on the BBC Microcomputer. Understanding these few thousand kilobytes of machine code and how they interact with the machines is easily food for thought for a year. Then just multiply that by a few thousand in terms of resolution, bandwidth, speed, and you'll understand modern computation better.

Or just go travelling for a year and don't think about computers...


Build an 8-bit computer from scratch: https://eater.net/8bit


Maybe start with something a bit easier?

The RC2014 is a good cheap beginners' kit, I hear.

https://rc2014.co.uk/

1. Start with a ROM BASIC.

2. Upgrade it to run CP/M and learn some CP/M apps.

3. Get TurboPascal or something and write & compile some Pascal code on CP/M.


Awesome videos with explanations.


I wouldn't take the year off you can do both!


This is sound advice.

Taking a year off with no income and studying something that doesn't directly lead to a job will increase OP'e anxiety.

Instead OP should do job, and might want to cut back on other activities for learning these.


http://mynor.org is the most minimalist but still useful computer I have found. Severe anxiety, I can relate, I have autism and persistent depressive disorder.


I have autism but not persstent depressive disorder and this random stranger wants to wish you well with handling it because it sounds difficult. I've nearly gone insane with my OCD (people with autism are at more risk of having OCD) and our mental health can be hard to handle with disorders.


It's a wide field, let in mint that HW is modular like SW, but abstraction does not get too far, computers are really physical things, and (IMHO) left out VHDL FPGA and similar, they are not necessary at beginning, and transistors too, the base is digital logics, combinatory and sequential circuits, then look at a very simple CPU (8 bit), then a simple system (CPU + memory).

A good old book will help, (EG) look at: Digital Logic And Computer Design - Morris Mano (free pdf at archive.org)


My suggestion just do a few embedded projects. After that you'll basically understand how computers work. Most embedded is basic enough to get the gist of. Where a modern computer you'll get swamped with too much complexity.

Semtech has some dev boards and tutorials for connecting to Lorawan. Notably it all seems to just work if you follow the directions. Not true for a lot of other development boards and software.


Reading between the lines, I suspect OP just wants to get a feel for 'the turtles' that are all the way down... :-)

If so, I second Gibbon1's:

> just do a few embedded projects.

Easiest entry: download a simulator for microcontroller (family) you have in mind. One that lets you single-step through assembler instructions, see effect on registers, CPU flags, memory contents, I/O pin state, etc.

Get 'close to the metal': eg. grab an Arduino + USB <-> JTAG (and/or serial) thingie, download IDE, work through "blinkie LED" example project.

From there, explore some of the integrated peripherals & what you can do with those:

Pulse Width Modulation (both in hardware, or software) as a kind of poor man's analog output.

Hook up character LCD display. Or graphic one, and code some mini games a la "snake", tetris or the like. A few I/O pins, buttons, couple of lines assembly code & presto! You've built a joystick from scratch.

Hook up sensors, relais, or some sensor network LAN stuff, etc etc.

WHATEVER seems interesting. Once you've done a number of such projects (and written a decent amount of assembly code), write some small C programs for the microcontroller, and see what assembly code it's translated into. Or write a small Forth system. See how such things change your perspective from programmer -> low level hardware.

From there on up, it's just layers upon layers of (mostly arbitrary) abstraction. Some 'invisible', some with a huuuge performance cost.

Quad core x86-64 is just a really fast 8051 with more & wider registers + bigger instruction set + huge amount of RAM. ;-)


Another historical thing that is simple to understand is old school micro-coded CPU's. Obsolete but if you understand how one works everything that comes after is just implementing the same thing mostly.


Learn some C. Choose a modern book or go with K&R. Then make sure to go through Nick Parlante's amazing C resources.

Then read CS: APP.

Many will suggest nand2tetris. But many people I know couldn’t keep up with it.

I finished it with much struggle. If you are a self-taught front-end dev, it’s quite likely you are not going to be able to finish it.


Not really an answer: but I found the technical challenge of building my own PC too much. I'm more of a software guy and can tell you a lot about software, but as for the hardware that software runs on, I am clueless. I'd rather just splash out on a pre-built Dell tower and call it a day.


I don't think that's whats being asked here - the question isn't "how do I build a PC with parts you buy on the market", rather it's "how do I manually build the logic for a computer to understand the computations being done on an electrical level". Unless I'm very mistaken. This would involve learning about logic gates, like XOR, AND, NAND and so on, and then move up levels of abstraction until you've created, or theoretically understood, how a computer works.


Building your own PC is simpler than LEGO.

Quick read about what what CPU is compatible with what motherboard then selecting memory and sufficient power supply.

You have 6 main components.

-Case

-Power supply

-Memory

-CPU

-Motherboard

-Hard Drive

I'm really surprised someone on HN would feel like it is a challenge.


Wouldn't say simpler than LEGO as there are some nuances. For example:

* making sure the motherboard supports the CPU via socket and also nominally

* making sure the heatsink can be mounted on top of the CPU socket

* having the case fit your motherboard form factor

* if there is a dedicated GPU, making sure it fits inside the case and there is a PCI-E slot with sufficient lanes for it

* if not, making sure there is an integrated GPU

* selecting a PSU that can handle the maximum power load for the GPU and that has a power cable for the GPU if it needs one

* making sure to buy the right type of ram in accordance with what the CPU and motherboard support

* if you want wifi, making sure there is built-in or there is a m.2 slot for wifi

* if you want a m.2 NVMe SSD, there should be a m.2 slot with the right key interface

Not often you end up buying parts that don't work well with each other and need to buy other parts. I once bought a small factor m.2 ssd only to discover it didn't fit the slot. I think it was trying to fit an M key device into a B key slot. Sometimes even the vendor data can be incorrect.


> but I found the technical challenge of building my own PC too much

It's really not necessarily that hard -- I say this not as an insult, but as an encouraging clue that whatever documentation or technique you followed last time you tried may have been overcomplicating things -- it can be about as easy as putting legos together.

So, if building your own PC from off the shelf parts (which is quite different from what the poster is talking about actually) is something that interests you, I would strongly recommend not giving up and assuming that it's too hard for you, and instead concluding that whatever resources you used last time to guide you are inadequate or aimed at a more complex goal than you need.

I can't give a specific recommendation since I haven't done it in years, but you really just need to pick out a case (which usually will include a power supply), motherboard, CPU, RAM, and hard disk. To make it easier, avoid needing a CPU and just get a motherboard that includes the CPU. (Same goes for GPU) Then, ensure the motherboard is compatible with the case, the RAM is compatible with the motherboard, and the hard disk is compatible with the motherboard. Finally, total the power usage for each component and ensure it's less than the power supply's power output. Honestly, this compatibility planning is the "hard" part, once you get the components it's just plugging them into each other in a logical way, it's not like decades ago where you had to fiddle with jumper switches and the like. For your first time, you can also just set your expectations low, make sure you get things with good return policies, and return components if you end up being mistaken about their compatibility, but this should not be an issue if you read their specs carefully.

You can even buy kits that already include parts known to be compatible. Or for example, bundles that include the motherboard and some compatible RAM -- if you get one of those all you really need is the case and you're done (Since technically, the hard drive is sort of optional, if you always boot from a live USB or netboot image!)

NewEgg.com used to be great for this kinda stuff years ago, although I've heard they've "gone downhill"? No idea

Or even further towards ease, take apart your PC and put it back together.

That said, lol, you're right, this is something for most people you do once, and it was cool, but next time you just buy off the shelf to save time. There was a time when you could save a lot of money building your own but that time is long past.


I learned a lot about computers by creating my own bootloader and kernel. It will touch on so much, eventually also how USB works, or SATA. I can really recommend osdev.org.

It nicely combines software and learning computers!

Another option is to write an emulator for a simple ISA like PICO8 or for a device like the Gameboy.


I applaud anyone building hardware but you could probably get more from reading Hennessey & Patterson.


I would look into making a cyberdeck, as it'll be more fun and unique than just building a generic computer.

https://old.reddit.com/r/cyberDeck/


Microcontroller programming is one option to learn low-level fundamentals. You can get dirt cheap dev boards for the Atmega328P (the chip that the Arduino uses.)


https://www.nand2tetris.org/ - Another course. I'm not familiar with Hotz's course, but I like what this one covers and it's very approachable. It's roughly a survey version of a computer engineering curriculum so not deep (and ignores a lot of technical details, like assuming perfect timing for the logic circuits instead of dealing with actual electronics) but it's pretty comprehensive. It's a good introduction before going on to study the various areas it covers in more depth.

EDIT:

Looking up the course you mentioned it seems like it's intended to cover similar terrain as Nand2Tetris but doesn't have nearly as much material available or a reasonable timeline. Is this https://github.com/geohot/fromthetransistor really all he has posted? I'd definitely recommend Nand2Tetris first, it consists of 12 projects. It can be reasonably completed in 12 weeks of part time effort and then you can take that as a jumping off point into fuller treatments of the topics that catch your interest or where you find yourself with an obvious gap in knowledge.

Also this concerns me:

  Section 4: Compiler: A “high” level language -- 3 weeks
  - Building a C compiler(Haskell, 2000) -- A bit more interesting, cover the basics of compiler design. Write in haskell. Write a parser. Break this into subchapters. Outputs ARM assembly.
  - Building a linker(Python, 300) -- If you are clever, this should take a day. Output elf files. Use for testing with QEMU, semihosting.
  - libc + malloc(C, 500) -- The gateway to more complicated programs. libc is only half here, things like memcpy and memset and printf, but no syscall wrappers.
  - Building an ethernet controller(Verilog, 200) -- Talk to a real PHY, consider carefully MMIO design.
  - Writing a bootloader(C, 300) -- Write ethernet program to boot kernel over UDP. First thing written in C. Maybe don’t redownload over serial each time and embed in FPGA image.
That does not seem like a 3 week project to me if you've never written a compiler or linker before. Especially given he provides (from here) no other material or guidance and you end up using 3 separate languages. "basics of compiler design" in less than 3 weeks along with "if you're clever, this should take a day"? And an ethernet controller, and a libc and malloc, and a bootloader?

If you know Haskell enough to make a compiler, Python enough to make a linker, C well enough to make libc + malloc + a bootloader, Verilog well enough to make an ethernet controller all in three weeks, then you don't need this "course" at all. Just the C compiler in Haskell part is a semester long academic course, and rarely actually results in a full compiler with a teacher setting the pace (with assignments, quizzes, and tests).


My son is at this very moment doing the nand2tetris course on Coursera as a summer project, because he wanted to understand how computers work. It's very well done and the tools provided isolate the beginner from a lot of low-level EE details. The first half of the project has you build a simple 16-bit computer starting from logic gates, using a basic hardware description language, as well as an assembler for it. Simulators are provided. As you wrote, timing considerations are sweeped under the rug, which is too bad.

The second half is more software-oriented: you start by writing a stack machine emulator for your computer, and then you write a compiler for an object oriented high-level language that outputs stack machine code. Finally, you write a standard library for your language.

As a third part to this course, we will then implement that computer on an FPGA, following Michael Schröder at https://gitlab.com/x653/nand2tetris-fpga/ . This will be my first experience with FPGA development, so I'm looking forward to it as well.


There are many levels to work through so you'll have to decide where you want to start, and whether to start top down, or bottom up (or a bit of both?) and whether you want to know the electrical side too (I have a basic understanding, but not a lot here - enough to understand what I see on an oscilloscope is 0 and 1s - based on pull down/up and clock frequency - but not how to use it).

Ground up this video is fantastic and shows why first computers were made from lightbulbs: https://youtu.be/FU_YFpfDqqA

Top down you'll to want to start working with a lower level language, if you're confident with languages like Java, start looking at C, particularly pointer arithmetic which reflects memory locations. From there look at how drivers work - C on an Arduino for example to control electronics. This is simpler in some ways that trying the equivalent through many framework abstraction layers you don't need to know about on a PC. This teaches you registers, byte and memory manipulation to control hardware, as well serial data transfer technology (low level data transfer protocols over a wire one which modern USB is based). It also helps with your understanding for how some hardware such as a GPS you can literally read NMEA (coordinate) data as a string over a serial port/USB connection https://en.wikipedia.org/wiki/NMEA_0183 . This was an eye opener for me ~20 years ago.

Going down from the level of memory and byte manipulation you get to assembly language, which tends to be machine/CPU specific operations but will teach you the architecture side of a computer, and depending on the arch you learn align with CPU instruction sets (as well as basic copy memory type ops, modern CPUs have SIMD instructions, e.g. MMX or hardware encryption etc). You can go slightly lower here to microcode but the gains would be minimal in advancing your general knowledge.

Lower from there you need to consider how the components are made and their electrical properties, e.g. flipflops, CPU parts like ALU etc. You're then pretty much at the ground up stage so the video above shouldn't be an eye opener...

Then to test your knowledge end to end... write an emulator for something like a Gameboy in Javascript :D

https://imrannazar.com/GameBoy-Emulation-in-JavaScript:-The-...


Bebop to the Boolean Boogie is a great book - it's aimed at kids but covers the concepts very well. You could read it and go through the exercises in a weekend.


Hi, embedded developer here. Learning electronics and lower-level computing concepts is very fun, and I'll always encourage it. But I also don't think you need to feel particularly anxious about it. For some perspective, web stuff scares me, and while I have some passing knowledge of things like CSS, React, SQL databases, Docker, etc., I'd be hard pressed to actually use those technologies to create and stand up a modern web service without lots of research and learning.

"How a computer works" is very broad, and covers a lot of different disciplines. Like everything else in computing, it's layers of abstraction, and there's a lot of depth you can go into at any level. What you're describing is basically an ECE undergraduate curriculum, but it's very possible to get a "tour" of various layers in less time than that without going to school for it.

There's a lot of different ways to approach learning, and the bottom-to-top tourist approach is certainly one way to do it. I personally would not recommend it, as you're going to run into lots of different concepts that will take time to digest, and some of the tooling will be rather opaque or foreign, without a mentor to guide you. Another approach would be top-to-bottom, where you do some C systems and kernel hacking and work your way down from there. If you the art of programming and Computer Science, that might be a better fit, but there's also lots of arcane stuff in Linux and x86 that can be demotivating. The approach I advocate is usually the "maker" one, where you hang out in embedded systems land, and come up with projects you want to make. The benefit of embedded projects is that your projects will be physical things that interact with the real world (which may or may not be actually useful). That lets you explore a breadth of topics as needed, but is a bit adjacent to your goal of "knowing how a computer works".

Re: geohotz's curriculum, have others actually done his course? The curriculum looks interesting, but laser focused on bringing up a CPU in Verilog and bootstrapping the OS in C. I'm not sure how easy the course would be without at least some Verilog and systems programming background. 12 weeks seems very aggressive, and you're gonna end up missing concepts if you try to do it at that pace. The course I usually see recommended is nand2tetris, but I haven't tried it myself.

For foundational curriculum, I would probably recommend:

* The CSAPP Book (https://csapp.cs.cmu.edu/) - The introductory systems programming book/course. The labs are really good; do them! You could probably spend a year just with this course and come away satisfied. It'll have you interfacing with computers in C, learning about how cache works, writing your own malloc, doing some networking code, etc.

* Circuit Design - Optional, but some electronics knowledge doesn't hurt, depending on how far down the stack you want to go. Don't need to go into the fancy stuff, but should at least know enough of the basics to understand how transistors work, and how they can be used to form gates.

* Digital Design / FPGA stuff - I don't have a good rec for this. Nand2Tetris? There are some interesting projects out there that make FPGAs more accessible, like fomu and the reverse engineered open lattice toolchains.

* Computer Architecture by Hennessy & Patterson - Guides you through the concepts of a CPU, and has you writing your own MIPS CPU in Verilog. ARM is cool and all, but for a toy CPU, MIPS is a little more manageable, IMO. If you try to go straight to comp arch without some base level of digital design/FPGA/Verilog experience, you will probably have a bad time or end up with some gaps in your knowledge.


I should add my personal opinion, too. FPGAs and comp arch can be fun, but are largely academic, IMO. Unless it's your _thing_, it just provides you with lots of background knowledge when writing OS and systems level code. Messing around at the systems/OS/embedded level will be more fulfilling and scratch the same itches.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: