Sign in

username:

password:



Not a member?

Search rabbit-semi



Search tips

Subscribe to rabbit-semi



Ads

Discussion Groups

Discussion Groups | Rabbit-Semi | Questions about time and speed

This is a group for folks designing and programming embedded systems using the Rabbit Semiconductor C-programmable microcontroller. Rabbit Semi is a spin-off from Z-World who makes a variety of embedded modules and tools. This group is not affiliated with either Rabbit or Z-World, but is a user forum for sharing ideas, asking questions, flaunting knowledge, and other typical user group stuff. The Rabbit is a powerful uC, supported by a full-featured C-compiler.

Questions about time and speed - Marco Trapanese - May 28 15:04:28 2008

Hello!

I have some questions:

1) What's the data type which leads to the smallest / fastest code?
char or int?
2) How much time do math operations take? I'm looking for something
like this table:

http://www.ccsinfo.com/faq.php?page=time_for_math
3) With a Rabbit RCM4100 @ 58.9824 MHz I try the following test code:

for (;;) {
BitWrPortI(PBDR, &PBDRShadow, 1, 6)
BitWrPortI(PBDR, &PBDRShadow, 0, 6)
}

I measured a frequency of about 600 kHz. Why it's so low?

Thanks you in advance
Marco / iw2nzm

------------------------------------



(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )


Re: Questions about time and speed - Scott Henion - May 28 16:08:25 2008

Marco Trapanese wrote:
> Hello!
>
> I have some questions:
>
> 1) What's the data type which leads to the smallest / fastest code?
> char or int?
>
The rabbit processor has better instructions for 16-bit data.

>
> 2) How much time do math operations take? I'm looking for something
> like this table:
>
> http://www.ccsinfo.com/faq.php?page=time_for_math
>

You will have to test the, should be similar.
>
> 3) With a Rabbit RCM4100 @ 58.9824 MHz I try the following test code:
>
> for (;;) {
> BitWrPortI(PBDR, &PBDRShadow, 1, 6)
> BitWrPortI(PBDR, &PBDRShadow, 0, 6)
> }
>
> I measured a frequency of about 600 kHz. Why it's so low?
>
Debugging will slow down. Try disabling rst 28's in advanced options,
compile to flash and see what you get (will not run under debugger.)

Also the 4100 runs at about an effective speed of about 36mhz due to
wait states. If you want full speed, go with the RCM4200.

Using a faster compiler will help too.

What do you need to do? The rabbits are not very fast, there are other
options. I just did a similar loop on a Netburner and got a 5mhz clock ;)



--
------------------------------------------
| Scott G. Henion| s...@shdesigns.org |
| Consultant | Stone Mountain, GA |
| SHDesigns http://www.shdesigns.org |
------------------------------------------
Rabbit libs: http://www.shdesigns.org/rabbit/
today's fortune

As President Roosevelt said: "We have nothing to fear but fear itself. And Chuck Norris."
------------------------------------



(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )

Re: Questions about time and speed - Marco Trapanese - May 28 16:46:29 2008


First, let me thank you for your quick answer.
> Debugging will slow down. Try disabling rst 28's in advanced options,
> compile to flash and see what you get (will not run under debugger.)

I'm pretty sure I ran the code with rst 28's disabled. Anyway,
tomorrow I redo the test again.
> Also the 4100 runs at about an effective speed of about 36mhz due to
> wait states.

How many instruction cycles does BitWrPortI require? What's the
single-instruction execution time?

With a clock of 59 MHz I expect an output frequency of about 20 MHz!
> What do you need to do? The rabbits are not very fast, there are other
> options. I just did a similar loop on a Netburner and got a 5mhz
clock ;)

Yeah, and with an AVR @ 20 MHz I got a 10 MHz square wave :)

Actually, I don't need "a lot" of speed. But I want to know how much
time takes my code when executed. I can't write code without
understand what I'm doing...
Bye
Marco / iw2nzm

------------------------------------



(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )

Re: Re: Questions about time and speed - Scott Henion - May 28 17:07:32 2008

