|
发表于 2005-10-30 00:11:03
|
显示全部楼层
没错。
我的意思是说,并不是所有指令都有数据访存和回写流水线(实际上用到这两条流水线的指令并不占多数)。
刚才仔细看了Datasheet,发现C8051真的有预取指,不过不像AVR那样每次只取1条指令,而是每次取4个字节(采用32位总线)。C8051的预取指只是为了让Flash的速度适应CPU的运行速度,因为Flash的速度只有CPU的1/4,这一点跟Philips的ARM很像。而且C8051还有分支目标缓存,用来保存上次分支目标处的4个字节指令,用来对付循环语句很管用,根本不用重新取指,这也和Philips的ARM很相似。以下是Datasheet的原话:
When running linear code (code without any jumps or branches), the prefetch engine alone allows instructions to be executed at full speed. When a code branch occurs, a search is performed for the branch target (destination address) in the cache. If the branch target information is found in the cache (called a “cache hit”), the instruction data is read from the cache and immediately returned to the CIP-51 with no delay in code execution. If the branch target is not found in the cache (called a “cache miss”), the processor
may be stalled for up to four clock cycles while the next set of four instructions is retrieved from FLASH memory. Each time a cache miss occurs, the requested instruction data is written to the cache if allowed by the current cache settings.
当代码是线性执行时或分支目标处的代码位于缓存中时,CPU能全速执行。当缓存未命中时,要花4个周期重新取指。
这样,答案就很明显了。 |
|