Author Topic: Why 32 bit CPUs with 16 bit DMA transfer counters?  (Read 2262 times)

0 Members and 3 Guests are viewing this topic.

Offline peter-hTopic starter

  • Super Contributor
  • ***
  • Posts: 3947
  • Country: gb
  • Doing electronics since the 1960s...
Why 32 bit CPUs with 16 bit DMA transfer counters?
« on: December 28, 2022, 06:49:06 pm »
It seems strange to have say 10M-100M transistors on a chip and not have a 32 bit DMA counter.
Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 

Offline Brianf

  • Regular Contributor
  • *
  • Posts: 73
  • Country: gb
Re: Why 32 bit CPUs with 16 bit DMA transfer counters?
« Reply #1 on: December 28, 2022, 07:14:15 pm »
It seems strange to have say 10M-100M transistors on a chip and not have a 32 bit DMA counter.

What practical application is there for a DMA unit that will do more than 64k transfers?
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 11625
  • Country: us
    • Personal site
Re: Why 32 bit CPUs with 16 bit DMA transfer counters?
« Reply #2 on: December 28, 2022, 07:15:28 pm »
It is enough in most practical applications. A lot of those CPUs don't have more than 64 K of SRAM. Usually bigger CPUs include channel linking, so you can assemble whatever size you want.

Plus in most cases it is 64K transfers, so if you are just copying the memory blocks, you can use word transfers and get 256 Kbytes with a single transaction.

For multi-channel DMA controller everything multiplies and becomes quite big. A single counter may be 32-bits. But 8 32-bit counters with 8 32-bit compare registers is quite a bit of logic for no real gain in performance except in a couple marginal cases.
Alex
 

Offline hans

  • Super Contributor
  • ***
  • Posts: 1668
  • Country: nl
Re: Why 32 bit CPUs with 16 bit DMA transfer counters?
« Reply #3 on: December 28, 2022, 07:36:31 pm »
It seems strange to have say 10M-100M transistors on a chip and not have a 32 bit DMA counter.

What practical application is there for a DMA unit that will do more than 64k transfers?

Framebuffer transfers for LCDs? Don't need a crazy high resolution screen to get to 64K transfers (256K 16-bit = 128K pix, ~= 480x272 screen size). Admittedly though, it's a relative niche case. For more serious graphics performance, you'd get a MCU like the STM32F427 with DMA2D that has lines/rowsize numbers (14x16bit) as region transfer setting.

And even if you don't get DMA2D, the penalty of 1 IRQ per 64K is not too bad, especially if you can set up ping/pongs in hardware. 64K is also a lot of data to set up and reserve.. so 2 ping-pong buffers is also a huge chunk of memory gone.

DMA streams can run for much much longer in circular mode, but I wouldn't really count that use-case as it's not about accessing a linear region src/dst of greater than 64K at once.
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 11625
  • Country: us
    • Personal site
Re: Why 32 bit CPUs with 16 bit DMA transfer counters?
« Reply #4 on: December 28, 2022, 07:40:09 pm »
Framebuffer transfers for LCDs?
But you don't need cycle perfect performance for this, so a couple minor interruptions to reload the counters and pointers is not a huge deal and does not affect overall performance.
Alex
 
The following users thanked this post: hans

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15098
  • Country: fr
Re: Why 32 bit CPUs with 16 bit DMA transfer counters?
« Reply #5 on: December 28, 2022, 07:51:12 pm »
It seems strange to have say 10M-100M transistors on a chip and not have a 32 bit DMA counter.

What practical application is there for a DMA unit that will do more than 64k transfers?

For small MCUs, this would indeed be unusual due to the limited amount of memory you have access to anyway, but for beefier MCUs, there sure could be uses. For graphics stuff for instance.
But I think some have dedicated DMAs for this. For instance for some STM32's, you have a DMA2D block which can (IIRC) handle larger transfers than 64KB.
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 11625
  • Country: us
    • Personal site
Re: Why 32 bit CPUs with 16 bit DMA transfer counters?
« Reply #6 on: December 28, 2022, 07:56:53 pm »
Regular DMA does not guarantee timings, so it is not useful for driving raw display panels directly anyway. And it is not that hard to send the frame buffer in multiple transfers. It may be inconvenient, but no more than that.  And I definitely can't  see it as a justification to increase hardware complexity.

