Jump to content

IB/Group 4/Computer Science/Computer Organisation/The Hardware Layer

From Wikibooks, open books for an open world

Electrical Components

[edit | edit source]

What are Transistors ?

[edit | edit source]
Image containing multiple transistors of different sizes
Multiple different types of transistors

A transistor is an electrical component made up of a semiconductor that is capable of regulating the flow of electricity. Transistors are commonly made of silicon or germanium. A transistor has three connections: the emitter, which functions as an output, the base, which is what controls the current, and the collector, which functions as an output. Electrical flow from the collector to the emitter is regulated using the base.

Transistors are used to create logic gates or switches, done using the ability to control the output from the emitter. Different types of transistors can also be made, using different structures, to represent different logic gates. For example, the transistor layout for an AND gate is different to an OR gate, with the OR gate having the emitter in a different location.

Transistors were originally created to replace vacuum tubes, which served a similar purpose. Originally, transistors were discrete objects which functioned individually, and were and computers were assembled with individual transistors. Today, transistors can be assembled in large numbers in integrated circuits (see below).


Note

Not needed for the exam



What are integrated circuits ?

[edit | edit source]
Note

Not needed for the exam



Overview

An integrated circuit

An Integrated Circuit (or IC) is the central component of electronic devices or, as some say, “the heart and brains of most circuits” (SparkFun Learn). More commonly called a ‘chip’ or ‘microelectronic circuit’, an IC is a semiconducting wafer - usually made out of silicon (a semiconducting material) -  on which tiny elements are placed to ensure the functioning of the device (such as resistors - which regulate the electric current - capacitors - which store energy - diodes - which signal current - and transistors - binary switch gates /see the What are Transistors? article). The capacity of such microchips fluctuates  from thousands to millions of transistors, depending on the need of the machine.

Making-process: photolithography

ICs are made thanks to the repetition of a process called photolithography, a technique using light rays to transfer complex patterns onto patterned films of suitable material called a photomask (often metal) placed onto the silicon wafer (a semiconducting material); to build transistors.

Fitting transistors onto an IC

The process is then repeated until all desired patterns are transferred onto the sample, which then becomes a transistor. See Moore’s Law graph (transistor page) to understand how the number of transistors which could be fitted in an IC evolved  throughout the last decades.

ICs are electronic elements that are the equivalent of our DNA: they constitute the building bricks of the device, ensuring its basic functioning. Its role is thus key in the functioning of any unit, ensuring the simultaneous running of numerous actions (acting as an amplifier, an oscillator, a timer, a counter etc.) (Whatis.com, 2021).  

Even if the first attempts of combining several electronic particles have been traced back to the 1920s, the first chip which could be compared to modern IC was made by  Warner Jacobi, a German engineer who filed in 1949 a patent for his invention: a   semiconductor amplifying device showing five transistors fitted on a three-stage amplifier arrangement (Wikipedia, 2022). However, most of the progress regarding ICs took place in the 60s, 70s and 80s, as engineers tried to overcome the Tyranny of Numbers problem (when millions of electronic parts were to be all assembled onto form one single chip, of which then hundreds of thousands were to be fitted onto a single computer thanks to the photolithographic process). In 2022, 63 years after Jacobi’s discovery, Apple managed to fit 114 billion transistors in its ARM-based dual-die M1 Ultra system, a chip using TSMC’s 5 nanometer (1 metre x 10-9) semiconductors (Wikipedia, 2022).


Boolean gates

[edit | edit source]
Use BOOLR to practice using logic gates.

2.1.11 Define the Boolean operators; AND, OR, NOT, NAND, NOR, and XOR.

2.1.12 Construct truth tables using the above operators.

The gates in a computer are sometimes referred to as logic gates because they each perform just one logical function. That is, each gate accepts one or more input values and produces a single output value. Because one is dealing with binary information, each input and output is either 0, corresponding a low-voltage signal, or 1, corresponding to a high-voltage signal. The type of gate and the input values determine the output value.


