[go: up one dir, main page]

0% found this document useful (0 votes)
57 views70 pages

ENGG1310 CE LT1 Vtam

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 70

ENGG 1310

(CE Part)
LT1: Introduction to Computer Engineering
- Computer Systems, Programming & Networking

Dr. Vincent Tam


ENGG1310 - VT 1
Dept. of EEE, HKU
KEY Learning Objectives/Outcomes

+ What is Computer Engineering ?


+ Computer Organization and Working Principles
+ Computer Programming
+ Computer Networking
+ Modern Applications of Computer Engineering

ENGG1310 - VT 2
Extensive. Essential.
Extremely complicated.

ENGG1310 - VT 3
Wordcloud based on all course offered by HKU EEE
Created by www.jasondavies.com/wordcloud
ENGG1310 - VT 4
Wordcloud based on all course offered by HKU EEE
Created by www.jasondavies.com/wordcloud
ENGG1310 - VT 5
3 Modules, 1 Assignment

Digital
Logic

Computer
Systems & Assignment Modern CE
Networking Applications

General Engineering Skills


ENGG1310 - VT 6
What is Computer Engineering (CE) ?
Computer
Organization
&
Working
Principles !

( H/W + S/W )

ENGG1310 - VT
YouTube Video : https://www.youtube.com/watch?v=avZTQgLs064 7
Hardware
& Software
+ Hardware (H/W) is the physical and tangible parts of a
computer, e.g. keyboard, monitor, mouse and printer;
+ Software (S/W) refers to the programs (as a sequence
of instructions) and data;
+ A computer system requires both H/W and S/W to
operate.

ENGG1310 - VT 8
About Moore’s law (on Computer H/W)…
+ “The number of transistors incorporated in a chip will approximately
double every 24 months.”
—Gordon Moore, Intel Co-Founder (1965)
+ Core i7-980 has 1.17 billion transistors, at 3.33 GHz, 32nm technology

ENGG1310 - VT 9
taken from: http://www.intel.com/content/www/us/en/silicon-innovations/moores-law-embedded-technology.html
If Moore’s Law were to apply to assignment
+ Assume:
10 minutes to solve an assignment question with 10 circuit
components (level of this course)
Amount of time needed to analyze the circuit scales linearly
(much worse in real-life)
An Intel Core i7 CPU contains ~1 billion components
+ How long does it take to fully analyze the processor?
+ Ans:

109 minutes = 694,444 days = 1,901 years

ENGG1310 - VT 10
~ To Address Computer Systems..
+ Abstraction is the process of encapsulating (low-
level) details by well-defined interfaces.
Related concepts: layering, sub-system, hierarchy

+ Hiding low-level details allows one to focus on the


big-picture (current picture);
+ In simple terms: Make use of something even before
you fully understand how it works.

ENGG1310 - VT 11
Decomposition of Computer/Complex
Systems (1)
Top-Level System Subsys B Subsys
Subsystem A B-1
Subsys
C
Subsys
B-2

+ Decompose a system into multiple sub-systems


Each sub-systems can be decomposed into more sub-systems
A top-down approach
+ Compose larger systems by connecting smaller sub-
systems
Each composed system can be used to compose even bigger systems
A bottom-up approach
+ The organization of sub-systems forms a hierarchy

ENGG1310 - VT 12
Abstraction of Computer/Complex Systems (2)
Top-Level System Subsys B Subsys
Subsystem A B-1
Subsys
C
Subsys
B-2

+ Engineers usually represent each sub-system as a


block, forming block diagrams.
+ The boundary of each sub-system is somewhat
arbitrary
Up to the engineering team
+ But the key is to have a clean and well-defined
interface
Abstraction

ENGG1310 - VT 13
Computer/Electronic Systems

Physical Physical
World Input Process Output World

+ All computer/electronic systems must ultimately be


interacting with the physical world:
Temperature of the air,
Time,
Light,
Sound,
Human movement…
+ Hierarchy (the use of sub-system), might hide that fact,
but all systems do interact with the physical world