There may be some middle ground with 24-bit counters, for example, which has to cover everything for a while. But the issue does not seem to be too urgent to warrant hardware redesign.

And more recent designs do include larger counters. Even RP2040 has DMA with full 32-bit counters.
« Last Edit: December 28, 2022, 08:00:12 pm by ataradov »
Alex
 
The following users thanked this post: DiTBho

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15098
  • Country: fr
Re: Why 32 bit CPUs with 16 bit DMA transfer counters?
« Reply #7 on: December 28, 2022, 08:02:02 pm »
Even the PIC32MX did AFAIR. Appeared 15 years ago.
 

Offline peter-hTopic starter

  • Super Contributor
  • ***
  • Posts: 3947
  • Country: gb
  • Doing electronics since the 1960s...
Re: Why 32 bit CPUs with 16 bit DMA transfer counters?
« Reply #8 on: December 28, 2022, 08:03:24 pm »
There may not be much more than 64k spare RAM on-chip, but to drive some things (like LCDs which are to display fast graphics/video) you have to bring out a load of address/data lines anyway (can't use SPI, and the bigger LCDs don't have SPI anyway) so you could easily have megabytes of RAM (off-chip).

The CPU is plenty fast enough.
Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 11625
  • Country: us
    • Personal site
Re: Why 32 bit CPUs with 16 bit DMA transfer counters?
« Reply #9 on: December 28, 2022, 08:07:01 pm »
Sure, but a minor interruption to reload the counter is well amortized with 64K chunks.

It is convenient to do it all in one go, for sure. And for new designs I would absolutely consider 24- or 32-bit counters. It is just not an urgent issue to modify the existing well proven IP.
« Last Edit: December 28, 2022, 08:08:41 pm by ataradov »
Alex
 

Offline janoc

  • Super Contributor
  • ***
  • Posts: 3851
  • Country: de
Re: Why 32 bit CPUs with 16 bit DMA transfer counters?
« Reply #10 on: December 28, 2022, 08:08:23 pm »
There may not be much more than 64k spare RAM on-chip, but to drive some things (like LCDs which are to display fast graphics/video) you have to bring out a load of address/data lines anyway (can't use SPI, and the bigger LCDs don't have SPI anyway) so you could easily have megabytes of RAM (off-chip).

The CPU is plenty fast enough.

And why would you want to drive such LCD from such an MCU requiring off-chip RAM and complex design instead of using parts actually intended for the purpose, with sufficient RAM and dedicated display driving hw?  If you are abusing a low-end MCU for this anyway, then the 16bit DMA counters are likely the least of your problems.
« Last Edit: December 28, 2022, 08:10:11 pm by janoc »
 
The following users thanked this post: DiTBho

Offline peter-hTopic starter

  • Super Contributor
  • ***
  • Posts: 3947
  • Country: gb
  • Doing electronics since the 1960s...
Re: Why 32 bit CPUs with 16 bit DMA transfer counters?
« Reply #11 on: December 28, 2022, 09:04:40 pm »
Quote
instead of using parts actually intended for the purpose, with sufficient RAM

On chip RAM is very expensive, and you can't get much no matter what you pay.
Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 

Offline AndyC_772

  • Super Contributor
  • ***
  • Posts: 4263
  • Country: gb
  • Professional design engineer
    • Cawte Engineering | Reliable Electronics
Re: Why 32 bit CPUs with 16 bit DMA transfer counters?
« Reply #12 on: December 28, 2022, 10:40:42 pm »
It seems strange to have say 10M-100M transistors on a chip and not have a 32 bit DMA counter.

What practical application is there for a DMA unit that will do more than 64k transfers?

I hit this particular limit just last week. My application was to download a large quantity of data from a high speed UART to an external SPI Flash, at the fastest rate possible.

My UART driver uses a circular DMA buffer to receive data, so it can receive at high speed without interrupting all the time. Each time round its main loop, the application checks the number of DMA transfers which have occurred, and parses any characters which have been received since last time.

When the Flash is busy, the STM32 has nowhere to put the incoming data except its own internal RAM. The size needed for the UART Rx buffer becomes dictated by the Flash page write time and the incoming data rate; if the circular buffer fills before the Flash becomes available again, the entire buffer contents are lost.

Ergo, the highest transfer speed is limited by the buffer size, which in turn is limited by that DMA counter.

Offline MT

  • Super Contributor
  • ***
  • Posts: 1662
  • Country: aq