What is boolean logic ?

[edit | edit source]

Boolean logic(boolean algebra) is a mathematical tool commonly used for computer logic.

In boolean logic, values are only represented by "False" or "True"(0 or 1). In the hardware, the "False" and "True" is represented by the current being "off" or "on".

There are boolean operators (AND, OR, NOT, NAND, NOR, and XOR) which takes one or two inputs and spit out 1 output. These manipulations are fundamentals to more complex computer algorithms.

How are boolean gates built from transistors ?

[edit | edit source]

Transistors are composed of three main sections, the collector, base and emitter (labelled "C", "B" and "E" respectively in the diagram to the right). The collector constantly has a stream of electricity, however it is blocked if the base has no electricity as well. Following the same logic, if the base has electricity flowing but the collector does not, electricity is blocked. If both the collector and the base have electricity flowing, then the emitter outputs the electricity.

Two transistors in series can create the boolean gate AND, since if the first transistor outputs nothing then the second transistor's collector will have no electricity.

Two parallel transistors can create the boolean gate OR since if either one's emitter outputs electricity then it will reach the output.

What is the NOT boolean gate ?

[edit | edit source]
Boolean Expression Logic Diagram Symbol Truth Table
X = A' AX
A X
0 1
1 0

A NOT gate takes in one input signal and produces one output signal. The table to the right illustrates a NOT gate in three ways: a Boolean expression, a logical diagram symbol, and a truth table. In each representation, the variable A represents the input signal, which is either 0 or 1. The variable X represents the output signal, whose value (0 or 1) is determined by the value of A.

By definition, if the input value for a NOT gate is 0, the output is 1; if the input value is 1, the output is 0. A NOT gate is sometimes referred to as an inverter because it inverts the input value.

In boolean expressions, the NOT operation is represented by the ' mark. Sometimes this operation can also be shown as a horizontal bar over the value being negated (eg. ā). In the respective representation in the table to the right, a value is assigned to X by applying a NOT operation to input value A. In such an assignment statement, the variable on the left of the equal sign takes on the value of the expression on the right-hand side.

The logical diagram symbol for a NOT gate is represented by a triangle with a small circle (called an inversion bubble) on the end. The input and output are shown as lines flowing in and out of the gate. Sometimes these lines are labeled, though not always. The input signal Ais often being put to the left of the diagram and the output X is often on the right of the diagram representing the result of the NOT gate.

The truth table shows all possible input values for a NOT gate and their respective output values. Because there is only one input signal to a NOT gate, and that signal can only be 0 or 1, there are only two possibilities for the column labelled input signal A in the truth table. The column labelled X shows the output of the gate, which is the inverse of the input. Note that out of the three representations, only the truth table actually defines the behavior of the gate for all situations or possibilities.

These three notations are different ways of representing the NOT gate. For example, the result of the Boolean expression 0' is always 1, and the result of the Boolean expression 1' is always 0. This behavior is always consistent with the values shown in all three notations.

What is the AND boolean gate ?

[edit | edit source]
Boolean Expression Logic Diagram Symbol Truth Table
X = A • B
A X
B
A B X
0 0 0
0 1 0
1 0 0
1 1 1

Unlike the NOT gate, which accepts one input signal, an AND gate accepts two input signals. The values of both input signals determine what the output signal will be. If the two input values for an AND gate are both 1, the output is 1; otherwise, the output is 0.

The AND operation in Boolean algebra is expressed using a single dot () or, in some cases, an asterisk (*). Often the operator itself is assumed, for example A•B is often written as AB.

Because there are two inputs and two possible values for each input, four possible combinations of 1 and 0 can be provided as input to an AND gate. Therefore, four situations can occur when the AND operator is used in a Boolean expression.

Likewise, the truth table showing the behaviour of the AND gate has four rows, showing all four possible input combinations.

What is the OR boolean gate ?

