**UPGRADE YOUR BROWSER**

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

Turn on suggestions

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

Showing results for

- Community Forums
- :
- Forums
- :
- Vivado RTL Development
- :
- Design Entry
- :
- How can I impliment this formula??

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

goodspeed2009

Contributor

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

04-10-2010 06:31 AM

8,801 Views

Registered:
12-29-2009

How can I impliment this formula??

I am a newbie.

I don't know how to implement the following formula in VHDL .

And I don't know how to make the derivative of X.

Formula: x's derivative=9*(x-5)+7;

11 Replies

drjohnsmith

Scholar

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

04-11-2010 03:06 AM

8,783 Views

Registered:
07-09-2009

Re: How can I impliment this formula??

Hi

thats a general question,

and I'm afraid it's a long road to get the answer.

You could just write

deri <= 9 * ( deri - 5 ) + 7;

BUT

that makes a lot of assumptions.

Like:

what size / format is deri ?

I'm assuming you have this in a clocked prosess ?

size off the numbers, which bits of the numbers do you want to take, remember your in the hardware world now, so you have to decide how many bits you want, not what the cpu gives you.

Take big step back, I guess you need to learn a lot of hardware design before you go forward.

<== If this was helpful, please feel free to give Kudos, and close if it answers your question ==>

goodspeed2009

Contributor

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

04-11-2010 03:54 AM

8,782 Views

Registered:
12-29-2009

Re: How can I impliment this formula??

Thanks for your reply. But there are some misunderstanding between us.

I will explain the formula to you.

First,assume a variable is 10 bit whose name is X.

The derivative of X equal to 9*(X-5)+7.

How can I get the result of the variable X?

drjohnsmith

Scholar

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

04-11-2010 06:24 AM

8,777 Views

Registered:
07-09-2009

Re: How can I impliment this formula??

Hi

Well Ok, lets split this out for you:

A <= X - 5;

B <= A * 9;

C <= B + 7;

X <= some_bits_of( C );

What size is A,B abd C going to be ?

you then need to re size C back to 10 bits to assign it back to X.

Ahh, all these things you don't have to worry about in the world of C,

but unfortunatly in hardware, it's up to you to specify the size of bits used, and where the decimal point goes.

e.g. you could, but I would not, specify A,B and C as floating point 64 bits numbers, it's what a CPU would do, but that would be an Amazing waste in hardware !

so right out the maths you want done, and think how many bits and where you want the decimal point to go.

<== If this was helpful, please feel free to give Kudos, and close if it answers your question ==>

goodspeed2009

Contributor

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

04-11-2010 06:56 AM

8,781 Views

Registered:
12-29-2009

Re: How can I impliment this formula??

Yeah,sir.You are right that I have to consider the width of the data which is inevitable in hardware.

All the data in my programme is integer. In that case ,I don't need to care about the point.

I j wonder how can I deal with **some_bits_of** ??

drjohnsmith

Scholar

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

04-11-2010 08:20 AM

8,771 Views

Registered:
07-09-2009

Re: How can I impliment this formula??

Hi

Ok, so integers,

so what size do we need say A to be ?

example, say x = 3, what would that make A ?

<== If this was helpful, please feel free to give Kudos, and close if it answers your question ==>

woutersj

Explorer

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

04-11-2010 09:23 AM

8,768 Views

Registered:
07-27-2009

Re: How can I impliment this formula??

Hi,

to get your required bit width:

x-5: 11 bits assuming min(x)=-512

9*(x-5): 14 bits

9*(x-5)+7: 14 bits

You can verify this (or correct me) by filling in the max and min numbers that X can take. I guess X inside [+511, -512] for 10 bit integers, so the formula will result in the derivative being inside [+4561,-4646]. To represent these numbers you need 14 bits or a range [+8191, -8192].

To shrink the bit width of the derivative, you probably want to read up on saturation, truncations, etc. to avoid nasty numerical side effects.

Cheers,

Johan

goodspeed2009

Contributor

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

04-11-2010 05:39 PM

8,762 Views

Registered:
12-29-2009

Re: How can I impliment this formula??

Thanks sir. With your help ,I know how to determine the width of the data .

But I still unsure how to get the value of X in the formula. Could you give me some advice about that?

bassman59

Historian

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

04-11-2010 09:58 PM

8,757 Views

Registered:
02-25-2008

Re: How can I impliment this formula??

goodspeed2009 wrote:Thanks for your reply. But there are some misunderstanding between us.

I will explain the formula to you.

First,assume a variable is 10 bit whose name is X.

The derivative of X equal to 9*(X-5)+7.

How can I get the result of the variable X?

Integration?

----------------------------Yes, I do this for a living.

woutersj

Explorer

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

04-11-2010 10:51 PM

8,756 Views

Registered:
07-27-2009

Re: How can I impliment this formula??

But I still unsure how to get the value of X in the formula. Could you give me some advice about that?

Review differential equation solving?

Cheers,

Johan

eilert

Advisor

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

04-11-2010 11:25 PM

3,673 Views

Registered:
08-14-2007

Re: How can I impliment this formula??

Hi ,

your question is a little confusing.

Ok, you have this formula:

derivative=9*(x-5)+7;

so what's your input signal and what's your output?

If yor Input is X then you (simplified) calculate:

derivative<=9*(x-5)+7;

Like it was mentioned in one of the first replies.

If X is the Output and derivate the input then the formula changes to:

x <= ((derivate - 7)/9)+5;

where you get some problem with synthesis, since 9 is no power of two result.

So, what are you about to do?

Can you provide us with some entity or process template where we can see what 's declared and how the data flow is intended to be?

Have a nice synthesis

Eilert

eneserdin

Observer

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

04-12-2010 11:38 PM

3,660 Views

Registered:
12-25-2007

Re: How can I impliment this formula??

You mean integration as i understand and in the previous replies it was asked. The exact explanation of the problem is

d(f(x))/dx = 9(x-5)+7

what is f(x), you meant this, didn't you?

if it is a specific function like above then it is a paper & pencil work.

f(x) = 9/2*x^2 - 38*x + C

But, you must specify your boundaries. However, if the equation is not a specific one like above then you have to study on taking integral in discrete domain.