|
Hi Ashok,
(1) The workaround using trigonometric functions :
> a = fi(val);
> % find sine of a: sin(a)
> b = fi(sin(double(a)),numerictype(b));
------->
Isn't that similar to
b = fi(sin(a.data),T_b,fimath_obj) ;
where T_b : numerictype object of b.
fimath_obj : fimath object of the operations to be done in the code.
(2) I'm trying to simulate a code in Fixed-point to know what are the number of bits needed to hold the variables in all the expressions that shall be converted to HDL in the next stage , so
a- I use 'ScaledDoubles' and the 'On' Logging mode of the fipref object to know the number of bits for every constant and variable.
b- fimath object uses 'Specify precision' with 50 bits of WordLength and 25 bits for the fractionLength for both the procut and sum operations.
a complex expression will be like the following where the computation is done first using the data field due to using the 'tan' and then it is casted to the numeric type I want in the 2nd line
az_k , w , v_k , la_k , N , az ------> all are fi objects
az_calc = az_k.data - ((w.data(sec_count)) - v_k.data*tan(la_k.data)/(N.data));
az(sec_count) = fi(az_calc,'numerictype',T_az,'fimath',fimath_obj);
-So how can you help me with this expression and using emlmex ? "This expression is a simple one (not that complex as I omitted some operations)"
- Since I'm doing this (not applying the operations on the fi objects) , I think the fimath_obj is not utilized at all ... am I right ?
- Everyone of these variables has a numerictype object of its own:
for example:
1- az_k : Signed = 1 , WordLength = 50 , FractionLength = 40
2- la_k : Signed = 0 , WordLength = 50, FractionLength = 10
where fimath object is 'SpecifyPrecision' , WordLength = 50 , FractionLength = 25 for both the product and sum operations
If I'm doing this
out = az_k * la_k; ------> Output should be of WordLength of 100 (if fullpresion is used) but I'm forcing it to be of WordLength of 50 and 25 due to the fimath properties .. right ?
what if I made it like this
out = fi(az_k * la_k , T_out)
where T_out : Signed = 1 , WordLength = 60 , FractionLength = 35
so the way it will work is that the output due to the operation is [50 25] due to the fimath object and then it will be casted to [60 35] ---- Is that the right way, and so if that is happening the other bits will just filled with zeros and then they will be useless .. right?
(3) Last issue:
When using Simulink fixed point, with the division block
1st input is fixdt(0,50,20)
2nd input is fixdt(0,50,20)
Why is the output defined to be fixdt(0,50,0) if the "Inherit via internal rule" option is used?
-If I'm using the product point instead and I forced the output to be fixdt(0,70,30)
then how will I get this precision?
I mean is the product operation done first so the output is calculate in fixdt(0,100,40) and then it is casted to fixdt(0,70,30) or how it will be done ?
-If the output of the product is casted to be fixdt (0,60,50) ,,,, how will be the mapping from fixdt(0,100,40) ....... I mean how will the integer parts and fraction parts be casted after forcing the outputs to a smaller length , so will I take the LS bits of the 60 (100-40) Integer bits and put them on the 10(60-50) bits for forcing ... and take the 40 fraction bits and put them in the the MS bits of the 50 fraction bits and add zeros to the last 10 bits ??
The answer to the last question will be very helpful as I want to know how it can be done in Hardware, as for that reason I'll have to make the product in a register of a longer length first and then cast it or I can have an output of whatever length I want from the product operation directly.
Thank you so much Ashok for your continuous help and simple answers.
KUDOS
Walid F. Abdelfatah
|