Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Memory Organization and Access in Computer Systems, Lecture notes of Logic

Various memory registers and concepts in CPU design, including Memory Address Register (MAR), Memory Buffer Register (MBR), Instruction Register, Stack Control Register, primary memory, secondary memory, and different modes of addressing. It also discusses the concepts of CISC and RISC, cache memory, and associative memory.

Typology: Lecture notes

2021/2022

Uploaded on 09/27/2022

flowersintheair
flowersintheair 🇬🇧

4.2

(11)

272 documents

1 / 33

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
INTROCTION ABOUT CPU, REGISTERS AND MEMORY, GENERAL REGISTER
ORGANIZATION
A central processing unit (CPU) is the electronic circuitry within a computer that carries out
the instructions of a computer program by performing the basic arithmetic, logical, control
and input/output (I/O) operations specified by the instructions.
A register may hold an instruction, a storage address, or any kind of data (such as a bit
sequence or individual characters). Some instructions specify registers as part of the
instruction. For example, an instruction may specify that the contents of two defined registers
be added together and then placed in a specified register.
Registers are the most important components of CPU. Each register performs a specific
function. A brief description of most important CPU's registers and their functions are given
below:
1. Memory Address Register (MAR): This register holds the address of memory where
CPU wants to read or write data. When CPU wants to store some data in the memory or reads
the data from the memory, it places the address of the required memory location in the MAR.
2. Memory Buffer Register (MBR): This register holds the contents of data or instruction
read from, or written in memory. The contents of instruction placed in this register are
transferred to the Instruction Register, while the contents of data are transferred to the
accumulator or I/O register. In other words you can say that this register is used to store
data/instruction coming from the memory or going to the memory.
3. Program Counter (PC): Program Counter register is also known as Instruction Pointer
Register. This register is used to store the address of the next instruction to be fetched for
execution. When the instruction is fetched, the value of IP is incremented. Thus this register
always points or holds the address of next instruction to be fetched.
4. Instruction Register (IR): Once an instruction is fetched from main memory, it is stored
in the Instruction Register. The control unit takes instruction from this register, decodes and
executes it by sending signals to the appropriate component of computer to carry out the task.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21

Partial preview of the text

Download Memory Organization and Access in Computer Systems and more Lecture notes Logic in PDF only on Docsity!

INTROCTION ABOUT CPU, REGISTERS AND MEMORY, GENERAL REGISTER

ORGANIZATION

A central processing unit (CPU) is the electronic circuitry within a computer that carries out the instructions of a computer program by performing the basic arithmetic, logical, control and input/output (I/O) operations specified by the instructions.

A register may hold an instruction, a storage address, or any kind of data (such as a bit sequence or individual characters). Some instructions specify registers as part of the instruction. For example, an instruction may specify that the contents of two defined registers be added together and then placed in a specified register.

Registers are the most important components of CPU. Each register performs a specific function. A brief description of most important CPU's registers and their functions are given below:

  1. Memory Address Register (MAR): This register holds the address of memory where CPU wants to read or write data. When CPU wants to store some data in the memory or reads the data from the memory, it places the address of the required memory location in the MAR.
  2. Memory Buffer Register (MBR): This register holds the contents of data or instruction read from, or written in memory. The contents of instruction placed in this register are transferred to the Instruction Register, while the contents of data are transferred to the accumulator or I/O register. In other words you can say that this register is used to store data/instruction coming from the memory or going to the memory.
  3. Program Counter (PC): Program Counter register is also known as Instruction Pointer Register. This register is used to store the address of the next instruction to be fetched for execution. When the instruction is fetched, the value of IP is incremented. Thus this register always points or holds the address of next instruction to be fetched.
  4. Instruction Register (IR): Once an instruction is fetched from main memory, it is stored in the Instruction Register. The control unit takes instruction from this register, decodes and executes it by sending signals to the appropriate component of computer to carry out the task.
  1. Accumulator Register: The accumulator register is located inside the ALU; it is used during arithmetic & logical operations of ALU. The control unit stores data values fetched from main memory in the accumulator for arithmetic or logical operation. This register holds the initial data to be operated upon, the intermediate results, and the final result of operation. The final result is transferred to main memory through MBR.
  2. Stack Control Register: A stack represents a set of memory blocks; the data is stored in and retrieved from these blocks in an order, i.e. First In and Last Out (FILO). The Stack Control Register is used to manage the stacks in memory. The size of this register is 2 or 4 bytes.
  3. Flag Register: The Flag register is used to indicate occurrence of a certain condition during an operation of the CPU. It is a special purpose register with size one byte or two bytes. Each bit of the flag register constitutes a flag (or alarm), such that the bit value indicates if a specified condition was encountered while executing an instruction.