Re: Why 32 bit CPUs with 16 bit DMA transfer counters?
« Reply #13 on: December 29, 2022, 05:02:52 am »
It seems strange to have say 10M-100M transistors on a chip and not have a 32 bit DMA counter.

What practical application is there for a DMA unit that will do more than 64k transfers?

Variable sample rate audio playback DMA. Was used in Fairlight CMI I, II, IIx, III, MFX, Emu Emulator 1,2,3, Emax, Drumulator, Korg DSS1, DSM. AKAI S900, S950, S612, S1000,
and some other audio machines.





 

Offline Brianf

  • Regular Contributor
  • *
  • Posts: 73
  • Country: gb
Re: Why 32 bit CPUs with 16 bit DMA transfer counters?
« Reply #14 on: December 29, 2022, 08:26:44 am »
It seems strange to have say 10M-100M transistors on a chip and not have a 32 bit DMA counter.

What practical application is there for a DMA unit that will do more than 64k transfers?

Variable sample rate audio playback DMA. Was used in Fairlight CMI I, II, IIx, III, MFX, Emu Emulator 1,2,3, Emax, Drumulator, Korg DSS1, DSM. AKAI S900, S950, S612, S1000, and some other audio machines.

But, as has been pointed out, DMA does not guarantee any sort of timing due to bus arbitration.
 

Offline peter-hTopic starter

  • Super Contributor
  • ***
  • Posts: 3947
  • Country: gb
  • Doing electronics since the 1960s...
Re: Why 32 bit CPUs with 16 bit DMA transfer counters?
« Reply #15 on: December 29, 2022, 08:55:42 am »
It is really really close though, surely. On a 168MHz CPU for example, what is the max wait due to bus arbitration? A few clocks?

Also any kind of DMA activity where you want regularity is driven from a timer, or from an external DMA request signal.
Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4263
  • Country: us
Re: Why 32 bit CPUs with 16 bit DMA transfer counters?
« Reply #16 on: December 29, 2022, 09:03:16 am »
Quote
When the Flash is busy, the STM32 has nowhere to put the incoming data except its own internal RAM.
:
Ergo, the highest transfer speed is limited by the buffer size, which in turn is limited by that DMA counter.
Sounds to me like the transfer speed is limited by the flash speed.  Since flash pages will probably also be smaller than 64k, doing larger flash writes probably takes longer, leaving you with a no-win situation.

See the various "Buffer bloat" discussions about The Internet, and/or the ancient paper (RFC790) on "packet switches with infinite memory."


 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 8540
  • Country: fi
Re: Why 32 bit CPUs with 16 bit DMA transfer counters?
« Reply #17 on: December 29, 2022, 10:29:07 am »
Framebuffer transfers for LCDs?
But you don't need cycle perfect performance for this, so a couple minor interruptions to reload the counters and pointers is not a huge deal and does not affect overall performance.

It would, however, make writing and maintaining code easier. I prefer helpful hardware which offloads the CPU, over hardware which needs constant baby-sitting by the CPU, even if said babysitting is not a big performance issue. It still needs to be implemented, tested and verified, and managing peripherals notoriously introduces weird rare corner cases and this is impossible to properly unit test or verify on a PC, because no simulation models exist for the hardware.

You don't have to go to the most expensive flagship models to have more RAM than 64K. UART, SPI, I2S or DCMI transfers can easily go in range of a few hundred K. You can't always utilize word-size transfers. Actually I would think 20-bit counter would cover almost all use cases, 24 for sure.

Mid-range STM32 DMA mapping system is just so ****ed up. They have gazillion of streams available (say, typically 2*8 = 16) - you never ever use that many in a real project simultaneously. But you can only map a few peripherals to each, so before committing to a PCB layout, one needs to verify if they can have even just two simultaneously. They waste a lot of silicon into needlessly high number of counters, comparators and control logic, yet did not want to create a simple full request matrix, but sixteen half-assed matrices instead.

H7 series was the first to finally add the DMAMUX. They could have halved the number of channels at the same time if they wanted to save some silicon. Instead, they added even more DMA controllers to the thing, but that's OK because the chip is expensive anyway.
« Last Edit: December 29, 2022, 01:08:02 pm by Siwastaja »
 
The following users thanked this post: peter-h

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4263
  • Country: us
