Forums - Open Redstone Engineers
6 tick hex CCA, adds up to 32 bit binary :O - Printable Version

+- Forums - Open Redstone Engineers (https://forum.openredstone.org)
+-- Forum: ORE General (https://forum.openredstone.org/forum-39.html)
+--- Forum: Projects & Inventions (https://forum.openredstone.org/forum-19.html)
+---- Forum: Completed Projects (https://forum.openredstone.org/forum-21.html)
+---- Thread: 6 tick hex CCA, adds up to 32 bit binary :O (/thread-8209.html)



6 tick hex CCA, adds up to 32 bit binary :O - Magic :^) - 10-31-2015

There's a warp: /warp hexcca

So, I finished my hex adder earlier this week. It is actually based on a subtraction algorithm I made up, to skip over the double inversion malarkey of your conventional hex adders. I just wired the inputs to default to 2's complement inversion on the B (-) input and inverted the Cin and Cout to make it an adder.

[Image: 90d5925647.png]
[Image: 6969316bab.png]


More photos:

[Image: de28bcd6bc.png]
[Image: 6c33f2b9b6.png]
[Image: 315ecec7fd.png]


I tried to draw out the algorithm here:

[Image: e071d816ec.jpg]

Explanation of the subtraction algorithm:

The first thing I did was do A-B and B-A. If B was greater than A, then that means the B-A part is on. I need to do some extra processing in that case, as it is a negative result.
Otherwise, I pass the result (the A-B output) to the end of the adder.

Oh, also since only one of those two outputs can be on at a time, I can OR those together later no bother, so keep that in mind.


Processing the case of B-A > 0
Now, let's deal with what happens when we find out we need to borrow.

So for a borrow, I take that B-A output and do 0x10 - (B-A). This is done by subtracting 1 from the B-A signal, and then inverting it like this:
[Image: e50584a99a.png]

Now, you might notice that the output of this inverter thing is still going to be F on 0 signal, the same as if there was a 1. This is bad, as there will be an F outputting when we don't want anything at all. (when B-A is 0, we want to be using the A-B output instead!)

The next thing to do is put a check for 0 on the B-A output. When the output is 0, we will disable that specially inverted output. After this, you're done processing the B-A output Big Grin

Interfacing with a CCA carry tower:

From the B-A output, you will be generating a 'borrow' signal if it is on. Just pretend you're generating a carry and you'll be ok Wink
that borrow signal goes into the generate input of a CCA carry tower. There is a trick here that I do which saves a tick, but it isn't necessary so I'll leave It out for simplicity's sake.

From the A-B output, you will be getting a 'borrow cancel' signal. Plug this in to the carry cancel input of the CCA carry tower.

Final steps and a special case

OK, that's about a half of the logic taken care of! Now to deal with the final subtraction and a special case.

So, now I have two outputs (A-B and the processed B-A) and a borrow output from the CCA carry tower. All I have to do now is to recombine the signals!

My two main outputs can be ORed together no problem, only one can be on at a time.

Next, I take the borrow signal, and if it is True I subtract 1 from the output. Obviously I do nothing if it is False.

Now there is a final special case, which is when A - B is 0. This is the subtraction equivalent of a propogate signal. It actually works fine on the existing hardware up until the point where a borrow is required. If you can do basic hex arithmetic you'll realise that 10 - 01 = F, but I can't do 10 - 1 with a comparator!

What I can do though is take my borrow signal and see if it is True while the other two inputs are 0. If these conditions are met, I can just override the output with full signal strength, which is F!

With that taken care of, the whole subtractor is done. (well, 1 layer. It stacks up to 8 layers)

phew

I hope that makes sense?


RE: 6 tick hex CCA, adds up to 32 bit binary :O - slugdude - 11-01-2015

I don't even


RE: 6 tick hex CCA, adds up to 32 bit binary :O - Chibill - 11-01-2015

Very cool. This can speed up hex computing.


RE: 6 tick hex CCA, adds up to 32 bit binary :O - PNWMan - 11-04-2015

What is the point of the end portals? Do they have some sort of special property?


RE: 6 tick hex CCA, adds up to 32 bit binary :O - Chibill - 11-04-2015

They put out a value on the compactor. Can't remember what value but.


RE: 6 tick hex CCA, adds up to 32 bit binary :O - Legofreak - 11-04-2015

its just the max value(15). its easier than filling a container all the way and it copies with worldedit without losing the entities liek some contiainers would.


RE: 6 tick hex CCA, adds up to 32 bit binary :O - Magic :^) - 11-04-2015

Also, from the perspective of all other devices, an ender portal acts exactly like a basic block. you can put redstone on top without it bleeeding, and repeaters don't treat it the same as comparators do either.


RE: 6 tick hex CCA, adds up to 32 bit binary :O - PI-Pyru-Pyru - 03-21-2016

I saw it yesterday!  This is awesome! Too bad I couldn't try it.


RE: 6 tick hex CCA, adds up to 32 bit binary :O - Legofreak - 03-21-2016

please dont bump threads that are 5 months old if it does not contribute to the discussion.


RE: 6 tick hex CCA, adds up to 32 bit binary :O - Magic :^) - 07-19-2016

I never really explained the thing that saves a tick on that adder so I'll just mention it briefly here:

I purposely bleed the CCA carry tower's generate line with the cancel line and use subtraction mode comparators. The way I bled it was so that the output of the borrow calculation would always be either 0 or 2 signal strength. Because I was guaranteed a consistent sig. strength with this technique, I could use the output directly to do -1 on later parts that depended on that 'borrow' evaluation.

So yeah, saved a tick.