For example, if zero value is put into an arithmetic register (accumulator) as a result of an arithmetic operation or a comparison, then the zero flag will be raised by the CPU. Thus, the subsequent instruction can check this flag and when a zero flag is "ON" it can take an appropriate route in the algorithm.

Memory This unit can store instructions, data, and intermediate results. This unit supplies information to other units of the computer when needed. It is also known as internal storage unit or the main memory or the primary storage or Random Access Memory (RAM). Its size affects speed, power, and capability. Primary memory and secondary memory are two types of memories in the computer. Functions of the memory unit are −

  1. It stores all the data and the instructions required for processing.
  2. It stores intermediate results of processing.
  3. It stores the final results of processing before these results are released to an output device.
  4. All inputs and outputs are transmitted through the main memory.

General Register organization

Generally CPU has seven general registers. Register organization show how registers are selected and how data flow between register and ALU. A decoder is used to select a

Binary code SELA SELB SELD or SELREG

000 Input Input ---

001 R1 R1 R

010 R2 R2 R 011 R3 R3 R

100 R4 R4 R 101 R5 R5 R

110 R6 R6 R 111 R7 R7 R

Operation with symbol Operation selection code Operation symbol

0000 Transfer A TSFA

0001 Increment A INC A

0010 A+B ADD

0011 A-B SUB

0100 Decrement A DEC

0101 A AND B AND

0110 A OR B OR

0111 A XOR B XOR

1000 Complement A COMA

1001 Shift right A SHR

1010 Shift left A SHL

What is CONTROL WORD?

  • The combined value of a binary selection inputs specifies the control word.
  • It consists of four fields SELA, SELB, and SELD or SELREG contains three bit each and SELOPR field contains four bits thus the total bits in the control word are 13-bits.

SEL A SELB SELREG OR SELD SELOPR

FORMATE OF CONTROL WORD

  1. The three bit of SELA select a source registers of the input of the ALU.
  2. The three bits of SELB select a source registers of the b input of the ALU.
  3. The three bits of SELED or SELREG select a destination register using the decoder.
  4. The four bits of SELOPR select the operation to be performed by ALU.

CONTROL WORD FOR OPERATION R2 = R1+R

SEL A SEL B

SEL D OR

SELREG SELOPR

Note: Control words for all micro operation are stored in the control memory Example:

MICROOPERATIO

N

SE

L A

SE

L B

SEL D

OR

SELRE

G

SELOP

R CONTROL WORD

R2 = R1+R3 R1 R3 R2 ADD 1 1 0 0

DAY 3-10 STACK ORGANIZATION, INSTRUCTION FORMAT &ADDRESSING

MODE

hardware-implemented instructions, specify their binary code format, and provide a precise definition of each instruction. A computer will usually have a variety of instruction code formats. It is the function of the control unit within the CPU to interpret each instruction code and provide the necessary control functions needed to process the instruction.

The format of an instruction is usually depicted in a rectangular box symbolizing the bits of the instruction as they appear in memory words or in a control register. The bits of the instruction are divided into groups called fields. The most common fields found in instruction formats are:

  1. An operation code field that specifies the operation to be performed.
  2. An address field that designates a memory address or a processor registers.
  3. A mode field that specifies the way the operand or the effective address is determined.

Computers may have instructions of several different lengths containing varying number of addresses. The number of address fields in the instruction format of a computer depends on the internal organization of its registers. Most computers fall into one of three types of CPU organizations:

1 Single accumulator organization. 2 General register organization. 3 Stack organization.