ENGG1310 - VT 14
System Components - Input
• Sound
• Voltage (V)
• Temperature
Physical • Current (I)
• Light World Input
• Resistance (R)
• Pressure
• Capacitance, Inductance…
• …

+ Convert physical quantities into internal quantities that are


easy to manage
+ In any computer/electronic system, it usually means
converting a physical quantity into electrical signals, such as
voltage (V), current (I), resistance (R), etc…
+ Examples
A microphone translates movement of air in the form of air pressure into
voltage
A wind turbine translates wind into electrical power
A light sensor translate light intensity (lumens) into resistance
A thermistor translates temperature into resistance

ENGG1310 - VT 15
System Components - Output
• Sound
• Voltage (V)
• Temperature
• Current (I) Physical
Output World • Light
• Resistance (R)
• Pressure
• Capacitance, Inductance…
• …

+ Convert internal quantities that are easy to manage


into physical quantities that interact with the
physical world
+ Examples
A speaker translates voltage values (V) into movement of air
in the form of air pressure that generate sound
A light bulb that turns current values (I) into light
A motor that drives a wheel to spin
A solenoid that generates a pulling force on a shaft

ENGG1310 - VT 16
System Components - Processing

Process

+ Performs the intended function of the system.


+ Examples
Amplifies the electrical signal from a microphone
Control the power of the motor of a fan depending on input
voltage
+ Slightly more complex example:
Mixes the voltage input from two different microphones, amplifies
the signal, and control the voltage that will drive a signal indicator
and output speaker

ENGG1310 - VT 17
An Example Application of Computer
Systems
Process
Ball Rolls Turns on
Input Output
Past Sensor Laser
3 times?

ENGG1310 - VT 18
Abstraction At Work…
Process
Ball Rolls Turns on
Input Output
Past Sensor Laser
3 times?

DI DO

+ The “Process” block only needs to focus on its own


function:
If DI is TRUE, then increment internal counter, otherwise do nothing
Set DO to TRUE only if internal count is 3, otherwise set DO to FALSE
+ It does not need to know how the rest of the system
works
It doesn’t know how to detect a ball
It doesn’t know how to turn on laser

ENGG1310 - VT 19
Process
Ball Rolls Turns on
Input Output
Past Sensor Laser
3 times?

DI DO

Assume we want to change the behavior of the system such that

“the laser is turned on only after 3 balls have passed through the
tunnel AND a toy car has reached the bottom of a ramp”

Can we change the system easily by reusing all existing modules?

ENGG1310 - VT 20
“the laser is turned on only after 3 balls have passed
through the tunnel AND a toy car has reached the bottom
of a ramp”

Car at Ramp Input

Process
Ball Rolls Turns on
Input Output
Past Sensor Laser
3 times?

A system that output TRUE when both inputs are


TRUE

ENGG1310 - VT 21
Abstraction of A Computer System

ENGG1310 - VT 22
The Hardware Architecture…

ENGG1310 - VT 23
The Hardware Architecture…(2)

ENGG1310 - VT 24
The Hardware Architecture…(3)
INPUT OUTPUT

ENGG1310 - VT 25
Computer Organization

ENGG1310 - VT 26
Input Devices…
+ Accept data/information from the outside world (e.g. human,
physical environment or other computers) into the computer
system for processing;

+ Examples of input devices interacting with human: keyboard,


mouse, microphone, touch screen, webcam, etc.

+ Examples of input devices interacting with other computers:


hard disk, wireless (WiFi/Zigbee) network router, etc.

ENGG1310 - VT 27
Output Devices…
+ Output processed information to the outside world (e.g.
human, physical environment or other computers);

+ Examples of output devices interacting with human: monitor,


printer, speaker, etc.

+ Examples of output devices interacting with other computers:


hard disk, wireless (WiFi/Zigbee) network router, etc.

