CS代写 PIC18 is an 8-bit microcontroller, which has a data bus consisting of 8 wir

Chapter 1 Introduction To Computer Systems
Computer Organization
Address Bus Data Bus Control Bus
Memory Unit

Copyright By PowCoder代写 加微信 powcoder

Input/Output (I/O) Unit 2

1.1 Data Transfer in Computer
Data Transfer
• CPU is connected to memory and I/O through strips of wire called a bus.
• The CPU transfers data to or from a selected memory location by:
– Activating the selected memory by putting the address of the selected memory onto the address bus.
– Sending a control signal (READ/WRITE) to indicate the direction of the transfer (via control bus).
– The CPU waits until the transfer has been completed (data transfers via data bus).

• Buses are used to communicate between the computer components.
– Data Bus
– Address Bus – Control Bus
• The CPU puts the address on the address bus, and the decoding circuitry finds the device (i.e., Unidirectional)
• The CPU uses the data bus either to get data form that device or to send data to it (i.e., Bidirectional)
• The control buses are used to provide read or write signals.
• The address bus and data bus determine the capacity of a given CPU.

Memory Read Operation – Step 1
Memory Read Operation – Step 2

Memory Read Operation – Step 3
Address Bus
• Size of address buses is larger, the larger the number of devices and memory locations that can be addressed.
– Example:8 bits (small), 16 bits, 32 bits, 64 bits (large).
– A 16-bit address bus is associated with 216=64K addressable memory locations.
– Independent of the size of the data bus. • Unidirectional

Address Bus
Add. lines
Number of memory locations
216 =65536=64K 220 =1048576=1M 224 =16777216=16M 232 =4294967296=4G
264 = 18 446 744 073 709 551 616 = 16 EiB (1018)
Example on Address Bus
0000 0000 0000 0000
0000 000F FFFF FFFF
FFFF FFFF FFFF FFFF

Size Of Memory System
• Nibble = 4 bits
• Byte = 8 bits
• Kilobyte = 210 (1,024) bytes
• Megabyte = 220 (1,048,576) bytes
• Gigabyte = 230 (1,073,741,824) bytes
• Data bus carries data in and out of the CPU (bi-directional).
• The number of wires in the data bus usually depend on the word size that the CPU operates with.
• PIC18 is an 8-bit microcontroller, which has a data bus consisting of 8 wires.

Answer the following questions:
• A given computer has a 2-bit data bus. What is the largest unsigned number that can be carried into the CPU at a time? How about a 32-bit data bus?
• Assuming each memory location contains a byte, find the total amount of memory that can be addressed by a 3-bit address bus. How about a 32-bit address bus?
Memory Read Operation – Step 1

Memory Read Operation – Step 2
Memory Read Operation – Step 3

Memory Write Operation – Step 1
Memory Write Operation – Step 2

Memory Write Operation – Step 3
1.2 Computer Components

The Memory Unit
• Store programs and data.
• Arranged sequentially into units.
• Each unit is referred as a memory location and identified by a unique address.
• The larger the number of address bits, the larger the number of memory locations that can be addressed.
• e.g., 20 address bits  220 = 1,048,576 locations
• Program and data may share the same memory space or they may be separated.
Input/Output (I/O) Unit
• Handles the transfer of data between the computer and external devices or peripherals.
• Each unit is identified by a unique address.
• The physical devices used to communicate
are called ports.
• The equipment for data input/output from
outside world is called peripheral.
• Typical peripherals are keyboard, video monitor, mouse, printer, disks, tape and CD- ROM drive.

Central Processing Unit (CPU)
• The CPU controls the sequence of operation of the computer.
• Made up for 3 components: – Arithmetic-Logic Unit (ALU) – Registers
– Control Unit
Arithmetic-Logic Unit (ALU)
• Performs arithmetic or logic operation on data
• Common operations:
– Arithmetic operations: addition, subtraction, multiplication and division.
– Shifting operations
– Logic operations: AND, OR, Exclusive-OR etc.