THREE-ADDRESS INSTRUCTIONS Computers with three-address instruction formats can use each address field to specify either a processor register or a memory operand. The program in assembly language that evaluates X = (A + B) ∗ (C + D) is shown below, together with comments that explain the register transfer operation of each instruction. ADD R1, A, B R1 ← M [A] + M [B] ADD R2, C, D R2 ← M [C] + M [D] MUL X, R1, R2 M [X] ← R1 ∗ R It is assumed that the computer has two processor registers, R1 and R2. The symbol M [A] denotes the operand at memory address symbolized by A. The advantage of the three-address format is that it results in short programs when evaluating arithmetic expressions. The disadvantage is that the binary-coded instructions

require too many bits to specify three addresses. An example of a commercial computer that uses three-address instructions is the Cyber 170. The instruction formats in the Cyber computer are restricted to either three register address fields or two register address fields and one memory address field.

TWO-ADDRESS INSTRUCTIONS Two address instructions are the most common in commercial computers. Here again each address field can specify either a processor register or a memory word. The program to evaluate X = (A + B) ∗ (C + D) is as follows: MOV R1, A R1 ← M [A] ADD R1, B R1 ← R1 + M [B] MOV R2, C R2 ← M [C] ADD R2, D R2 ← R2 + M [D] MUL R1, R2 R1 ← R1∗ R MOV X, R1 M [X] ← R The MOV instruction moves or transfers the operands to and from memory and processor registers. The first symbol listed in an instruction is assumed to be both a source and the destination where the result of the operation is transferred.

ONE-ADDRESS INSTRUCTIONS One-address instructions use an implied accumulator (AC) register for all data manipulation. For multiplication and division there is a need for a second register. However, here we will neglect the second and assume that the AC contains the result of tall operations. The program to evaluate X = (A + B) ∗ (C + D) is LOAD A AC ← M [A] ADD B AC ← A [C] + M [B] STORE T M [T] ← AC LOAD C AC ← M [C] ADD D AC ← AC + M [D] MUL T AC ← AC ∗ M [T] STORE X M [X] ← AC All operations are done between the AC register and a memory operand. T is the address of a temporary memory location required for storing the intermediate result.

organized computer are implied-mode instructions since the operands are implied to be on top of the stack.

2 Immediate Mode: In this mode the operand is specified in the instruction itself. In other words, an immediate mode instruction has an operand field rather than an address field. The operand field contains the actual operand to be used in conjunction with the operation specified in the instruction. Immediate-mode instructions are useful for initializing registers to a constant value. It was mentioned that the address field of an instruction may specify either a memory word or a processor register. When the address field specifies a processor register, the instruction is said to be in the register mode.

3 Register Mode: In this mode the operands are in registers that reside within the CPU. The particular register is selected from a register field in the instruction. A k-bit field can specify any one of 2k registers.

4 Register Indirect Mode : In this mode the instruction specifies a register in the CPU whose contents give the address of the operand in memory. In other words, the selected register contains the address of the operand rather than the Op code Mode Address operand itself. Before using a register indirect mode instruction, the programmer must ensure that the memory address for the operand is placed in the processor register with a previous instruction. A reference to the register is then equivalent to specifying a memory address. The advantage of a register indirect mode instruction is that the address field of the instruction uses fewer bits to select a register than would have been required to specify a memory address directly.

5 Auto increment or Auto decrement Mode: This is similar to the register indirect mode except that the register is incremented or decremented after (or before) its value is used to access memory. When the address stored in the register refers to a table of data in memory, it is necessary to increment or decrement the register after every access to the table. This can be achieved by using the increment or decrement instruction. However, because it is such a common requirement, some computers incorporate a special mode that automatically increments or decrements the content of the register after data access. The address field of an instruction is used by the control unit in the CPU to obtain the operand from memory. Sometimes the value given in the address field is the address of the operand, but sometimes it