ENGG1310 - VT 28
Central Processing Unit
(CPU)
+ Controls the operations of all parts of the computer
system
- Arithmetic operations;
- Decision making;
+ A physical CPU (such as one you buy from Intel or
AMD) may include functions of other parts of the
system
- Part of the memory system;
- Part of I/O.

ENGG1310 - VT 29
CPU – Arithmetic and Logic Unit
(ALU)
+ The ALU of a CPU performs the actual computation
+ Typical functions:
Arithmetic: + − × ÷
Bit operations: shift left/right, bitwise AND, OR
Comparison: < > ≤ ≥ = ≠
+ ALU can be controlled to perform any one of the above
functions according to instructions specified in a program.

ENGG1310 - VT
30
CPU – Control Unit
+ Determines what to do based on
- Instruction
- Result of previous computation
+ Internal control
- Determines the function of the ALU based on the given instruction
- Determines if and when should a memory read/write be performed
- Determines if the CPU should perform a reset of the datapath
+ Typical control-related instructions
Branching: determines the next instruction to fetch from the memory
Memory operations: load/store data from memory

ENGG1310 - VT
31
A Quick Summary: Reality Check
Memory
ALU (cache)
+
Control
Unit

Input/Output
(I/O)
ENGG1310 - VT
32
Memory
+ Stores instructions and data
+ Instructions:
- Control the operation of the CPU
- Obtained from a user’s software program through a process called
compilation.
+ Data e.g.
- User input
d = (a + b) × c
• Input data: values of a,b,c
- Temporary data • Temp data: (a+b)
- Computed output • Output data: d

ENGG1310 - VT
€ 33
Memory Storage Capability
+ Every memory device has a storage capacity, indicating
the number of bytes it can hold
+ Bytes: 1 Byte = 8 bits
+ Storage capacities are specified in the following units:
Unit Symbol No. of Bytes
kilobyte KB 210 = 1024
megabyte MB 220 (> 106 )
gigabyte GB 230 (> 109)
terabyte TB 240 (> 1012)
ENGG1310 - VT 34
Main Memory
+ Main memory is volatile – i.e. stored information is lost if
the electric power is removed;
+ Main memory are direct access devices - information can
be reached directly;
+ Main memory is consisted of:
- Random Access Memory (RAM) to store the user programs;
- Read-Only Memory (ROM) to store the operating systems (or system S/W
as stated on P. 22).

ENGG1310 - VT 35
Real Processor: Cache Memory
+ Modern processor systems have layers of cache memory
Level 1 (L1), Level 2 (L2), Level 3 (L3)

+ Cache are high-performance memory with low access


latency
Latency (or Delay): L1 < L2 < L3 < Main Memory

+ Act as temporary storage of values for fast access;


+ The layers of caches form a memory hierarchy.

ENGG1310 - VT
36
The Stored Program Architecture
+ Also called the von Neumann
architecture
+ Named after John von Neumann
- Talented mathematician;
- Key person behind the development of EDVAC in
the 1940s;
+ A stored-program computer
- stores both program instruction and data in the
same memory storage;
- performs computation by executing instructions
stored in the memory

ENGG1310 - VT
37
Stored-Program Computers

Determines
Get the
Execute the the next
current
instruction instruction
instruction
to fetch

ENGG1310 - VT
38
Pros and Cons of Stored-Program
Computers…
+ Pros of the stored-program architecture:
- Control unit gets data and instructions in the same way from the
main memory unit;
- Similarly, data from memory and data from external devices are
accessed in the same way;

+ Cons of the stored-program architecture:


- The memory unit is the performance bottleneck of the stored-
program architecture since both data and instruction are stored
in the same place;
- The CPU is idle for a certain amount of time while memory is
being accessed.
ENGG1310 - VT 39
Today’s Computers

ENGG1310 - VT 40
3 Classes of Computers
+ Desktop
+ Server Dominate the Future
+ Embedded System

Same fundamental principle of operation, but


with different design optimizations and tradeoffs.

