I'm working on a shift accumulator (for multiplication) and I was looking into how to make the serial input automatic. So a parallel to serial converter is one step that I have to take in automating it.

Can we just move on and enjoy the engineering feat that has been accomplished here? Maybe make some constructive criticism? I'm interested in learning more about this, but this thread has become a warzone instead of something productive. Thanks to those who are trying to keep it on topic, I appreciate it. So if you don't have something good to say, why are you going to post it?

On that matter, I've been thinking about how to make this work, and I'm thinking some sort of RAM would make this infinitely more useful. If you can find an instant wire way to make RAM, even better. The ability to be able to save states in this would really change up the way people think in engineering terms here.

Sweet, thanks! I'm gonna build this and see how well it works.
By the way, can this take multiple inputs? And how would I put a clear memory function on it? And last, are the inputs and outputs seperate? If not, how would I go about placing a isolated output on it?
Thanks again.

I've upped the world save for anyone who would like to try it out, as the technical explanation, on second thought, is terribly difficult to understand. Try it out!

Sometimes I'm not quite sure I do either...I just know that it works. And more or less HOW it works. But then again, any explanation of how something works makes it difficult to understand, which is why I made that diagram up. It saved my life multiple times while I was building this sucker.

Disclaimer: This is version 0.1. It has NOT been compacted at all yet, and it is still manually operated. I'm going to compact and speed it up first, and then I'll work on a clocking system prototype to automate the whole thing. Also, the shift register used for this version is nikobroo's, and the adder is from the Minecraft Wiki.

On to the meat then.

Pics

Logic Diagram

Green and purple are the reset, or clear functions, white is the 3 bit adder (parallel input), the AND gate (serial input), 6 bit adder, all into shift register A. Black is the second adder, which feeds in to shift register B (blue), which simultaneously feeds back into the white 6 bit adder, and into the black one as well. Red is a visual output I put in for testing.

How it works:
Your parallel input (3 bit adder) is the first number you want to multiply. The serial input (the single switch that turns the AND gates on and off) is hooked through the outputs of the 3 bit adder, and represents the number you want to multiply by, starting at the left-most bit. When the serial input is on, it counts as being multiply by a binary "1", and off is "0".

So the order, for example, is this:
111 (7, parallel) x 010 (2, serial) = 1110 (14, total output).
You can ignore the first 0 on the serial, as it won't affect the answer, you simply just start at the leftmost "1" to begin. So 111 would be cycled into the system, but on the second bit, the serial input would be deactivated, preventing the input from entering. That's how the input works.

On to the next bit (pun intended):
The inputs feed into the white adder, and you shift it into shift register A one time (or bit) to store the data. Then, you shift it into shift register B twice, which through the use of binary and the adder, doubles the amount. 7 is now = 14. This is then put directly into the 6 bit white adder. As the next bit is "0", and it does not require a shift, you clear shift register A and shift the input in. You now have 14 displaying from your output.

Now lets go with 111 (nice and easy to keep track of that 7) x 101 (5). Follow the same process for each input, shift it through, until it comes time for the second bit. You deactivate the serial input, and shift it all the way through once again (remember that shift register B always will shift it two bits), and back into the white adder. Your trip has turned that 7 into a 14 on the first trip, and a 28 on the second trip. Now, you reactivate the serial, and after clearing shift register A (you always have to clear the shift registers before putting new input into them), you shift the result in. It takes that 28, adds the last 7, and outputs it. Remember that on the last bit, it goes straight to the output, and does not travel through the rest of the circuit. You now have 35.

Now, I hope that all made sense. I don't have any video making capabilities as of yet, so I can't make a demonstration, but if someone would like to, that would be awesome.

Remember that this is v 0.1, this is the prototype, the proof of concept. This can get a LOT smaller, and a LOT faster still. And once that is done, it can be automated, which potentially makes it a much more compact, and potentially less complex solution for multiplication that doing peasant multiplication or chaining a huge array of adders together.

Comments? If anyone wants the world save, just let me know and I'll put it up. Sorry for the explanation, I'm not too great at it.

EDIT: I decided to include the world save for ease of understanding, you can test it out for yourself. I made sure to add some basic instructions in with it. Don't mind all the other redstone stuff there, this is my test world.

Your idea is definably worthwhile to experiment on, I like your way of thinking. However your shift register looks like nikobroo 's which is not a bad thing because if you came up with that yourself then you have the right idea of how a shift register works.

Yeah, that's where I got the shift register design in the first place, I guess I didn't mention it very clearly, but it's there. Credit is due where credit is due. I was looking for a nice simple one that I could chain together. For a PoC, it does the job rather nicely, I think, but obviously it can be optimized quite a bit. I'm gonna crunch some numbers and see if I can't put together what this particular 3 bit to 6 bit can put out. I'm gonna start with single set input though, double sets could get confusing, and quick.

