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.

Numerical computation in FPGA

Status
Not open for further replies.

gary36

Full Member level 4
Joined
Mar 31, 2018
Messages
208
Helped
0
Reputation
0
Reaction score
0
Trophy points
16
Activity points
1,806
Currently I am interfacing FPGA to ADC and the ADC outputs 0-4095 counts corresponding to 0-5V. In FPGA I would like to convert these counts back to process value. What are the methods to achieve this objective?
 

What do you mean by convert the counts back?

The outputs of the ADC represent the input voltages seen on the analog input of the ADC. i.e. 0V == 0, 2.5V== 2047, and 5V == 4095, and all other values (counts) between represent other voltages.
 

4095 counts have to be translated to process value just like we do with micro-controllers. I have to do numerical scaling ( to convert the count to physical value to indicate pressure, temperature etc) of the count value and then display in LCD or 7 segment LED.
 

Hi,

Why these vague informations?

Example for a 3 digit voltmeter:
0...4095 (ADC) --> "0.00" ... "5.00"

This means 500 steps with a value of 10mV per step on the display.
The according decimal point in the display simple is fixed "ON" and has nothing to do with the calculation.
The solution to the above is to multiply the ADC_value with 500/4096.
Do this as an integer multiplication with the value 500. At least 12bits x 9 bits = 21 bits. Ignore the lower 12 bits of the result.

Klaus
 

Hi

Can we just use the divide function (say in verilog) as you have proposed or should we customize the division function?
 

As ads-ee mentioned, the 12 bit unsigned number represents already the process value and don't necessarily need to be converted. Conversion to engineering units with defined scaling is however a possible operation, for example integer millibar or 0.1 °C, also gain and zero adjustment ("calibration") of measurement values. If you start with practical FPGA coding, you'll realize that division by a constant factor is a bad idea due to large resource consumption of the divider unit. Instead you'll use fixed point multiply.
 

Hi FvM

Thanks for that info. I finally understood the concept. I am really looking for a hardware efficient multiplier algorithm to be implemented in verilog.
 

Modern FPGA synthesis tools almost free you from worrying about efficient multiplier algorithms. It's your job to design the dataflow and useful pipelining for everdays numerical computation problems.
 

I don't think this is a good use-case for a multiplier. The problem is to display a value in decimal format. For this, a small FSM with an adder/subtractor seems correct. The FSM would accumulate 100 (just a guess) samples. After getting 100 samples, the fsm would try to subtract 1V. if there are 4095 counts per 5V, then there 819 counts per 1V. Because the samples have been accumulated 100 times, 1V would be 81900 in the accumulated version. With each subtraction, the unit place of a temporary output value is incremented. this continues until the accumulator is lower than 81900. At that point, 8190 is subtracted until accumulator is less than 8190. the 0.1's place is determined based on the number of times 8190 is subtracted. The process repeats for 819 to get the .01's place. After this, the temporary output value is moved to the output -- all digits update at the same time.

There are other variations on this. This one is easy to understand. The sampling rate should make it clear if accumulating 100 samples is acceptable, or if the input should be multiplied by 10 or 100.
 

Hi,

Yes, this is the overall ADC to Display (BCD) solution.

The multiply solution is a general solution like asked in post#1.
(In post#1 here is no BCD and no display)

Indeed for ADC to Display I'd prefer a microcontroller.
It's easier to do offset and gain calibration and store the calibration values in EEPROM.
Interrupt driven it may just take 1% of processing power.

Klaus
 

Hi FvM

Thanks for that info. I finally understood the concept. I am really looking for a hardware efficient multiplier algorithm to be implemented in verilog.

Hello,

almost all of modern FPGAs have hardware multipliers "on board".

See for example these links:

https://www.xilinx.com/support/documentation/application_notes/xapp467.pdf

https://www.xilinx.com/products/intellectual-property/multiplier.html

You can use them using free "IP cores" from your FPGA vendor.

Regards
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top