ENGG1310 - VT
41
Desktop Computers
+ Most people’s everyday encounter to computers;
+ Signifies by the rise of personal computer (PC) in the
early 1990s;
+ Typical examples:
- PC with a tower
- Laptop/Notebook computers
- Apple iMac, Mac Pro
+ Post-PC Era
- Tablet
- Smart Phones

ENGG1310 - VT
42
Embedded Systems
+ A computer system embedded
within a larger system
i.e. Computer systems as components

+ Perform simple, dedicated


functions (e.g. navigation) as part
of a larger system;
+ Limited resources
- Processing power;
- Memory;
Cost & power consumption
- Storage, etc.
are major design concerns
ENGG1310 - VT
43
Modern Embedded Systems
+ Embedded systems everywhere;
+ Perform far more than “simple,
dedicated” tasks;
+ Not so limited resources.

Cost & power


consumption
are major
design concerns

44
Ex: Smart TVs
+ Video processing
- Scaling
- Motion compensation
- Full HD, 4k
+ Audio processing
+ Internet access
- Video conference, YouTube…
- Motion Detection
- Voice Control
+ Example
- Samsung TVs run fully functional Linux
system internally
- 600 MHz ARM v7 processor
45
Servers
+ Includes many of the most powerful computers in
operations;
+ Most modern servers are implemented using highly
parallel multiprocessor systems
-Super-computers;
-Computer clusters;
+ Usually accessed only through networks;
+ Responsible for the most demanding computing
needs
- Web, video streaming
- Datacenter Google handles > 1 billion
- Scientific computations searches per day
- Financial computations
ENGG1310 - VT 46
• Roadrunner @ Los Alamos
National Laboratory
• 1st > petaflops
supercomputer
• 12,960 IBM PowerXCell 8i
CPUs + 6,480 AMD
Opteron dual-core
• USD$125M
• 444.94 Mflops/W

2022 State-of-the-art:
• 2008 World’s fastest ~ 1102 petaflops
• 2010 3rd fastest ~ 8.7 million cores
• 2012 #22
• 2013 Decommisioned Current #1: Frontier
HPE Cray EX235a, AMD
“Roadrunner has been replaced with Optimized 3rd Generation
something smaller, faster, more energy United States
efficient and cheaper.” –AP

ENGG1310 - VT URL : https://www.top500.org/lists/top500/2022/06/ 47


Warehouse Scale Computer
+ A new class of computer
for massively parallel
cluster of computers;
+ Datacenter as a computer
~100,000 servers;
include design choices in electrical,
electronic and building
construction
+ Exploit service level
parallelism;
+ Designed for cloud-based
services.
ENGG1310 - VT
48
Power Consumption is the Limit
+ 15 years ago, only mobile/embedded systems
were concerned with power consumption
Battery life;

+ Today, power consumption is major concern for


ALL classes of computer
Performance is always needed;

+ High power consumption incurs:


High Heat, High Cost, Low Reliability, Low Performance;
+ The problem:

High performance increases power consumption

ENGG1310 - VT
49
The Big Challenge
+ Generally speaking,
power consumption
increases with

Performance
Power/
performance;
Energy + Technical challenge:
find ways to improve
performance without
significant increase to
power.

TOP500 Green500

http://top500.org http://green500.org

ENGG1310 - VT
50
Latest Development in Computer
Systems…
+ Multi-Core CPU for parallel processing;

+ Graphics processing units (GPUs) opening many new


possibilities in gaming, content creation, machine learning,
etc.

+ Edge computing : edge computing keeps computer data


close to end users for a faster response, e.g. robotics.

https://www.intel.com/content/www/us/en/products/docs/processors/what-is-a-gpu.html
ENGG1310 - VT 51
Multi-Core CPU

Intel Lynnfield processor


(source: AnandTech)
ENGG1310 - VT
52
An Example: Calculating Class Grades*
grade = 0.1 ´ lab + 0.2 ´ mt
+0.3 ´ hw + 0.4 ´ proj;