Marco Trapanese wrote:
>> Also the 4100 runs at about an effective speed of about 36mhz due to
>> wait states.
>>
>
> How many instruction cycles does BitWrPortI require? What's the
> single-instruction execution time?
>
> With a clock of 59 MHz I expect an output frequency of about 20 MHz!
>

Most instructions are 2-7 clocks, some up to 11.

Just the "ioi ld (hl),n" is 9 clocks.

Just noticed it is a 4100, that does run 0 wait states.

DC generates very poor code with no optimization. If you need speed, use
assembly language. Most of my stuff uses asm for low-level stuff. I also
use a better optimizing compiler. ;)

--
------------------------------------------
| Scott G. Henion| s...@shdesigns.org |
| Consultant | Stone Mountain, GA |
| SHDesigns http://www.shdesigns.org |
------------------------------------------
Rabbit libs: http://www.shdesigns.org/rabbit/
today's fortune
* Knghtbrd pelts wichert with NERF darts
* wichert notes there are no ICBM nerfs yet and ignores kngtbrd
wichert - just wait, after seeing the NERF gatling guns, ICBMs
are not far off (just pump the damned thing for an hour or two
is all...)


(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )

Re: Re: Questions about time and speed - Aaron Carlson - May 28 17:12:24 2008

Write it in assembly. That should generate the fastest code. Also, you
can count the cycles each instruction takes by looking them up in the
assembly instructions table in the rabbit documentation. Also you don't
necessarily have to use shadow registers, read up on it in the
documentation. Good luck :)

-Aaron

On Wed, 28 May 2008 13:46:21 -0700, Marco Trapanese
wrote:

>
> First, let me thank you for your quick answer.
>> Debugging will slow down. Try disabling rst 28's in advanced options,
>> compile to flash and see what you get (will not run under debugger.)
>
> I'm pretty sure I ran the code with rst 28's disabled. Anyway,
> tomorrow I redo the test again.
>> Also the 4100 runs at about an effective speed of about 36mhz due to
>> wait states.
>
> How many instruction cycles does BitWrPortI require? What's the
> single-instruction execution time?
>
> With a clock of 59 MHz I expect an output frequency of about 20 MHz!
>> What do you need to do? The rabbits are not very fast, there are other
>> options. I just did a similar loop on a Netburner and got a 5mhz
> clock ;)
>
> Yeah, and with an AVR @ 20 MHz I got a 10 MHz square wave :)
>
> Actually, I don't need "a lot" of speed. But I want to know how much
> time takes my code when executed. I can't write code without
> understand what I'm doing...
> Bye
> Marco / iw2nzm

------------------------------------



(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )

Re: Re: Questions about time and speed - Tom Collins - May 28 18:39:14 2008

The Rabbit4000 also has bit registers for port D and E that would allow you to skip using the shadow register if you just want to flip a single bit.

Should be two assembly instructions:

ld a, 1
ioi ld (PDB0R), a

16 clocks total.

-Tom
(sent from my Treo 680)
-----Original Message-----
From: "Aaron Carlson"
Date: Wednesday, May 28, 2008 2:12 pm
Subject: Re: [rabbit-semi] Re: Questions about time and speed
To: r...@yahoogroups.comReply-To: r...@yahoogroups.com

Write it in assembly. That should generate the fastest code. Also, you
can count the cycles each instruction takes by looking them up in the
assembly instructions table in the rabbit documentation. Also you don't
necessarily have to use shadow registers, read up on it in the
documentation. Good luck :)

-Aaron

On Wed, 28 May 2008 13:46:21 -0700, Marco Trapanese
wrote:

>
First, let me thank you for your quick answer.

>
> Debugging will slow down. Try disabling rst 28's in advanced options,
> compile to flash and see what you get (will not run under debugger.)

> I'm pretty sure I ran the code with rst 28's disabled. Anyway,
tomorrow I redo the test again.

>
> Also the 4100 runs at about an effective speed of about 36mhz due to
> wait states.

> How many instruction cycles does BitWrPortI require? What's the
single-instruction execution time?

> With a clock of 59 MHz I expect an output frequency of about 20 MHz!

