Author Topic: Z80 clock  (Read 3028 times)

0 Members and 1 Guest are viewing this topic.

Offline kelp7

  • CPC664
  • ***
  • Posts: 123
  • Country: gb
    • Sharp MZ-80A Secrets
  • Liked: 31
  • Likes Given: 56
Z80 clock
« on: 23:24, 23 April 15 »
Hi,


Just a quick query. Where does the Z80 get its clock from? Is it internal to the chip or is it an external input to the chip? Taking a guess I would say external but just wanted to check. I presume there's some source that does the timing for it.....?

Offline Bryce

  • The Hardware Guy.
  • Supporter
  • 6128 Plus
  • *
  • Posts: 11.727
  • Country: wf
  • It's not broken, it just hasn't been fixed yet.
    • index.php?action=treasury
  • Liked: 4219
  • Likes Given: 444
Re: Z80 clock
« Reply #1 on: 23:32, 23 April 15 »
The CPC has a 16Mhz crystal that produces the main frequency. This is fed to the Gate Array which is clocked at 16Mhz, but it has a divide by 4 circuit and outputs 4Mhz for the system clock. There's a further divide by 4 circuit to create a 1Mhz which is needed for the AY but also used to time the RAM access between the CPU and the CTRC.

Bryce.

Offline kelp7

  • CPC664
  • ***
  • Posts: 123
  • Country: gb
    • Sharp MZ-80A Secrets
  • Liked: 31
  • Likes Given: 56
Re: Z80 clock
« Reply #2 on: 23:41, 23 April 15 »
Brilliant, thanks very much for the informative and quick reply. Guess different machines will generate that frequency in different ways, but that definitely answers my question anyway. Thanks again.

Offline Bryce

  • The Hardware Guy.
  • Supporter
  • 6128 Plus
  • *
  • Posts: 11.727
  • Country: wf
  • It's not broken, it just hasn't been fixed yet.
    • index.php?action=treasury
  • Liked: 4219
  • Likes Given: 444
Re: Z80 clock
« Reply #3 on: 23:53, 23 April 15 »
CPUs don't usually have internal clocks, only Microcontrollers tend to have these.

Bryce.

Offline Apollo

  • Supporter
  • CPC664
  • *
  • Posts: 66
  • Country: de
  • Liked: 22
  • Likes Given: 337
Re: Z80 clock
« Reply #4 on: 06:06, 29 May 15 »
As I didn't see the info elsewhere, is it right that the CPC+ has a 40MHz clock for the ASIC and 9 divider to 4,44 MHz for the Z80 with additional wait cycles for DMA to even the speed out to a 4,00 MHz equivalent?
CPC - My beloved first computer!

Offline arnoldemu

  • Supporter
  • 6128 Plus
  • *
  • Posts: 5.336
  • Country: gb
    • Unofficial Amstrad WWW Resource
  • Liked: 2274
  • Likes Given: 3478
Re: Z80 clock
« Reply #5 on: 11:02, 29 May 15 »
EDIT:

"2.10 PAL subcarrier locking The main oscillator for the ASIC is 40MHz. A divide by 9 output at 4.444MHz is provided with a 5:4 mark/space ratio. It is possible to change the main crystal to 9 x 4.33619MHz = 39.902571 MHz, slowing the whole system by 0.25%. This may or may not upset the disk drives, but even if this is the case, a diskless unit could provide PAL subcarrier frequency locked to the master oscillator, thus improving the picture quality. "
The Z80 has the same timings as CPC however, so about 4Mhz, but realistically about 3.3 with wait states.
« Last Edit: 11:05, 29 May 15 by arnoldemu »
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Offline Apollo

  • Supporter
  • CPC664
  • *
  • Posts: 66
  • Country: de
  • Liked: 22
  • Likes Given: 337
Re: Z80 clock
« Reply #6 on: 01:17, 30 May 15 »
Thanks but that info I know already and it just talks about how PAL carrier signal is generated, not in what relation this stand to the Z80.

I remember somebody said to me once at Breakpoint demo party that the Plus Z80 has a 4.44 MHz clock and with the additional wait cycles is a tiny bit slower then the original 4MHz Z80, but I find no information about that relationship either in Wiki, Grimware or any other place I know of. I know very good how the GA and Z80 relate to each other on the normal CPC, but about the Plus there is rather few information available about how the clock signals are generated and how wait states differ to be able to feed the 3 DMA channels.
Sadly I don't have an Oscilloscope here, otherwise I would just open my 6128+ and measure the clock pin and wait pin on the Z80 myself.

