Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
module F_P(in,result,decimal
);
input [15:0]in;
output[11:0]result;
output[11:0]decimal;
reg [3:0]ex_decimal;
reg [7:0]fr_decimal;
assign decimal = (in/4095)*3.3;
assign [3:0]ex_decimal = [11:8]decimal;
assign [7:0]fr_decimal = [ 7:0]decimal;
assign result = {ex_decimal,fr_decimal};
endmodule
You need to learn Verilog before coding with it. There are syntax errors in this code snippet. You also need to read up on the difference between floating point and fixed point representation of numbers. Learn about offset binary or 2's complement outputs from ADCs and what they mean in relation to the voltage at their analog nput.The aim was to display the analog floating point value through a seven segment display(of a 3.3V ADC). The code is not working.
Code:module F_P(in,result,decimal ); input [15:0]in; output[11:0]result; output[11:0]decimal; reg [3:0]ex_decimal; reg [7:0]fr_decimal; assign decimal = (in/4095)*3.3; assign [3:0]ex_decimal = [11:8]decimal; assign [7:0]fr_decimal = [ 7:0]decimal; assign result = {ex_decimal,fr_decimal}; endmodule
mv = adc * 3300 / 4096
The OP is making things so confusing, they have the input in declared as a 16-bit value.Provided you want to scale the 12-bit ADC value to integer millivolts, you may calculate
Code Verilog - [expand] 1 mv = (adc * 3300) >> 12; / / use an explicit right shift, i.e. truncate the right 12 bits of the multiplication
Hi,
your posts are rather confusing:
Some issues. Please rectify them:
* You say "BCD to float", but your description is "float_to_BCD"
* you say "analog floating point". There is no "analog" floating point. Floating point is always digital.
* you say "floating point" but your code doesn´t contain a "floating point value" at all.
Usually an ADC output is binary type. --> read it´s datasheet.
Give more detailed informations:
* draw and show us a sketch of your application
* give the ADC type
* give the display type.
* a schematic will be helpful, too.
Klaus
Give more detailed information:
* draw and show us a sketch of your application
* give the ADC type
* give the display type.
* a schematic will be helpful, too.
Makes no sense for the code posted so far. If the input is BCD, you can't scale it by multiplying with a factor.Iam converting binary in to BCD so now iam having BCD available that is given to the variable "in". using this we can calculate the respective analog value right??? i want this analog value (ranging from 0 to 3.3 V) to be displayed in sevensegment.
Once more...
Please start from that ==> * draw and show us a sketch of your application
Now we are talking.
Please update the drawing with a width of the buses and add details how FPGA is connected with a 7segs (e.g. common BCD signals and independent Cathodes/Anodes)?
Now we are talking.
Please update the drawing with a width of the buses and add details how FPGA is connected with a 7segs (e.g. common BCD signals and independent Cathodes/Anodes)?
ADC output is binary only i agreed. Iam converting binary in to BCD so now iam having BCD available that is given to the variable "in"...
I didn't write this, but I agree that this is the way to go.Please update the drawing with a width of the buses and add details how FPGA is connected with a 7segs (e.g. common BCD signals and independent Cathodes/Anodes)?
Which value is converted to bcd? As mentioned before, the ADC value must be first scaled, e.g. to integer millivolt 0- 3300 and the converted to bcd. If you have bcd data, you are almost done, just apply seven-segment decoding to each digit and if intended, leading zero blanking.all i have is 12 bit binary and binary converted bcd output.
Hi,
People want to help you.
They will lead you step by step through the challenge.
If you don't follow the steps....don't be surprised if they stop to assist you.
I didn't write this, but I agree that this is the way to go.
Mind the underlined text.
Believe me or not - but after decades of desinging electronic circuits - I do it this way. Either at the PC, but mostly on a sheet of paper.
Klaus
A bit of guessing, yes. Post #3 however suggests scaling to 3.3V, post #11 4 digits.