grade = 0;
tmp = 0.1 ´ lab;
grade = grade + tmp;
tmp = 0.2 ´ mt; Time
grade = grade + tmp;
tmp = 0.3 ´ hw;
grade = grade + tmp;
tmp = 0.4 ´ proj;
grade = grade + tmp;

*This is not how we are going to calculate your grades in this course !
ENGG1310 - VT
53
Calculation in Sequential Processors
0.1 0.1 0.2 0.2 0.4 0.4

lab lab mt mt proj proj

tmp
× tmp
+ tmp
× tmp
+ tmp
+ tmp

grade grade grade grade grade grade


clock cycle 1 clock cycle 2 clock cycle 3 clock cycle n
TIME

+ Values are loaded from memory into CPU for computation


Results are stored back to memory
+ CPU performs different computation on each cycle:
1st cycle: x, 2nd cycle +, …
+ One operation per cycle
+ As many cycle as needed to complete application
ENGG1310 - VT
54
Calculate Class Grades on Parallel or
Multi-core CPU
0.1 lab 0.2 mt 0.3 hw 0.4 proj

× × × ×

+ +
+ Time
grade

SPACE
ENGG1310 - VT
55
2 Ways to Compute…
0.1 0.1 0.2 0.2 0.4 0.4

lab lab mt mt proj proj

tmp
× tmp
+ tmp
× tmp
+ tmp
+ tmp

grade grade grade grade grade grade


clock cycle 1 clock cycle 2 clock cycle 3 clock cycle n
TIME

× Sequential Processor
+
×
+
×
+ Parallel Which way is faster?
× Processor
ENGG1310 - VT
56
GPU…
+ A multi-core CPU consists of a few [say 2 - 8] (processor) cores in
which each processor core is a processing unit which reads in
instructions to perform specific actions;
+ Each CPU is optimized for sequential serial processing while a
GPU has a massively parallel architecture consisting of
thousands of smaller, more efficient cores designed for handling
multiple tasks simultaneously.

ENGG1310 - VT
57
Performance Gain by GPU-Accelerated
Computing… Source URL at:
http://www.nvidia.com/object/what-is-gpu-computing.html
+ GPU-accelerated
computing offers attractive
performance gain by
offloading compute-
intensive portions (ar. 5%
on average) of the
application to the GPU,
while the remainder (~
95%) of the program code
still runs on the CPU.
ENGG1310 - VT
58
Edge Computing (EC)…
+ instead of processing and storing data in the data
centers far away from end users, EC keeps data
close to users to reduce the delay of waiting for any
server response in cloud computing;
+ Essentially, EC is a distributed computing
paradigm to bring computation and data storage
closer to the sources of data
Helping to reduce response times while saving network
bandwidth;
+ Potential applications: autonomous vehicles, home
automation, robotics, smart cities, Industry 4.0, etc.

ENGG1310 - VT 59
System S/W
+ Operating Systems (e.g. MS Windows 11, Linux, Mac OS)
- Controls all machine activities such as running of the processes;
- Provides the user interface to the computer;
- Manages resources such as the CPU and memory, etc.
+ Compilers/Interpreters
- Translate a computer program in a high-level programming
language such as C++ into low-level machine instructions (0 or 1);
- A compiler will translate the whole program in a batch mode
while an interpreter will translate the program line-by-line.

ENGG1310 - VT 60
Python Programming
+ Python is an interpreted high-level programming
language in which the Python interpreter will translate
each Python statement to machine instructions and
directly execute the machine instructions on a CPU.

ENGG1310 - VT 61
How a Python Program Works…
+ Basically, a CPU will continuously follow the fetch-
decode-execute cycle to go thru’ all instructions in a
Python program.

ENGG1310 - VT 62
How a Python Program Works…(2)
+ Essentially, all the CPU components go
thru’ the detailed steps of the fetch-
decode-execute cycle as follows.
Ø The control unit fetches (i.e. reads) the
instruction from the main memory;
Ø The control unit decodes (i.e. decides what it
means) and moves the required data from the
main memory to the ALU;
Ø The ALU executes the arithmetic, logical or other
predefined instruction.