EDIT: This 3 to 6 bit version has a total of 25 outputs, not removing any redundant outputs. I'll calculate them and run the numbers out for ya, and from there I should be able to pull some kind of equation to pull the outputs easily or show the number of possible different outputs.

Also, small brainwave. Don't know if it'll work, but you could change the multiplication values to a tradition 1, 2, 3, 4, 5, etc. by using a unary adder to decode the output. While that would make it less useful for higher numbers, as you'd have to expand somehow in order to reach greater numbers, it could make it a much more versatile design.

EDIT 2: Numbers for those who are interested:
The numbers 7, 6, 5, and 4 can each shift 3 times total, 3 and 2 can go up to 4 times, and 1 can make the shift 5 times. There are 8 redundant outputs, making it a total of 17 outputs for 25 combinations (not including zero).
The possible numbers are: 1, 2, 3, 4, 5, 6, 8, 10, 12, 14, 16, 20, 24, 18, 32, 40, 48, and 56 with what I've already got up and running, not using the shift register's ability to take two full data sets. This could actually also be used as a slightly more complicated, but I think more compact way of adding up in higher bit ranges, by feeding the inputs into a shift register from a simple 3 or 4 bit adder, and using the shift register as the sum outputs.

EDIT 3: Just crunched a few more numbers, and if you took the 5 minutes necessary to make it a 4 bit adder into an 8 bit shift register, your total (redundancy check not done yet) number of outputs/input combinations jumps to a whopping 71 possibilities, and some of those numbers start getting quite high, and it starts filling in the lower register quite nicely too.

Ok, so I've been looking around at how to do multiplication here, but up until this point, most of the circuits I've seen have been either bulky, complex, or both. They focus on either "peasant" multiplication, or a series of adders chained together. I was looking for something a bit simpler, and after talking it over with an electrical engineer (I got lucky, my dad is one), I wanted to try a shift/add multiplier. And I haven't tested its full capabilities yet, but I got it working on the first try, which says something about its simplicity.

First off, technical definition, according to Wikipedia:

Shift and add

Most computers use a "shift and add" algorithm for multiplying small integers. Both base 2 long multiplication and base 2 peasant multiplication reduce to this same algorithm.
In base 2, multiplying by the single digit of the multiplier reduces to a simple series of logical AND operations. Each partial product is added to a running sum as soon as each partial product is computed. Most currently available microprocessors implement this or other similar algorithms (such as Booth encoding) for various integer and floating-point sizes in hardware multipliers or in microcode.
On currently available processors, a bit-wise shift instruction is faster than a multiply instruction and can be used to multiply (shift left) and divide (shift right) by powers of two. Multiplication by a constant and division by a constant can be implemented using a sequence of shifts and adds or subtracts. For example, there are several ways to multiply by 10 using only bit-shift and addition.
((x << 2) + x) << 1 # Here x*10 => x*[(2^2+1)*2]
(x << 3) + (x << 1) # Here x*10 => x*[(2^3+2)]
In some cases such sequences of shifts and adds or subtracts will outperform hardware multipliers and especially dividers. A division by a number of the form 2n or often can be converted to such a short sequence.
These types of sequences have to always be used for computers that do not have a "multiply" instruction,[5] and can also be used by extension to floating point numbers if one replaces the shifts with computation of 2*x as x+x, as these are logically equivalent.

A bit complex, but what it comes down to is you plug an adder into a shift register, and then shift the data over, with each shift giving you an (exponentially) higher output. It's more limited on possible outputs, but this could be changed by some kind of hybrid mix in with existing multiplication solution. I haven't done the logic on that bit yet, but that's the next step I'm going to try and work on.

Example:
1st shift (into the system) = Input x 1
2nd = Input x 2
3rd = Input x 4
4th = Input x 8
...and so on, I think you get the idea.

For my proof-of-concept, I decided to use a 3 bit adder, into a 6 bit shift register. Credits for the shift register design go to nikobroo, who put it up on Youtube, where I found it, and the adder design is from the Minecraft Wiki Advanced Redstone Circuits page. I'm using a pulse limiter to preclude any possibility of the input overloading the circuit (may not be necessary, once again, I haven't done the math yet). A couple downsides are that the current design requires one shift to place the actual data INTO the shift register, a toggle for each and every shift you want, and having to manually reset the circuit by toggling the data out through the end of the shift register.

One thought that I just had is that this could have more possible outputs if you use 2 or more sets of inputs from the adder.

Hope this makes sense. Any thoughts?

And sorry for the links and the pictures not being embedded, the board won't let me use the [img] tags for some reason.

Ok, so I've been experimenting a bit with a personal idea on how to make a toggleable add/subtract function, with out going the traditional route of inverting half of the inputs on a full adder to make the subtractor. I know that particular solution functions, but it's not what I'm going for. It may not (actually, it's probably not) be the most efficient way of doing it, but I'm using it as a personal exercise in redstone.