is just an address from which the address of the operand is calculated. To differentiate among the various addressing modes it is necessary to distinguish between the address part of the instruction and the effective address used by the control when executing the instruction. The effective address is defined to be the memory address obtained from the computation dictated by the given addressing mode. The effective address is the address of the operand in a computational-type instruction. It is the address where control branches in response to a branch-type instruction. 6 Direct Address Mode: In this mode the effective address is equal to the address part of the instruction. The operand resides in memory and its address is given directly by the address field of the instruction. In a branch-type instruction the address field specifies the actual branch address. 7 Indirect Address Mode: In this mode the address field of the instruction gives the address where the effective address is stored in memory. Control fetches the instruction from memory and uses its address part to access memory again to read the effective address.

8 Relative Address Mode: In this mode the content of the program counter is added to the address part of the instruction in order to obtain the effective address. The address part of the instruction is usually a signed number (in 2’s complement representation) which can be either positive or negative. When this number is added to the content of the program counter, the result produces an effective address whose position in memory is relative to the address of the next instruction. To clarify with an example, assume that the program counter contains the number 825 and the address part of the instruction contains the number 24. The instruction at location 825 is read from memory during the fetch phase and the program counter is then incremented by one to 826 + 24 = 850. This is 24 memory locations forward from the address of the next instruction. Relative addressing is often used with branch-type instructions when the branch address is in the area surrounding the instruction word itself. It results in a shorter address field in the instruction format since the relative address can be specified with a smaller number of bits compared to the number of bits required to designate the entire memory address.

9 Indexed Addressing Mode: In this mode the content of an index register is added to the address part of the instruction to obtain the effective address. The index register is a special CPU register that contains an index value. The address field of the instruction defines the beginning address of a data array in memory. Each operand in the array is stored in memory

CONCEPT OF CPU DESIGN, RISC & CISC

Day 12 to 18

Hardwired v/s Micro-programmed Control Unit

To execute an instruction, the control unit of the CPU must generate the required control signal in the proper sequence. There are two approaches used for generating the control signals in proper sequence as Hardwired Control unit and Micro-programmed control unit.

Hardwired Control Unit –

The control hardware can be viewed as a state machine that changes from one state to another in every clock cycle, depending on the contents of the instruction register, the condition codes and the external inputs. The outputs of the state machine are the control signals. The sequence of the operation carried out by this machine is determined by the wiring of the logic elements and hence named as “hardwired”.

  1. Fixed logic circuits that correspond directly to the Boolean expressions are used to generate the control signals.
  2. Hardwired control is faster than micro-programmed control.
  3. A controller that uses this approach can operate at high speed.

Characteristics:

  1. It uses flags, decoder, logic gates and other digital circuits.
  2. As name implies it is a hardware control unit.
  3. On the basis of input Signal output is generated.
  4. Difficult to design, test and implement.
  5. Inflexible to modify.
  6. Faster mode of operation.
  7. Expensive and high error.
  8. Used in RISC processor.

Micro-programmed Control Unit –

  1. The control signals associated with operations are stored in special memory units inaccessible by the programmer as Control Words.
  2. Control signals are generated by a program are similar to machine language programs.
  3. Micro-programmed control unit is slower in speed because of the time it takes to fetch microinstructions from the control memory.

This architecture is an evolution and alternative to complex instruction set computing (CISC). With RISC, the basic concept is to have simple instructions that do less but execute very quickly to provide better performance. The most basic RISC feature is a processor with a small core logic that allows engineers to increase the register set and increase internal parallelism by using the following:

  1. Thread level parallelism: Increases the number of parallel threads executed by the CPU
  2. Instruction level parallelism: Increases the speed of the CPU's executing instructions

The words "reduced instruction set" are often misinterpreted to refer to a reduced number of instructions. However, this is not the case, as several RISC processors, like the PowerPC, have numerous instructions. At the opposite end of the spectrum, the DEC PDP-8, a CISC CPU, has only eight basic instructions. Reduced instruction actually means that the amount of work done by each instruction is reduced in terms of number of cycles - at most only a single data memory cycle - compared to CISC CPUs, in which dozens of cycles are required prior to completing the entire instruction. This results in faster processing.

CISC

The main intend of the CISC processor architecture is to complete task by using less number of assembly lines. For this purpose, the processor is built to execute a series of operations. Complex instruction is also termed as MULT, which operates memory banks of a computer directly without making the compiler to perform storing and loading functions.

