Calculating Percentages in VHDL?

C

Cory Shol

Hello all,

I am working on a project that needs to complete safety crosschecks on a regular basis.

If a User sets up the equipment at a specific setting the FPGA logic will calculate a Reference Voltage (lets say a 16 bit number ). The user will also set a percentage from 10-35% (Overvoltage Threshold).

Once the user says he wants the system to allow 15% of overvoltage.

I want to calculate in the logic the 16 bit referance voltage * .15 .


How does one go about calculating percentages? I am using a Xilinx Spartan 3a 700a. A link to an tutorial or algorithm would be great.

Thanks
 
R

Rob Gaddi

Hello all,

I am working on a project that needs to complete safety crosschecks on a regular basis.

If a User sets up the equipment at a specific setting the FPGA logic will calculate a Reference Voltage (lets say a 16 bit number ). The user will also set a percentage from 10-35% (Overvoltage Threshold).

Once the user says he wants the system to allow 15% of overvoltage.

I want to calculate in the logic the 16 bit referance voltage * .15 .


How does one go about calculating percentages? I am using a Xilinx Spartan 3a 700a. A link to an tutorial or algorithm would be great.

Thanks

R * 0.15 = R * (0.15 * 2^17) / 2^17
 
C

Cory Shol

R * 0.15 = R * (0.15 * 2^17) / 2^17



--

Rob Gaddi, Highland Technology -- www.highlandtechnology.com

Email address domain is currently out of order. See above to fix.

Ahh yes , I actually just thought about something similar to that just before I read the reply. Sometimes your brain doesn't work as fast as you want it to.
 
A

Andy

Try the fixed point library in VHDL. It is included in the 2008 standard, and a quick google search will get you the vhdl fixed point user guide that shows you how to use it.

Andy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top