Chapter3 - Hardware

3.01 Computer architecture

冯诺依曼体系架构

vonneumannarchitecture

Von Neumann architecture

Von Neumann introduced the idea of the stored program computer, which has been the basis of many computers for a number of years.

main novel features:

CPU 架构

hardware-CPU

通俗理解: 计算单元主要执行算术运算、移位等操作以及地址运算和转换;存储单元主要用于保存运算中产生的数据以及指令等;控制单元则对指令译码,并且发出为完成每条指令所要执行的各个操作的控制信号。

The central processing unit

The central processing unit (CPU) has the responsibility for execution and processing of all instructions and data in a computer.

It consists of:

A microprocessor is an integrated circuit (microchip) – also referred to as a processor or CPU.

difference between CPU and microprocessor:

Components of a typical CPU

CPU 指令流程

步骤:

  1. Fetch - CPU通过地址总线获取必要的指令并将他们存储到内部存储位置(IAS中)
  2. Decode - CPU通过对指令解码理解刚刚获取的指令
  3. Execute - CPU执行指令
  4. Store - 将执行的结果在存储到内部存储IAS中去

CPU的具体过程:

  1. 控制单元CU先取指令(Fetch);
  2. 指令译码(Decode)解析出要执行什么指令;
  3. 确认指令是对哪些数据(操作数Operand)进行操作;
  4. 将操作数从主存加载到寄存器中;
  5. ALU执行指令(Execute);
  6. 结果写回Store;

Register寄存器

存储器的基本组成:

运算器基本组成:

控制器的基本组成:

PC(Program Counter) - 程序计数器,存放当前欲执行指令的地址,并可自动计数形成下一条指令地址的计数器;
IR(Instruction Register) - 指令寄存器,存放当前正在执行的指令的寄存器;
CU(Control Unit) - 控制单元(部件),控制器中产生微操作命令序列的部件,为控制器的核心部件;

程序首地址PC:

取指令:PC->MAR->存储体M-MDR->IR

分析指令:IR->CU

执行指令:IR->MAR->M->MDR->ACC

Components of the central processing unit (CPU)

The main components of the CPU are the Control Unit (CU), Arithmetic & Logic Unit (ALU) and system clock.

Arithmetic & Logic Unit (ALU)

The Arithmetic & Logic Unit (ALU) allows the required arithmetic (e.g. +, - and shifting) or logic (e.g. AND, OR) operations to be carried out while a program is being run;

Computers can have more than one ALU.

The ALU allows multiplication and division using shifting operators.

Control Unit (CU)

The control unit reads instructions from memory. The address of the location where the instruction can be found is stored in the Program Counter (PC). This instruction is then interpreted using the Fetch–Decode–Execute cycle (see later in this section).

A system clock is used to produce timing signals on the control bus to ensure this vital synchronisation takes place – without the clock the computer would simply crash!

The RAM holds all the data and programs needed to be accessed by the CPU. The RAM is often referred to as the Immediate Access Store (IAS). The CPU takes data and programs held in backing store (e.g. a hard disk drive) and puts them into RAM temporarily.

Registers

Registers can be general or special purpose. We will only consider the special purpose registers.

System buses and memory

Buses transfer data and control signals throughout a computer.

The width of the data bus and address bus determines the word length/size and the performance of the computer.

The stored-program concept

A stored-program computer is a computer that stores programs and instructions in digital memory.

A modern stored-program computer is one that keeps its programmed instructions, as well as its data, in read-write, random-access memory(RAM).

The fetch-execute cycle

What-is-the-fetch-decode-execute-cycle

step 1 - Fetching the instruction

The CPU fetches the necessary data and instructions and stores them in its own internal memory locations (the IAS). To fetch the instruction the CPU uses the address bus.

The PC contains the address of the memory location of the next instruction to be of fetched from memory (MAR).

The address is copied from the PC to the MAR using the address bus.

The contents of the memory location contained in the MAR are then copied into the MDR.

The contents of the MDR are then copied to CIR and the PC is incremented by one so the next instruction can be processed.

step 2 - Decoding the instruction

The instruction is now decoded so that it can be interpreted in the next part of the cycle.

step 3 - Executing the instruction

The CPU passes the decoded instructions as a set of control signals to appropriate computer components.

This allows each instruction to be carried out in a logical sequence.

