Monday, July 18, 2011

Latches and Flip Flops

Two interesting video on latches and flip flops, courtesy of Dublin City University.

SR latch and Gated SR latch:


D-type and JK flip flop:



Java simulation of clocked SR flip-flop

Friday, July 8, 2011

Encoder



The Encoder IC can be viewed as a device which produce or generate the binary code for a particular input. In this example, the 10 input pins are connected to a keypad consisting of 10 keys '0' to '9'. When the key '9' is depressed, the particular input signal is active low, and hence the generated output code is binary "1001", representing the decimal number 9.

Now, for encoder (as different from the decoder), there is a possibility of multiple inputs active at the same time. For the example given above, this happens when two or more keys are depressed at the same time. Hence, there must be a priority scheme to give higher priorities to some inputs. For this case, if another key lower value than '9' is depressed at the same time, the priority will be given to '9' and the output will remain at "1001".

Hence, the truth table for the encoder is:




[more: timing diagram]

Decoder



The decoder IC can be viewed with the analogy as shown above. The input code (ABC) is analogous to the delivery instruction written on the package - the name/address/date etc. and the outputs (Y0:Y7) are analogous to dispatching the delivery man. The enable input (G1, G2A, G2B) are analogous to the cash payment. Once received, the delivery service will be enabled. Note that, when enabled, for each code there will only be one output activated.

For example, when the input code (written on the package) is "110", and the enable inputs G1G2aG2b = "100", the decoder will be enabled and activates the output signal on output pin Y6, since binary "110" = decimal 6.

Active High/Active Low

Some students find it difficult to understand the concept of "active high" or "active low". They are just different ways of control, depending on the requirement of the next stage. As an analogy, you can either ask "those who agree put up your hand" or "those who disagree put up your hand", although the purpose of that is more psychological than technical.

Hence, for the decoder 74LS138, only the output that is activated goes low, the other outputs stay high (inactive). Thus, we can construct the truth table of this decoder:




[more: timing diagram]

Thursday, June 30, 2011

Laws of Boolean Algebra

Boolean Algebra can be thought of as a subset or variant of ordinary Elementary Algebra. The numbers and variables in Boolean Algebra are just 0 and 1. That is, any variable, any expression, can eventually by evaluated to either 0 or 1. Example,

A
AB
A+C
A(D+EF)+BC

Note that since we are dealing with the set {0,1} here, so additions and multiplications are not the same as ordinary algebraic additions and multiplications. The addition sign denotes logical OR, and the multiplication sign denotes logical AND. There is an additional operator - the inverter, which denotes logical complement. The 'bar' over the variable is denoted by the single quotation mark:

not(A) = A'

There are differences between Boolean Algebra and Elementary Algebra in terms of the operations and laws, but a large number of laws are common to both. Example,

Commutative:

AB = BA
A+B = B+A

Distributive:

A(B+C) = AB + AC

Some common "laws" of Boolean Algebra

Most of these are not actually laws, but can be readily derived from the fundamentals. Students often misunderstood/forget how they are derived.

AND

A.0 = 0
A.1 = A
A.A = A
A.A' = 0

OR

A+0 = A
A+1 = 1
A+A = A
A+A' = 1

These are not laws/rules but basics derived from the definitions of AND and OR gate. Students who do not understand these should refer back to fundamental of AND and OR gates, their respective truth tables etc. When one input is connected to signal A, and the other input connected to 0/1/A/A', what is the output?

For example, A.A' = 0 can be seen from the AND gate's truth table:

ABOut=A.B
000
010
100
111

In this case, B = A', and it means we need only look at rows 2 and 3, where the two inputs are complement of each other. In both cases, the output is 0. Hence A.A' = 0.


Absorption

A+(A')B = A + B

This "law" can be proven using the following "law":

A+AB = A(1+B) = A

Hence, we replace A by the complicated version (A+AB) and factorize out B. The term (A + A')=1. Hence we have

A+(A')B = A + AB + (A')B = A + (A + A')B = A + B

Similarly,

A' + AB = A' + B

DeMorgan's Theorem

(A+B)' = A' . B'
(AB)' = A' + B'

Tuesday, June 28, 2011

Handling Boolean Expressions

When marking papers, I often come across mistakes on handling boolean expressions, especially those which involve the use of DeMorgan's Theorem. Students often overlook the importance of brackets, say, when changing from (A . B)' to (A' + B'). For example:





Strictly speaking, this step is already wrong!

The problem of omitting the brackets results in this kind of error.











Another example of omitting the brackets, resulting in wrong factorization.

Almost identical mistake as the one above!










This one made a mistake in factorization, even when brackets are used


Careless mistake.





Another common mistake is inconsistency when applying DeMorgan's Theorem. In the following example, the student is able to apply the theorem correctly fro single variable term, eg.

(B' . D)' = B + D'

but when it comes to a product term of 2 variables, it was neglected.








Up to here, it is still correct.

The term (C' . D) should be taken as a whole, i.e. with a bar across the whole product term.

Monday, June 27, 2011

Relating Truth Table, Boolean Expression, and Logic Circuit

Many students have difficulties relating the 3 of them together. Basically, they are interrelated. The truth table, as the name suggests, describes the input conditions under which the output is true, i.e. output = 1. From the truth table, a boolean expression can be written for the output in terms of the input variables. For every line (or row) in the truth table where the output = 1, a product term can be written from the input conditions. The final expression is then a sum of the product terms. Having the boolean expression, we can then draw the logic circuit associated with the output.

Take for example, the XOR gate. The truth table for the XOR function is defined as:


Hence, from the truth table, there are 2 lines (or rows) where output = 1:

when (A=0 and B=1) or when (A=1 and B=0).

Hence, we can write the boolean expression for the output as

Output = (A' . B) + (A . B')

where A' denotes A_bar, or A complement/inverted, and B' denotes B_bar. This form of expression is called Sum-Of-Product (SOP) expression.

The logic circuit for the XOR function is:



Notice we have defined a special symbol for the XOR function.

Given one of the three, you be able to derive the other two. Remember, they are interrelated:

  1. Truth Table
  2. Boolean Expression
  3. Logic Circuit

An interesting website: Logic Gate Flash Animation


Digital Fundamentals Lecture Topics

Digital Fundamentals 1

Topic 1: Introductory Digital Concepts
Topic 2: Logic Gates
Topic 3: Boolean Algebra & Logic Simplification
Topic 4: Combinational Logic
Topic 5: Functional Blocks
Topic 6: Latches & Flip-flops
Topic 7: Number Systems

Digital Fundamentals 2

Topic 1: Introduction to Sequential Logic Circuits
Topic 2: Registers
Topic 3: Counters
Topic 4: Memory Devices
Topic 5: Conversion Between Digital and Analog Signals
Topic 6: IC Technology