Live data from Hacker News

Building a Modern Computer from First Principles

nand2tetris.org

71–80 of 84 posts

Re: Building a Modern Computer from First Principles

#72
post #20

Earlier quoted context omitted.

If you built it from real hardware, you'd be going to the store to buy a couple thousand NAND chips, like this: http://www.digikey.com/product-detail/en/SN7400N/296-14641-5... And a giant honking breadboard.

It might be beyond the scope of a normal hobbyist project, but writing Verilog or VHDL to drive an FPGA might bring interested people half of the way there. You mentioned Altera design software in another post; I don't know if Xilinx's is any better (I'm guessing not really), but Digilent sells FPGA boards intended for the educational market at a pretty reasonable cost. Powerful enough, I'd reckon, to allow for somet…

There's a link (on the "cool stuff" page here: http://www.nand2tetris.org/coolstuff.php) to an implementation of their machine in FPGA.

Here's a (video) presentation: http://www.youtube.com/watch?v=UHty1KKjaZw.

Re: Building a Modern Computer from First Principles

#73
post #2

The lecture slides are in Comic Sans, ugh.

I used to feel like this, until I saw Simon Peyton Jones use Comic Sans for a slide deck on Haskell and decided this was a such a petty, knee-jerk reaction to something as superficial as font-choice. At this point, I'd almost choose Comic Sans on purpose for my own presentations, just to weed out and troll the people who aren't paying attention to what matters. http://research.microsoft.com/en-us/um/people/simonpj/pa…

I've never understood the enormous enthusiasm people seem to to have for badmouthing Comic Sans. It's not particularly elegant, but it's quite readable and not particularly ugly. It more or less looks like hand-lettered dialogue in comics, and that seems quite accepted, and even respected.

I suppose type designers or whoever might be particularly sensitive to whatever transgressions it commits (I dunno), but almost everybody I've seen indulge in a bit of C.S.-bashing seems to otherwise not care very much about typography at all.

As far as I can figure, it's just because people love a bandwagon, especially one that's really easy to hop onto and entails few risks....

Re: Building a Modern Computer from First Principles

#74

Earlier quoted context omitted.

I think the advantage this has is you have one continuous path from NAND gate to Tetris. Whereas in my experience attempting CS at Cal Poly, we did all these steps but they were disconnected. The output of one course was not used as input to the next. I don't know if there is any pedagogical benefit from being able to say "I built this whole thing from scratch". But it sure is cool.

It's really hard to go from NAND to Tetris, because there's a logical jump when you get to VLSI. This is the whole notion of quantity being a qualitative property: when you get enough gates together, you really start abstracting them and thinking about higher-order components. There's no smooth zoom out, there's just a sudden discontinuity when you stop using individual gates and start using MUXes, flip-flops, etc as…

I don't know what you mean about MUXes. It's just simple abstraction to say "yeah, take this pattern of gates and give it a symbol so we don't have to draw it over and over again in detail". You're still just wiring up combinational logic...

Flip-flops and sequential logic made my brain flip-flop itself for a while though when I first ran into it. :) That really does require a different sort of thinking, since you're introducing time as a factor.

Re: Building a Modern Computer from First Principles

#75

Earlier quoted context omitted.

Just as meaningful as a full course. This is just a "depth first search" thru the content, getting from top to bottom in one pass; you're complaining its not a "breadth first search" covering everything on one level. Done this way, you get the gist of how it all does, in fact, go from NAND gate to games - yes a lot is glossed over or missed, but once the student sees the vertical structure he can see how each layer c…