Cores, cache and internal clock

The system clock defines the clock cycle used to synchronise all computer operations.

Timing signals are transmitted via the control bus.

How to speed up the cpu performance?

Overclocking, caused by changing the clock speed in the Basic Input/ Output System (BIOS), can lead to overheating and to non-synchronised instructions which can cause the computer to crash.

Caches

Caches, which store frequently used instructions and data, can speed up CPU

Instruction set

opcode and operand

Instructions are a set of operations that need to be decoded in sequence; each operation is made up of an opcode and an operand.

A number of allowed opcodes exist and these are referred to as the instruction set.

The Fetch-Decode-Execute cycle controls the sequence of steps to process each instruction in sequence.

Instruction sets are low level language instructions that instruct the CPU how to carry out an operation.

Embedded Systems

the general make-up of an embedded system

An embedded system is a combination of hardware and software designed to carry out a specific task.

Hardware can be electronic, electrical or electro-mechanical.

Embedded systems can be based on a microcontroller, microprocessor or system on a chip (SoC).

Embedded systems can be programmable or non-programmable.

Benefits:

Drawbacks:

Examples of the use of embedded systems include:

3.03 Input Devices

I/O Device (Input/Output Device)

io_device

input and output devices at a checkout:

Barcode scanners(readers)

A barcode is a series of dark and light parallel lines of varying thickness. The numbers 0 to 9 are each represented by a unique series of lines.

Note there are different patterns for digits on the left-hand side and for digits on the right-hand side.

Each digit is made up of 2 dark lines and two light lines. The width representing each digit is the same.

Advantages to the management of using barcodes :

Advantages to the customers of using barcodes :

usages:

Quick response (QR) codes

QR Code is made up of a matrix of filled-in dark squares on a light background.

QR Code Uses
Advantages
Disadvantages

Input Devices

input_device

Digital Cameras

Modern digital cameras simply link to a computer system via a USB port or by using Bluetooth (which enables wireless transfer of photographic files).

What happens when a photograph is taken?

Digital cameras (after 2023)

Digital images taken by cameras can easily be transferred to a computer (or other device) via USB port, Bluetooth (wireless transfer) or memory card reader.

Microprocessors in the camera automatically control many camera functions, such as shutter speed, focus, aperture size, flash, ‘red eye’ removal and so on.

Keyboards

Keyboards are by far the most common method used for data entry.They are used as the input devices on computers, tablets, mobile phones and many other electronic items.

The keyboard is connected to the computer either by using a USB connection or by wireless connection. In the case of tablets and mobile phones, the keyboard is often virtual or a type of touch screen technology.

each character on a keyboard has an ASCII value. Each character pressed is converted into a digital signal, which the computer interprets.

how the computer recognises a letter pressed on the keyboard?

Keyboards (after 2023)

Physical keyboards (connected via USB or Bluetooth) or virtual keyboards (for example, on a smartphone or keyboard using the touchscreen features).

Each character on a keyboard has an ASCII value. The computer is able to detect which key is pressed, which allows it to determine the character that was selected.

Entry of data via a keyboard is a slow process which is also prone to error and can lead to injuries such as repetitive strain injury (RSI).

Microphones

Microphones are either built into the computer or are external devices connected through the USB port or using Bluetooth connectivity.

Microphones (after 2023)

Microphones have a number of applications, for example, as a sensor (to detect sound in an intruder detection system), to input text into a computer (of particular benefit to a disabled person who cannot use a keyboard) or for doing voiceovers on presentation slides and so on.

Microphones convert sound into electric currents of varying amplitude. A diaphragm in the microphone vibrates and a copper coil and cone attached to the diaphragm create an electric current as the coil vibrates back and forth. The electric current can be converted into digital data and then stored in a computer memory.

Optical mouse (after 2023)

A mouse is used to move an on-screen cursor which allows the user to take actions

The optical mouse is an example of a pointing device. It uses tiny cameras and a red LED light source to allow the exact position of the mouse to be calculated.

Advantages of an optical mouse compared to a mechanical mouse

Advantages of a wired mouse (using USB) compared to a wireless mouse

2D and 3D scanners

2D scanners - These types of scanner are the most common form and are generally used to input hard copy (paper) documents. The image is converted into an electronic form that can be stored in a computer.