[edit | edit source]
Boolean Expression Logic Diagram Symbol Truth Table
X = A + B
A X
B
A B X
0 0 0
0 1 1
1 0 1
1 1 1

Like the AND gate, there are two inputs to an OR gate. If the two input values are both 0, the output value is 0; otherwise, the input is 1.

The Boolean algebra OR operation is expressed using a plus sign (+). The OR gate has two inputs, each of which can be one of two values, so as with an AND gate there are four input combinations and therefore four rows in the truth table.



What are the NAND and NOR boolean gates ?

[edit | edit source]
NAND Gate
Boolean Expression Logic Diagram Symbol Truth Table
X = (A • B)'
A X
B
A B X
0 0 1
0 1 1
1 0 1
1 1 0
NOR Gate
Boolean Expression Logic Diagram Symbol Truth Table
X = (A + B)'
X = A - B
A X
B
A B X
0 0 1
0 1 0
1 0 0
1 1 0

The NAND and the NOR gate accept two input values. The NAND and NOR gates are essentially the opposite of the AND and OR gates, respectively. That is, the output of a NAND gate is the same as if one took the output of an AND gate and put it through an inverter (a NOT gate).

There are typically no specific symbols used to express the NAND and NOR gates operations in Boolean algebra. Instead, one should rely on their definitions to express the concepts. That is, the Boolean algebra expression for NAND is the negation of the AND operation. Likewise, the Boolean algebra expression for NOR is the negation of an OR operation.

The logic diagram symbols for the NAND and NOR are the same as those for the AND and OR except that the NAND and NOR symbols have the inversion bubble (to indicate the negation). Compare the output columns for the truth tables for the AND and NAND. They are the opposite, row by row. The same is true for OR and NOR gates.






What is the XOR boolean gate?

[edit | edit source]

The XOR boolean gate differs in two main ways from the regular OR gate, often referred to as an inclusive OR gate.

Boolean Expression Logic Diagram Symbol Truth Table
X = A ⊕ B
A X
B
A B X
0 0 0
0 1 1
1 0 1
1 1 0

The XOR boolean gate differs in two main ways from the regular OR gate, often referred to as an inclusive OR gate.

First off, The XOR boolean gate, or exclusive OR functions exactly the same as an OR with the exception that if both inputs are true (1), then the resulting output is false. A XOR gate produces false (0) if the two inputs are true (1), and true (1) otherwise. Note the difference between the XOR gate and the OR gate; they differ only in one input situation. When both input signals are true (1), the OR gate produces true (1) and the XOR produces false (0).

The Boolean algebra symbol ⊕ is sometimes used to express the XOR operation. However, the XOR operation can also be expressed using the other operators such as А̄B + AB̅.

The other main difference between an inclusive OR gate and an exclusive OR gate, is the symbol used to show the XOR gate. The XOR gate symbol has the same main shape of the inclusive OR gate, however its left, a curve following the left curved porting of the inclusive OR gate.

How to construct a boolean truth table from a boolean expression ?

[edit | edit source]

Six specific types of gates have been observed. It may seem to be a difficult task to keep them straight and remember how they all work. Well, that probably depends on how one thinks about it. One should not be encouraged to try and memorise truth tables. The processing of these gates can be described briefly in general terms. If one thinks of them that way, one can produce the appropriate truth table any time needed.

Some of these descriptions are in terms of what input values cause the gate to produce as 1 as a n output; in any other case, it produces a 0:

  • A NOT gate inverts its single input value
  • An AND gate produces 1 if both input values are 1
  • An OR gate produces 1 if one or the other or both input values are 1
  • An XOR gate produces 1 if only one input value is 1
  • A NAND gate produces the opposite results of an AND gate
  • A NOR gate produces the opposite results of an OR gate
Truth table representing Q = A NOR B

