Difference between revisions of "CPU Speed control"

From SpecNext official Wiki
Jump to: navigation, search
m (Ped7g moved page Acceleration to CPU Speed control: Acceleration is quite misleading name for this)
(Reworking the article to make it more accurate with current state)
Line 1: Line 1:
''Acceleration'', or ''Turbo mode'', allows the Next to run at faster clock speeds than a standard Spectrum.
+
Next CPU speed is configured by {{NextRegNo|$07}}. User can use NMI menu, or NMI+8 ("F8" on PS/2 keyboard) to further change/toggle current CPU speed. NextBASIC programmers can select CPU speed by "RUN AT x" command.
  
Acceleration is enabled via {{NextRegNo|$06}} and configured via {{NextRegNo|$07}}, or via a user control. There are three (0..2) potential settings:
+
The standard Spectrum does run the Z80 CPU at 3.5 MHz, Next can be reconfigured to run at 7, 14 and 28 MHz (x2, x4, x8 of standard speed).
  
* Turbo off, or turbo on and $07 set to #00: 3.5 Mhz (standard clock).
+
Enabling the expansion bus (edge connector at the back of the board) will limit the speed to 3.5MHz, to keep signals' timing compatible with classic peripherals (in future it may become possible to enable expansion bus while using higher CPU speed, if Next-compatible peripheral is connected, details to be disclosed upon completion of the feature).
* Turbo on, $07 set to #01: 7 Mhz (x2). (Standard for [[Reference machines|Pentagon]]).
+
 
* Turbo on, $07 set to #10: 14 Mhz. (x4) Some features, such as [[Layer 2]] (vertically visible pixel area) and shadow-VRAM of ZX128 (whole pixel area), will automatically throttle down to 7MHz while specified areas of display are sent to the video signal.
+
The running SW may disable NMI and F8 keys, making impossible to change the CPU speed for the user, this is available for Next SW to make sure it will run at designed CPU speed all the time.
* Turbo on, $07 set to #11: 28 Mhz. (x8) - this mode is removed for the moment, due to HW limitations (the system was not stable enough at 28MHz).
+
 
 +
The CPU speed will literally speed up the CPU, giving it twice/four/eight times as many timing signals per second, shortening the duration of single machine cycle that many times. So simple Z80 instruction like for example `nop` will still take four cycles, but its duration in seconds will be halved in 7MHz mode. The video signal and maskable-interrupts are driven by video signal timings, which are not modified by CPU speed, the interrupts in VGA0 50Hz mode still happen 50 times per second (but instead of roughly 70 thousand machine cycles per one frame the SW will have x2/x4/x8 machine cycles available for instructions execution).
 +
 
 +
Running SW at CPU speeds it was not originally designed can produce different results, from:
 +
* more smooth and responsive gameplay (for example Stunt Car Racer) when the gameplay ticks at interrupt speed and only graphics rendering is accelerated
 +
* full game including gameplay being accelerated (probably to the unplayable level)
 +
* garbled screen rendering in games which require precise timing to display multi-color effects (Old Tower)
 +
* crash/reset of the SW if it is even more sensitive to the precise machine timing (this could happen also when the machine timing subtly differs from original, like HDMI 50Hz mode not being identical to original VGA0 50Hz timing, but so sensitive software should be very rare)
 +
 
 +
The 28 MHz mode currently induces extra wait state to every memory read, so instruction like `nop` will take five machine cycles instead of four and `ld a,(hl)` will take nine machine cycles instead of seven, making the effective speed of Next about 21-24 MHz in 28 MHz mode. This may be further improved in future Next cores, making the Next SW to run even slightly faster.

Revision as of 19:36, 20 September 2020

Next CPU speed is configured by CPU Speed Register ($07). User can use NMI menu, or NMI+8 ("F8" on PS/2 keyboard) to further change/toggle current CPU speed. NextBASIC programmers can select CPU speed by "RUN AT x" command.

The standard Spectrum does run the Z80 CPU at 3.5 MHz, Next can be reconfigured to run at 7, 14 and 28 MHz (x2, x4, x8 of standard speed).

Enabling the expansion bus (edge connector at the back of the board) will limit the speed to 3.5MHz, to keep signals' timing compatible with classic peripherals (in future it may become possible to enable expansion bus while using higher CPU speed, if Next-compatible peripheral is connected, details to be disclosed upon completion of the feature).

The running SW may disable NMI and F8 keys, making impossible to change the CPU speed for the user, this is available for Next SW to make sure it will run at designed CPU speed all the time.

The CPU speed will literally speed up the CPU, giving it twice/four/eight times as many timing signals per second, shortening the duration of single machine cycle that many times. So simple Z80 instruction like for example `nop` will still take four cycles, but its duration in seconds will be halved in 7MHz mode. The video signal and maskable-interrupts are driven by video signal timings, which are not modified by CPU speed, the interrupts in VGA0 50Hz mode still happen 50 times per second (but instead of roughly 70 thousand machine cycles per one frame the SW will have x2/x4/x8 machine cycles available for instructions execution).

Running SW at CPU speeds it was not originally designed can produce different results, from:

  • more smooth and responsive gameplay (for example Stunt Car Racer) when the gameplay ticks at interrupt speed and only graphics rendering is accelerated
  • full game including gameplay being accelerated (probably to the unplayable level)
  • garbled screen rendering in games which require precise timing to display multi-color effects (Old Tower)
  • crash/reset of the SW if it is even more sensitive to the precise machine timing (this could happen also when the machine timing subtly differs from original, like HDMI 50Hz mode not being identical to original VGA0 50Hz timing, but so sensitive software should be very rare)

The 28 MHz mode currently induces extra wait state to every memory read, so instruction like `nop` will take five machine cycles instead of four and `ld a,(hl)` will take nine machine cycles instead of seven, making the effective speed of Next about 21-24 MHz in 28 MHz mode. This may be further improved in future Next cores, making the Next SW to run even slightly faster.