ENGG1310 - VT 63
Computer Networking
+ A network contains two or more connected
computer systems/servers where data and
resources can be shared;
+ Each device has its own network address
(e.g. 192.168.0.100), which uniquely
identifies it among the others;
+ A local area network (LAN) covers a small
distance with a small number of computers,
e.g. home or campus WiFi;
+ A wide area network (WAN) such as the
Internet connects computers over long
distances. Therefore, users can be
geographically distributed (i.e. ubiquitous
computing) while accessing the information
on different computers.
ENGG1310 - VT Image Sources : https://www.heavy.ai/technical-glossary/local-area-network 64
https://www.softwaretesttips.com/wide-area-network/
Modern CE Applications…
+ With the availability of high-performance computing
technologies such as the GPU computing, artificial intelligence
(AI) or machine algorithms (ML) have wide applicability in many
sophisticated CE applications including computational finance or
tele-medicine;
+ Besides, cloud or edge computing platforms have nurtured many
interesting applications in embedded systems (ES) or Internet of
Things (IoT) for robotics, smart cities/homes/offices, and Industry
4.0, etc.

Img Src : https://aliga.sk/en/what-the-heck-is-a-smart-city/


ENGG1310 - VT 65
Summary…
+ H/W is the physical and tangible part of a computer while S/W refers to programs
and data;
+ Both H/W and S/W components construct computer systems in hierarchical layers,
as each lower layer hiding details from the layer above. This principle of
“abstraction” is fundamental in understanding nowadays computer systems;
+ The Moore’s law predicts that the number of transistors incorporated in a chip (i.e.
H/W of a computer or electronic system) will approximately double every 24
months;
+ The basic organization of any computer system consists of 5 key components :
input devices, central processing unit (CPU), memory, output devices, and axillary
storage devices;
+ The CPU consists of the control unit to decide what to perform based on
instructions and results of the previous computation, and also the arithmetic/logic
unit (ALU) to perform the actual computation (e.g. +, -, x, /, logical operations);

ENGG1310 - VT 66
Summary…(2)
+ Cache are high-performance memory with low access latency (or delay): L1 < L2 <
L3 < Main Memory;
+ The stored-program computer stores both program instruction and data in the
same memory storage. The pros is data/instructions from memory and also data
from external devices are accessed in the same way. On the contrary, the main
memory becomes the performance bottleneck;
+ There are 3 classes/types of modern computer systems including: desktop
computers, embedded systems, and servers with different design optimizations
and tradeoffs;
+ Computer networks connects different computer systems to share resources via
the local area networks (LANs) or the wide area network (WAN);
+ Modern CE applications may include various engineering applications with the
uses of AI/ML algorithms and/or ES/IoT technologies.

ENGG1310 - VT 67
Example Questions
+ When using the MS Word application to process of a word
document, why will all/most of the data be lost when the
electrical power is suddenly off ? What happens if you save
the document?
+ Key points: 1. Main Memory is volatile which means the data
stored there will be lost when the electricity is off;
2. When your MS Word application is running, the data
working there will be stored at the main memory.
3. If you save the document, the data will be transferred to a
secondary storage such as the hard disk;
4. A secondary storage like the hard disk is non-volatile.

ENGG1310 - VT 68
Example Questions
+ Which of the following is not a hardware component of a
computer?
+ (a) CPU
+ (b) RAM
+ (c) ROM
+ (d) Speaker
+ (e) Operating system

Ans : (e) as an operating system is S/W component, not a H/W component !

ENGG1310 - VT 69
Example Questions…
+ How many Megabytes (MB) will a coloured (RGB) image
with the resolution of 1080 pixels × 1920 pixels occupy?

Ans: 1080 × 1920 × 3 × 8


= 49766400 bits
= 49766400/8
= 6220800 bytes
= (6220800 / 220 ) megabytes [refer to P. 34]
= 5.9326 MB
ENGG1310 - VT 70

You might also like