A truth table is a visual representation of the various inputs of a circuit and the outputs that are associated with each combination of inputs. To create a truth table, draw a table sequentially with one column for each input and one for the output. The image to the right represents a truth table to Q = A NOR B. In the first row, write the name of your inputs and output in order as seen in the image. Then, add every possible combination of inputs, each on a new row, and determine the output for each row depending on the inputs for the selected boolean gate.

The number of input combinations should correspond to 2 raised to the number of inputs (2 inputs = 4 combinations, 3 inputs = 8 combinations).

For more complex boolean expressions, it is best to add extra columns for intermediate operations.

For instance, for the expression Q = A AND (B OR C), in addition to the columns for the inputs A, B and C, you can add a new column for "B OR C". This is not mandatory but helps visualise the operations and prevent mistakes.

How to construct a boolean truth table from a logic diagram ?

[edit | edit source]

How to construct a logic diagram from a boolean expression ?

[edit | edit source]
  1. Identify the gates from the boolean expression
  2. Determine the orders at which the gates or processed
  3. Start plugging in true or false for the input signals, follow through the boolean expression to understand the logic flow behind
  4. Start constructing the logic diagram

Exercises - Boolean gates

[edit | edit source]

1. Construct a truth table for the following expression: (A AND B) XOR C

Logic components

[edit | edit source]

A combinational circuit consists of logic gates whose outputs are determined at any time from the present combination of inputs irrespective of previous inputs. It consists of input variables, logic gates and output variables. The logic gate accept signals from inputs and generate signals at the outputs. Some examples of combinational circuits are binary adder, decimal adder, decoder, multiplexer, half adder, half subtractor etc.

What is a half adder ?

[edit | edit source]
Note

Not needed for the exam


A logic circuit for the addition of two one-bit numbers is called a half adder. Two bits are outputted: the sum of the addition and the carry. It just so happens that, since 0 + 0 = 0 and 1 + 0 = 0 + 1 = 1, if A and B aren't both 1, a half adder's outputs are identical to those of a XOR gate, an AND gate only becoming necessary to add 1 and 1 together.

half adder
A half adder circuit diagram

The carry is therefore only necessary for the addition of 1 + 1, which equals 10 (binary for 2). The addition process is reproduced in this truth table.

A B Carry Sum
0 0 0 0
0 1 0 1
1 0 0 1
1 1 1 0


What is a full adder ?

[edit | edit source]
Logic gates that make up a full adder. Comprised of two half adders and an OR gate.

A full adder is a circuit made up of logic gates that is similar to a half adder, but with an extra input to account for the carry variable. The full adder can add up to three one-bit variables, and outputs a sum and carry, the same as a half adder. A full adder is made up of two half adders and an OR gate that is used to handle the carry.

Truth Table for a full adder
A B C Carry Sum
0 0 0 0 0
0 0 1 0 1
0 1 0 0 1
0 1 1 1 0
1 0 0 0 1
1 0 1 1 0
1 1 0 1 0
1 1 1 1 1


Note

Not needed for the exam


What is an 8 bit ripple carry adder ?

[edit | edit source]
A full 8 bit ripple carry adder

Now that you are familiar with half adders and full adders, we can build a complete circuit that add two 8 bit integers. This circuit is called the 8 bit ripple carry adder.

The structure is simple. The first circuit is a half adder and the rest that follows are full adders. The carry from the first circuit will be given to the full adders who will then give its carry to the next full adder and so on. Each component receives a bit from two numbers from its respective position. Each component also outputs the result. When combined together, the string of results of each individual components give the final result.

Note

Not needed for the exam



What is an ALU ?

[edit | edit source]

The Arithmetic Logic Unit is one of the main components of the CPU (Central Processing Unit) responsible for the execution of arithmetic operations on binary numbers provided from different storage places such as the RAM or the hard disk.

The ALU is composed of 2 essential components: arithmetic unit and logic unit.

