Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

sqt function required for rms calculation

Status
Not open for further replies.

habbas33

Newbie level 5
Joined
Oct 19, 2008
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,346
i want to calculate rms values of some signals.

xrms = sqrt{ 1/n*( x_1^2 + x_2^2 + ...... + x_n^2 ) }.

but the problem is sqrt operation. i have used cordac but it does not gives precise values u can either give integers or fractions. I have also tried sqrt function from fixed_alg_ug pkg but its not synthesizable because it depends on real_math pkg.
i need a sqrt code which can give me precise answer for example

when 48 goes to => sqrt => gives 6.928 => not 7
 

TrickyDicky

Advanced Member level 5
Joined
Jun 7, 2010
Messages
7,108
Helped
2,079
Reputation
4,177
Reaction score
2,043
Trophy points
1,393
Activity points
39,598
fixed point will be precise to the nearest 2^-N, where N is the number of fraction bits. I guess with cordic you didnt give enough fraction bits.
Have you also considered a look up table (it uses less resources and has smaller latency than cordic.)
 

habbas33

Newbie level 5
Joined
Oct 19, 2008
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,346
fixed point will be precise to the nearest 2^-N, where N is the number of fraction bits. I guess with cordic you didnt give enough fraction bits.
Have you also considered a look up table (it uses less resources and has smaller latency than cordic.)

to get result in fraction, cordic can only take 1 bit integer...

can u please explain the how can i use look up table method because i dont have known values of inputs and ouputs
 

axcdd

Full Member level 3
Joined
Jan 29, 2012
Messages
155
Helped
58
Reputation
116
Reaction score
57
Trophy points
1,308
Activity points
2,133
Code:
to get result in fraction, cordic can only take 1 bit integer...

can you change your cordic 'vendor' ?
Richard Herveille cordic core is 16bit in /20 bit out length in standard.
 

TrickyDicky

Advanced Member level 5
Joined
Jun 7, 2010
Messages
7,108
Helped
2,079
Reputation
4,177
Reaction score
2,043
Trophy points
1,393
Activity points
39,598
A look up table is just a ROM. The input address is the X value, the output is the squaroot answer. The ROM values need to be pre-calculated (this can easily be done with something like matlab and can even be generated in VHDL).
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
49,914
Helped
14,484
Reputation
29,238
Reaction score
13,396
Trophy points
1,393
Location
Bochum, Germany
Activity points
286,608
Most FPGA vendors have IP (Megafunction, core generator, ...) for integer squareroot. It can be applied for fixed point calculations by applying suitable scaling.

The first point to write synthesizable code for operations like this is to design the involved number formats.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top