Computers equipped with optical character recognition (OCR) software allow the scanned text from the document to be converted into a text file format. If the original document was a photograph or image, then the scanned image forms an image file such as JPEG.

3D scanners - 3D scanners scan solid objects and produce a three-dimensional image. Since solid objects have x, y and z coordinates, these scanners take images at several points along these three coordinates. A digital image which represents the solid object is formed.

usages:

Touch Screens

Touch screens are now a very common form of input device. They allow simple touch selection from a menu to launch an application (app).

Capacitive touch screens

Capacitive touch screens are composed of a layer of glass (protective layer), a transparent electrode (conductive) layer and a glass substrate. Since human skin is a conductor of electricity, when bare fingers (or a special stylus) touch the screen, the electrostatic field of the conductive layer is changed.

There are presently two main types of capacitive touch screens - surface and projective

3.04 Output Devices

Output Devices

Actuators

An actuator is a mechanical or electromechanical device such as a relay, solenoid or motor.

Light projectors

two common types of light projector:

Projectors are used to project computer output onto larger screens or even onto interactive whiteboards.

Digital light projectors (DLP)

The use of millions of micro mirrors on a small digital micromirror device (DMD chip) is the key to how these devices work.

Works in principle:

The DMD chip is a microoptoelectromechanical system (MOEMS) that contains several thousand microscopic mirrors (made out of polished aluminium metal) arranged on the chip surface. They are each about 16 µm (16 × 10 -6 metres) in size and each corresponds to a pixel in the displayed screen image.

Liquid crystal display (LCD) projector

These are older technology than DLP. Essentially a high-intensity beam of light passes through an LCD display and then onto a screen.

works in principle:

DLP:高对比度(contrast ratio)、高可靠性(relaability)、寿命更长(longevity)、速度更快(quick running)、机器更小
LCD:高锯齿(sharper image)、高饱和度(colour saturation)、发热量小

Inkjet printers

Inkjet printers are essentially made up of:

steps:

  1. the data from the document is sent to a printer driver
  2. the printer driver ensures that the data is in a format that the chosen printer can understand
  3. a check is made by the printer driver to ensure that the chosen printer is available to print (e.g. is it busy, is it off- line, is it out of ink, and so on)
  4. the data is then sent to the printer and it is stored in a temporary memory known as a printer buffer (数据发送到打印机缓冲区)
  5. a sheet of paper is then fed into the main body of the printer; a sensor detects whether paper is available in the paper feed tray – if it is out of paper (or the paper is jammed) then an error message is sent back to the computer
  6. as the sheet of paper is fed through the printer, the print head moves from side to side across the paper printing the text or image; the four ink colours are sprayed in their exact amounts to produce the desired final colour (打印头在纸张左右移动,四色墨水喷涂)
  7. at the end of each full pass of the print head, the paper is advanced very slightly to allow the next line to be printed; this continues until the whole page has been printed (逐行打印)
  8. if there is more data in the printer buffer, then the whole process from stage 5 is repeated until the buffer is finally empty (重复以上过程打印缓冲区数据)
  9. once the printer buffer is empty, the printer sends an interrupt to the CPU in the computer; this is a request for more data to be sent to the printer; the whole process continues until the whole of the document has been printed

Laser printers

Laser printers use dry powder ink rather than liquid ink and make use of the properties of static electricity to produce the text and images. Unlike inkjet printers, laser printers print the whole page in one go. Colour laser printers use 4 toner cartridges – blue, cyan, magenta and black.

steps:

  1. the data from the document is sent to a printer driver
  2. the printer driver ensures that the data is in a format that the chosen printer can understand
  3. a check is made by the printer driver to ensure that the chosen printer is available to print (e.g. is it busy, is it off-line, is it out of ink, and so on)
  4. the data is then sent to the printer and it is stored in a temporary memory known as a printer buffer
  5. the start of the printing process involves a printing drum being given a positive charge; as this drum rotates, a laser beam is scanned across it removing the positive charge in certain areas; this leaves negatively charged areas that exactly match the text/images of the page to be printed
  6. the drum is then coated with positively charged toner (powdered ink); since the toner is positively charged, it only sticks to the negatively charged parts of the drum
  7. a negatively charged sheet of paper is then rolled over the drum
  8. the toner on the drum now sticks to the paper to produce an exact copy of the page sent to the printer
  9. to prevent the paper sticking to the drum, the electric charge on the paper is removed after one rotation of the drum
  10. the paper finally goes through a fuser which is a set of heated rollers; the heat melts the ink so that it fixes permanently to the paper
  11. at the very end, a discharge lamp removes all the electric charge from the drum making it ready to print the next page

