cputhing is a software model of a simple 8 bit cpu and small computer systemto go with it (the Simple As Possible 1 or SAP-1). I've been watching Ben Eaters "Build an 8 Bit Breadboard Computer" video serieson youtube (https://www.youtube.com/playlist?list=PLowKtXNTBypGqImE405J2565dvjafglHU)and got inspired to experiment. I don't have the parts (yet) but wanted to buildsomething and cputhing is the result. It's not an emulator (not in the traditional sense anyways). It works in the same wayas the hardware version. Ram, a bus, registers, counters and microcoded control logic. It has the same instruction set even and is in fact binary compatible.
I spent some time ripping apart the signal setting/handling so that it's bit more abstract and reusable (previously I was setting and checking bits in an unsigned 16 bit int but now have a Signal class). This should decouple things a bit better.
I also spent some time cleaning up the Blinkenlights and organizing the code into separate go packages. After that I shaved a cycle off of most instructions.
I decided to drop the time.Ticker in favour of a simple for{} loop with a time.Sleep() at the bottom. This allows for variable clock rate (hit +/- to adjust) with 11 (of course) steps. While doing this I noticed something strange with the granularity/overhead of time.Sleep() (and the ticker too) on Linux. At speed 11 the sleep is set for 50 Microseconds (about 20Khz) but my Linux box tops out at about 8.5KHz My (slower/older) MBP gets about 10Khz at the fastest speed and the timers seem more accurate on the Mac as well.
But to know how fast it's running we need a speed display so I added that. While there, I added code limit updates to the display. Once all that was done, I wondered how fast could it run with no sleep, so I added a turbo mode (toggle with 't'). My Linux box gets about 700Khz, the Mac about half that :). With the clock disabled (ie not running anything), in turbo mode my linux box runs the loop at about 45-50 Mhz(!)
Next steps are probably to start thinking about implementing a more capable 8bit architecture with a 16bit address space, more instructions in the ISA, etc.