Misr University for Science & Technology
Faculty Of Information Technology
Department of Computer Science
Embedded System
Embedded
EmbeddedSystem
System
CPU Register Set
• Registers can be categorized based on their specific functions. Some
common types of registers include:
• General-purpose registers are used for any purpose, hence the name general
purpose.
• Used for various purposes, such as storing operands or results.
• Special-purpose registers have specific functions within the CPU.
• Program Counter (PC): Holds the address of the next instruction to be executed.
• Instruction Register (IR): Stores the current instruction being executed.
• Memory Address Register (MAR): Holds the address of a memory location to be read
from or written to.
• Memory Data Register (MDR): Temporarily stores data being transferred to or from
memory.
• Accumulator (ACC): Stores intermediate results of arithmetic and logic operations.
AI 230 Dr. Ahmed Zakaria Spring 2025
Embedded
EmbeddedSystem
System
CPU Register Set
AI 230 Dr. Ahmed Zakaria Spring 2025
Embedded
EmbeddedSystem
System
CPU Register Set (Special-purpose )
• How Registers Work:
• When the CPU executes an instruction, it
fetches the instruction from memory and
stores it in the Instruction Register (IR).
• The Program Counter (PC) keeps track of
the next instruction to be executed.
• Data required for the operation is loaded
into registers like the Accumulator (ACC) or
General-Purpose Registers.
• After processing, the result is stored back in
a register or memory.
AI 230 Dr. Ahmed Zakaria Spring 2025
Embedded
EmbeddedSystem
System
Central Processing Unit (CPU)
• Arithmetic logic unit (ALU): The ALU
provides the circuitry needed to perform
the arithmetic, logical and shift operations
demanded of the instruction set.
• It performs essential computations such as
addition, subtraction, multiplication, and
division, as well as logical operations like
AND, OR, XOR, and NOT.
• Modern processors may have multiple ALUs
to enhance performance by enabling
parallel processing of instructions.
AI 230 Dr. Ahmed Zakaria Spring 2025
Embedded
EmbeddedSystem
System
Central Processing Unit (CPU)
• Control unit (CU):
• Its primary function is to direct the
operation of the processor.
• The control unit is the entity responsible
for fetching the instruction to be
executed from the main memory and
decoding and then executing.
• The CU interprets instructions from the
computer's memory and converts them
into a sequence of control signals.
AI 230 Dr. Ahmed Zakaria Spring 2025
Embedded
EmbeddedSystem
System
Clock cycle
Clock and Clock cycle
• The clock in a CPU is a critical component that synchronizes the operations
of the processor and other parts of the computer system.
• It generates a series of regular electrical pulses, known as the clock signal.
• The clock ensures that all components of the CPU work in harmony by
providing a timing reference for the fetch-decode-execute cycle and other
operations.
AI 230 Dr. Ahmed Zakaria Spring 2025
Embedded
EmbeddedSystem
System
Clock cycle
Clock and Clock cycle
• The clock signal is generated by a clock generator,
which is typically a quartz crystal oscillator.
• This oscillator produces a stable and precise
frequency, ensuring that the CPU operates reliably.
AI 230 Dr. Ahmed Zakaria Spring 2025
Embedded
EmbeddedSystem
System
Clock cycle
Clock and Clock cycle
• The clock refers to a microchip that regulates the timing and speed of all
computer functions.
• A clock cycle is defined as the time interval between rising edges of a
repetitive clock signal.
• A computer processor or CPU (Central Processing Unit) speed is
determined by the clock cycle
AI 230 Dr. Ahmed Zakaria Spring 2025
Embedded
EmbeddedSystem
System
Clock cycle
Clock and Clock cycle
• The clock speed is measured in Hz, often either MHz (megahertz) or GHz
(gigahertz).
• For example, a 4 GHz processor performs 4,000,000,000 clock cycles per
second.
1 1
• 𝑐𝑦𝑐𝑙𝑒 𝑡𝑖𝑚𝑒 = = = 0.00000000025 = 0.25ns/cycle
𝑐𝑙𝑜𝑐𝑘 𝑐𝑦𝑐𝑙𝑒 4𝐺𝐻𝑧
AI 230 Dr. Ahmed Zakaria Spring 2025
Embedded
EmbeddedSystem
System
Example 1
A processor has a clock frequency of 2 GHz. Determine the duration of one
clock cycle and find out how many cycles it completes in 5 milliseconds.
Solution
a 2 GHz processor performs 2,000,000,000 clock cycles per second.
Clock Cycle Duration
1 1
• T(𝑐𝑦𝑐𝑙𝑒 𝑡𝑖𝑚𝑒) = = = 0.0000000005 = 0.5×10 −9 =0.5 ns/cycle
𝑓 2𝐺𝐻𝑧
Number of Cycles in 5 ms: −
3
5𝑥10
• = 2,000,000,000 x 5 x 10-3 = = 10 x 106 cycle
0.5×10 −9
AI 230 Dr. Ahmed Zakaria Spring 2025
Embedded
EmbeddedSystem
System
Example 2
A processor executes an instruction that takes 2 ns to complete. If the clock
cycle time is 0.5 ns, how many clock cycles does the instruction take?
Solution
• Clock Cycles = 𝐼𝑛𝑠𝑡𝑟𝑢𝑐𝑡𝑖𝑜𝑛 𝐸𝑥𝑒𝑐𝑢𝑡𝑖𝑜𝑛 𝑇𝑖𝑚𝑒
= 2 𝑛𝑠
= 4 cycles
𝐶𝑙𝑜𝑐𝑘 𝐶𝑦𝑐𝑙𝑒 𝑇𝑖𝑚𝑒 0.5 𝑛𝑠
AI 230 Dr. Ahmed Zakaria Spring 2025
Embedded
EmbeddedSystem
System
Example 3
A program consists of 1,000 instructions. Each instruction takes 4 clock cycles
to execute. If the processor operates at a clock frequency of 1 GHz, what is the
total execution time for the program?
Solution
a 1 GHz processor performs 1,000,000,000 clock cycles per second.
Clock Cycle Duration
1 1
• T(𝑐𝑦𝑐𝑙𝑒 𝑡𝑖𝑚𝑒) = = = 1 𝑛𝑠
𝑓 1𝐺𝐻𝑧
AI 230 Dr. Ahmed Zakaria Spring 2025
Embedded
EmbeddedSystem
System
Example 3
The total number of clock cycles
Total Clock Cycles=Number of Instructions × Clock Cycles per Instruction
=1,000×4
=4,000 cycles
the total execution time
Total Execution Time=Total Clock Cycles × T
= 4,000 × 1 ns
= 4,000 ns
= 4 microseconds (μs)
AI 230 Dr. Ahmed Zakaria Spring 2025
Embedded
EmbeddedSystem
System
Example 4
Processor A operates at 2 GHz and takes 3 clock cycles per instruction.
Processor B operates at 3 GHz and takes 2 clock cycles per instruction. Which
processor is faster, and by how much?
Solution
the clock cycle time for each processor
1 1
• TA = 𝑓 = = 0.5 𝑛𝑠
2𝐺𝐻𝑧
1 1
• TB = 𝑓 = = 0.333 𝑛𝑠
3𝐺𝐻𝑧
AI 230 Dr. Ahmed Zakaria Spring 2025
Embedded
EmbeddedSystem
System
Example 4
Solution
calculate the time per instruction for each processor:
• Processor A: Time per Instruction=3×0.5 ns=1.5 ns
• Processor B: Time per Instruction=2×0.333 ns=0.666 ns
Processor B is faster, and the speedup is:
1.5 𝑛𝑠
Speedup = = 2.25 times
0.66 𝑛𝑠
AI 230 Dr. Ahmed Zakaria Spring 2025
Embedded
EmbeddedSystem
System
Example 5
A program consists of 1 million instructions. The processor executes
instructions with an average CPI (Clock Cycles Per Instruction) of 2. The clock
frequency is 2.5 GHz. Calculate the total execution time.
Solution
The execution time is given by the formula:
𝑁𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝐼𝑛𝑠𝑡𝑟𝑢𝑐𝑡𝑖𝑜𝑛𝑠×𝐶𝑃𝐼 1𝑥 106 𝑥 2
CPU Time = = = 0.8 𝑚𝑠
𝑐𝑙𝑜𝑐𝑘 𝑓𝑟𝑒𝑞𝑢𝑒𝑛𝑐𝑦 2.5 𝐺𝐻𝑧
the execution time is 0.8 milliseconds (ms).
AI 230 Dr. Ahmed Zakaria Spring 2025
Embedded
EmbeddedSystem
System
Example 6
A program takes 5 ms to execute on a processor with a 2 GHz clock and
executes 10 million instructions. Find the Clock Cycles Per Instruction (CPI).
Solution
The execution time is given by the formula:
𝑐𝑙𝑜𝑐𝑘 𝑓𝑟𝑒𝑞𝑢𝑒𝑛𝑐𝑦 ×𝐶𝑃𝑈 𝑡𝑖𝑚𝑒
Clock Cycles Per Instruction CPI =
𝑁𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝐼𝑛𝑠𝑡𝑟𝑢𝑐𝑡𝑖𝑜𝑛𝑠
2𝑥 109 𝑥 5 𝑥 10−3
= =1
10 𝑥 106
AI 230 Dr. Ahmed Zakaria Spring 2025
Embedded
EmbeddedSystem
System
Example 7
A processor runs at 2 GHz and executes a program in 10 seconds. If the
processor is upgraded to 3 GHz, how long will the program take to execute
(assuming the same CPI and instruction count)?
Solution
Execution time is inversely proportional to clock speed
𝑂𝑙𝑑 𝐹𝑟𝑒𝑞𝑢𝑒𝑛𝑐𝑦
New Time = Old Time x
𝑁𝑒𝑤 𝐹𝑟𝑒𝑞𝑢𝑒𝑛𝑐𝑦
2𝑥 109
= 10 𝑥 9
= 6.66 𝑠𝑒𝑐
3𝑥 10
AI 230 Dr. Ahmed Zakaria Spring 2025
Embedded System
MICROPROCESSOR
VERSUS
MICROCONTROLLER
AI 230 Dr. Ahmed Zakaria Spring 2025
Embedded
EmbeddedSystem
System
Processors
• Up to now, we have used the general term “ processor ” for the entire
assortment of processing units containing some kind of CPU.
• A processor is a broad term that refers to any device or unit capable of
processing data.
• However, under the processor class, there are two distinct subclasses,
microprocessors and microcontrollers.
• This can include central processing units (CPUs), graphics processing units
(GPUs), digital signal processors (DSPs),
AI 230 Dr. Ahmed Zakaria Spring 2025
Embedded
EmbeddedSystem
System
Processors
• Digital signal processors (DSPs): DSPs are specialized for high-speed
numeric calculations and are often used for demanding tasks like audio
processing, telecommunications and image processing
• Graphics processing units (GPUs): GPU processors are specially
designed for the demanding task of rendering digital video and graphics
requiring high-powered performance and parallel processing.
• GPU rocessors are also commonly used in cryptocurrency mining and
are known for high power consumption.
AI 230 Dr. Ahmed Zakaria Spring 2025
Embedded
EmbeddedSystem
System
Processors
AI 230 Dr. Ahmed Zakaria Spring 2025
Embedded
EmbeddedSystem
System
Microprocessors
• A microprocessor is a specific type of processor that integrates the
functions of a CPU onto a single integrated circuit (IC).
• Microprocessors are widely used in personal computers, embedded
systems, and other electronic devices.
• first embedded systems were designed that were based on
microprocessors and a set of external memory and I/O devices.
AI 230 Dr. Ahmed Zakaria Spring 2025
Embedded
EmbeddedSystem
System
Microcontrollers (standard)
• A microcontroller is an integrated circuit containing a CPU, as well as an
interconnected set of memory devices, peripheral interface units,
timers/counters, etc.
• Hence, the microcontroller can take direct input from devices and sensors
and directly control external actuators.
• A modern microcontroller could contain the following set of PIUs and
memory devices:
• SRAM, EEPROM or Flash • Serial interface
• ADC • Timers and counters
• Direct - memory - access controller • Pulse - width modulators
• Parallel inputs and outputs • Watchdog timer
AI 230 Dr. Ahmed Zakaria Spring 2025
Embedded
EmbeddedSystem
System
Microcontrollers (standard)
• Essentially, a microcontroller is a small computer on a single chip
containing:
• Central processing unit (CPU): A processor core (or cores), Colloquially
referred to as the computer’s “brain,” the CPU is responsible for executing
instructions and controlling operations.
• Memory: Microcontrollers contain both volatile memory (RAM), which stores
temporary data that may be lost if the system loses power, and non-volatile
flash memory (ROM) for storing the microcontroller’s programming code.
• Peripherals: Depending on the intended application, a microcontroller may
contain various peripheral components, such as I/O interfaces, timers,
counters, analog-to-digital converters (ADCs) and communication protocols
(UART, SPI, I2C).
AI 230 Dr. Ahmed Zakaria Spring 2025
Embedded
EmbeddedSystem
System
Microcontrollers (standard)
• Microcontroller types
• 8-bit microcontrollers: The most basic type of microcontroller features limited
processing and memory and typically used in small appliances, such as toys and
remote controls.
• 16-bit microcontrollers: 16-bit microcontrollers are used for more complex
applications, including medical devices, automotive systems and industrial control
systems.
• 32-bit microcontrollers: The most powerful and feature-rich type of
microcontrollers, these are used for demanding applications, such as gaming
consoles, entertainment devices and high-end industrial automation.
AI 230 Dr. Ahmed Zakaria Spring 2025
Embedded
EmbeddedSystem
System
Microcontrollers (standard)
• Microcontroller types
• Reduced instruction set computer (RISC) microcontrollers: RISC microcontrollers
incorporate a design architecture that simplifies and improves operations by
executing fewer compute instructions faster than other methodologies, such as the
complex instruction set computer (CISC) architecture.
• ARM microcontrollers: Formerly an acronym for Advanced RISC Machines, these
types of microcontrollers incorporate the ARM architecture, including the modern
Arm Cortex subset, that bolster performance and reliability.
• Arm microcontrollers are widely used in mobile devices, automotive systems and
industrial control systems.
AI 230 Dr. Ahmed Zakaria Spring 2025
Embedded
EmbeddedSystem
System
Microcontrollers (standard)
• Microcontroller types
• PIC Microcontrollers: Developed by Microchip Technology, the PIC Microcontroller
is the world’s smallest microcontroller, and it is found frequently in robotics, home
and industrial automation and renewable energy systems.
• FPGA-based microcontrollers: Commonly used in applications necessitating digital
signal processing, video processing and high-speed networking, these
microcontrollers use customizable chips called field-programmable gate arrays
(FPGAs), which can be configured and reconfigured on the hardware level to create
unique hardware solutions for demanding processing requirements.
AI 230 Dr. Ahmed Zakaria Spring 2025
Embedded
EmbeddedSystem
System
Custom Microcontrollers
• A custom microcontroller, on the other hand, is specifically designed and
tailored for a particular application.
• These microcontrollers are either modified versions of existing
microcontrollers or entirely new designs created to meet specific
requirements such as power efficiency, specialized input/output interfaces,
or enhanced processing speed.
• Custom microcontrollers are commonly used in proprietary systems where
performance optimization and hardware-software integration are critical
AI 230 Dr. Ahmed Zakaria Spring 2025
Embedded
EmbeddedSystem
System
Microcontrollers vs. Microprocessors
AI 230 Dr. Ahmed Zakaria Spring 2025
Embedded
EmbeddedSystem
System
Microcontrollers vs. Microprocessors
Feature Microcontroller Microprocessor
Purpose Designed for specific, embedded applications. Designed for general-purpose
computing tasks.
Components Includes CPU, RAM, ROM, I/O ports, timers, Only includes the CPU;
ADC, etc., on a single chip. external components like RAM,
ROM, and I/O are required.
Cost Lower cost due to integrated components. Higher cost due to the need for
external components.
Power Low power consumption, ideal for battery- Higher power consumption,
Consumption operated devices. suitable for power-rich
environments.
AI 230 Dr. Ahmed Zakaria Spring 2025
Embedded
EmbeddedSystem
System
Microcontrollers vs. Microprocessors
• Top 8-bit Microcontrollers (MCU) Manufacturers in the World
AI 230 Dr. Ahmed Zakaria Spring 2025
Embedded
EmbeddedSystem
System
Thank You
AI 230 Dr. Ahmed Zakaria Spring 2025