>
> What do you need to do? The rabbits are not very fast, there are other
> options. I just did a similar loop on a Netburner and got a 5mhz
clock ;)

> Yeah, and with an AVR @ 20 MHz I got a 10 MHz square wave :)

> Actually, I don't need "a lot" of speed. But I want to know how much
time takes my code when executed. I can't write code without
understand what I'm doing...

>
Bye
Marco / iw2nzm

>

------------------------------------



(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )

RE: Re: Questions about time and speed - Julian Higgison - May 28 22:19:36 2008



> How many instruction cycles does BitWrPortI require? What's the
> single-instruction execution time?

You just timed it.

About 600KHz gives us a period of about 1.7 us - And you have 2 instructions
in that period, so each BitWrPortI() is about 0.85us.

give or take..

Of course BitWrPortI() is not a single instruction, but many many machine
code instructions.

> With a clock of 59 MHz I expect an output frequency of about 20 MHz!

Not on a rabbit, you don't.

Rabbit's don't execute 1 instruction per cycle.

ESPECIALLY not in a high level language where you are calling a function
(stacks, program counter loads, etc )and copying to and from system memory
as well.

Try getting a look at the assembler output of DC for your simple test code,
if you want to see what kind of instructions those two lines of Dynamic C
generate.

> Yeah, and with an AVR @ 20 MHz I got a 10 MHz square wave :)

That's because AVRs are awesome!

..and because you're directly setting a port to a value. Not masking bits,
reading, fiddling with a stack, or jumping about your program memory.

But yeah. code differences aside, a 20MHz AVR is equivalent in MIPS to about
what a 100-200MHz rabbit would be, if it existed.. And about an 80MHz pic.

J

> I can't write code without understand what I'm doing...

In that case, I think that you have a fair bit of learning to do.

Julian Higginson

Bruttour International P/L

Tel : +61 2 9987 1581

www.bruttour.com.au



(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )

Re: Questions about time and speed - Marco Trapanese - May 29 2:30:11 2008

Thanks you to all!
I'll do some stuff in asm when I need speed. Obviously, an high-level
language is very useful for complex tasks.

Marco / iw2nzm

------------------------------------



(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )

Re: Questions about time and speed - fairy_dave - May 29 4:59:36 2008

--- In r...@yahoogroups.com, "Marco Trapanese"
wrote:
>
> Hello!
>
> I have some questions:
>
> 1) What's the data type which leads to the smallest / fastest code?
> char or int?
> 2) How much time do math operations take? I'm looking for something
> like this table:
>
> http://www.ccsinfo.com/faq.php?page=time_for_math
> 3) With a Rabbit RCM4100 @ 58.9824 MHz I try the following test
code:
>
> for (;;) {
> BitWrPortI(PBDR, &PBDRShadow, 1, 6)
> BitWrPortI(PBDR, &PBDRShadow, 0, 6)
> }
>
> I measured a frequency of about 600 kHz. Why it's so low?
>
> Thanks you in advance
> Marco / iw2nzm
>

As for the speed of operations I did some tests a while back (see
message http://tech.groups.yahoo.com/group/rabbit-
semi/message/36958 ) and I found that signed INT is generally the
fastest in the Rabbit. I included the message so you can run it on
your own system, and because it shows times for different types of
operations.

Cheers
------------------------------------



(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )

Re: Questions about time and speed - Marco Trapanese - May 29 6:01:09 2008

> As for the speed of operations I did some tests a while back (see
> message http://tech.groups.yahoo.com/group/rabbit-
> semi/message/36958 ) and I found that signed INT is generally the
> fastest in the Rabbit. I included the message so you can run it on
> your own system, and because it shows times for different types of
> operations.
This is the result for my system (RCM4100 @ 59MHz):

Task Long Int Float

Compare 211 173 352

Add/Sub 276 184 860

Mul 264 116 429

Div 1431 796 872

Printf 8536 3996 11287
Just another question, slightly OT from the original post but related
in some way.

In DC10.21 how to know the RAM / flash in use? I'd like to compare
different functions to find the smallest / fastest.

Marco / iw2nzm

------------------------------------



(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )