500 likes | 511 Views
Learn about bits, Boolean algebra, logic gates, truth tables, and circuits in computer systems, including half-adders, full-adders, and computer architecture.
E N D
Data Representation A Bit (Binary digIT) has two possible values– 0 and 1 Used to represent one of two discrete states. 0 (OFF) or 1 (ON) 0 (False) or 1 (True) Two bits can represent four different things. Three bits can represent eight different things. How many things can n bits represent? Bits are used to represent numbers, text characters, images, sound, etc.
Binary (bit) Addition Only four possible combinations of input: Truth Table Logic Gates (Circuit) Boolean Expressions
Logic Gates Bits can be used to represent electrical signals: 0 (0V) or 1 (5V) A gate is a device that performs a logical operation on electrical signals These logical operations were defined by the mathematician George Boole (1815-64) The most common logic (Boolean) operations are: NOT AND OR XOR NAND NOR
Logic Gates Symbols Each gate has its own logic symbol which allows circuits to be represented by a logic diagram AND NAND OR NOR NOT Exclusive OR (XOR) Logic gates have one or more inputs and a single output
Logic Gates The behaviour of gates (and circuits) are commonly represented in any of the following ways: Boolean Expressions Uses Boolean algebra, a mathematical notation for expressing two-valued logic Logic Diagrams A graphical representation of a circuit; each gate has its own symbol Truth Tables A table showing all possible input values and the associated output values
The AND operation In order for the output to be 1 both inputs must be 1
The OR operation In order for the output to be 1 either input must be 1.
The NOT operation Inverts a single input. Also called an inverter.
NAND A NAND B = NOT (A AND B) NOR A NOR B = NOT (A OR B)
The XOR (eXclusive OR) operation In order for the output to be 1 either (but not both) inputs must be 1. (A AND NOT B) OR (NOT A AND B) = A XOR B
Boolean Algebra Boolean Constants: these are ‘0’ (false) and ‘1’ (true) Boolean Variables: variables that can only take the vales ‘0’ or ‘1’ Boolean Functions:such as NOT, AND and OR (in that order) Boolean Theorems: a set of identities and laws
Using truth tables to verify identities Let’s say we wanted to investigate whether the identity holds Is NOT A AND NOT B = NOT (A AND B) ?
Using truth tables to verify identities Investigate whether the identity holds
Using truth tables to verify identities Distribution :
Using truth tables to verify identities Distribution :
Using truth tables to verify identities - exercise De Morgan's laws are used to simplify Boolean equations so that you can build equations only involving one sort of gate. Verify De Morgan's laws using truth tables
Create a Boolean Expression from a logic diagram Work progressively from the inputs to the output adding logic expressions to the output of each gate in turn
Create a Boolean Expression from a logic diagram Work progressively from the inputs to the output adding logic expressions to the output of each gate in turn
Connect Logic Gates (to create circuits) Logic gates may be combined by using the output of one gate as the input to another.
Connect Logic Gates (to create circuits) Circuits in which the output is determined solely by the current inputs are termed combinational logic circuits. A AND NOT B OR NOT A AND B = A XOR B
Half-adder A SUM Half Adder An adder is a digital circuit that performs addition of numbers. B CARRY A half adder adds two binary digits and produces two outputs – the sum and the carry
Half-adder Only four possible combinations of input:
Half-adder B A SUM A CARRY B
Half-adder A B SUM CARRY
Half-adder (refined) The circuit for SUM can be simplified as follows: = (i.e. A XOR B) The half-adder can now be realised with fewer gates as shown A SUM B CARRY
Full-adder A full adder adds the carry in bit to two binary digits and produces two outputs – the sum and carry out. A SUM Full Adder B Carry In CARRY (out)
Full-adder A full adder adds the carry in bit to two binary digits and produces two outputs – the sum and carry out
Full-adder (circuit for SUM) Taking, A B SUM C
Full-adder (circuit for CARRY) A B C CARRY
Full-adder A A XOR B B SUM C A XOR B XOR C C AND (A XOR B) CARRY C AND (A XOR B) OR (A AND B) A AND B
The stored program concept • Early computers (e.g. ENIAC) were fixed-program machines. • Programs were wired into the machines. (Data and programs were treated separately.) • In 1945 John von Neumann and Alan Turing independently proposed what has become known as the stored program computer. • A computer architecture that allows programs and data to reside together in memory. The contents of memory is interpreted as an instruction when the next instruction pointer references it and as data when an instruction references it. • Stored programs are not part of physical machine. • Program instructions are directly accessible by the processor. • Instructions are fetched and executed one at a time.
Von Neumann Architecture Central Processing Unit (CPU) Control Unit (CU) Arithmetic Logic Unit (ALU) Input Devices Output Devices 2.11 describe the different components within a computer and the function of those components Primary Memory Secondary Storage Devices The components are connected to one another by a collection of wires called a bus
Von Neumann Architecture There are four major components in a computer connected together by buses: • Primary Memory: The temporary store for instructions and data. • Central Processing Unit (CPU): Controls the operation of the computer. • The Control Unit (responsible for the fetch-execute cycle) • The Arithmetic Logic Unit (ALU) (carries out arithmetic and logical operations) • Input/Output (I/O) Units: Handle communication with the outside world. • Secondary Storage Units: Long term storage of data. Data is moved from secondary storage to primary memory for CPU execution.
Memory Memory is a collection of cells, each with a unique physical address A cell is the smallest addressable unit of memory Addresses are of fixed size – the address length Cells are of fixed size – the word length (word size) Random Access Memory (RAM) A cell with a low address is just as accessible as one with a high address. Contents are volatile. Read Only Memory (ROM) Non-volatile memory used to store firmware (specialised programs used to carry out specific tasks typically when a computer is switched on.)
The von Neumann Architecture of a Computer Central Processing Unit (CPU) Arithmetic Logic Unit (ALU) Control Unit (CU) IR PC ACC1 ACC3 ACC2 MAR MDR Input Devices Output Devices System Buses Input Output Controller Input Output Controller Primary Memory PC: Program Counter Secondary Storage Devices IR: Instruction Register MAR: Memory Address Register MDR: Memory Data Register ACC: Accumulator
Registers • Storage locations internal to the CPU • Used as a scratchpad by the CPU to store data, addresses or instructions as it executes each program instruction • Data can be moved into and out of registers faster than from memory – dedicated pathways • Made from the fastest memory technology. Therefore, • Expensive • Relatively few (typically several dozen) • Each register is wired for a specific purpose. • Two broad types – general purpose and special purpose
Special Purpose Registers Program Counter Register(PC) • Contains the address of the next instruction to be execute • Also called instruction pointer (IP) Current Instruction Register (IR) • Holds the instruction that is being executed Memory Address Register (MAR) • Holds the address of the next piece of data or instruction to be used Memory Data Register (MDR) • Holds the data to be stored in memory / loaded from memory Accumulator • Used by the ALU to perform arithmetic and logic operations
The Fetch-Execute Cycle At the start of the fetch-execute cycle the Program Counter contains the address of the next instruction to be executed. Central Processing Unit (CPU) Decode Arithmetic Logic Unit (ALU) Execute Control Unit (CU) Step 1. Fetch. The contents of the address in the PC are loaded from memory to the Instruction Register (IR) (via the MAR and MDR) PC IR ACC Step 2. Decode The control unit determines the type of instruction to be carried out and sets the control signals accordingly. MAR MDR Fetch (Store) Step 3. Execute The operation is carried out by the CU or the ALU (depending on the instruction – load and store operations are carried out by the CU while arithmetic and logical operations are carried out in the ALU). Primary Memory (RAM) https://www.youtube.com/watch?v=jFDMZpkUWCw https://www.youtube.com/watch?v=04UGopESS6A Step 4. Store The result of the operation is written to registers or RAM.
Basic Electronics Voltage Current Resistors Capacitors Transistors Integrated Circuits Students learn about: CPU: ALU, Registers, Program counter, Memory / Basic electronics: voltage, current, resistors, capacitors, transistors
Recommended Viewing https://www.youtube.com/results?search_query=crash+course+computer+science