Application of inkjet and laser printers

Inkjet printer – inkjet printers are often used for printing one-off photos or where only a few pages of good quality, colour printing is needed; the small ink cartridges or small paper trays would not be an issue with such applications.

Laser printer – these devices produce high quality printouts and are very fast when making multiple copies of a document; any application that needs high volume printing (in colour or monochrome) would choose the laser printer (for example, producing a large number of high-quality flyers or posters for advertising). Laser printers have two advantages: they have large toner cartridges and large paper trays (often holding more than a ream of paper).

Inkjet Printer: 少量打印,打印照片

Laser Printer: 大量打印,快速打印

3D printers

3D printers are used to produce solid objects that actually work. They are primarily based on inkjet and laser printer technology.

How to create a solid object using 3D printers

uses of 3D printing

LED screens

An LED screen is made up of tiny light emitting diodes (LEDs). Each LED is either red, green or blue in colour. By varying the electric current sent to each LED, its brightness can be controlled, producing a vast range of colours.

Recent advancements in LED technology have led to the introduction of OLED (organic LED) screens (see later).

LCD Screens

LCD screens are made up of tiny liquid crystals. These tiny crystals make up an array of pixels that are affected by changes in applied electric fields.

Because LCD’s don’t produce any light, LCD screens are back-lit using light emitting diode (LED) technology and must not be confused with pure LED screens.

Organic light emitting diodes (OLED)

Newer LED technology is making use of organic light emitting diodes (OLEDs). These use organic materials (made up of carbon compounds) to create semiconductors that are very flexible.

Advantages of using OLED compared to existing LEDs and LCDs:

Loud Speakers

Loudspeakers are output devices that produce sound.

principle :

Sensors

Sensors are input devices which read or measure physical properties from their surroundings.

Sensors constantly send signals to a microprocessor (or computer); they usually pass through an analogue to digital converter (ADC) first since computers can only understand binary (digital) data.

sensorlist

3.03 Data storage

存储

存储金字塔

各级缓存分别对应哪些位置?

Memory and Storage

All computers require some form of memory and storage.

Memory is usually referred to as the internal devices used to store data that the computer can access directly.This memory can be the user’s workspace, temporary data or data that is key to running the computer.

Storage devices allow users to store applications, data and files. The user’s data is stored permanently and they can change it or read it as they wish.

主存储器

main_memory

存储体由许多的存储单元组成,每个存储单元里面又包含了若干个存储原件,每个存储元件可以存储一位二进制数 0/1。

一个存储单元可以存储一连串的二进制代码,这串二进制代码被称为一个存储字,代码的位数为存储字长

在存储体中,存储单元是有编号的,这些编号称为存储单元的地址号。

MAR叫做存储地址寄存器,保存的是存储单元的地址,其位数反映了存储单元的个数

MDR表示存储数据寄存器,其位数反映存储字长。MDR存放的是从存储原件读出,或者要写入某存储原件的数据。

~ CPU读写主存储器的流程?

Primary memory

Primary memory is the part of the computer memory which can be accessed directly from the CPU; this includes random access memory (RAM) and read-only memory (ROM) memory chips.

Random access memory (RAM)

These memory devices are not really random; this refers to the fact that any memory location in RAM can be accessed independent of which memory location was last used.

feature:

Dynamic RAM (DRAM)

Each DRAM chip consists of transistors(晶体管) and capacitors(电容). Each of these parts is tiny since a single RAM chip will contain millions of transistors and capacitors.

This type of RAM needs to be constantly refreshed (that is, the capacitor needs to be re-charged every 15 microseconds otherwise it would lose its value). If it wasn’t refreshed, the capacitor’s charge would leak away very quickly leaving every capacitor with the value 0.

DRAM advantages:

Static RAM (SRAM)

A major difference between SRAM and DRAM is that SRAM doesn’t need to be constantly refreshed.

