+ Post New Thread
Results 1 to 11 of 11

9th May 2018, 16:25 #1
 Join Date
 Mar 2018
 Posts
 28
 Helped
 0 / 0
 Points
 172
 Level
 2
Numerical computation in FPGA
Currently I am interfacing FPGA to ADC and the ADC outputs 04095 counts corresponding to 05V. In FPGA I would like to convert these counts back to process value. What are the methods to achieve this objective?

9th May 2018, 16:41 #2
 Join Date
 Sep 2013
 Location
 USA
 Posts
 6,603
 Helped
 1596 / 1596
 Points
 28,836
 Level
 41
Re: Numerical computation in FPGA
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.

9th May 2018, 16:41

9th May 2018, 16:56 #3
 Join Date
 Mar 2018
 Posts
 28
 Helped
 0 / 0
 Points
 172
 Level
 2
Re: Numerical computation in FPGA
4095 counts have to be translated to process value just like we do with microcontrollers. 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.

9th May 2018, 16:56

9th May 2018, 17:19 #4
Awards:
 Join Date
 Apr 2014
 Posts
 11,998
 Helped
 2778 / 2778
 Points
 58,825
 Level
 59
Re: Numerical computation in FPGA
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.
KlausPlease donīt contact me via PM, because there is no time to respond to them. Thank you.

9th May 2018, 17:19

9th May 2018, 17:25 #5
 Join Date
 Mar 2018
 Posts
 28
 Helped
 0 / 0
 Points
 172
 Level
 2
Re: Numerical computation in FPGA
Hi
Can we just use the divide function (say in verilog) as you have proposed or should we customize the division function?

9th May 2018, 17:48 #6
 Join Date
 Jan 2008
 Location
 Bochum, Germany
 Posts
 42,286
 Helped
 12870 / 12870
 Points
 243,431
 Level
 100
Re: Numerical computation in FPGA
As adsee 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.

9th May 2018, 17:55 #7
 Join Date
 Mar 2018
 Posts
 28
 Helped
 0 / 0
 Points
 172
 Level
 2
Re: Numerical computation in FPGA
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.

11th May 2018, 23:19 #8
 Join Date
 Jan 2008
 Location
 Bochum, Germany
 Posts
 42,286
 Helped
 12870 / 12870
 Points
 243,431
 Level
 100
Re: Numerical computation in FPGA
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.

12th May 2018, 05:26 #9
 Join Date
 Feb 2015
 Posts
 863
 Helped
 247 / 247
 Points
 5,172
 Level
 17
Re: Numerical computation in FPGA
I don't think this is a good usecase 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.

12th May 2018, 07:02 #10
Awards:
 Join Date
 Apr 2014
 Posts
 11,998
 Helped
 2778 / 2778
 Points
 58,825
 Level
 59
Re: Numerical computation in FPGA
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.
KlausPlease donīt contact me via PM, because there is no time to respond to them. Thank you.

12th May 2018, 07:02

12th May 2018, 09:38 #11
 Join Date
 Dec 2017
 Location
 Bydgoszcz  Poland
 Posts
 32
 Helped
 6 / 6
 Points
 266
 Level
 3
Re: Numerical computation in FPGA
Hello,
almost all of modern FPGAs have hardware multipliers "on board".
See for example these links:
https://www.xilinx.com/support/docum...es/xapp467.pdf
https://www.xilinx.com/products/inte...ultiplier.html
You can use them using free "IP cores" from your FPGA vendor.
Regards
+ Post New Thread
Please login