05-06-2019 09:38 AM
Hello everyone i have a problem in my result and more precisely in the arithmetical operation. i have two text file contains 16 bit coded pixel. my operation is: (A + 0.14 (A-B) +0.0032 (A-B) * (A-B) +0.83) * 10
I use the package fixed point the operations gives a correct result as to A higher than B but in the opposite it gives different result which is great for example 0110111010110100 I do not know the problem.I downloaded files A and B and the result
05-06-2019 10:25 AM
05-06-2019 10:45 AM
05-06-2019 07:20 PM
05-07-2019 01:58 AM
Have you considered that the result might go negative?
ufixed is "Unsigned Fixed", therefore negative results are not handled, 0 -N wraps around
You should be using sfixed type instead.
05-07-2019 02:12 AM
why are yo using
I'd strongly suggest using just
A bit of a diatribe on it her
basicaly, there have been competing 'standards' over the years fomr a few companies trying to force / pre empt the IEEE process.
If yo uuse libraries form the multiple camps, then you ar ein to a world of pain, as som eof the definitoins disagree with each other, and th eway VHDL works, the last declared one wins,
so if you have two programs with none standard libraries in them, and in the two programs the they are declare din different order, then your results can differ.....
It is possible to do , and there are a few c;ever cases I have seen over th eyears,
you have been warned, don't mix vendors libraries.
if there is a proper IEEE lib available, use it.
05-07-2019 02:54 AM
The only clash is with std_logic_arith and numeric_std. numeric_std plays perfectly fine with std_logic_unsignd as they work on different types (numeric_std = signed/unsigned, std_logic_unisnged= std_logic_vector). Yes std_logic_unsigned is non-standard, but it works with all vendors, afaik, as expected (and they all use the synopsys version of the library rather than their own).
If you are in VHDL 2008, I would recommend using numeric_std_unsigned instead. Its basically the VHDL standardised version of std_logic_unsigned.
05-07-2019 06:03 AM
thank you verry much for this explanation,my result must be positive. When I do the math the result is positive, i just i dont know where is the probleme
05-08-2019 09:30 AM
Your result may be positive, but are all of the intermediate terms positive? If any of them could be negative, you should be using signed types.
05-15-2019 04:13 AM
sorry for this late response, yes they are some intermidiate terms that could be nigatibe but when B is bigger than A i did that but when i add the negative result with positive they give me error .
05-15-2019 05:46 AM
A.txt is all zero.
(A + 0.14 (A-B) +0.0032 (A-B) * (A-B) +0.83) * 10
so A-B will be negative.
as said above , you need to work in signed numbers,