Apparently it won't let me post the picture directly for some reason, so take the link.

I have a 3 bit adder set up(left), and opposite it, a 3 bit subtractor (basically a 3-bit adder with only the outputs inverted, on right), and I'm using a JK Flip Flop to toggle between the two (center). Unless it's necessary to create the intended result, you can go ahead and ignore the ugly bit of wiring in the center, it's just bringing the two arithmetic units into a unified output (which possibly may be my problem right there, we'll see). The JKFF triggers the set of pistons on either side, toggling between which input is used.

My question is this. How can I add a number using the adder, store that number, and then switch to and use the subtractor to subtract from the stored number? Any ideas and help would be appreciated. Once I can get this part figured out, I'll hook it up to a couple of decoders and a 7-seg display.

That would require tnt underground, and a creeper could easily trigger that from the surface.

Just call it a feature! It would make for an awesome survival horror map.

"But remember, if you hug the green frowning creatures, you will receive a...surprise...."

On another thought, this trigger could also be used to prevent a player from going back after he's gone to far on an adventure map, and he could possibly have to lure a monster into a one of these in order to progress. Nice idea!

0

0

0

On that matter, I've been thinking about how to make this work, and I'm thinking some sort of RAM would make this infinitely more useful. If you can find an instant wire way to make RAM, even better. The ability to be able to save states in this would really change up the way people think in engineering terms here.

0

0

By the way, can this take multiple inputs? And how would I put a clear memory function on it? And last, are the inputs and outputs seperate? If not, how would I go about placing a isolated output on it?

Thanks again.

0

0

0

0

0

Disclaimer: This is version 0.1. It has NOT been compacted at all yet, and it is still manually operated. I'm going to compact and speed it up first, and then I'll work on a clocking system prototype to automate the whole thing. Also, the shift register used for this version is nikobroo's, and the adder is from the Minecraft Wiki.

On to the meat then.

Pics

Logic Diagram

Green and purple are the reset, or clear functions, white is the 3 bit adder (parallel input), the AND gate (serial input), 6 bit adder, all into shift register A. Black is the second adder, which feeds in to shift register B (blue), which simultaneously feeds back into the white 6 bit adder, and into the black one as well. Red is a visual output I put in for testing.

How it works:

Your parallel input (3 bit adder) is the first number you want to multiply. The serial input (the single switch that turns the AND gates on and off) is hooked through the outputs of the 3 bit adder, and represents the number you want to multiply by, starting at the left-most bit. When the serial input is on, it counts as being multiply by a binary "1", and off is "0".

So the order, for example, is this:

111 (7, parallel) x 010 (2, serial) = 1110 (14, total output).

You can ignore the first 0 on the serial, as it won't affect the answer, you simply just start at the leftmost "1" to begin. So 111 would be cycled into the system, but on the second bit, the serial input would be deactivated, preventing the input from entering. That's how the input works.

On to the next bit (pun intended):

The inputs feed into the white adder, and you shift it into shift register A one time (or bit) to store the data. Then, you shift it into shift register B twice, which through the use of binary and the adder, doubles the amount. 7 is now = 14. This is then put directly into the 6 bit white adder. As the next bit is "0", and it does not require a shift, you clear shift register A and shift the input in. You now have 14 displaying from your output.

Now lets go with 111 (nice and easy to keep track of that 7) x 101 (5). Follow the same process for each input, shift it through, until it comes time for the second bit. You deactivate the serial input, and shift it all the way through once again (remember that shift register B always will shift it two bits), and back into the white adder. Your trip has turned that 7 into a 14 on the first trip, and a 28 on the second trip. Now, you reactivate the serial, and after clearing shift register A (you always have to clear the shift registers before putting new input into them), you shift the result in. It takes that 28, adds the last 7, and outputs it. Remember that on the last bit, it goes straight to the output, and does not travel through the rest of the circuit. You now have 35.

Now, I hope that all made sense. I don't have any video making capabilities as of yet, so I can't make a demonstration, but if someone would like to, that would be awesome.

Remember that this is v 0.1, this is the prototype, the proof of concept. This can get a LOT smaller, and a LOT faster still. And once that is done, it can be automated, which potentially makes it a much more compact, and potentially less complex solution for multiplication that doing peasant multiplication or chaining a huge array of adders together.

Comments? If anyone wants the world save, just let me know and I'll put it up. Sorry for the explanation, I'm not too great at it.

EDIT: I decided to include the world save for ease of understanding, you can test it out for yourself. I made sure to add some basic instructions in with it. Don't mind all the other redstone stuff there, this is my test world.

http://www.mediafire.com/?bzkx8wga8kdg7bx

0

