Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Intel Community
- FPGAs and Programmable Solutions
- Nios® II Embedded Design Suite (EDS)
- Timing calculation help!

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Altera_Forum

Honored Contributor I

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

12-11-2016
01:27 PM

710 Views

Timing calculation help!

Hi, I'm new to nios. I'm writing an app to calculate position of a moving point.

S = S0 - v*t. I need help to implement the t value. I'm thinking of using for loop for (t=0;t<1000;t++) { S = S0 - v*t; } As I understand, each t increase will be equivalent to 1 clock cycle so it will be 20ns (my clock is 50MHz). So if I want t to calculate in second I must do it like this: S = S0 - v*t*20/1000,000,000 Is it usable or I must use timer interval core?Link Copied

1 Reply

Altera_Forum

Honored Contributor I

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

12-15-2016
07:25 PM

51 Views

I have some limited experience with NIOS, so what I write is a more general answer.

Having said that, you need to look into the cycle count of each operation. This one line of code actually does three things: 1. multiply v and t 2. substract that result from S0 3. store that result in S Then you need to know the types of the inputs and results. Floating point arithmetic may take longer than integer calculations. Then you need to know how much of those 3 steps are run in one cycle. Generally the store comes "free" with any other operation, i.e. it does not have a cost in cycles. On top of this the compiler may do some compiler magic so you don't exactly know the cycle count until you take a look at the assembler code, or write your own assembly code. As long as you know the cycle count you can calculate the time it takes to execute one loop iteration (the a loop also takes instructions, unless it is unrolled).- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

For more complete information about compiler optimizations, see our Optimization Notice.