This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Why Thumb?

I want to understand, why most (or all?) examples for MCP2100 (by the way very useful) are for the Thumb mode?
The main resource of the LPC2129, which has not an external memory support, most attractive for designers, I think, is speed, the Flash size is the second or third.
Maybe there is some misunderstanding, and Thumb is better than ARM both by size and performance?
Then why ARM?

Great thanks in advance,
Varuzhan

Parents Reply Children
  • Thank you,

    But it is not an answer on my question.
    Maybe it is very good answer, but for another question, my was about Keil examples.

    Varuzhan

  • "But it is not an answer on my question."

    Isn't it?
    You said:

    "The main resource of the LPC2129, which has not an external memory support, most attractive for designers, I think, is speed, the Flash size is the second or third."

    The article says:

    "The difference between two equivalent instructions lies in how the instructions are fetched and interpreted prior to execution, not in how they function. Since the expansion from 16-bit to 32-bit instruction is accomplished via dedicated hardware within the chip, it doesn't slow execution even a bit. But the narrower 16-bit instructions do offer memory advantages." (my emphasis).

    So you says speed is most important; the article says it's not affected. But there is an advantage to memory requirements.

    Thus using Thumb does have the advantage, without compromising your key requirement - what more could you want?! :-)

    Memory saving is particularly important on a part with on-chip code memory, and no external memory interface - because you have no chance whatsoever to even think of adding extra code memory!

    Thus, the use of Thumb sounds particularly appropriate!

  • Thank you.
    Then, if thumb has the same performance and smaller size, why ARM?

    Varuzhan

  • According to that same article,

    "Every Thumb instruction could instead be executed via the equivalent 32-bit ARM instruction. However, not all ARM instructions are available in the Thumb subset; for example, there's no way to access status or coprocessor registers."

    So, for some operations, you must switch to and use ARM instructions.

    Jon

  • Varuzhan,

    Did you actually read the article?

  • Here are two statements from Philips LPC2000 users manuals:

    - THUMB code is able to provide up to 65% of the code size of ARM, and 160% of the performance of an equivalent ARM processor connected to a 16-bit memory system.

    - For critical code size applications, the alternative 16-bit Thumb Mode reduces code by more than 30% with minimal performance penalty.

    These statements are somehow confusing, but you need to keep in mind that instruction fetching is slower than code execution.

    Effectively more Thumb mode instructions are required compared to ARM mode, but in Thumb mode code size is less and therefore more instructions can be executed in the same time.

    When LPC2000 devices execute code from on-chip Flash at maximum clock (= 60MHz) the Flash sub-system delivers 128 bits (4 ARM or 8 Thumb instructsion) at a rate of 20MHz. ARM code that executes sequencial requires no stalls. But, real code contains branches (conditional or sub-routine calls). For Thumb code more instructions can be fetched at the same time which requires less stalls. We do not have comparisons yet for Thumb vs. ARM speed, however Philips told us to focus on Thumb mode.

    The assumption is that the speed penalty is less than 10% (compared to 35% size reduction). High-speed interrupts may be coded directly in ARM mode (and the code may be stored in RAM using the __ram compiler attribute). Therefore extreme time-critical stuff still uses highest ARM execution speed whereas the majority of the code uses the Thumb mode for maximum code efficiency with minimal speed reduction.

    Reinhard

  • Dear Reinhard,

    Thank you very much. I have seen this 160%,that is why I especially mentioned the part without external memory.
    The 10% less speed assumption is, maybe not too large, but if not all flash is used, why
    sacrifice this 10% for unused 35%.

    Best regards,
    Varuzhan

  • If code size is not an issue, just use ARM mode and you are fine.

    Our focus is code size, since on-chip Flash ROM is limited (and most programs tend to required more functionality than estimated in the beginning) .

    With other words: use Thumb and purchase an 32KB LPC2131 instead of an 512KB LPC2138. Then spend the saved moeny for a good dinner with your girl friend.