Re: Why 32 bit CPUs with 16 bit DMA transfer counters?
« Reply #18 on: December 29, 2022, 10:55:45 am »
I dunno.  I prefer peripherals that don’t interfere with deterministic performance of the cpu (ie by bus contention.)  I guess determinism is pretty much a lost cause, anyway, on more complex CPUs.

 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15098
  • Country: fr
Re: Why 32 bit CPUs with 16 bit DMA transfer counters?
« Reply #19 on: December 29, 2022, 07:08:28 pm »
The OP seems to be generalizing a point while focusing on a pretty specific MCU line (STM32F4 is what the OP uses the most IIRC) anyway.
The only way of getting out of its limitations would be to switch to something else, something he's reluctant to do.
 

Offline peter-hTopic starter

  • Super Contributor
  • ***
  • Posts: 3947
  • Country: gb
  • Doing electronics since the 1960s...
Re: Why 32 bit CPUs with 16 bit DMA transfer counters?
« Reply #20 on: December 29, 2022, 09:19:55 pm »
Hmmm, no; this is not related to anything I am designing now.

There is no need to get personal. I know forums get like that but it's not productive. I thought it was a reasonable Q.

Anyway, most people (well, those who are trying to make things work, rather than just shaft their employer for more bread on the table at home) want to switch CPUs like they want a hole in the head (an English saying).
« Last Edit: December 29, 2022, 09:34:41 pm by peter-h »
Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 

Offline thm_w

  • Super Contributor
  • ***
  • Posts: 6912
  • Country: ca
  • Non-expert
Re: Why 32 bit CPUs with 16 bit DMA transfer counters?
« Reply #21 on: December 29, 2022, 10:34:31 pm »
I hit this particular limit just last week. My application was to download a large quantity of data from a high speed UART to an external SPI Flash, at the fastest rate possible.

My UART driver uses a circular DMA buffer to receive data, so it can receive at high speed without interrupting all the time. Each time round its main loop, the application checks the number of DMA transfers which have occurred, and parses any characters which have been received since last time.

When the Flash is busy, the STM32 has nowhere to put the incoming data except its own internal RAM. The size needed for the UART Rx buffer becomes dictated by the Flash page write time and the incoming data rate; if the circular buffer fills before the Flash becomes available again, the entire buffer contents are lost.

Ergo, the highest transfer speed is limited by the buffer size, which in turn is limited by that DMA counter.

DMA double buffer mode, if available.
or switch to another buffer when DMA interrupt half full occurs (kind of waste of RAM though).
Profile -> Modify profile -> Look and Layout ->  Don't show users' signatures
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15098
  • Country: fr
Re: Why 32 bit CPUs with 16 bit DMA transfer counters?
« Reply #22 on: January 01, 2023, 08:19:13 pm »
There is no need to get personal. I know forums get like that but it's not productive. I thought it was a reasonable Q.

There was nothing personal about it. It was just factual. Your original statement was a generalization. As some of us have pointed out, a number of 32-bit MCUs do have DMAs which can handle larger transfers. Or do have specific peripherals for handling large tranfers of display data such as STM32's DMA2D.

For MCUs that only handle transfers with 16-bit counters, that is just one of many decisions designers have to make. On those chips they probably figured that it would have little value due to their limited amount of memory, and as others have said, due to the fact that handling transfers in chunks of 64K words has completely negligible overhead compared to transfering largers blocks in one go. Some of those design decisions may look pointless from an external POV, but chip design is a bunch of such decisions. Some may look a bit arbitrary but designing a chip is all about making decisions. Sometimes, part of the decision is purely marketing. The vendor may have a line of "performance" MCU with more RAM, better DMA controllers, etc, and doesn't want their mid-level lines to compete with that.

And, with that said, my point was that if you still absolutely need > 16K word transfers, there definitely are MCUs out there that can. While wondering why things are what they are is interesting (and we mostly came up with hypotheses rather than definite facts), ultimately we just have to deal with it and select our components accordingly.
 

Offline PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 1750
  • Country: au
Re: Why 32 bit CPUs with 16 bit DMA transfer counters?
« Reply #23 on: January 01, 2023, 08:29:45 pm »
Why 32 bit CPUs with 16 bit DMA transfer counters?

My beef is Why 32 bit MCUs with 16 bit timers/counters ?
It's largely legacy reasons, and partly die costs, some vendors wanted to keep register conventions from their 8 bit parts, but it is thankfully becoming more common to see 24-32 bit timer/counter in 32 bit MCUs
I think NXP got this right early on.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf