Forums - Open Redstone Engineers
Logic gate formulas - Printable Version

+- Forums - Open Redstone Engineers (https://forum.openredstone.org)
+-- Forum: ORE General (https://forum.openredstone.org/forum-39.html)
+--- Forum: Tutorials (https://forum.openredstone.org/forum-24.html)
+---- Forum: Advanced Tutorials (https://forum.openredstone.org/forum-26.html)
+----- Forum: Concepts (https://forum.openredstone.org/forum-28.html)
+----- Thread: Logic gate formulas (/thread-12558.html)

Pages: 1 2


Logic gate formulas - Splavacado100 - 07-02-2017

Me and Data are working on a hex ALU, i.e. inputs have 16 states, and I devised a common formula for make logic gates with n input states. Sorry if this post doesn't go into much detail, I will update it with a much more in-depth explanation.

OR gate: max(x,y)
AND gate min(x,y)

Now the XOR gate is a little tricky but I've found a formula: |x-y|. Now, when doing hex subtraction, compactors have the function max(0, back - side), only using one side. You can using max(x - y, y - x) when doing a hex XOR. Simply put, and XOR gate is the absolute difference between the inputs. The max function is easier, just combine all lines, highest signal strength wins. For the min function, first do invert on each input, i.e. 15-x, then combine (max) each line, then hex invert back again. This is actually the structure of a common and gate, just now using hex NOTs instead of binary NOTs. Please comment any questions!


RE: Logic gate formulas - Matthew - 07-02-2017

max wont work for OR, 8 OR 1... 1000(8ss) 0001(1ss) Max of 8 and 1 is 8... but 8 is not (8 OR 1) so... similar issue with AND


RE: Logic gate formulas - Splavacado100 - 07-02-2017

Data, the formula is for 16 state logic, 16 different input stats. The hex inputs don't represent 4 bits of binary.


RE: Logic gate formulas - Matthew - 07-02-2017

(07-02-2017, 12:38 AM)Splavacado100 Wrote: Data, the formula is for 16 state logic, 16 different input stats. The hex inputs don't represent 4 bits of binary.

Oh, well then you are not doing boolean logic... So i would not call it OR, AND etc. I don't know the correct terminology for what you are doing but saying boolean functions alone is true/false inputs/outputs only.


RE: Logic gate formulas - Splavacado100 - 07-02-2017

AND and OR aren't exclusively for binary, are they?


RE: Logic gate formulas - Matthew - 07-02-2017

(07-02-2017, 12:53 AM)Splavacado100 Wrote: AND and OR aren't exclusively for binary, are they?

Then are indeed Tongue When you read AND, OR, etc. The default supposition is boolean unless otherwise specified.


RE: Logic gate formulas - ph1234k - 07-04-2017

(07-02-2017, 01:22 AM)Matthew Wrote:
(07-02-2017, 12:53 AM)Splavacado100 Wrote: AND and OR aren't exclusively for binary, are they?

Then are indeed Tongue When you read AND, OR, etc. The default supposition is boolean unless otherwise specified.

They are not indeed. In fact AND, OR and NOT are just other names for MIN, MAX and COMPLEMENT and it does not matter how many states you have, they are defined for and work the same for all such systems. 

e.g. 0 MIN 0 = 0. 1 MIN 0 = 0. 0 MIN 1 = 0. 1 MIN 1 = 1. 

As for boolean logic, if you wanted to do that then you do it and you can convert it to a single line of redstone with a hex converter if you like. 
This post though is about 16 state logic, not 2 state logic. 16 state logic is particularly interesting over 2 state logic as it allows more realistic modeling. For instance, instead of saying something is "hot/1" or "not hot/0" you can say that something has a degree of truthfulness to being called hot between "0/not hot" and "15/hot" so that "10" can be used for instance as a degree to which calling something hot is true and still not represent it as an absolute truth. It allows more accurate modeling of the real world for such concepts and is also known as "Fuzzy Logic".

More information can be found here: https://en.wikipedia.org/wiki/Fuzzy_logic


RE: Logic gate formulas - ph1234k - 07-04-2017

I actually designed such an ALU when the comparators were first released and attempted to make a computer based around 16 state logic, I ran into issues on how to address certain things though. Specifically, what functions to include in a fuzzy logic ALU.


RE: Logic gate formulas - Matthew - 07-06-2017

(07-04-2017, 08:43 AM)ph1234k Wrote: I actually designed such an ALU when the comparators were first released and attempted to make a computer based around 16 state logic, I ran into issues on how to address certain things though. Specifically, what functions to include in a fuzzy logic ALU.

Can fuzzy logic do anything usefull in redstone cpus like generate partial products to multiply? also if i'm not mistaken when reading a logical function the default assumption is boolean. I believe most of if not all algorithms on ore use boolean logic except for decoders. So where is the use case for "fuzzy logic"


RE: Logic gate formulas - ph1234k - 07-08-2017

Well, yes Fuzzy Logic can do everything that boolean can do. It just has more states. I won't comment on people's default assumptions however there was nothing to be assumed here since in the original post it was explained that he was using 16 states. Since it was explicitly stated, we need no assumption. Your reply here is referencing a use case in which I had created a partial ALU (didn't have adder/subtractor, only logic functions as I was tinkering with a 4 bit adder using comparators at the time and didn't complete it), also a use case is exactly what the original post here is about.

I am not sure how usage cases outside of the post would be relevant unless they were directly related however you could image a general purpose ALU based on 16 state logic which would be programmed to check outputs of some device (a chest that is part of a sorting machine for example) and then take action on the output (allowing a drain of the chest before filling to prevent the hopper from backing up and ruining the sorting functionality for example). In this example, yes you can do it without a computer and yes you could do it in boolean assuming you convert the output of the comparator but it is just an example. Like all logic devices, the limitations are based on how you can use the signal to interact with other hardware and your imagination.