Features of CISC Architecture

  1. To simplify the computer architecture, CISC supports microprogramming.
  2. CISC have more number of predefined instructions which makes high level languages easy to design and implement.
  3. CISC consists of less number of registers and more number of addressing modes, generally 5 to 20.
  4. CISC processor takes varying cycle time for execution of instructions – multi-clock cycles.
  5. Because of the complex instruction set of the CISC, the pipelining technique is very difficult.
  1. CISC consists of more number of instructions, generally from 100 to 250.
  2. Special instructions are used very rarely.
  3. Operands in memory are manipulated by instructions.

Advantages of CISC architecture

  1. Each machine language instruction is grouped into a microcode instruction and executed accordingly, and then are stored inbuilt in the memory of the main processor, termed as microcode implementation.
  2. As the microcode memory is faster than the main memory, the microcode instruction set can be implemented without considerable speed reduction over hard wired implementation.
  3. Entire new instruction set can be handled by modifying the micro program design.
  4. CISC, the number of instructions required to implement a program can be reduced by building rich instruction sets and can also be made to use slow main memory more efficiently.
  5. Because of the superset of instructions that consists of all earlier instructions, this makes micro coding easy.

Drawbacks of CISC

  1. The amount of clock time taken by different instructions will be different – due to this – the performance of the machine slows down.
  2. The instruction set complexity and the chip hardware increases as every new version of the processor consists of a subset of earlier generations.
  3. Only 20% of the existing instructions are used in a typical programming event, even though there are many specialized instructions in existence which are not even used frequently.
  4. The conditional codes are set by the CISC instructions as a side effect of each instruction which takes time for this setting – and, as the subsequent instruction changes the condition code bits – so, the compiler has to examine the condition code bits before this happens.

other backup information. Only programs and data currently needed by the processor reside in main memory. All other information is stored in auxiliary Memory and transferred to main memory when needed.

Memory Hierarchy

Memory is categorized into volatile and nonvolatile memories, with the former requiring constant power ON of the system to maintain data storage. Furthermore, a typical computer system provides a hierarchy of different times of memories for data storage.

Different levels of the memory hierarchy

  1. Cache (MB): Cache is the fastest accessible memory of a computer system. Its access speed is in the order of a few nanoseconds. It is volatile and expensive, so the typical cache size is in the order of megabytes.
  2. Main memory (GB): Main memory is arguably the most used memory. When discussing computer algorithms such as quick sort, balanced binary sorted trees, or fast Fourier transform, one typically assumes that the algorithm operates on data stored in the main memory. The main memory is reasonably fast, with access speed around 100 nanoseconds. It also offers larger capacity at a lower cost. Typical main memory is in the order of 10 GB. However, the main memory is volatile.
  3. Secondary storage (TB): Secondary storage refers to nonvolatile data storage units that are external to the computer system. Hard drives and solid state drives are examples of secondary storage. They offer very large storage capacity in the order of terabytes at very low cost. Therefore, database servers typically have an array of secondary storage devices with data stored distributed and redundantly across these devices. Despite the continuous improvements in access speed of hard drives, secondary storage devices are several magnitudes slower than main memory. Modern hard drives have access speed in the order of a few milliseconds.
  4. Tertiary storage (PB): Tertiary storage refers storage designed for the purpose data backup. Examples of tertiary storage devices are tape drives are robotic driven disk arrays. They are capable of peta byte range storage, but have very slow access speed with data access latency in seconds or minutes.

RAM AND ROM CHIPS

A RAM chip is better suited for communication with the CPU if it has one or more control inputs that select the chip only when needed. Another common feature is a bidirectional data bus that allows the transfer of data either from memory to CPU during a read operation or from CPU to memory during a write operation. A bidirectional bus can be constructed with three-state buffers. A three-state buffer output can be placed in one of three possible states: a signal equivalent to logic 1, a signal equivalent to logic 0, or a high-impedance state. The logic 1 and 0 are normal digital signals. The high-impedance state behaves like an open circuit, which means that the output does not carry a signal and has no logic significance. The block diagram of a RAM chip is shown in Fig. The capacity of the memory is 128 words of eight bits (one byte) per word.