Uploaded by Ahmad Burnat

qustions-solutions by jamal

advertisement
Q1. What are the differences between embedded systems and generalpurpose
computers?
•
•
Reliability and Stability: Embedded systems are expected to be highly reliable and stable
, they are engineered to minimize errors and downtime
Fixed or Changeable Functionality: embedded systems have fixed functionality and
cannot be easily updated or modified once deployed
• Minimal User Interface: : Embedded systems have minimal or no user interface, and User
interaction is limited
•
•
•
•
•
•
Long Lifecycle: Embedded systems have a longer lifecycle
Cost Constraints:
Real-time Operation: Many embedded systems are required to operate in real-time,
Resource Constraints: Embedded systems have limited resources.
Integration: Embedded systems are often integrated into larger systems or devices
Efficiency: Embedded systems are designed to be highly efficient in terms of power
consumption and performance.
Q2. Draw a block diagram of a microcontroller system and explain the
purpose of each
component.
Microprocessor unit: it acts like the brain of microcontroller ,its function is to execute programs
stored in main memory by fetching there instructions ,examining them(decode) and then
execute
Memory: is used to store the data that the processor receives and uses to respond to
instructions that it's been programmed to carry out and there is two types:
1- program memory: stores long-term information about the instructions that the CPU carries
out , and its non-volatile
2- data memory: d for temporary data storage while the instructions are being executed, and
its volatile.
I/O ports: the interface for the processor to the outside world,they are separet circuits that
enable microcontroller to interface with sensors,accuaters.ext.
Supporting devices: like
• Analog to Digital Converter (ADC): It allows the processor at the center of the microcontroller
to interface with external analog devices, such as sensors
• Digital to Analog Converter (DAC) : to communicate its outgoing signals to external analog
components.
• Serial port: an I/O port that allows the microcontroller to connect to external components
Q4. Mention the main differences between Intel and ARM instruction set architectures?
intel
Its cisc, has larger instructions ,more
operations, more addressing modes ,
Fewer registers, mainly used in normal PCs,
workstations, and servers.
ARM
RISC
simplified instruction set (100 instructions or
less),
more general-purpose registers than CISC,
uses instructions that operate only on
registers and uses a Load/Store
Q5. Explain how the data and instructions move between different
components inside an
ARM based microcontroller.
• Program Counter (PC): stores the address of the next instruction*
• The incrementer: is used to increment the value of stored PC
• MAR (memory address register): store memory that currently be accessed inside RAM
• MDR/MBR (memory data/buffer register): store data from memory
• General-purpose registers: General-purpose registers hold either data or an address
• Instruction register (IR): Stores the instruction currently being executed
1. Fetching Instructions
Program Counter (PC): The Program Counter holds the address of the next instruction to be
executed. It sends this address to the memory to fetch the instruction.
Memory (Flash or ROM): The instruction is stored in the flash memory (ROM). The address from
the PC is used to retrieve the instruction and send it to the Instruction Register (IR).
2. Decoding Instructions
Instruction Register (IR): The fetched instruction is stored in the IR.
Instruction Decoder: The instruction decoder interprets the instruction stored in the IR to
determine what operation needs to be performed.
3. Executing Instructions
Control Unit: The control unit generates the necessary control signals based on the decoded
instruction to direct the data flow and the operations of the ALU (Arithmetic Logic Unit),
registers, and other components.
Registers: Depending on the instruction, data may be read from or written to the generalpurpose registers (R0-R15) or special-purpose registers (like the Status Register).
ALU (Arithmetic Logic Unit): For arithmetic or logical operations, the ALU performs the required
computation based on the control signals and operands provided by the registers.
Q6. What are the differences between program memory and data
memory?
1- program memory: stores long-term information about the instructions that the CPU carries
out , and its non-volatile
2- data memory: d for temporary data storage while the instructions are being executed, and
its volatile.
Q7. What is the AHB-Lite bus and how does it work?
Advanced High-performance Bus and there is four external ones in the processor:
1. ICode memory interface
2. DCode memory interface
3. System interface
4. Private Peripheral Bus (PPB)
Q8. What do we mean by memory space?
the addressable range of memory locations that a computer or microcontroller can
access
Q9. What does the term “load-store architecture” imply?.
a type of computer architecture where the CPU can only perform operations on data
that are in registers (data must be loaded from memory into registers before any
arithmetic or logical operations can be performed on it, and results must be stored
back into memory from registers).
Q10. Define the purposes of the following registers in ARM cortex
processor
a. R0-R12 general purpose registers : can be used as operands for ARM
instructions
b. Stack-pointer : it is used for accessing the stack memory via PUSH and POP
operations
c. Link register : a special-purpose register which holds the address to return to when a
function call completes.
d. Program counter: has the address of the next instruction to be executed from
memory
Q12. Explain the different addressing modes in ARM, give an example
of each addressing mode.
immediate addressing offset: The offset is an unsigned number that can be added to or
subtracted from the base register
useful for accessing data elements that are a fixed distance from the start of the data object,
LDR R0, [R1, #4]
register addressing offset:
The offset is a value from a general-purpose register This register cannot be the PC.
LDR R0, [R1, R2]
Scaled register-indexed addressing offset:
The offset is a general-purpose register, other than the PC, shifted by an immediate value,
then added to or subtracted from the base
LDR R8, [R9, R10, LSL #2]
Q13. Could you describe the instruction format in ARM architecture?
op-code is a part of the instruction that tells the processor what should be done
Operand is a part of the instruction that contains the data to be acted on, or the memory
location
ARM instructions commonly take two or three operands
Q14 q15.
Answerd in Q2
Q16. Define the instruction execution cycle.
The CPU executes each instruction in a series of small steps. It fetches the next instruction
from memory, determines the type of instruction, and then executes the instruction.
This process is repeated for as long as the computer is powered.
This sequence of steps is frequently referred to as the instruction execution cycle
Q17. What does “pipelining” in microprocessor mean?
a technique that allows the CPU to work on multiple instructions at the same time by
breaking down the execution process into smaller steps, or stages
Q19. How can you define the term “Architecture” in the context of
microprocessor
system?
refers to the design and structure of the microprocessor, defining how it processes
instructions, manages data, and interacts with memory
The instruction set architecture (ISA): describes the instructions that the computer can
execute
Microarchitecture: refers to the way in which the ISA is implemented in hardware
system architecture ; describes the complete system including the processor, memory,
busses and peripheral.
Q21. Why does data alignment mean?
Putting the data in memory at an address equal to some multeble of word size.
Q23. Suppose you have a memory cell consisting of 16-bit, what is the
minimum width of the address bus required to express all bits of a 512bit memory?
Each memory cell is 16 bits wide.
The total memory size is 512 bits.
Number of memory cells = Total memory size / Size of each memory cell
Number of memory cells = 512 bits / 16 bits per cell = 32
2^5 = 32➔ n = 5
Initial Values
- var1 at address 0x20000000: 0x1
- var2 at address 0x20000004: 0x2
- var3 at address 0x20000008: 0x3
- var4 at address 0x2000000C: 0x4
Program:
1. MOV R1, #0x200
-R1 = 0x200
2. LSL R1, #16
R1 = 0x200 << 16 = 0x2000000
0000 0000 0000 0000 0000 0000 0010 0000
0000 0000 0010 0000 0000 0000 0000 0000 = 0x02000000
3. ORR R2, R1, #0x4
R1 = 0x2000000
R2 = 0x2000000 | 0x4
0000 0000 0010 0000 0000 0000 0000 0000
Or
0000 0000 0000 0000 0000 0000 0000 0100
= 0x2000004
4. LDR R3, [R1, #4]
Load the value from the memory address (R1 + 4) into R3.
R1 = 0x2000000, so the address is 0x2000000 + 0x4 = 0x2000004.
The value at address 0x2000004 is var2, which is 0x2.
R3 = 0x2
5. MOV R0, #0x4
R0 = 0x4
6. CMP R0, R2
Compare R0 with R2.
R0 = 0x4
R2 = 0x2000004
7. BLT skip1
- Branch if R0<R2 .
- R0 (0x4) is less than R2 (0x2000004), so branch to skip1.
8. skip1
Branch was taken, so the following instructions are skipped:
ADD R4, R0, #0x4
- B skip2
Execute the code at skip1:
MOV R1, #0x200
R1 = 0x200
STR R0, [R1]
Store the value of R0 (which is 0x4) at the address R1 (which is 0x200).
Address 0x200 does not match the given variable addresses (0x2000000,
0x2000004, 0x2000008, 0x200000C), so no variable is affected.
- BX LR
- Return from the subroutine.
Since the branch was taken to skip1, the code at skip2 is not executed,
and the program ends after executing the instructions under skip1.
Final Register Values
- R0 = 0x4
- R1 = 0x200
- R2 = 0x2000004
- R3 = 0x2
- R4 = (not assigned any value in the executed path)
var1 (at address 0x20000000) = 0x1 (unchanged)
var2 (at address 0x20000004) = 0x2 (unchanged)
var3 (at address 0x20000008) = 0x3 (unchanged)
var4 (at address 0x2000000C) = 0x4 (unchanged)
Download