[HN Gopher] I don't know how CPUs work so I simulated one in cod...
       ___________________________________________________________________
        
       I don't know how CPUs work so I simulated one in code (2019)
        
       Author : azefiel
       Score  : 17 points
       Date   : 2024-08-01 13:54 UTC (4 days ago)
        
 (HTM) web link (djharper.dev)
 (TXT) w3m dump (djharper.dev)
        
       | vhodges wrote:
       | Neat, I've seen a few logsim systems. After watching Ben Eaters
       | videos (and not having enough time to tinker with hardware) I
       | built
       | 
       | https://git.sr.ht/~vhodges/cputhing
        
       | dang wrote:
       | Discussed at the time:
       | 
       |  _I don 't know how CPUs work so I simulated one in code_ -
       | https://news.ycombinator.com/item?id=19969321 - May 2019 (172
       | comments)
        
       | cogman10 wrote:
       | So, what this project misses, which is quite hard to capture if
       | you think of gates being just on off switches, is the fact that
       | signals are not instantaneous, and everything runs in parallel.
       | 
       | As the AND gate 4 gates up the chain switches the NOT gate 4
       | gates down the chain starts to send different and unstable
       | signals which may or may not be interpreted as a 1 or 0 in the
       | downstream gate.
       | 
       | That's the reason computers have a clock, to make sure all
       | transistors in a given stage of a CPU reach a steady state before
       | moving on to the next instruction.
       | 
       | This is why it's probably a good idea to work with a HDL instead
       | of just trying to wing it.
        
       | leoh wrote:
       | If, for fun, I wanted to train an ML model on a ton of CPU
       | instructions (which each predicted state/label being the state of
       | the registers), does anyone have any clue how to gather that kind
       | of data?
        
         | 01HNNWZ0MV43FF wrote:
         | Maybe a game console emulator?
        
       | sam_perez wrote:
       | Reminds me of some scenes from the first book of the three body
       | problem.
        
       ___________________________________________________________________
       (page generated 2024-08-05 23:00 UTC)