3

How slow is z80 compared to Arduino Uno when they read an output pin if the Z80 is 2.5Mhz??

I/O cycle and cpu herz and is there anything else to consider?

  • 5
    Arduino Uno is a development board, the Z80 is a microprocessor. You should compare an Atmega328p (the MCU of the Arduino Uno) and a CMOS Z80 (with zero wait-state for RAM, ROM, and I/O), and both clocked to 2.5 MHz, so it would be a fair comparison. – 比尔盖子 Sep 2 at 11:12
  • 4
    A Z80 CPU doesn't have any output pins in the same way as the Atmega328P. It have address, data and control pins. It can't work without supporting circuits. You are comparing apples and bananas here. – UncleBod Sep 2 at 11:38
  • oh, i used to use 8255 chip for z80 to read an output pin – uma Sep 3 at 1:23
  • 2
    @比尔盖子, Re, "both clocked to 2.5 MHz;" There's an argument for clocking them both at the same speed, and there's an argument for clocking each of them at its max rated clock speed. Which one you choose would depend on what you were trying to prove. – Solomon Slow Sep 4 at 13:23
7

How slow is z80 compared to Arduino Uno when they read an output pin if the Z80 is 2.5Mhz??

Quite slow.

An IN instruction to read a port will take 12 (11 with IN A,<port>) cycles. An AVR IN takes a single cycle. So a 16 MHz Arduino Uno is about (12/2,500,000) / (1/16,000,000) = 76.8 times faster.

Of course extracting the pin from the byte read will add some more cycles, but won't change the over all picture.

I/O cycle and cpu herz and is there anything else to consider?

Looking at just the I/O instruction will show just a tiny part of the picture. While it gives a rough estimation, speed of an application is usually not defined by this single instruction, but over all code. So a CPU with a dedicated instruction set may execute way certain tasks better than a different one with just a faster I/O instruction.

For example it it's about testing a port bit for being set will take on a 65C02 a single instruction of 5 cycles, where a Z80 (or AVR) has to have at least 3 instructions, puting it somewhere inbetween both.

Bottom Line: Since all three of them are rather simple and similar constructions, any comparsion based on clocks per instruction per MHz will be sufficient for a rough estimate.

  • "where a Z80 (or AVR) has to have at least 3 instructions" -- now quite true, since Z80 sets zero and sign flags on the data read by any IN r,(C) instruction (including INF or IN (HL),(C) partially undocumented instruction). AVR, in turn, has SBIS/SBIC instructions that allow testing some IO pins in two instructions. – lvd Sep 2 at 15:14
  • @lvd, true, but that's a special case for the sign bit (or if no bit at all is set). All other 7 bits need an AND plus an according Jxx. Similar AVR's skip instructions work only, as you mention, in special circumstances. I guess above simplification works for a generic description, wouldn't you agree? – Raffzahn Sep 2 at 19:09
  • @Raffzahn on top of all this Atmell MCUs have a lot of supporting HW around the CPU core (that's why they are MCUs) which can significantly ease up the task burden off the CPU tweaking the comparison in more favor for MCU. However I am not actively coding for old ATMega328P as I moved to Atmells UC3 years ago and there the new architecture and HW multiplies the effect even more enabling task impossible on CPU's with the same clock (like VGA signal generation) – Spektre Sep 3 at 7:16
  • @Spektre Sure, all true, then again, I think all he wanted is a basic comparison between the two, based o the CPU core. And while the AVR got much build in peripheral, the same can be given to a Z80, even quite capable. [Personally I love the Cypress PSoC1's I/O most. fully runtime configurable 'proto' devices, allowing kind of parallel processing in each. Incredible. Similar the PSoC5, but here even integrated with an ARM core and a quite capable data shovelling structure - eventually the best for data acquisition and control I know - but, you know, ARM] – Raffzahn Sep 3 at 8:24
2

I/O cycle and cpu herz and is there anything else to consider?

If we are talking Arduino then we should also consider software overheads and overall system throughput. The ATmega328 is much faster clock for clock than a Z80, but some Arduino functions need a lot of instructions. DigitalWrite() for example is about 20 times slower than writing directly to an I/O port.

Interrupt overhead on the ATmega328 can be huge because up to 32 registers may have to be stacked and unstacked, whereas the Z80 has EX AF,AF' and EXX which exchange all registers in a few microseconds.

The Z80 can directly address 64k RAM and run code from it, whereas the ATmega328 only has 2k RAM and can only execute code from Flash. As soon as you need more than 2k the ATmega328 gets very slow, since you must use SPI, I2C or I/O port manipulation to access external RAM. If you want to load and run user programs then it gets slower still, since sketches have to be uploaded and written to flash via the bootloader.

Bottom line - If you took a 2.5MHz Z80 CP/M machine and replaced the CPU board with an Arduino Uno (with sufficient 'glue' logic to interface it to the S100 bus), then converted the OS and user programs into Arduino sketches, how much faster - or slower - would it be?

  • This answer is good because it shows it's not an apples to apples comparison – Wilson Sep 3 at 9:29
  • DigitalWrite() is slow, in large part, because it's a generalized solution. There are non-generalized solutions which are much faster. Please keep in mind that "Wiring" isn't intended for performance, it's intended to be using by hobbyists. – Julie in Austin Sep 8 at 0:02
1

As said earlier, AVR core in this arduino runs at 16MHz, and it has ~2 clocks to read a pin.

Z80 has 11 or 12 clocks to read IO port. Thus, it is ~6 times slower in clocks and 6*(16/2.5) ~ 38 times slower in absolute values.

0

The Arduino Uno has an ATmega328P, which is clocked at 16 MHz so it is considerably faster regarding MHz speed.

Both are 8 bit CPUs, so that is comparable.

I don't know about the efficiency of a Z80 to read a pin, for an Atmel it's selecting the port and pin number.

My guess is (mostly based on the difference in MHz), that the Arduino Uno is faster.

UPDATE: See comment of Curt J. Sampson below.

  • 1
    The difference is greater than you think: The Z80 divides the input clock by four to produce bus cycles at 1/4 the rate of the clock, making a Z80 clocked at 4 MHz in one sense a "1 MHz" chip. This was not uncommon on early 8-bit CPUs: the 6809 also did this. This can create confusion as Z80 or 6809 clocked at 4 MHz and a 6502 clocked at 1 MHz would all have 1 MHz bus cycles. – Curt J. Sampson Sep 3 at 3:37
  • @CurtJ.Sampson You can better make it an answer, so I can delete my answer. – Michel Keijzers Sep 3 at 8:41
  • 1
    Raffzahn's answer already covers most of the stuff I would say in mine, so I think we can just leave things as they are. I just wanted to pass that little bit of info back to you. – Curt J. Sampson Sep 3 at 8:43
  • 2
    Z80 does NOT divide input clock by any number. The fact is that instruction byte fetch for Z80 lasts 4 clocks. Simple memory read or write lasts 3 clocks, IO access 4 clocks again. Besides that, Z80 can perform internal operations for a given number of undivided clocks (for example, 5 clocks for adding signed byte to 16 bits, 2 clocks for incrementing 16 bit regpair, etc.). There is no internal division at all. – lvd Sep 3 at 11:02
  • 2
    @lvd Technically you are correct, and I was being rather arm-wavy there because there's not a lot of space in comments for details, nor need in this situation. It remains true that, as a simple approximation, you can think of a Z80 running at n MHz as having a "n/4 Mhz bus." For anybody who needs them, here are the timing details. – Curt J. Sampson Sep 3 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.