The Arithmetic/Logic Unit (ALU) is capable of performing basic arithmetic operations such as adding, subtracting, multiplying, and dividing two numbers. This unit is also capable of performing logical operations such as AND, OR, and NOT. The ALU operates on words, a natural unit of data associated with a particular computer design. Historically, the word length of a computer has been the number of bits processed at once by the ALU. However, the current Intel line of processors has blurred this definition by defining the word length to be 16 bits. The processor can work on words (of 16 bits), double words (32 bits), and quadwords (64 bits). In the rest of this wiki, when referring to word, it will be of the historical nature aforementioned.

represents the arithmetic unit

Most modern ALUs have a small number of special storage units called Registers. These registers contain one word and are used to store information that is needed again immediately. For example, in the calculation of 1 × (2 + 3). 2 is first added to 3 and the result is multiplied by 1. Rather than storing the result of adding 2 and 3 in memory and then retrieving it to multiply it by 1, the result is left in a register and the contents of the register is multiplied by 1. Access to registers is much faster than access to memory locations.

Metaphorically, the ALU can be seen both as a calculator and a human brain (where all the logic is handled).

What is a carry look ahead adder ?

[edit | edit source]

Ripple carry adders work fine, but are slow due to how each full adder in the "ladder" have to wait for the previous one's carry in order to perform calculations. A carry look ahead adder can perform much faster calculations by circumventing this issue, calculating the carries ahead of time with a separate module. Carry adder

Note

Not needed for the exam


What is a shifter circuit ?

[edit | edit source]

First off, a shifter circuit is a type of logic gate which implements a shift on the input by a specified amount and in a specified direction. They are mostly used to move data from one area to another by shifting them a certain number of bits. A shifter circuit, such as the one shown in the image below, is made up of OR gates and AND gates.

A shifter circuit

A binary shifter circuit takes 2 inputs and outputs one time. One of the inputs (A) is the input that will be shifted and the other input (D) is the shifter. The D input will shift the A input by a certain amount. When D = 0, the A input will shift 1 bit to the left, and the opposite happens when D = 1, the A input will shift 1 input to the right.

Shifting a number by 1, 2, or 3 bits would mean dividing it or multiplying it 2, 4, of 8 times. So what would be needed to shift an A input? We would need another input, the D input which would shift the A input any number of bits in a specified direction.

What is a comparator circuit ?

[edit | edit source]

A comparator circuit is an electronic circuit that compares 2 inputs to finally produce an output. The output value of this circuit indicates which of the input is greater or less using an op-amp. An op-amp can help amplify the voltage between 2 inputs.

There are 2 types of comparator circuits: Inverting and non-inverting.

An inverting comparator circuit

Note

Not needed for the exam


What is a multiplexer ?

[edit | edit source]

Multiplexers are a a combinational circuit that can have many outputs based on one or many selection inputs.

In the image to the left we can see that the possible outputs (labelled 'A' and 'B') are changed based on the selector input (labelled 'sel').

The Truth table for this multiplexer would be:

sel output
0 A
1 B

In the truth table above we can observe that based on the output of 'sel', the output of the entire circuit changed from A to B.


If we want to have even more possible outputs, we must also change the amount of selector inputs. For N input lines, we need selector inputs. Following the same logic, we need input lines per selector lines.

The truth table for this multiplexer would be:

X Y output
0 0 f(0)
0 1 f(1)
1 0 f(2)
1 1 f(3)

Memory

[edit | edit source]

Memory is a collection of cells, each with a unique physical address. We use the generic word cell here rather than byte, because the number of bits in each addressable location, called the memory's addressability, varies from one machine to another. Today, most computers are byte addressable.

To fully illustrate the concept of memory, take a computer with 4GB of RAM as an example. The memory consists of 4 × 230 bytes, which means each byte of the computer is uniquely addressable, and the addressability of the machine is 8 bits. The cells in memory are numbered consecutively beginning with 0. For example, if the addressability is 8, and there are 256 cells of memory, the cells would be addressed as follows:


Address Contents
00000000 11100011
00000001 01010101
11111100 00000000
11111101 11111111
11111110 10101010
11111111 00110011


