larryjoe701

09-25-2011, 04:32 AM

I just completed a signed analog multiplication chip. It takes two real number values between -1 and +1, multiplies them and spits out the answer as a signed real number between -1 and +1 in one or two cycles.

For example 0.2 (20%) * -0.5 (-50%) = -0.1 (-10%)

Anyone interested in it? I don't have it in a level or anything, but if you ping me I'll send it to you.

For those of you interested in the math...

Figuring this out consumed way too much of my time and brain. I determined that I could fairly easily divide one analog value by powers of three, then add or subtract or ignore those reduced values based on the base 3 representation of the second number. The idea hinged on being able to convert the second value into its base 3 repr, which turned out to be a little tricky. Since I wanted this to be fast and not require an enormous sequencer, I couldn't just convert it whole-sale. I was OK using a sequencer to determine one "trit", but sequencers are slow so that part had to be done in parallel for all the "trits". I thought the key was going to be taking the number mod 1/3, the tripling for each digit. Unfortunately, there really isn't a way to get the discontinuity required by MOD. When I got stuck I also explored basic binary, but it had the same problem.

Ultimately I discovered I didn't really need the sharp rise of MOD (/|/|/|/|)... instead I could use a triangle wave (/\/\), which is much easier to obtain given LBPs reflecting around -1/+1 and absolute value operations. Any time the trit ended up having the middle value, flipped all the subsequent additions or subtractions. Given another middle value, just flip the rest back.

So ultimately I ended up with an equation something like this:

B/2 + A[1]*B/3 + A[2]*B/9 + A[3]*B/27...

where B is the raw analog value and A[n] is the nth digit in the ternary representation, using -1, 0, & 1.

Seems to work pretty well!

For example 0.2 (20%) * -0.5 (-50%) = -0.1 (-10%)

Anyone interested in it? I don't have it in a level or anything, but if you ping me I'll send it to you.

For those of you interested in the math...

Figuring this out consumed way too much of my time and brain. I determined that I could fairly easily divide one analog value by powers of three, then add or subtract or ignore those reduced values based on the base 3 representation of the second number. The idea hinged on being able to convert the second value into its base 3 repr, which turned out to be a little tricky. Since I wanted this to be fast and not require an enormous sequencer, I couldn't just convert it whole-sale. I was OK using a sequencer to determine one "trit", but sequencers are slow so that part had to be done in parallel for all the "trits". I thought the key was going to be taking the number mod 1/3, the tripling for each digit. Unfortunately, there really isn't a way to get the discontinuity required by MOD. When I got stuck I also explored basic binary, but it had the same problem.

Ultimately I discovered I didn't really need the sharp rise of MOD (/|/|/|/|)... instead I could use a triangle wave (/\/\), which is much easier to obtain given LBPs reflecting around -1/+1 and absolute value operations. Any time the trit ended up having the middle value, flipped all the subsequent additions or subtractions. Given another middle value, just flip the rest back.

So ultimately I ended up with an equation something like this:

B/2 + A[1]*B/3 + A[2]*B/9 + A[3]*B/27...

where B is the raw analog value and A[n] is the nth digit in the ternary representation, using -1, 0, & 1.

Seems to work pretty well!