This notes sheet looks at the basics of logic & binary code, including logic gates, logic networks, bolean identities, sequential logic, switches and grey code.

## Binary

Transistors make up the majority of computing, but they can only exist in two states: on and off.

Therefore, we need a system of passing information in zeros and ones only – binary.

Starting from right to left, the value of each digit (bit) increases in powers of two:

For example, the number represents:

When converting a decimal number, , to binary, you need to know how many bits, , you will need:

A **byte **is unit of data expressed as a binary number.

The byte above (1101) is 4-bit and represents the decimal number 13 (decimal meaning base 10,

out normal counting system, as opposed to binary).

## Logic Gates

A logic gate is a series of transistors that that change binary inputs into (sometimes) different

binary outputs.

A **truth table **is used to represent the output of a gate for each possible set of inputs.

**Boolean algebra** is used to express a series of logic operations compactly. Generally, M represents

the output.

### NOT Gate

A | M |
---|---|

0 | 1 |

1 | 0 |

### AND Gate

A | B | M |
---|---|---|

0 | 0 | 0 |

0 | 1 | 0 |

1 | 0 | 0 |

1 | 1 | 1 |

### OR Gate

A | B | M |
---|---|---|

0 | 0 | 0 |

0 | 1 | 1 |

1 | 0 | 1 |

1 | 1 | 1 |

### NAND Gate

A | B | M |
---|---|---|

0 | 0 | 1 |

0 | 1 | 1 |

1 | 0 | 1 |

1 | 1 | 0 |

### NOR Gate

A | B | M |
---|---|---|

0 | 0 | 1 |

0 | 1 | 0 |

1 | 0 | 0 |

1 | 1 | 0 |

### XOR Gate

A | B | M |
---|---|---|

0 | 0 | 0 |

0 | 1 | 1 |

1 | 0 | 1 |

1 | 1 | 0 |

## Boolean Identities

There are a number of important identities that can be sued to simplify logic networks:

## Sequential Logic

### S-R Latch

A latch is a logic network with two inputs, set (S) and reset (R):

The outputs are Q and NOT Q. This means there is one row in the truth table that is illegal, as they

cannot both be 1:

S | R | Q | NOT Q |
---|---|---|---|

0 | 0 | 1 | 0 |

0 | 0 | 0 | 1 |

0 | 1 | 0 | 1 |

0 | 0 | 1 | 0 |

1 | 1 | 1 | 1 |

The last row is **illegal**.

Note that there are two possibilities where both S and R are zero. **This allows the latch to storememory**, as when both inputs return to zero, the latch will stay wherever it was before (1 or 0),

until another action happens.

### Clocked Latches

An S-R latch can be connected to a clock – a signal that regularly alternates between 1 and 0 at

a fixed interval. This means that the inputs are gated and can only reach the latch when the clock

(Ck) equals 1.

This can be used to count elapsed time, but generally it is used to ensure that multiple actions

happen simultaneously.

The latch can be set up in such a way that the inputs reach the latch either when the clock pulse

goes from 0 to 1 (rising edge) or when it goes from 0 down to 1 (falling edge).

### Toggle Flip-Flop

A toggle flip-flop is a clocked S-R latch without S and R inputs. Instead, the only input is the clock,

Ck, and so the outputs Q and NOT Q switch values whenever a pulse is applied at the clock input.

These are used to count time and binary.

## Switches

Switches have poles and throws. They could have any number of each of these, leading to a vast

number of switches being available:

### Pull-Up Switch

To generate a logic output from a switch, a pull-up resistor needs to be incorporated to minimise

the time delay:

- When the switch is open, the input voltage flows through the resistor to the output (only very small amount of power is lost).
- When the switch is closed, the circuit is shorted, and the output voltage is zero.

### Switch Bounce

Logic outputs are very time-sensitive, and so the tiny bounces of the switch when it is operated

can screw up the system. Therefore, a **switch debouncer** is required so that the logic network

ignores any repeat inputs:

A switch with a built in debouncer is known as ‘TTL Compatible’, as they are ready for use

with TTL (logic) gates.

## Grey Code

Grey code is an alternative way of counting binary in which only one bit changes value at a time.

This is generally used to avoid errors in transmission – if more than one bit changes at once you

know something is wrong – but it is sometimes used for constructing logic networks.

Decimal | Binary | Decimal | Greycode |
---|---|---|---|

0 | 000 | 0 | 000 |

1 | 001 | 1 | 001 |

2 | 010 | 3 | 011 |

3 | 011 | 2 | 010 |

4 | 100 | 6 | 110 |

5 | 101 | 7 | 111 |

6 | 110 | 5 | 101 |

7 | 111 | 4 | 100 |

This may seem confusing, but is a key step in using Karnaugh Maps to produce simplified logic networks.

- The key boolean identities are:
- An
**S-R**latch is used to store data – this can be clocked to count time or binary - Greycode is binary but in a different order: only one byte changes every time.