Page 1 of 1

MULX data resolution?

Posted: Fri Jun 06, 2025 2:03 am
by knutolai
I have two positive counter with bipolar incrementation. The first one "A" works as intended while the other one "B" is stuck at 0Hz (no incrementation). The only difference in the codes is the value stored in 'base'. 1024 works fine while 256 does not. This seems to indicate that MULX doesn't register the 8 (or 9?) LSBs of the multiplication register. Or is there something else going on? My interpretation from the documentation is that MULX does multiplication of all 24bits.

A:

Code: Select all

equ	count1	reg0
equ	base	reg1

or	1024		; 1024
wrax	base, 0		; store, clr

or	$7fffff		; 1
rdax	POT0, -2	; 1 to -1
mulx	base		; x base increment
or	$800000		; offset positive increments by -1
rdax	count1, 1	; add counter
and	$7fffff		; +1 offset
wrax	count1, 1	; store, keep in acc
B:

Code: Select all

equ	count1	reg0
equ	base	reg1

or	256	; 256
wrax	base, 0		; store, clr

or	$7fffff		; 1
rdax	POT0, -2	; 1 to -1
mulx	base		; x base increment
or	$800000		; offset positive increments by -1
rdax	count1, 1	; add counter
and	$7fffff		; +1 offset
wrax	count1, 1	; store, keep in acc

Re: MULX data resolution?

Posted: Fri Jun 06, 2025 7:39 am
by frank
The coefficient is 16-bits so 256 would be 0b0000 0000 0000 0001 which is a really small number so when you multiply it the result will also be really small and when we truncate the LSBs of the result you could end up at 0x0 depending on the other value. We do a 24-bit by 16-bit multiply which give a 40-bit result but we drop the lower 13-bits after the multiplier then after the second adder and saturation limiters we are back to 24-bits.

You may want to simply force the LSB to 1 after the multiply to make sure there is a minimum value in it to cause the counter to change.

Re: MULX data resolution?

Posted: Fri Jun 06, 2025 7:47 am
by knutolai
What instruction's coefficient are you referring to here? There's no coefficients for the MULX instruction.

Re: MULX data resolution?

Posted: Fri Jun 06, 2025 8:26 am
by frank
Sorry, by coefficient I meant the multiplier (register in the case of mulx,, 'base' in your code) is 16-bit while the multiplicand (acc in mulx) is 24-bit. If you look at page 23 of the SpinAsm pdf under the drawing of the ALU we touch on multiplier resolution.