BarkingOven's comments

BarkingOven | 12 years ago | on: Ask HN: did you ever implement a toy processor?

I made a processor <edit> I emulated it </edit> in c++ in college. Started off with an abstract logic gate that had two inputs and an output, created an event queue to propagate outputs to inputs, created a couple of different buses, tristate and open drain I believe, and then created methods to link inputs and outputs as well some concrete logic gate classes to each other and also to the various bus end points.

The event queue even handled propagation delay.

I made it so that if a tristate bus was held to both high and low at the same time, then an exception would be thrown that told you you "let the blue smoke out" and ended the program.

Binary instructions were read from a static string buffer which were then interpreted by the logic to implement the functions of the cpu and alu.

In the end, I discovered that the cpu logic block that we had been told to emulate was missing a one clock cycle delay buffer and should not have functioned properly if anyone else implemented it accurately.

Wish I still had the code for that, it was super fun to make.

BarkingOven | 12 years ago | on: Why does the alarm clock snooze button give you nine extra minutes, not ten?

I'll tell you exactly why it's nine minutes. Because in the olden days where everything was made with discrete components, the math of 9 minutes is WAY cheaper.

Let's say it's 6:00, and you hit the snooze button. Save the current value of the minute minus 1, into a comparitor, Trigger the alarm when the comparitor goes off automatically.

If you save the current value into the comparitor, the alarm triggers immediately. Now you need to add delay logic. Just use current minus 1, since it's only a few half-adders.

You can't use the high order minute digit because then your snooze length will depend on your current low order minute digit. Any logic to compensate starts adding a multiple of the number of components required.

page 1