• Refactoring complete and more

    Vince Hodges08/31/2019 at 13:32 0 comments

    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.