Registers in CPU
• Temporary storage within a processor.
• Not all registers can be accessed by users.
• Some are special-purpose and some are general-purpose.
Types of Registers in CPU
• Accumulator:Principleregisterforarithmeticand logical operations. Normally used to store an operand prior to computation and the result after computation.
• ProgramCounter(PC):holdsthememoryaddress of the next instruction to be executed.
• InstructionRegister(IR):holdstheinstructionthat is currently being executed.
• Stack&StackPointer:Stackholdsthereturn address of subroutine calls. Stack pointer holds the top address of the stack.
• STATUS:asetofone-bitflagsthattheprocessor sets or clears during the execution of each instruction.

Status Register
• N (Negative Bit): Turns 1 if arithmetic result is negative
• OV (Overflow Bit): Turns 1 if overflow occurred for signed arithmetic
• Z (Zero Flag): Turns 1 if the result of an arithmetic/logic operation is zero
• DC (Digit carry bit): Turns 1 if a carry-out from the 4th low-order bit occurred.
• C (Carry bit): Turns 1 if a carry-out from the MSB occurred
Example: Unsigned Addition
C = 0: No carry beyond MSB
DC = 1: A carry from the first and second nibble (4 bits)
Z = 0: The result of addition is not zero
38 + 2F 67

Example: Use of the Carry Bit
• 16-bit addition
34 32 +57 DF
Control Unit
• Controls the processing of an instruction
• Brain of the brain
• The control unit consists of:
– Circuitry for generating the timing and control signals
– Instruction decoder to decode instruction

Instruction Processing
• The processing of an instruction is done in an instruction cycle.
• The CPU (Control Unit + ALU) does 4 things in each instruction cycle:
1. The control unit fetches (gets) the instruction from memory.
2. The control unit decodes the instruction and move data to ALU.
3. ALU executes the instruction.
4. ALU stores the result in memory.
2, 3, 4 are collectively referred to as execution
Fetching and Decoding in Control Unit
• Instruction Fetching
1. The control unit places the content of the program counter on the address bus in order to fetch an instruction from memory.
2. The program counter is incremented.
3. The control unit places the instruction in the instruction register (IR).
• Instruction Decoding
– The instruction decoder identifies:
1. the operation specified in IR.
2. the address of the source operands and the results.

Harvard vs von
• von Neumann – uses the same address and data bus for program and data memories.
• Harvard – uses different address and data buses to access program and data memory.
• von Neumann architecture is slow because program and data memories cannot be accessed simultaneously.
• Implementing Harvard architecture is expensive.

Von is Slow
30 30 30 30 30 30 30 30

Advantage of Harvard Architecture
30 30 30 30 30
Disadvantage of Harvard Architecture
• Pentium μP with 64-bit data bus and 32-bit address bus needs about 100 wires.
• Number of wires is doubled for Harvard architecture.

1.3 Microprocessor, Microcontroller and Embedded System
Microprocessor
• A CPU implemented on a very large scale integration (VLSI) chip
• Needs peripheral chip to interface with with I/O devices
• No RAM, ROM, I/O on CPU chip itself
• A personal computer is a microprocessor

Microcontroller
• The CPU and peripheral functions implemented on one VLSI chip
• It gives rise to embedded system
Microprocessor vs. Microcontroller
Microprocessor
Microcontroller
• CPU is stand-alone, RAM, • ROM, I/O, timer are
CPU, RAM, ROM, I/O and timer are all on a single chip
• Designer can decide on the amount of ROM, RAM and the number of I/O ports.
• General-purpose
• Expensive
• Less emphasis on real-
time reaction
• Fix amount of on-chip ROM, RAM, I/O ports
• Single-purpose
• For applications in which cost, power and space are critical
• Real-time reaction to events

You should be able to …
• Describe the purpose of the major components of a computer system.
• List the three types of buses found in computers and describe the purpose of each type.
• Describe the major components of CPU and their functions in a computer system.
• Describe the differences between Harvard and von Neumann architecture.
• Describe the difference between a microcontroller and a microprocessor.

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com