What are the contents of address 11111110? The bit pattern stored at that location is 10101010. However, what the contents actually represents, be it instructions, value, sign, etc. will be discussed later. What is important, however, is to understand that the bit pattern is information and can be interpreted.

When referring to the bits in a byte or word, the bits are numbered from right to left beginning with zero. The bits in address 1111110 are numbered as follows:


Bit Position 7 6 5 4 3 2 1 0
Contents 1 0 1 0 1 0 1 0

What is a gated latch?

[edit | edit source]
This is a Gated Latch circuit

A gated latch is a circuit which has 3 inputs. Similar to a regular latch circuit, a gated latch uses a set and reset latch, it differs from a regular latch by its use of an enabler switch.

The set and reset switches, commonly known as the S-R latch are used to either Set the input to 1 or Reset the input to 0.

This switch turns on the previously mentioned switches, set and reset. What would happen if this enabler switch was turned off? If the enabler switch is off, then the set and reset switches are also turned off. So when the enabler switch is on, the two other switches, the Set switch and Reset switch, are able to power up if need be.

What are gated switches primarily used for? Gated Latches are primarily used for digital storage and are essential for every electronic device. When there is memory that is stored in the gated latch that does not need to be used by the computer the gated latch will be turned off.

What is a Register ?

[edit | edit source]

A register is small block of memory that stores a single number. Larger memory structures, such as RAM, are made up of multiple registers. Registers are also used in CPUs where they act as small but fast ways of temporarily storing information (these are called processor registers).

Elitegroup 761GX-M754 - AMIBIOS (American Megatrends) in a Winbond W39V040APZ-5491

What is Read Only Memory (ROM) ?

[edit | edit source]

Read Only Memory(ROM) is a memory device that cannot be changed upon creation. To do this, the device usually has to be hardwired.

As the name implies, one can only read data from ROM.

Typically, ROM is used for softwares that rarely needs changing. However the executions speed of a ROM is slower than that of a RAM.

To the right is an example of how ROM might look like on a mother board.

Sticks of RAM with different amounts of memory

What is primary memory ?

[edit | edit source]

Primary memory is defined as memory that is accessible and modifiable by the CPU directly. This comes with the side effect of being volatile, which means deleted when power is switched off, however it increases the speed of reading and writing to memory by the CPU. Primary memory is made up of a computer's registers, cache, and RAM.

Primary memory is used for operations that need fast memory accesses, as it is faster than writing everything to the secondary memory. It is also used for storing data that does not need to be saved (for example when you copy something it is stored in primary memory), and for remembering instructions for the CPU to do.

What is secondary memory ?

[edit | edit source]
Functions as a storage

Secondary memory is non-volatile, meaning that data and programs can be accessed or retrieved even when the power is turned off. Secondary memory consists of all permanent or persistent storage devices, such as read-only memory (ROM). In computing operations, secondary memory is accessed only by the primary memory and later transported to the processor - that is the reason why it runs slower than RAM.

Generally, anything that is long term goes into the second memory. This is mainly the boot up part of a computer system that should stay consistent like the files needed for Windows to run.

It can be interpreted as the file storage system in the computer. RAM can easily access data from the secondary memory when needed.

What are secondary storage devices ?

[edit | edit source]

2.1.5 Identify the need for persistent storage.

An input device is the means by which data and programs are entered into the computer and stored into memory. An output device is the means by which results are sent back to the user. Because most of main memory is volatile and limited, it is essential that there be other types of storage devices where programs and data can be stored when they are no longer being processed or when the machine is not turned on. These other types of storage devices (other than that of main memory) are called secondary or auxiliary storage devices. Because data must be read from them and written to them, each storage device is also an input and an output device.

Examples of secondary storage devices include;

  • Magnetic Tape,
  • Magnetic Disks,
  • CDs and DVDs,
  • Flash Drives,
  • External Hardrives