FLOOR/Behavioural source giving error

Hello,

Am trying to make a decimal to bit conversion using behavioural voltage source. but one of the equation is returning value as ‘2’ instead of ‘0’ which is given below.

.param A=4

B_a_out0 a_out0 0 V=FLOOR(A/2)

B_a0 a0 0 V=A-2FLOOR(A/2)
B_a1 a1 0 V=V(a_out0)-(2
FLOOR(V(a_out0)/2)) ← returns value 2 instead of 0

Can anyone check on this why this is happening? In calculator, this equation is returning 0. But in simulation, its not.

Note : a0 and a1 are the bits output and A is the input integer. a_out0 is the intermediate output as per decimal to binary conversion logic.

Thank you,
Kishan

floor.qsch (1.7 KB)

You can find symbols for 4-bit, 8-bit, and 12-bit DEC to Binary conversion in Digital Symbol Github Link, which are based on the B-source with a general formula. Below is an example of how they are used.

example.dec2binary-4bits.qsch (3.1 KB)

Thanks a lot @KSKelvin , it was something that I messed up. I restarted the whole and tested again and now its working(Meanwhile I upgraded to latest version and removed some unwanted code from the file which might be the source of issue)

I was starting to do a simple comparison between adders(RCA, CLA, CSA etc) and speed of processing and wanted to get bits first. the DEC2BINARY also seems to be an interesting solution.
Below is a snippet just for info about the current situation.

Thanks a lot again.

1 Like