Method for constructing a gate - boolean-logic

I'm trying to construct a multiplex gate. It has two inputs, and one selector. I got as far as
the truth table.
A | B | Sel | Out
0 0 1 0
0 1 1 0
1 0 1 1
1 1 1 1
0 0 0 0
0 1 0 1
1 0 0 0
1 1 0 1
And this is where my method fails. I've constructed simpler gates such as AND, and OR. Those were so simple I didn't need an articulate method. I went to wikipedia to see if I could get
a method. Instead I only discovered which gates I need to construct the circuit. For my goals, this misses the point. More important to me is the method that arrives at the answer, rather than the answer itself. I know I need to use DeMorgan's Laws, but fall down when trying to come up with specifics. Any hints would be most welcome.

Just to elaborate on Keith's answer, here's the Karnaugh map for your truth table:
AB
00 01 11 10
___________
sel 0 | 0 1 1 0
1 | 0 0 1 1
This is created by grouping A and B, and then making a matrix of the outputs for any given input. Note the column headings do not count in binary, rather they are more like a grey code, having only one transition between each column.
Now that's done, you can write an equation that ORs together terms that cover all the 1s in the Karnaugh map.
On the Karnaugh map, it's pretty easy to see terms that cover multiple 1s. For example, the term B.sel' (B and not sel) covers both the 1's in the top row.
That combined with A.sel for the 1's in the bottom row gives the equation
output = B.sel' + A.sel
This works out at 4 gates, including the NOT.

You can make a Karnaugh Map, which will help you pick the gates you need to implement your function.

Related

How to create a circuit that outputs only 1, regardless of inputs

So this is the truth table:
In_1 In_2 In_3 Out
0 0 0 1
0 0 1 1
0 1 0 1
0 1 1 1
1 0 0 1
1 0 1 1
1 1 0 1
1 1 1 1
How do I create a circuit that matches this truth table?
Here is what I have tried, but this did not work:
Please help would be appreciated.
You just need to connect the output to a constant logic 1, which is usually just the power supply voltage. This is a trivial logic function and requires no gates to implement.
The solution is to apply Kmap. We will be ending up with an equation that will be similar to
but this is not the reduced form. If we try to reduce this equation we will end up with 1.
Check this tool for better understanding.
https://www.boolean-algebra.com/kmap/

How to store a binary grid using a float variable

This is not connected to any particular programming language, I'm trying to look for the most efficient way to store a binary grid (It will look like this...)
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
Into an int with a limit of 9,999,999
So each "1" Have a Boolean of true/false a.k.a "1" or "0" state so it can be displayed as also
1 0 0 1 1
1 1 0 1 1
1 1 1 1 1
All this is expected to be stored in an int so it can be transformed binary into digits.
So at the end of the day, I should be able to first set a binary grid then turn the binary grid into digits where I can store them into a variable, And then be able to extract them after from the variable back to the binary grid.
And also to answer any question related to why I just don't simply use an array or anything in relation, Well basically this is the only way the engine lets me store things to then extract them later.
Things I try: I already know I can store things within the digit system, What I lack is getting the most out of it, right now I can store 23 Bits which means that I got to get a binary grid that looks like this
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1
And remember this is having the limit of 9,999,999
I found out the system can have it from -9,999,999 to 9,999,999.
Another thing is that the limit of 9,999,999 is all-around any function so adding 9,999,999 + 9,999,999 is out of the question for that limitation.
So I'm going to add all the relevant details:
I can only use digits to store data in a variable.
The limit of the digits go only to 9,999,999
If I were to use floats it will have to be < 999,999.00 note that the limit on the float is 2 decimal points (0.00)
If I want, I can use multiple variables in terms that have more capacity
What I'm looking for is to try to get the most amount of bits out of the digits limit in the variable.

Kind of logical subtraction

Having these two bitsets as an example:
1 1 0 0
1 0 0 1
How can I get this following result:
0 1 0 0
From my point of view this kind of logic operation must be a subtraction but omitting the borrow bit.
Is it possible to have a simple logical operation to get that result?
Thanks in advance.
it is only true, if A is true and B is false.
So it can be solved as A & ~B

Why Do You Need To Minus 1 When Determining The Maximum Number N Bits Can Represent?

So in binary to find the largest number you can represent given N amount of bits, you would use:
2^N - 1
But why the -1. To try understand it i created a 3 Bit systems and tried some examples:
2^1 = (2) - 1
0 0 1 --> 1
2^2 = (4) - 1
0 1 0 --> 2
0 1 1 --> 3
2^3 = (8) - 1
1 0 0 --> 4
1 0 1 --> 5
1 1 0 --> 6
1 1 1 --> 7
So it all works out as planned, but why the -1. This probably sounds like a stupid question but as you can see above i have done a fair amount of research.
Because you can represent 0 which always takes up one spot in all the permutations.
The research shown should reveal the answer already, but you have forgotten about the zero.
Three bits are able to represent 2^3 different values. The smallest value is zero, so the largest must be 2^3-1.
Note that if you use a different system (such as signed binary), the smallest and largest value may change, but the count of values does not.

MySql: Storing empty cells, is this bad?

I have a table with different sorts of things. The thing is that there are columns that just some of the rows fill with data. Because the other rows doesn't need that. Is it bad to have some cells empty? Should I store all of then in different tables and have a main table where columns that all objects need are? And then when I want to select something I do joins instead?
It is not bad to have some empty cells. Mostly you need only multiple tables when you can have a 1 on more relation between the tables.
From the little information you have provided, this might be a case of storing information about different types of objects in one table, like cars, people, houses etc.
And forgive me in advance for my overly simplistic example, could not think of a better one.
People have attributes like name, family name, birth date. Cars have attributes like brand, color, number of doors, engine volume etc. Houses have area, number of bedrooms, garden (yes or no) etc.
When such a table would be populated with entries, it would look like this:
id name attr1 atttr2 attr3 attr4 attr5 attr6
1 car1 1 1 0 0 0 0
2 car2 1 1 0 0 0 0
3 man1 0 0 1 1 0 0
4 man2 0 0 1 1 0 0
5 house1 0 0 0 0 1 1
6 house2 0 0 0 0 1 1
1 means cell has some data, 0 means cell is empty.
If your table looks like this, you might be better off splitting your table into more tables, as database normalization suggests.