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.

Fixed point operations in C

Status
Not open for further replies.

kaushiksangam

Newbie level 6
Joined
Apr 9, 2006
Messages
14
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,387
I want to emulate an algorithm in C before actually writing to hardware.

This algorithm invovles lot of multiplications and additions of real numbers. Hence, I want to use fixed point operations(to represent real numbers) in C to emulate the algorithm.

Can someone please tell me or give me an example of how to perform fixed point operations in C.
 

jagan326

Newbie level 3
Joined
Aug 22, 2006
Messages
3
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,291
hey can u give me the details of this topic
 

kaushiksangam

Newbie level 6
Joined
Apr 9, 2006
Messages
14
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,387
It is about the implementation of a Brain State in a Box (BSB) algorithm. Before implementinng this in hardware, i would want to emulate the same in C.

Already have implemented algorithm in C through floating point oprations.

I can also send you the code of the implementation.
 

neuralc

Full Member level 4
Joined
Nov 6, 2001
Messages
236
Helped
9
Reputation
18
Reaction score
3
Trophy points
1,298
Activity points
2,202
Why dont use floating point?
Which up are you using?

NeuralC
 

alvarorahul

Advanced Member level 4
Joined
Apr 13, 2005
Messages
110
Helped
6
Reputation
12
Reaction score
1
Trophy points
1,298
Activity points
2,062
u can use an array of two integers for each number then, for example
0.004676 can be stored as
var1=4676 and var2= -3 u can u short int for the var2 coz im assuming that ur powers would not vary too much
 

neuralc

Full Member level 4
Joined
Nov 6, 2001
Messages
236
Helped
9
Reputation
18
Reaction score
3
Trophy points
1,298
Activity points
2,202
This is floating point....
 

louisnells

Full Member level 4
Joined
May 8, 2006
Messages
209
Helped
19
Reputation
38
Reaction score
8
Trophy points
1,298
Activity points
3,019
Hi,
Fixed point operations in C is not that difficult to implement.
Lets say we are storing numbers in 8.24 format. So we can use a 32 bit un-signed integer for that. We are going to store the integer 8 bits in the MSB side and the fractional 24 bits on the LSB side (as we always represent in digital form - Little Endian). Then may be you should write a small library for fixed operations. Then implement operations like multiplication as bit-wise operations.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top