While checking the datasheet of ATMEGA 32 I have found a feature called 'On-chip 2-cycle Multiplier'.
Can anyone explain to me what's that and what's the advantage of it?
While checking the datasheet of ATMEGA 32 I have found a feature called 'On-chip 2-cycle Multiplier'.
Can anyone explain to me what's that and what's the advantage of it?
It means that the ALU in the microcontroller has a hardware multiplier, which takes two instruction clock cycles to perform a calculation.
This is faster than doing multiplication using software (e.g. adding multiple times in a for loop).
It means it has a hardware multiplier that takes can complete a multiply operation in two instruction cycles.
Some processors can't multiply numbers, they only have addition and bit boolean logic.
This website discusses how to implement multiplication on a 6502 (The old Apple ][ computer, as well as other computers of that era). https://www.lysator.liu.se/~nisse/misc/6502-mul.html
These 8bit x 8bit operations take about 100 cycles per multiplication. You can see that a 2 cycle multiplication (done in hardware) is far superior. You can do simple DSP type calculations if you can do multiplies at half the clock rate.
The best CPUs can still only do 1 multiplication per cycle, because that is the definition of a clock cycle (although they can do many in parallel).
(Now division is a lot harder. Most CPUs take at least N clock cycles to do a division, where N is the number of bits. For some reason, dealing with the "carry" bit in multiplication can be done quickly, while the "carry" bit in division is much more difficult.)
It's a feature that would perhaps have been impressive a decade or so ago.
Traditionally basic 8-bit processor cores did not have multiply instructions, silicon area was considered more important than performance.
Higher end 16 and 32 bit processor cores on the other hand typically did have hardware multiply instructions and furthermore worked with larger data word sizes.
Some of the high-end 8 bit (data word size) micro-controller architectures such as the "atmega32" and the "pic18" decided to add a multiply instruction. Since this was a new feature for 8-bit microcontrollers the manufacturers saw reason to shout about it. Both the "pic18" and "atmega32" implementations took a pair of 8 bit inputs and produced a 16 bit output, but the atmega32 version gives more options regarding the exact type of multiply that is desired.
but the elephant in the room is the arm cortex m0+. You can now get micro-controllers with a 32-bit data path and a single-cycle 32*32->32 multiplier for prices comparable to the high-end 8 bit micro-controllers.