Forums

Clock cycles

Started by arshadnatasha February 24, 2017
Hi all:

I have been stuck on this problem for a while - can someone help me figure
this out? For the following instruction, the instruction set manual says
it should take 5 clock cycles, whereas according to my measurements using
an oscilloscope, I should get 4 clock cycles. What could be the reason for
the difference? I am using TelosB.

add #1, -4(r4)




---------------------------------------
Posted through http://www.EmbeddedRelated.com
On Fri, 24 Feb 2017 07:52:51 -0600, arshadnatasha wrote:

> Hi all: > > I have been stuck on this problem for a while - can someone help me > figure this out? For the following instruction, the instruction set > manual says it should take 5 clock cycles, whereas according to my > measurements using an oscilloscope, I should get 4 clock cycles. What > could be the reason for the difference? I am using TelosB. > > add #1, -4(r4)
You don't say what processor. If it's pipelined, it's going to be hard to assign a one-and-only number of clock cycles, because the number taken will depend on _everything_. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com I'm looking for work -- see my website!
On 2/24/2017 6:52 AM, arshadnatasha wrote:
> I have been stuck on this problem for a while - can someone help me figure > this out? For the following instruction, the instruction set manual says > it should take 5 clock cycles, whereas according to my measurements using > an oscilloscope, I should get 4 clock cycles. What could be the reason for > the difference? I am using TelosB. > > add #1, -4(r4)
How are you measuring its execution time? Have you tried: add #9, -4(r4) and: add #1, -12(r4)
On 24.2.17 22:20, Tim Wescott wrote:
> On Fri, 24 Feb 2017 07:52:51 -0600, arshadnatasha wrote: > >> Hi all: >> >> I have been stuck on this problem for a while - can someone help me >> figure this out? For the following instruction, the instruction set >> manual says it should take 5 clock cycles, whereas according to my >> measurements using an oscilloscope, I should get 4 clock cycles. What >> could be the reason for the difference? I am using TelosB. >> >> add #1, -4(r4) > > You don't say what processor. > > If it's pipelined, it's going to be hard to assign a one-and-only number > of clock cycles, because the number taken will depend on _everything_. >
The TelosB data sheet says that the processor is a MSP430 8 MHz. -- -TV
Op Fri, 24 Feb 2017 14:52:51 +0100 schreef arshadnatasha  
<119076@embeddedrelated>:
> Hi all: > > I have been stuck on this problem for a while - can someone help me > figure > this out? For the following instruction, the instruction set manual says > it should take 5 clock cycles, whereas according to my measurements using > an oscilloscope, I should get 4 clock cycles. What could be the reason > for the difference? I am using TelosB. > > add #1, -4(r4)
Have you measured other instructions, like NOP? -- (Remove the obvious prefix to reply privately.) Gemaakt met Opera's e-mailprogramma: http://www.opera.com/mail/
On 2/24/2017 12:22 PM, Don Y wrote:
> On 2/24/2017 6:52 AM, arshadnatasha wrote: >> I have been stuck on this problem for a while - can someone help me >> figure >> this out? For the following instruction, the instruction set manual says >> it should take 5 clock cycles, whereas according to my measurements using >> an oscilloscope, I should get 4 clock cycles. What could be the reason >> for >> the difference? I am using TelosB. >> >> add #1, -4(r4) > > How are you measuring its execution time? > > Have you tried: > add #9, -4(r4) > and: > add #1, -12(r4)
This exercise totally baffles me. How can you precisely and directly measure a single instruction execution time? There are numerous ways to indirectly measure it and calculate a probable mean. JJS
On 2/28/2017 10:20 AM, John Speth wrote:
> On 2/24/2017 12:22 PM, Don Y wrote: >> On 2/24/2017 6:52 AM, arshadnatasha wrote: >>> I have been stuck on this problem for a while - can someone help me >>> figure >>> this out? For the following instruction, the instruction set manual says >>> it should take 5 clock cycles, whereas according to my measurements using >>> an oscilloscope, I should get 4 clock cycles. What could be the reason >>> for >>> the difference? I am using TelosB. >>> >>> add #1, -4(r4) >> >> How are you measuring its execution time? >> >> Have you tried: >> add #9, -4(r4) >> and: >> add #1, -12(r4) > > This exercise totally baffles me. How can you precisely and directly measure a > single instruction execution time? There are numerous ways to indirectly > measure it and calculate a probable mean.
I sidestepped the issue and offered a hint to the OP as to what he might want to consider by way of understanding the "discrepancy" in the *posted* example and his assumptions regarding it's execution time. [Note the deliberate changes I made to *that* instruction -- without introducing yet another instruction candidate] As to measuring a specific instruction's execution time, that depends a lot on the processor in question and the encompassing instruction stream (hot/cold cache, emptied pipeline, etc.)