This is actually closer to breadth-first (since the alternative is an 'in-depth' course) in my mind, but I get your meaning. The thing is, do you actually take anything away? If you don't talk about caching in the CPU, scheduling in the OS, or propagation delay in the gates, how does that help your understanding of how to write software? I'd be curious to know a) how deep your education actually went (since you've im…

We all start out not understanding how it's possible to make a CPU, write a compiler, communicate over wires, draw text into a framebuffer, and so on. These things seem like magic. This is a problem: as long as they seem like magic, we're deprived of engagement with them. You get a family of systematic errors:

* Magic is supposed to work. So you see people calling for functionality to be moved from whatever they're doing (their user-level code, say) into the magic: build something into the language, compile it to machine code instead of interpreting, do it in hardware, etc. Because of course if it's done by magic, it doesn't cost anything and it works perfectly!

* Magic is out of your control. So if it breaks, there's nothing you can do. If your operating system is crashing your program, or downloading updates you don't want, you're out of luck.

* Magic is easy. So the people who make the magic happen don't get the credit.

* Magic is memorized, not understood. So you need to memorize the incantations needed to squeeze performance from your database/OS/CPU/whatever instead of doing them yourself.

You don't need to understand how to use Karnaugh maps to understand that putting more multipliers on your chip is going to cost you real estate. You don't need to understand the different possible scheduling policies to understand that making your program multithreaded will slow it down, not speed it up, unless you have more than one core. Even a shallow understanding is sufficient to be very useful, and to enable you to question things.

Re: Building a Modern Computer from First Principles

#76

Earlier quoted context omitted.

OK, to clarify, this is a cool book/course. I don't mean to disparage the author, they've done an excellent job condensing a large body of material. However: The title is very ambitious. This is not really building a computer from first principles, there are some steps skipped. This is a high-level overview of modern computers, it's worth noting there's a lot of depth to be explored. Everyone agrees custom languages…

For whatever reason, you feel the need to defend the value of your degree. You forget that people have various reasons (some personal) for seeking knowledge. It's not always about gaining marketable skills or about learning all there is to know about a subject. Many of the points you make in your critique (lack of depth, etc) are obvious to anyone that decides to read the book. As an example, the book Learn Modern 3D…

I have to agree. The GP is getting bent out of shape. I think him describing the limitations of the course would be useful if not worded so defensively.

This is like a professional fabricator complaining that the 10 hour welding course at night-school doesn't cover welding aluminium. I don't think anyone was under the impression that this was a replacement for a an engineering degree. People will do this course because it's cool to build stuff you thought was beyond you.

Also, enroll in a welding course, it's cool to be able to build big stuff out of metal too.

Re: Building a Modern Computer from First Principles

#77

Earlier quoted context omitted.

My point is that after reading the book I kind of knew how I could implement a simple CPU in real HW (with ALU, memory, etc.) but it was not clear to me how the IO part (kbd, screen) would work. Is the kbd connected directly to a certain place of memory? How is this implemented? Would there be some screen/gpu HW that is directly connected to the memory region? How is the CPU clock involved? E.g. if you press a key, h…

If I'm not mistaken, the keyboard should raise high an interrupt pin on the CPU, which should cause an interrupt service routine to be called. That routine should then mask lower-priority interrupts, poll the appropriate region of memory (assuming memory-mapped IO) for the byte or bytes held down, push those onto the buffer for key inputs or into the STDIN equivalent, unmask lower-priorty interrupts, and return. It i…

The Hack CPU doesn't have interrupts, IIRC.

Re: Building a Modern Computer from First Principles

#78

Question to those that already have this book - is the book full of diagrams? I ask because I could get this on kindle instantly (but diagrams suffer) or in paperback in a week or so. Is it worth getting the physical book over the e-book for this?

Several of the chapters are available as pdfs from the site

Thanks, I see that now. Paperback version it is.

Re: Building a Modern Computer from First Principles

#79
post #77

Earlier quoted context omitted.

If I'm not mistaken, the keyboard should raise high an interrupt pin on the CPU, which should cause an interrupt service routine to be called. That routine should then mask lower-priority interrupts, poll the appropriate region of memory (assuming memory-mapped IO) for the byte or bytes held down, push those onto the buffer for key inputs or into the STDIN equivalent, unmask lower-priorty interrupts, and return. It i…

The Hack CPU doesn't have interrupts, IIRC.

I was actually working on implementing a simple little VM library in C as a fun exercise, and deciding how to handle interrupts was where I got caught up.

Re: Building a Modern Computer from First Principles

#80
post #77

Earlier quoted context omitted.

The Hack CPU doesn't have interrupts, IIRC.

I was actually working on implementing a simple little VM library in C as a fun exercise, and deciding how to handle interrupts was where I got caught up.

Most VMs don't have interrupts. As a less-complex alternative, you might consider implementing an I/O thread, something rarely done in hardware because an extra CPU is a lot more hardware than an interrupt mechanism.

One interesting exception is the Unix VM, whose interrupts are called "signals".

Post reply on HN