Forum Discussion
12 Replies
- Altera_Forum
Honored Contributor
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. - Altera_Forum
Honored Contributor
--- 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? - Altera_Forum
Honored Contributor
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.
- Altera_Forum
Honored Contributor
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.
- Altera_Forum
Honored Contributor
--- 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 - Altera_Forum
Honored Contributor
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.
- Altera_Forum
Honored Contributor
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) - Altera_Forum
Honored Contributor
--- 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. - Altera_Forum
Honored Contributor
--- 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. - Altera_Forum
Honored Contributor
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)?