It would also make sense to enhance the base clock of the Z80 slightly, to have more wait cycles while HSYNC is active to be able to feed the DMA channels without any bus collisions with the CPU.

So any information or pointers to the right source would be appreciated!
CPC - My beloved first computer!

Offline gerald

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.497
  • Liked: 1036
  • Likes Given: 257
Re: Z80 clock
« Reply #7 on: 10:44, 30 May 15 »
A picture being better than words, I let you count the number of 40MHz cycle that make a 4MHz cycle on the following diagram :
 [ Invalid Attachment ]

This is a trace I did of a 6128Plus.
  • 40MHz signal is taken at oscillator output
  • 16MHz signal is taken at CLK16 ASIC output (R168)
  • 4MHz is taken at Z80 clock input
  • 1MHz is taken at AY clock input
  • RAS/CAS/WE/RA/RD taken on RAM devices
Spoiler: show
As you see, the Z80 is clocked at 4MHz, with a WAIT signals low for 3 cycles out of 4. Like all CPC.

Offline arnoldemu

  • Supporter
  • 6128 Plus
  • *
  • Posts: 5.336
  • Country: gb
    • Unofficial Amstrad WWW Resource
  • Liked: 2274
  • Likes Given: 3478
Re: Z80 clock
« Reply #8 on: 12:53, 30 May 15 »
...
other place I know of. I know very good how the GA and Z80 relate to each other on the normal CPC, but about the Plus there is rather few information available about how the clock signals are generated and how wait states differ to be able to feed the 3 DMA channels.

...

It would also make sense to enhance the base clock of the Z80 slightly, to have more wait cycles while HSYNC is active to be able to feed the DMA channels without any bus collisions with the CPU.

The opcodes for the enabled DMA channels are read during HSYNC yes. Execution is processed after that. If you use normal HSYNC width of 6 there is enough time and no collisions. Perhaps if you reduce the hsync width and use DMA there will be but then the picture becomes unstable. If you are splitting the mode multiple times per screen and playing DMA then you will have fun :)


My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Offline gerald

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.497
  • Liked: 1036
  • Likes Given: 257
Re: Z80 clock
« Reply #9 on: 13:05, 30 May 15 »
Thanks but that info I know already and it just talks about how PAL carrier signal is generated, not in what relation this stand to the Z80.
The PAL carrier is not generated by the ASIC, but the ASIC base frequency was chosen to match one of its harmonic to minimise beat frequency.
I do not have a GX4000 with modulator, but it would be interresting to see the effect of a 40MHz oscillator on modulated output.

Offline Apollo

  • Supporter
  • CPC664
  • *
  • Posts: 66
  • Country: de
  • Liked: 22
  • Likes Given: 337
Re: Z80 clock
« Reply #10 on: 03:15, 31 May 15 »
@gerald: Thank you very much! That trace is indeed very helpful and at least a wrong imagination I had how the Plus works is now corrected.
Would it not be good to incorporate this trace and info into the wiki? I guess I am not the only one having this kind of questions.

@arnoldemu: So the DMA read cycles from ram are done in the cycles when the GA/ASIC normally reads screen memory, but as this is the HBLANK and no data is read, the otherwise empty wait cycles are used for the DMA ram read? But how is this related to the length of the HSYNC pulse? And by "mode splitting" do you mean the "fake" HSYNC to make the GA reload its mode status in the same line?
« Last Edit: 03:18, 31 May 15 by Apollo »
CPC - My beloved first computer!

Offline TFM

  • Visit the mysteries of the CPC at www.futureos.de
  • Supporter
  • 6128 Plus
  • *
  • Posts: 9.899
  • Country: aq
  • Space Chicken for FutureOS is free!
    • index.php?action=treasury
    • FutureOS - The revolution on CPC!
  • Liked: 1981
  • Likes Given: 4650
Re: Z80 clock
« Reply #11 on: 20:24, 01 June 15 »
Would it not be good to incorporate this trace and info into the wiki?


YES.  :)
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus