Beruflich Dokumente
Kultur Dokumente
· This chapter covers the following main topics:
o The components of the CPU
o The concept of Registers
o The memory unit and its operations
o The fetch-execute instruction cycle
o Instruction format
o Classification of instructions
Introduction
· This chapter and the next few chapters extents the Little Man Computer model to discuss the real
computer hardware architecture
· This chapter covers, in particular, both the Central Processing Unit (CPU) and Memory
· CPUs varies in their capabilities, complexity, and even applications
· The CPU model covered in this chapter is not based on any particular model
· Memory is separated both physically and functionally from the CPU
· The CPU and memory are very closely associated
o Every instruction the CPU executes requires at least one, and possibly more, memory
access
· Memory is responsible for temporarily holding instructions and data during program execution
· Data and instructions in memory are immediately available to the CPU
· Memory is connected to the CPU through special system bus
· Memory consists of linear storage cells
· Each cell is capable of storing a single data unit
· In most modern computers, the cell size is 1 byte (i.e. smallest addressable data unit)
· Memory cells are usually grouped to store large data unit (e.g. integer number)
· A memory cell is referenced by its address
· Each address is a unique unsigned integer number, starting at address 0
· All memory cells are identical in their purpose (e.g. store general purpose data)
The Operation of Memory
· The MAR and MDR registers acts as an interface between the CPU and memory
· MAR
o Holds the address in memory which to be open for data access
o Connected to address decoder that resolves the memory address to be accessed
· Address decoder
o Interpret the address passed from MAR to identify the address to be accessed
o Activate the appropriate address line in memory for access
· MDR
o MDR is data holding register during memory access
o Store the content of memory that is currently addressed by MAR in case of read
o Store the data to be stored into memory in case of write
o The word size that can be retrieved or stored into memory in a single operation is
determined by the size of MDR
· There are 3 control lines that controls memory access, see Figures 7.4 - 7.7 in pages 154 - 157
o Address line
§ There is 1 address line for every memory cell
§ An address line for a particular cell is turned only when addressing data within
that cell
o Read/write line
§ Determines whether the memory access is a read or a write operation
§ Turned on in case of read and off in case of write
o Activation line
§ Used to control the memory access operation
§ Turned on to start a memory access operation (i.e. read or write)
· See Figure 7.6 in page 172 to see how memory access is done
· The following are the steps taken to load data from a particular memory location (read
operation)
1. CPU copies the address of memory to be accessed into MAR
2. CPU sets the Read/Write switch on to indicate a read operation
3. CPU sets Activation line on to start the data transfer
4. Data transfer takes place retrieving data from the specified memory location and store it
into the MDR register
5. Data is copied from the MDR into another register depending on the type of read data
· The following are the steps taken to store data into a particular memory location (write
operation)
1. CPU copies the address of memory to be accessed into MAR
2. CPU copies data into MDR
3. CPU sets the Read/Write switch off to indicate a write operation
4. CPU sets Activation line on to start the data transfer
5. Data transfer takes place to store data into the specified memory location
· Only one memory location is addressed at any given time to prevent conflict
Memory Capacity
· The size of the MAR register is the main determining factors of the addressable physical memory
o Memory Capacity = 2n where n is the MAR size in bits
· In today’s computer a typical MAR is at least 32-bits which allows 4GB of memory addressing
· Many modern CPUs supports 64-bits which allows 264 = 16 x 1018 bytes of memory addressing
· In these computers the actual limiting factor for memory capacity would be
o Physical space for fitting large number of memory chips
o Time requirement for decoding and accessing such a huge memory
Memory Implementations
· The most popular types of memory in use by computers are
o Magnetic core memory
o Static RAM
o Dynamic RAM
o Read Only Memory (ROM)
Magnetic Core Memory
· Magnetic core memory is an old technology supporting non-volatile storage (i.e. data is
maintained after power is turned off)
· Magnetic core memory is expensive and slow and has been mostly replaced by RAM
· Few special purpose computers still uses this type of memory where non-volatile storage is
required
RAM
· Most current computers uses either static or dynamic RAM
· Both static and dynamic RAM are volatile and writeable (i.e. data is lost when power is turned
off)
· Dynamic RAM advantages over Static RAM:
o Less Expensive
o Requires less power
o Can be made smaller (i.e. can be made to fit more memory in a single chip)
· Static RAM advantages over Dynamic RAM
o Does not need periodic refreshing
o Faster access time (Static memory is what cache memory is made of)
· Dynamic RAM is more popular than static RAM
· The size of memory in a single dynamic RAM chip has increased significantly in the last few
years (from fewer than 64KB to over 64 MB)
ROM
· Supports non-volatile storage
· Read only (i.e. data never changes)
· Mostly used to store system programs and data used at computer starts up (i.e. boot time)
· Modern ROM is made so it can be erased and reprogrammed in the factory
· However within the computer ROM is still read only
EEPROM and Flash ROM
· Recent memory innovation supporting non-volatile and writeable memory
· Typically slower than ROM
The Fetch-Execute Instruction Cycle
· The fetch-execute cycle in a real computer works very similar to the one for LMC
· The fetch-execute instruction cycle is a 2 phase process
1. Fetch phase fetch an instruction from memory for execution
2. Execute phase execute the instruction
· The fetch phase is consistent and follow the same steps for all types of instructions
· The fetch phase consists of the following steps:
1. Copy content of PC to MAR – this result in transferring the instruction located at the
specified address to the MDR register
2. Copy content of MDR into IR
3. Decode the instruction
· The execution phase varies between the different instructions
· The LOAD instruction execution steps
1. Copy address specified in the instruction to MAR
2. Copy content of MDR register into a general-purpose register
3. Increment the PC register
· A special notation is used to describe the fetch-and-execute phase steps for instruction execution
REGa → REGb transfer data from one register to another
REG[address] → REGb transfer the address part of the register content to another register
REGa + REGb → REGc add content of two registers and store result into a third register
REGa + const → REGb add content of register to constant and store result into a third
register
Examples
· The LMC STORE instruction fetch-execute steps
1. PC → MAR
2. MDR → IR
3. IR[address] → MAR
4. A → MDR
5. PC + 1 → PC
· The LMC ADD instruction fetch-execute steps
1. PC → MAR
2. MDR → IR
3. IR[address] → MAR
4. A + MDR → A
5. PC + 1 → PC
· The LMC BR instruction fetch-execute steps
1. PC → MAR
2. MDR → IR
3. IR[address] → PC
Buses
· A bus is the physical interface to interconnect the different components within the computer
system
· This topic will be covered in more details in chapter 8
· The instruction set format in a typical real CPU is similar to the one supported by the LMC
· The instruction word format is divided into 2 parts
o Op code
o Address fields
· See Figure 7.14 in page 184 for an example 32-bit instruction format
· The address field may refer to register address, memory address or constant data
· Two types of addresses are defined
o Source address
o Destination address
· The source and destination addresses are also called operands
· The address may be expressed
o Explicitly as an address field in the instruction word
o Implicitly as part of the definition of the instruction (i.e. no address field is necessary)
· On some computers one or more of the addresses may be implicit
· In modern computers most address references are explicit
· Instructions with 1 address field are called unary instruction
· Instructions with 2 address fields are called binary instruction
· Instructions with 3 address fields are called ternary instruction
· The source(s) and destination addresses may be the same or may be different
· Example of instruction with the same source and destination is a complement of a register content
· The ADD instruction in LMC uses the accumulator register as both source for one of the numbers
and as the destination for the result
· The MOVE instruction obviously uses different source and destination addresses
Classification of Instructions