- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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).
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page