Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
21615 Discussions

Help: How can I implement e(t^2/l^2) in VHDL

Altera_Forum
Honored Contributor II
3,878 Views

Hi! Experts, 

 

Could anyone please help me to implement e(t^2/l^2) in VHDL? where t is continuous time and l is a constant. 

 

Thank you very much in advance. 

 

Regards, 

Akilan.T
0 Kudos
12 Replies
Altera_Forum
Honored Contributor II
2,001 Views

for synthesis or just a testbench? 

and do you mean e^(t^2/l^2)? 

 

You will probably have to implement it via a look up table.
0 Kudos
Altera_Forum
Honored Contributor II
2,001 Views

 

--- Quote Start ---  

for synthesis or just a testbench? 

and do you mean e^(t^2/l^2)? 

 

You will probably have to implement it via a look up table. 

--- Quote End ---  

 

 

 

Tricky, Yes that is right e^(t^2/l^2). Then, I want to sysnthesis it and to place into a FPGA. Look up table means have to place all the values into a long array?
0 Kudos
Altera_Forum
Honored Contributor II
2,001 Views

yes, but remember it has to map to physical hardware, so make sure you follow the coding guidlines for ROMS. You'll also have to make sure t isnt too many bits. t at 20bits per word will be about the limit for the larger devices.

0 Kudos
Altera_Forum
Honored Contributor II
2,001 Views

If your application is not critical you can use a small LUT e.g. 256 points then interpolate (linearly) between two values as they occur by finding the difference between input (t) value and nearst LUT values. i.e. some t values will point directly, most others will point in between LUT points so a basic calculation is needed to adjust the result.

0 Kudos
Altera_Forum
Honored Contributor II
2,001 Views

 

--- Quote Start ---  

If your application is not critical you can use a small LUT e.g. 256 points then interpolate (linearly) between two values as they occur by finding the difference between input (t) value and nearst LUT values. i.e. some t values will point directly, most others will point in between LUT points so a basic calculation is needed to adjust the result. 

--- Quote End ---  

 

 

 

Altera Guru, 

 

Infact, my design is critical. output need to be very precise. Is ther anyway for that?  

 

Now, I got some points then linearize them (y = mx + c) with a particular time interval, then write code like below. 

 

if t = 0 then  

e = 1; 

elsif t > 0 and t <= 1 then 

e = -0.5 * x + 1; 

 

...... 

 

end. 

 

Could I implement in this way? 

 

Thank you. 

 

Akilan.T
0 Kudos
Altera_Forum
Honored Contributor II
2,001 Views

Writing the piecewise linear characteristics as "hard coded" if .. then .. else structure requests all design resources from logic cells. Using a LUT would use the input value as index to a ROM and calculate the interpolated value based on the ROM content.

0 Kudos
Altera_Forum
Honored Contributor II
2,001 Views

To implement LUT interpolation follow these lines: 

 

youe input (T) is say represented by 16 bits unsigned value. Use its 8 MSBs as address to LUT. This picks up the nearest LUT point (lower) then what is left of your (T) value (remainder of 8 LSBs) indicate how much you should add taking into account your scaling. You need to find out (LUT2 - LUT1) where LUT1 is the value addressed at by 8 MSBs. Then translate the (T) excess into LUT extra thus your final value = LUT1 + 8 LSB value * (LUT2-LUT1) / delta (T) of two LUT points* scale factor. (remember delta y/delta x is gradient of any draph)
0 Kudos
Altera_Forum
Honored Contributor II
2,001 Views

 

--- Quote Start ---  

Could anyone please help me to implement e(t^2/l^2) in VHDL? where t is continuous time and l is a constant. 

--- Quote End ---  

 

 

What is the maximum value for 't' and what is the resolution of 't' , and the range for 'i'? What precision do you need for the result? 

If you want to use a Look-Up Table you will need ((tmax / resolution(t)) * precision) memory bits. If that exceeds the number of available you will have to find a (mathematical) solution to compute the result.
0 Kudos
Altera_Forum
Honored Contributor II
2,001 Views

 

--- Quote Start ---  

To implement LUT interpolation: 

--- Quote End ---  

 

 

Here the content of LUT must be 1s and 0s right?, but I have the generated values for e^(x) in floating point values where I take x = 0:0.001:10. could you please show me some directions or any links to such sample code?  

 

Thank you.
0 Kudos
Altera_Forum
Honored Contributor II
2,001 Views

Your numbers are fixed point not floating point. Fixed point means applying a fixed scaling to integer numbers. Most popular are binary (2^n) scaling factors. Number ranges and resolution can be different for x and y of a function and need to be defined according to your accuracy requirements. 

 

By the way, do you actually mean divergent exp(t^2/l^2) or gauss function exp(-t^2/l^2)?
0 Kudos
Altera_Forum
Honored Contributor II
2,001 Views

 

--- Quote Start ---  

By the way, do you actually mean divergent exp(t^2/l^2) or gauss function exp(-t^2/l^2)? 

--- Quote End ---  

 

 

Yes, I mean gauss function exp(-t^2/l^2).
0 Kudos
Altera_Forum
Honored Contributor II
2,001 Views

 

--- Quote Start ---  

Here the content of LUT must be 1s and 0s right?, but I have the generated values for e^(x) in floating point values where I take x = 0:0.001:10. could you please show me some directions or any links to such sample code?  

 

Thank you. 

--- Quote End ---  

 

 

Your LUT content need be in fixed point signed values, you can interpret it as binary zeros/ones or hex or just decimal. But you precompute the contents in fixed point i.e. by scaling values up to your bit width representation and round up any fractional remainders. Yoy precompute the largest possible expression (e.g. whole of exp(...))
0 Kudos
Reply