Yeah, that's where I got the shift register design in the first place, I guess I didn't mention it very clearly, but it's there. Credit is due where credit is due. I was looking for a nice simple one that I could chain together. For a PoC, it does the job rather nicely, I think, but obviously it can be optimized quite a bit. I'm gonna crunch some numbers and see if I can't put together what this particular 3 bit to 6 bit can put out. I'm gonna start with single set input though, double sets could get confusing, and quick.

EDIT: This 3 to 6 bit version has a total of 25 outputs, not removing any redundant outputs. I'll calculate them and run the numbers out for ya, and from there I should be able to pull some kind of equation to pull the outputs easily or show the number of possible different outputs.

Also, small brainwave. Don't know if it'll work, but you could change the multiplication values to a tradition 1, 2, 3, 4, 5, etc. by using a unary adder to decode the output. While that would make it less useful for higher numbers, as you'd have to expand somehow in order to reach greater numbers, it could make it a much more versatile design.

EDIT 2: Numbers for those who are interested:

The numbers 7, 6, 5, and 4 can each shift 3 times total, 3 and 2 can go up to 4 times, and 1 can make the shift 5 times. There are 8 redundant outputs, making it a total of 17 outputs for 25 combinations (not including zero).

The possible numbers are: 1, 2, 3, 4, 5, 6, 8, 10, 12, 14, 16, 20, 24, 18, 32, 40, 48, and 56 with what I've already got up and running, not using the shift register's ability to take two full data sets. This could actually also be used as a slightly more complicated, but I think more compact way of adding up in higher bit ranges, by feeding the inputs into a shift register from a simple 3 or 4 bit adder, and using the shift register as the sum outputs.

EDIT 3: Just crunched a few more numbers, and if you took the 5 minutes necessary to make it a 4 bit adder into an 8 bit shift register, your total (redundancy check not done yet) number of outputs/input combinations jumps to a whopping 71 possibilities, and some of those numbers start getting quite high, and it starts filling in the lower register quite nicely too.

0

Pics:

[IMG]http://i.imgur.com/Vo1w0.jpg[/IMG]

[IMG]http://i.imgur.com/xoLPM.jpg[/IMG]

[IMG]http://i.imgur.com/dRqs9.jpg[/IMG]

[IMG]http://i.imgur.com/xy1jA.jpg[/IMG]

First off, technical definition, according to Wikipedia:

A bit complex, but what it comes down to is you plug an adder into a shift register, and then shift the data over, with each shift giving you an (exponentially) higher output. It's more limited on possible outputs, but this could be changed by some kind of hybrid mix in with existing multiplication solution. I haven't done the logic on that bit yet, but that's the next step I'm going to try and work on.

Example:

1st shift (into the system) = Input x 1

2nd = Input x 2

3rd = Input x 4

4th = Input x 8

...and so on, I think you get the idea.

For my proof-of-concept, I decided to use a 3 bit adder, into a 6 bit shift register. Credits for the shift register design go to nikobroo, who put it up on Youtube, where I found it, and the adder design is from the Minecraft Wiki Advanced Redstone Circuits page. I'm using a pulse limiter to preclude any possibility of the input overloading the circuit (may not be necessary, once again, I haven't done the math yet). A couple downsides are that the current design requires one shift to place the actual data INTO the shift register, a toggle for each and every shift you want, and having to manually reset the circuit by toggling the data out through the end of the shift register.

One thought that I just had is that this could have more possible outputs if you use 2 or more sets of inputs from the adder.

Hope this makes sense. Any thoughts?

And sorry for the links and the pictures not being embedded, the board won't let me use the [img] tags for some reason.

EDIT: Pics problem fixed.

0

0

http://imageshack.us/photo/my-images/535/calculatoru.jpg/

Apparently it won't let me post the picture directly for some reason, so take the link.

I have a 3 bit adder set up(left), and opposite it, a 3 bit subtractor (basically a 3-bit adder with only the outputs inverted, on right), and I'm using a JK Flip Flop to toggle between the two (center). Unless it's necessary to create the intended result, you can go ahead and ignore the ugly bit of wiring in the center, it's just bringing the two arithmetic units into a unified output (which possibly may be my problem right there, we'll see). The JKFF triggers the set of pistons on either side, toggling between which input is used.

My question is this. How can I add a number using the adder, store that number, and then switch to and use the subtractor to subtract from the stored number? Any ideas and help would be appreciated. Once I can get this part figured out, I'll hook it up to a couple of decoders and a 7-seg display.

Thanks for the help and I hope I made sense.

0

Just call it a feature! It would make for an awesome survival horror map.

"But remember, if you hug the green frowning creatures, you will receive a...surprise...."

On another thought, this trigger could also be used to prevent a player from going back after he's gone to far on an adventure map, and he could possibly have to lure a monster into a one of these in order to progress. Nice idea!