I have seen a different style of Karnaugh Map for logic design. This is the style they used:
Anyone knows how this K-Map done? How to comprehend with this kind of map? Or how they derived from that equation from that map. The map is quite different from the common map like this:
The maps relate to each other this way, the only difference is the cells' (terms') indexes corresponding to the variables or the order of the variables.
The exclamation mark is only an alternative to the negation of a variable. !A is the same as ¬A, also sometimes noted A'.
!A A A !A ↓CD\AB → 00 01 11 10
+----+----+----+----+ +----+----+----+----+
!B | 1 | 0 | 1 | 0 | !D 00 | 1 | 1 | 1 | 0 |
+----+----+----+----+ +----+----+----+----+
B | 1 | 1 | 1 | 1 | !D ~ 01 | 1 | x | x | 1 |
+----+----+----+----+ +----+----+----+----+
B | x | x | x | x | D 11 | x | x | x | x |
+----+----+----+----+ +----+----+----+----+
!B | 1 | 1 | x | x | D 10 | 0 | 1 | 1 | 1 |
+----+----+----+----+ +----+----+----+----+
!C !C C C
If you are unsure, of the indexes in the given K-map, you can always check that by writing the corresponding truth-table.
For example the output value of the first cell in the "strange" K-map is equal to 1 if !A·!B·!C·!D (all variables in its negation), that corresponds with the first line of the truth-table, so the index is 0. And so on.
index | A B C D | y
=======+=========+===
0 | 0 0 0 0 | 1
1 | 0 0 0 1 | 1
2 | 0 0 1 0 | 0
3 | 0 0 1 1 | x ~ 'do not care' state/output
-------+---------+---
4 | 0 1 0 0 | 1
5 | 0 1 0 1 | x
6 | 0 1 1 0 | 1
7 | 0 1 1 1 | x
-------+---------+---
8 | 1 0 0 0 | 0
9 | 1 0 0 1 | 1
10 | 1 0 1 0 | 1
11 | 1 0 1 1 | x
-------+---------+---
12 | 1 1 0 0 | 1
13 | 1 1 0 1 | x
14 | 1 1 1 0 | 1
15 | 1 1 1 1 | x
You can use the map the same way you would use the "normal" K-map to find the implicants (groups), because all K-maps indexing needs to conform to the Gray's code.
You can see the simplified boolean expression is the same in both styles of these K-maps:
f(A,B,C,D) = !A·!C + A·C + B + D = ¬A·¬C + A·C + B + D
!A·!C is marked red,
A·C blue,
B orange
and D green.
The K-maps were generated using latex's \karnaughmap command and tikz library.
it's the same in principle just the rows and columns (or the variables) are in a different order
The red labels are for when the variable is true, the blue for when it's false
It's actually the same map, but instead of A they have C and instead of B they have A and instead of C they have D and instead of D they have B
Related
I need to design Programmable Logic Array (PLA) circuit with given functions. How can I design circuit with POS form functions. Can someone explain that? enter image description here
Below is the design process completed for F, the other two outputs, G and H, can done in a similar fashon.
F Truth Table
A B C D # F G H
0 0 0 0 0 1
0 0 0 1 1 0
0 0 1 0 2 0
0 0 1 1 3 1
0 1 0 0 4 1
0 1 0 1 5 1
0 1 1 0 6 0
0 1 1 1 7 0
1 0 0 0 8 0
1 0 0 1 9 0
1 0 1 0 10 1
1 0 1 1 11 1
1 1 0 0 12 0
1 1 0 1 13 0
1 1 1 0 14 1
1 1 1 1 15 1
F Karnaugh Map:
AB\CD 00 01 11 10
\
----------
00 0 | 1 x 1 | 0
----------
--------
01 | 1 y 1 | 0 0
--------
----------
11 0 0 | 1 1 |
| z |
| |
10 0 0 | 1 1 |
----------
F Sum Of Product Boolean:
(A'B'D)+(A'BC')+(AC)
x y z ==>(for ref):
x=(A'B'D)
y=(A'BC')
z=(AC)
F Logic Circuit:
------- ------
A---NOT---| | ------- | |
| AND |---| | | |
B---NOT---| | | AND | x | |
------- | |--------------| |
D---------------------------| | | |
------- | |
| | F
------- | OR |---
A---NOT---| | ------- ------ | |
| AND |---| | y | | | |
C---NOT---| | | AND |---| | | |
------- | | | | y+z | |
B---------------------------| | | |-----| |
------- | OR | | |
------- | | | |
A---NOT---| | z | | | |
| AND |---------------------| | ------
C---NOT---| | | |
------- | |
------
I have panel data:
Id | Wave| Localisation| Baseline
1 | 1 | AA | 1
1 | 2 | . | 0
1 | 3 | . | 0
2 | 2 | AB | 1
2 | 3 | . | 0
3 | 1 | AB | 1
3 | 3 | . | 0
4 | 2 | AC | 1
4 | 3 | . | 0
Some variable values of one panel (hhsize, localisation, whatever) serves as a reference (these values are included in the baseline interview only).
By consequence, for each id we do not have all the information. For the id==1 for instance, we have missing values in the column Localisation for not-baseline-interview (baseline==0).
I would like to spread the baseline values to each panel. That is, I want to replace missing values . in column Localisation by Localisation given in the baseline interview for each id.
In fact, the information Localisation remain the same across different waves. So it is useful to know the localization for each wave for one person.
If the data pattern you present is the same for the entire dataset, then the following should work:
clear
input Id Wave str2 Localisation Baseline
1 1 AA 1
1 2 . 0
1 3 . 0
2 2 AB 1
2 3 . 0
3 1 AB 1
3 3 . 0
4 2 AC 1
4 3 . 0
end
bysort Id (Wave): replace Localisation = Localisation[1] if Localisation == "."
list, sepby(Id) abbreviate(15)
+-------------------------------------+
| Id Wave Localisation Baseline |
|-------------------------------------|
1. | 1 1 AA 1 |
2. | 1 2 AA 0 |
3. | 1 3 AA 0 |
|-------------------------------------|
4. | 2 2 AB 1 |
5. | 2 3 AB 0 |
|-------------------------------------|
6. | 3 1 AB 1 |
7. | 3 3 AB 0 |
|-------------------------------------|
8. | 4 2 AC 1 |
9. | 4 3 AC 0 |
+-------------------------------------+
Suppose I have two matrices MatrixA and MatrixB given as follows (where i is the row number and j is the column number:
MatrixA | MatrixB
i | j | val | i | j | val
---|---|---- | ---|---|----
1 | 1 | 3 | 1 | 1 | 2
1 | 2 | 5 | 1 | 2 | 3
1 | 3 | 9 | 2 | 1 | 7
2 | 1 | 2 | 2 | 2 | -1
2 | 2 | 1 | 3 | 1 | 0
2 | 3 | 3 | 3 | 2 | -4
3 | 1 | 3 |
3 | 2 | -1 |
3 | 3 | 2 |
4 | 1 | 0 |
4 | 2 | 7 |
4 | 3 | 6 |
In a more familiar form, they look like this:
MatrixA = 3 5 9 MatrixB = 2 3
2 1 3 7 -1
-1 2 0 0 -4
7 0 6
I'd like to calculate their product (which is demonstrated in this YouTube video):
Product = 41 -32
11 -7
12 -5
14 -3
In the unpivoted column form I used earlier, this is
i | j | val
---|---|----
1 | 1 | 41
1 | 2 | -32
2 | 1 | 11
2 | 2 | -7
3 | 1 | 12
3 | 2 | -5
4 | 1 | 12
4 | 2 | -3
I'm looking for a general calculation that multiplies any compatible k x n and n x m matrices together as a calculated table.
I think I've got it figured out. If MatrixA is k x n and MatrixB is n x m dimensional:
Product =
ADDCOLUMNS(
CROSSJOIN(VALUES(MatrixA[i]), VALUES(MatrixB[j])),
"val",
SUMX(
ADDCOLUMNS(
SELECTCOLUMNS(GENERATESERIES(1, DISTINCTCOUNT(MatrixA[j])), "Index", [Value]),
"A", LOOKUPVALUE(MatrixA[val], MatrixA[i], [i], MatrixA[j], [Index]),
"B", LOOKUPVALUE(MatrixB[val], MatrixB[i], [Index], MatrixB[j], [j])),
[A] * [B]))
The CROSSJOIN creates a new table with columns [i] and [j] which has k x m rows. For each i and j row pair in this cross join table, the value for that cell is computed as the sum product of i row of MatrixA with j column of MatrixB. The GENERATESERIES bit just creates an Index list that has a length of the matching dimension n.
For example, when i = 3 and j = 2, the middle section for the given example is
ADDCOLUMNS(
SELECTCOLUMNS(GENERATESERIES(1, DISTINCTCOUNT(MatrixA[j])), "Index", [Value]),
"A", LOOKUPVALUE(MatrixA[val], MatrixA[i], 3, MatrixA[j], [Index]),
"B", LOOKUPVALUE(MatrixB[val], MatrixB[i], [Index], MatrixB[j], 2))
which generates the table
Index | A | B
------|-----|----
1 | -1 | 3
2 | 2 | -1
3 | 0 | -4
where the [A] column is the 3rd row of MatrixA and the [B] column is the 2nd row of MatrixB.
I am to implement an 8-to-1 multiplexer using the variables m(1,3,5,6,8,13). The function is:
F(A,B,C,D) = A′B′C′D + A′B′CD + A′BC′D + A′BCD′ + AB′C′D′ + ABC′D
I feel I have a basic idea of how multiplexers work, however I'm not entirely sure what to do with the numbers given. I created a truth table with ABCD and plugged it into the function. Then I created the multiplexer based upon the output. (Which I got to be: D', D', D', D, D, 0, D', 0) The only thing I haven't done, and I can't figure out how to do, is the variables. How do they relate to the function and multiplexer?
A multiplexer works as a switch. It selects one of the available inputs I and based on the given address bits S sends the selected input's value on the output Z.
For example:
–––––––––––
| MUX | +-------++-----+-----++-----+
| | | index || a_1 | a_0 || f |
D_0 –––| I_0 | |---------------------------|
D_1 –––| I_1 Z |––– f | 0 || 0 | 0 || D_0 |
D_2 –––| I_2 | | 1 || 0 | 1 || D_1 |
D_3 –––| I_3 | | 2 || 1 | 0 || D_2 |
| | | 3 || 1 | 1 || D_3 |
| S | +-------++-----+-----++-----+
–––––––––––
| |
a_1 a_0
In the example the output function is defined:
f = ¬a_1⋅¬a_0⋅D_0 + ¬a_1⋅a_0⋅D_1 + a_1⋅¬a_0⋅D_2 + a_1⋅a_0⋅D_3
In your case, the output is described by the given function of four variables and the multiplexer is supposed to be an 8:1, so there will be three variables used as the address bits (a, b and c) and the fourth (d) as the partitioned off input signal – parameter of the function f(d) representing the output value.
f(a,b,c,d)=¬a⋅¬b⋅¬c⋅d + ¬a⋅¬b⋅c⋅d + ¬a⋅b⋅¬c⋅d + ¬a⋅b⋅c⋅¬d + a⋅¬b⋅¬c⋅¬d + a⋅b⋅¬c⋅d
index || a | b | c | d || f(a,b,c,d) | f(d)
---------------------------------------------
0 || 0 | 0 | 0 | 0 || 0 | d
1 || 0 | 0 | 0 | 1 || 1 | d
2 || 0 | 0 | 1 | 0 || 0 | d
3 || 0 | 0 | 1 | 1 || 1 | d
---------------------------------------------
4 || 0 | 1 | 0 | 0 || 0 | d
5 || 0 | 1 | 0 | 1 || 1 | d
6 || 0 | 1 | 1 | 0 || 1 | ¬d
7 || 0 | 1 | 1 | 1 || 0 | ¬d
---------------------------------------------
8 || 1 | 0 | 0 | 0 || 1 | ¬d
9 || 1 | 0 | 0 | 1 || 0 | ¬d
10 || 1 | 0 | 1 | 0 || 0 | 0
11 || 1 | 0 | 1 | 1 || 0 | 0
---------------------------------------------
12 || 1 | 1 | 0 | 0 || 0 | d
13 || 1 | 1 | 0 | 1 || 1 | d
14 || 1 | 1 | 1 | 0 || 0 | 0
15 || 1 | 1 | 1 | 1 || 0 | 0
The truth table has been reduced to 8 lines by partitioning the input signal d off. Now the number of rows matches the number of multiplexer's inputs.
index || a | b | c || f(d)
-----------------------------
0 || 0 | 0 | 0 || d
1 || 0 | 0 | 1 || d
2 || 0 | 1 | 0 || d
3 || 0 | 1 | 1 || ¬d
-----------------------------
4 || 1 | 0 | 0 || ¬d
5 || 1 | 0 | 1 || 0
6 || 1 | 1 | 0 || d
7 || 1 | 1 | 1 || 0
In the following picture is a graphical representation of the multiplex.
Multiplexer (MUX)
MUX is a data selector
It allows digital information from several sources be routed into one single line for transmission over the line to a destination
A B C D are the sources and Q is the output. a b are the data selectors
Here is the truth table for 4:1 multiplexer
a | b | Q
0 | 0 | A
0 | 1 | B
1 | 0 | C
1 | 1 | D
The output Q is
Q = A+B+C+B
A=a'b' , B = a'b , C=ab' , D= ab
Q = a'b' + a'b + ab' + ab
Let's say I define a matrix:
matrix a = (2,3 \ 4,7 \ 6,13)
I can access "13" like this:
display a[3,2]
Is it also possible to access "13" while referring to "6" to specify the row? In other words, we would somehow signify that the row is the row (there could be more than one) that contains a 6 in the first column and then we want the second column of this row.
In R, we might do it like this:
a1 <- data.frame(c(2,4,6), c(3,7,13))
a1[a1[,1]==6, 2]
Is there anything analogous in Stata?
You could do this with Stata's matrix language, with some programming, but I would turn to Mata whose defined functions allow direct solutions similar in spirit to R. Consider this dialogue.
. mata
------------------------------------------------- mata (type end to exit) --------------
: a = (2,3 \ 4,7 \ 6,13)
: a :== 1
1 2
+---------+
1 | 0 0 |
2 | 0 0 |
3 | 0 0 |
+---------+
: a :== 6
1 2
+---------+
1 | 0 0 |
2 | 0 0 |
3 | 1 0 |
+---------+
: rowsum(a :== 6)
1
+-----+
1 | 0 |
2 | 0 |
3 | 1 |
+-----+
: select(a, rowsum(a :== 6))
1 2
+-----------+
1 | 6 13 |
+-----------+
: a2 = select(a, rowsum(a :== 6))
: a2[, 2]
13
: b = (6,6 \ 6,6 \ 6,6)
: select(b, rowsum(b :== 6))
1 2
+---------+
1 | 6 6 |
2 | 6 6 |
3 | 6 6 |
+---------+
: b2 = select(b, rowsum(b :== 6))
: b2[, 2]
1
+-----+
1 | 6 |
2 | 6 |
3 | 6 |
+-----+
"row contains a 6" is defined by the total of "element is equal to 6" across rows. Note that the code works if (a) there is more than one 6 on a row and/or (b) there is more than one row with a 6. In the last case, what is selected contains more than one element.
The notation should seem self-explanatory, except possibly that : as a prefix signals "elementwise" operations. To copy a Stata matrix into Mata, use st_matrix().
Note: Working out what the code should be to select in the first column only is set as an exercise for the zealous.