SRAM is much faster than DRAM when it comes to data access (typically, access time for SRAM is 25 nanoseconds and for DRAM is 60 nanoseconds).

SRAM & DRAM

SRAM主要用于二级缓存(Level2 Cache。与DRAM相比,SRAM的速度快,但是在相同面积中SRAM的容量要比其他类型的内存小

DRAM主要用于主存,内存条中。

Read-only memory (ROM)

Another form of primary memory is read-only memory (ROM). This is similar to RAM in that it shares some of its properties, but the main difference is that it cannot be changed or written to.

features:

RAM & ROM

Secondary and off-line storage

Secondary (and off-line) storage includes storage devices that are not directly addressable by the CPU.

They are non-volatile devices that allow data to be stored as long as required by the user.

This type of storage can store more data than primary memory, but data access time is considerably longer than with RAM or ROM.

Magnetic, optical and solid-state storage

Magnetic storage (磁存储器)

Hard disk drives (HDD) are still one of the most common methods used to store data on a computer.

Removable hard disk drives(移动硬盘) are essentially HDDs external to the computer that can be connected to the computer using one of the USB ports.

Solid state drives (SSD)

Latency is an issue in HDDs as described earlier. Solid state drives (SSD) remove this issue considerably since they have no moving parts and all data is retrieved at the same rate.

SSDs operate by controlling the movement of electrons within NAND or NOR chips. The data is stored as 0s or 1s in millions of tiny transistors.

Memory sticks, flash memories, SD cards and SSDs all use solid-state technology.

The main benefits of this newer solid state technology over hard disk drives are:

Memory sticks/flash memories

Memory sticks/flash memories (also known as pen drives) use solid state technology.

They usually connect to the computer through the USB port. Their main advantage is that they are very small, lightweight devices, which make them very suitable as a method for transferring files between computers.

Complex or expensive software, such as financial planning software, often uses memory sticks as a dongle(加密狗).

Optical media

CD/DVD disks

CDs and DVDs are described as optical storage devices. Laser light is used to read and write data to and from the surface of the disk.

Blu-ray discs

Blu-ray discs are another example of optical storage media. However, they are fundamentally different to DVDs in their construction and in the way they carry out read-write operations.

The main differences between DVD and Blu-ray are:

Virtual memory

One of the problems associated with memory management is the case when processes run out of RAM. If the amount of available RAM is exceeded due to multiple programs running, it is likely to cause a system crash. This can be solved by utilising the hard disk drive (or SSD) if we need more memory. This is the basis behind virtual memory. Essentially RAM is the physical memory, while virtual memory is RAM + swap space on the hard disk or SSD.

Benefits of virtual memory

Cloud storage

Cloud storage is the storing of vast quantities of data on remote physical servers.

There are three types of cloud storage

When using cloud storage, the same data is stored on more than one server in case of maintenance/repair – this is called data redundancy.

Benefits of cloud storage

Drawbacks of cloud storage

3.04 Network hardware

Network interface card

A network interface card (NIC) is needed to allow a device to connect to a network (for example, the internet). The NIC contains the Media Access Control (MAC) address, generated at the manufacturing stage. Wireless NICs (WNICs) can also be used; these plug into the USB port or can be part of an internal integrated circuit.

Media Access Control addresses

MAC addresses identify a device connected to a network. They are made up of 48 bits written in groups of six hex digits.

MAC addresses can be Universally Administered MAC addresses (UAAs) set at the manufacturing stage, or they can be altered by the user as Locally Administered MAC Addresses (LAAs) – these can be reset by the user if all devices on a network need a certain MAC format.

Internet Protocol addresses

When a device connects to a network, a router assigns the device an Internet Protocol (IP) address, via a Dynamic Host Configuration Protocol (DHCP) server, which is unique to that network.

IP addresses can be static or dynamic.

the difference between dynamic and static ip address

the differences between a MAC address and an IP address

Routers

Routers enable data packets to be routed between different networks, for example a local area network (LAN) to a wide area network (WAN).

Routers take data transmitted in one format (protocol) from network ‘A’ and convert the data to another format (protocol) that network ‘B’ understands.

Routers inspect data packets sent to it from another device or network. Every device on the same network has the same part of an IP address (for example, 215.164.10.XX) so the router can send data packets to an appropriate switch. The switch then directs the data packet to the correct device on the network.