Continue to Site

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.

simple logic circuit for 1/X

Status
Not open for further replies.

nba83

Junior Member level 3
Joined
Apr 9, 2006
Messages
30
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,288
Activity points
1,494
hi
i want to implement a simple logic circuit in CPLD (XC9572) which does this operation (1/X + X * 4 ) . what is the efficient way of calculating 1/X. X is a 12 bit number.
I already done the multiplication part but don't have any ideas about how to efficiently do the 1/x part. should I go for the divider module?
tnx in advanced for helpful comments
Neda
 

1/x is a large calculation. It is usually better to do a divide in a LUT (and with 12 bits, that would be easy) but there usually isnt much (if any ) memory in a CPLD.
 

hi
i want to implement a simple logic circuit in CPLD (XC9572) which does this operation (1/X + X * 4 ) . what is the efficient way of calculating 1/X. X is a 12 bit number.
I already done the multiplication part but don't have any ideas about how to efficiently do the 1/x part. should I go for the divider module?
tnx in advanced for helpful comments
Neda

the multiplection part is just shift left the number by 2 bits - so it will not consume logic.
the 1/x part will need a lot of logic.
as said before this is a small CPLD , so i doubt that you will be able to implement it with all the logic elements
it contains, but you might try.
(remember that for large number the result slightly changed, so it reduce the number of "when" in a case).
also you can reduce the 1/x to lesser bit calculation , for instance 4 bit,or 8 bit - this will reduce the logic elements you might need.
 

The question makes no sense without specifying a fixed point number format. For integer X, 1/X result is either 0, 1 or infinity, a quite simple logic problem.

Presuming a suitable fixed point format, e.g. 6.6, the logic surely won't fit XC9572. If no ROM blocks for an effective LUT are available in the respective logic family, I would look at serial dividers.
 

I don't know how powerful the XC9572 is but here's how one would accomplish x/1. First of all, I'm going to make the assumption that x is a natural number (positive integer). In that case, your result typically ranges from 0 to 1 (exception: 1/0 = infinity) As FvM pointed out, if your 12 bits directly represent your result, then your result must be rounded to a whole number - either 1 or 0.

One common way to get around the problem is to store numbers as fractions. Let's assume that your 12-bit number is the numerator of the fraction, and, as FvM suggested, the denominator is always assumed to be 64 (2^6). Then the largest possible number you can store is (2^12-1)/(2^6) and the smallest non-zero number is 1/(2^6).
So what your actually looking for is a numerator, not the straight up quotient.

Now the answer to your original question, 'quotient= 1/x', can be rephrased as 'numerator/64 = 1/x'. Multiply both sides by 64 and you get 'numerator = 64/x'. A naive algorithm to find 64/x in CPLD is to add 'x' to a register (keeping track how many times you added it) until the register exceeds 64. The number of times you added it is your result, rounded up to the nearest whole number. Keep in mind that when your hardware is ready to interpret your 12-bit number, it must divide by the implied denominator, 64. That is to say, 1/x = result/64.

PS. the "proper" way to implement division is the way you would do long division (as you would by hand), but as pointed out above, this may not fit on your logic hardware. Therefore the naive algorithm may be the best one for your purpose.
 

1/x is a large calculation. It is usually better to do a divide in a LUT (and with 12 bits, that would be easy) but there usually isnt much (if any ) memory in a CPLD.
tnx for replys, what do you mean by divide in a LUT?
 

basically, if there are only a few (eg 32) values for x, then just compute f(x) for all 32 values and store the results in a table.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top