I'm rebuilding my subtractor for my computer and was wondering if there is a better way than the way i'm doing it.
What I'm currently doing: (A-B.)
I take B and inverse it then add 1 to it. (this makes it -B, so A+ -B.)
Then I add the two together. (I get the right answer right now)
The Problem:
What I'm doing is not fast enough. Is there another way of doing subtraction that is simpler? (ie. less operations)
I do not need help constructing one I just need a better way to do the operation. For reference my current subtractor takes 5 ticks and I need to get it down to 4-3 ticks which may seem very fast already, but I need every tick I can get.
EDIT: I have finished the base of my new computer including the ALU so any modifications at this point would be large overhauls. I have tried every idea at this point and seem unable to get any to work, not because they are wrong, but my restraints will not let me. If a new way of doing it does turn up i will at least give it a go.
What you described is the fastest method of subtraction, at least as far as i know. The only thing that could speed things up is a faster adder, which is actually possible, depending on your design.
What you described is the fastest method of subtraction, at least as far as i know. The only thing that could speed things up is a faster adder, which is actually possible, depending on your design.
My adder is as fast as possible (2 ticks). unless pistons become less sensitive to nano-ticks I can't use my current method. I feel like there is a way to build a subtractor much like an adder, but to use different gates. I don't really know if there is such a thing, but if not I will just not include a subtractor. In it's place I'll make something that finds the compliment, aka makes a number negative.
Rollback Post to RevisionRollBack
Redstone FTW. Minecraft in Minecraft, you jelly Inception?
Have you ever wanted to punch trees IRL, look no further you answer lies Here
My adder is as fast as possible (2 ticks). unless pistons become less sensitive to nano-ticks I can't use my current method. I feel like there is a way to build a subtractor much like an adder, but to use different gates. I don't really know if there is such a thing, but if not I will just not include a subtractor. In it's place I'll make something that finds the compliment, aka makes a number negative.
2 ticks? What kind of adder is this! Some of the fastest i know of (using non-instant logic) are 3.5 ticks!
Just reverse output? Like put adder then reverse output which i think it will work
EDIT: just reverse input A and powered C in
Ill try that, i'll have to do some math first to make sure that works, and if it does then it should take 3 ticks which would work.
EDIT: I tried it and it SHOULD have worked, but like most of these things it did not. your method was correct and it combined it all into 1 operation. with a normal adder it would have worked. to get it to work it would have to be slowed down to 5 ticks. I don't understand why it refuses to work.
You can change the first half adder to use an XNOR gate and an implies gate (where the non inverted input is the B input) then +1 to the adder. This includes the inversion in the adder so saves you a tick. Also you could use Dornier's one tick adder design.
I did try the Xor gate idea. In theory it should have worked, but it ended up still as 5 ticks.
You could always make a subtractor. It doesn't take much modification of a instant carry adder to make it a subtractor, move the carry piston to block the "borrow" when XNOR and invert one of inputs to the carry generate. Then you can just mux the outputs of an adder and a subtractor, which can be done without additional delay.
since i'm using an instant wire adder, it technically has instant carry but it works very different. I do not think the whole borrow thing would work.
What I'm currently doing: (A-B.)
I take B and inverse it then add 1 to it. (this makes it -B, so A+ -B.)
Then I add the two together. (I get the right answer right now)
The Problem:
What I'm doing is not fast enough. Is there another way of doing subtraction that is simpler? (ie. less operations)
I do not need help constructing one I just need a better way to do the operation. For reference my current subtractor takes 5 ticks and I need to get it down to 4-3 ticks which may seem very fast already, but I need every tick I can get.
EDIT: I have finished the base of my new computer including the ALU so any modifications at this point would be large overhauls. I have tried every idea at this point and seem unable to get any to work, not because they are wrong, but my restraints will not let me. If a new way of doing it does turn up i will at least give it a go.
Have you ever wanted to punch trees IRL, look no further you answer lies Here
My adder is as fast as possible (2 ticks). unless pistons become less sensitive to nano-ticks I can't use my current method. I feel like there is a way to build a subtractor much like an adder, but to use different gates. I don't really know if there is such a thing, but if not I will just not include a subtractor. In it's place I'll make something that finds the compliment, aka makes a number negative.
Have you ever wanted to punch trees IRL, look no further you answer lies Here
EDIT: just reverse input A and powered C in
2 ticks? What kind of adder is this! Some of the fastest i know of (using non-instant logic) are 3.5 ticks!
Ill try that, i'll have to do some math first to make sure that works, and if it does then it should take 3 ticks which would work.
EDIT: I tried it and it SHOULD have worked, but like most of these things it did not. your method was correct and it combined it all into 1 operation. with a normal adder it would have worked. to get it to work it would have to be slowed down to 5 ticks. I don't understand why it refuses to work.
I did try the Xor gate idea. In theory it should have worked, but it ended up still as 5 ticks.
after there is an add 1 needed which is what slows me down
Believe it or not it is your instant adder, it takes 2 ticks in the worst case to prevent nano ticks. no fancy normal adder.
since i'm using an instant wire adder, it technically has instant carry but it works very different. I do not think the whole borrow thing would work.
Have you ever wanted to punch trees IRL, look no further you answer lies Here
your math was right and i did get the right answer some times, it is just the nano ticks made it wrong for the other few times
Have you ever wanted to punch trees IRL, look no further you answer lies Here
okay sound good!