I don't know how CPUs work so I simulated one in code
The final for Computer Architeture had us building an 8-bit CPU. It was a multiweek project, starting with 
designing the instruction set leading up to building the CPU in software implementing bubble sort in assembly.<p>The first and only time I had to do an all nighter (2 actually) in college was due to that project. Two days before the final presentation, the CPU didn't work. After a few clock cycles the memory would contain garbage. I ended up rebuilding it from scratch debugging every step of the way only to find out the 1-bit mux (a primitive supplied with the software) was wired backwards.<p>0 corresponded to the B input, and 1 selected the A input.<p>Once I correct that, the CPU worked like a charm, we nailed the final preso, and I slept for 16 hours.