Digital Logic

By digital logic we are referring to an electrical system that makes use of two distinct voltage levels to encode information.

In this case a binary system of 0's and 1's were 0 is a low voltage and 1 is a high voltage.

The 0's and 1's can be represented by switches which are either ON (1) or OFF (0) but beyond these simple actions these switches are combined to create more complex building blocks.

These building blocks are NOT, AND, OR, XOR

The NOT (negating/inverter), function when added to the output of the AND, OR & XOR creates the NAND, NOR & XNOR.

These logic functions are unidirectional meaning that changes at the input only affect the output.

All these basic functions only have one output.

The NOT gate only has one input whilst the other gates have a minimum of 2.

The NOT output from a digital logic perspective is in the opposite state to the input.

If the input is ON the output is OFF and if the input is OFF the output is ON.

Each function will be represented by symbols

Function Symbol
NOT -

AND ^

OR v

NAND ⊼

NOR ⊽

XOR ⊻

XNOR ⊙

{Multiple symbols exist for the same logic function the availability subject to fonts and whether graphics or text. This is particularly evident with the XOR/XNOR functions.}

For the other gates, combinations of the two inputs produce an output subject to the truth table

The truth table lists the input combinations and the corresponding output state.

Logic Levels

In this context we are referring to two distinct voltage states which represent the binary states of 0 and 1.

The 0 (Low = L), would be represented by a low voltage and the 1 (High = H), by a high voltage.

The voltage for the logic levels varies depending on the type of logic family.

In this case as we are using a Microbit with a supply voltage of 3.3V.

However, the inputs have logic thresholds which minimise the effect of variation in the voltage level due to finite variation in voltage accuracy and noise.

The logic input high level (VIH), is recognised as such if the input voltage is > ~1.8V*. (maximum 3.3V)

The logic input low level (VIL), is recognised as such if the input voltage is < ~1.4V*. (minimum 0V)

*Voltage levels as measured on an actual Microbit using a potentiometer to vary the input voltage.

If you are dealing with logic from the same family, logic thresholds will be compatible and can simply be reference as 0 = Low or 1 = High.

But if interfacing to different logic families the voltages become important and voltage level shifting ensures that the logic levels between the different logic families maintains correct function.

As we will be dealing purely with the Microbit no other logic families will be involved and therefore there will be no need for voltage level shifting.

Connections

he physical connections to the Microbit for the logic function use Analog inputs P0 and P1 and Digital output P2.

Enabling one or two input logic functions all with a single output.

Layout

The Microbit display is divided up into input, output and symbol area.

Button A - Selects a logic function and shows the symbol on the display.
Button B - Shows the truth table for the logic function selected with Button A

Button A+B - Enabled or disables the output at P2 whilst retaining live update at LED 4,4

Column 1 shows the inputs to the logic function with LED's at co-ordinates 0,1 (input a) & 0, 3 (input b)

Column 5 shows the status of the logic function output with LED at 4,2 (output).

When an input or output LED is lit it indicates a logic 1 (High) and when extinguished logic 0 (Low).

Columns 2 to 4 show the symbol for the selected logic function.

AND gate example:

This shows the input LED's with a logic 1 (High) at both inputs.

This shows the output LED with a logic 1 (High).

The symbol display area of 3x5 LED's shows the AND function.

Gates

NOT (Inverter)

Press button B for the truth table of the gate currently selected.

For the NOT gate the output is the opposite logic state to the input.

Boolean logic symbol - Y = !A, !

The input for the NOT gate is on P0 and the output is on P2

AND

Press button B for the truth table of the gate currently selected.

For the AND gate the output is logic high(1) only when both inputs are high under all other conditions the output is low(0).

Boolean logic - Y = A.B, ^

The inputs for the AND gate are on P0 and P1 and the output is on P2.

OR

Press button B for the truth table of the gate currently selected.

For the OR gate the output is logic high(1) when any input is high and low when both inputs are low(0).

Boolean logic - Y = A+B, v

The inputs for the OR gate are on P0 and P1 and the output is on P2.

XOR (Exclusive OR)

Press button B for the truth table of the gate currently selected.

For the XOR gate the output is logic high(1) only when both inputs are in different states if both inputs are the same the output is low(0).

Boolean logic - Y = (A@B)

The inputs for the XOR gate are on P0 and P1 and the output is on P2..

The XOR gate is listed as a basic building block, however this is actually a compound gate made up of the other basic functions and as such there are various configurations that are applicable.

Its still a basic function requiring no clocking, feedback or memory being static rather than dynamic logic.

An example is attached for reference.

NAND (Negated AND)

A NAND (Negated AND), gate is equivalent to an AND gate followed by an inverter.

Press button B for the truth table of the gate currently selected.

For the NAND gate the output is logic low(0) only when both inputs are high under all other conditions the output is high(1).

Boolean logic - Y = !(A.B), !^

The inputs for the NAND gate are on P0 and P1 and the output is on P2.

NOR (Negated OR)

A NOR (Negated OR), gate is equivalent to an OR gate followed by an inverter.

Press button B for the truth table of the gate currently selected.

For the NOR gate the output is logic high(1) only when both inputs are high under all other conditions the output is low(0).

Boolean logic - Y =!(A+B), !v

The inputs for the NOR gate are on P0 and P1 and the output is on P2.

XNOR (Negated XOR)

A XNOR (Negated XOR), gate is equivalent to an XOR gate followed by an inverter.

Press button B for the truth table of the gate currently selected.

For the XNOR gate the output is logic low(0) only when both inputs are in different states if both inputs are the same the output is high(1).

Boolean logic - Y = !(A@B)

The inputs for the XNOR gate are on P0 and P1 and the output is on P2.