Coos Unit-2
Coos Unit-2
Operating systems
By
NILOFER
(Assistant prof)
Dept. ECE, MRCET
Unit-2
contents
MICRO PROGRAMMED CONTROL: Control Memory, Address Sequencing, Micro
program Examples, Design of Control Unit, Hard Wired Control, Micro programmed Control.
Hardwired Control:
➢ When the control signals are generated by hardware using conventional logic design
techniques, the control unit is said to be hardwired.
➢ The key characteristics are
o High speed of operation
o Expensive
o Relatively complex
o No flexibility of adding new instructions
➢ Examples of CPU with hardwired control unit are Intel 8085, Motorola 6802, Zilog 80, and
any RISC CPUs.
Micro programmed Control:
Control Word: All the control information required for one clock cycle
Control Memory:
Control Memory(Control Storage: CS) Storage in the micro programmed control unit to store the
micro program.
➢ Microinstructions are stored in control memory in groups, with each group specifying a
routine.
➢ Each computer instruction has its own micro program routine to generate the micro
operations.
➢ The hardware that controls the address sequencing of the control memory must be capable
of sequencing the microinstructions within a routine and be able to branch from one routine
to another
➢ Steps the control must undergo during the execution of a single computer instruction:
▪ Load an initial address into the CAR when power is turned on in the computer. This
address is usually the address of the first microinstruction that activates the
instruction fetch routine –IR holds instruction .
▪ The control memory then goes through the routine to determine the effective
address of the operand –AR holds operand address .
▪ The next step is to generate the micro operations that execute the instruction by
considering the opcode and applying a mapping process.
• The transformation of the instruction code bits to an address in control
memory where the routine of instruction located is referred to as
mapping process
▪ After execution, control must return to the fetch routine by executing an
unconditional branch
In brief the address sequencing capabilities required in a control memory are:
➢ Incrementing of the control address register.
➢ Unconditional branch or conditional branch, depending on status bit conditions.
➢ A mapping process from the bits of the instruction to an address for control memory.
➢ A facility for subroutine call and return.
The block diagram of a control memory and the associated hardware needed for selecting the
next microinstruction address.
➢ The microinstruction in control memory contains a set of bits to initiate micro
operations in computer registers and other bits to specify the method by which the
next address is obtained.
➢ In the figure four different paths form which the control address register (CAR)
receives the address.
• The incrementer increments the content of the control register address register by one, to
select the next microinstruction in sequence.
• Branching is achieved by specifying the branch address in one of the fields of the
microinstruction.
• Conditional branching is obtained by using part of the microinstruction to select a specific
status bit in order to determine its condition.
• An external address is transferred into control memory via a mapping logic circuit.
• The return address for a subroutine is stored in a special register, that value is used when the
mico program wishes to return from the subroutine
Conditional Branching:
Unconditional Branch
Fixing the value of one status bit at the input of the multiplexer to 1
MAPPING OF INSTRUCTIONS
Direct Mapping
OP-codes of Instructions
address
0000 ADD Routine
ADD 0000
AND 0001 0001 AND Routine
LDA 0010
STA 0011
BUN LDA Routine
0100 0010
OP-code
Mapping memory
(ROM or PLA)
Control address
register
Control Memory
Subroutines:
➢ Subroutines are programs that are used by other routines to accomplish a particular task
and can be called from any point within the main body of the micro program.
➢ Frequently many micro programs contain identical section of code.
➢ Microinstructions can be saved by employing subroutines that use common sections of
microcode.
➢ Micro programs that use subroutines must have a provision for storing the return
address during a subroutine call and restoring the address during a subroutine return.
➢ A subroutine register is used as the source and destination for the addresses
MICROPROGRAM EXAMPLE ➢ The process of code generation for the
control memory is called
microprogramming.
➢ The block diagram of the computer
configuration is shown in figure
➢ Two memory units:
▪ Main memory –stores instructions
and data
▪ Control memory –stores micro
program
➢ Four processor registers
▪ Program counter –PC
▪ Address register –AR
▪ Data register –DR
▪ Accumulator register -AC
➢ Two control unit registers
Control address register –CAR .
Subroutine register –SBR
ADDRESSING MODE
Sample machine instructions EA-effective address
Symbol opcode description
A symbolic micr oprogram can be translated into its binary equivalent by a micro program
assembler.
Sample Format
five fields: label; micro-ops; CD; BR; AD
- In-Line Sequencing
→ CAR + 1
- Branch, Subroutine
Call → CS(AD)
- Return from
Subroutine → Output of
SBR
- New Machine
instruction → MAP
HORIZONTAL AND VERTICAL MICROINSTRUCTION
In the micro-program control unit all the control signals associated with micro-operations are
Stored in memory called control memory.
Set of control signals that cause micro operation to occur is called micro-instructions
Micro-programmed control unit can be classified into two types based on the type of Control
Word stored in the Control Memory, viz.,
➢ Horizontal micro-programmed control unit
➢ Vertical micro-programmed control unit.
In Horizontal micro-programmed control unit, the control signals are represented in the
decoded binary format, i.e., 1 bit/CS. Here ‘n’ control signals require n bit encoding. On the
other hand.
In Vertical micro-programmed control unit, the control signals are represented in the encoded
binary format. Here ‘n’ control signals require log2n bit encoding.
In Horizontal micro-programmed control unit, the control signals are represented in the
decoded binary format, i.e., 1 bit/CS. Here ‘n’ control signals require n bit encoding. On the
other hand.
16 15 14 13 …………………………… 0
In Vertical micro-programmed control unit, the control signals are represented in the encoded
binary format. Here ‘n’ control signals require log2n bit encoding.
EXAMPLE: if 16 control signals are needed in a system then 4 bits are required
then 𝐥𝐨𝐠 𝟐 𝟏𝟔= 𝐥𝐨𝐠 𝟐 𝟐𝟒 = 4 𝐥𝐨𝐠 𝟐 𝟐= 4bits
next address field
3 0
Decoder 4x16
16 0
Horizontal micro instructions Vertical micro instructions
Requires large control memory space requires less memory control space
UNIT-2 PART B
• Memory Hierarchy
• Main Memory
• Auxiliary Memory
• Associative Memory
• Cache Memory
• Virtual Memory
➢ On the other hand, when the word is to be read from an associative memory, the
content of the word, or part of the word, is specified. The words which match the
specified content are located by the memory and are marked for reading.
➢ The words which are kept
in the memory are
compared in parallel with
the content of the
argument register.
If more than one word in memory matches the unmasked argument field, all the matched words
will have 1‘s in the corresponding bit position of the catch register. It is then necessary to scan
the bits of the match register on eat time. The matched words are read in sequence by applying
a read signal to each word line whose corresponding Mi bit is a 1
WRITE OPERATION
if unwanted words have to be deleted and new words inserted one at a time, there is a need for
a special register to distinguish between active and inactive words. This register, sometimes
called a tag register, would have as many bits as there are words in the memory. For every active
word stored in memory, the corresponding bit in the tag register is set to 1. A word is deleted
from memory by clearing its tag bit to 0.
Cache Memory
➢ The data or contents of the main memory that are used frequently by CPU are
stored in the cache memory so that the processor can easily access that data in a
shorter time.
➢ Whenever the CPU needs to access memory, it first checks the cache memory. If
the data is not found in cache memory, then the CPU moves into the main
memory.
Cache memory is placed between the CPU and the main memory. The block diagram for a
cache memory can be represented as:
Performance of Cache Memory System:
.
➢ The performance of the cache memory is frequently measured in terms of a
quantity called hit ratio.
➢ When the CPU refers to memory and finds the word in cache, it is said to produce a
hit.
➢ If the word is not found in the cache, it is in main memory and it counts as a miss.
➢ The ratio of the number of hits divided by the total CPU references to memory (hits
plus misses) is the hit ratio.
Performance of Cache Memory System
Te = Tc + (1 - h) Tm
➢ Main memory is divided into equal size partitions called as blocks or frames.
➢ Cache memory is divided into partitions having same size as that of blocks called as lines.
➢ During cache mapping, block of main memory is simply copied to the cache and the block
is not actually brought from the main memory.
1. Direct Mapping
2. Associative Mapping
3. Set Associative Mapping
1. Direct Mapping-
In direct mapping,
➢ A particular block of main memory can map only to a particular line of the cache.
➢ The line number of cache to which a particular block can map is given by-
Example-
In direct mapping,
• There is no need of any replacement algorithm.
• This is because a main memory block can map only to a particular line of the cache.
• Thus, the new incoming block will always replace the existing block (if any) in that
particular line.
Special Cases-
If k = 1, then k-way set associative mapping becomes direct mapping i.e
If the page number is found, the 5-bit word is read out from memory. The corresponding block
number, being in the same word, is transferred to the main memory address register. If no
match occurs, a call to the operating system is generated to bring the required page from
auxiliary memory.
PAGE FAULT: if page is not available in memory the it is said to be page fault
PAGE REPLACEMENT
Decision on which page to displace to make room for an incoming page when no free frame is
available
The policy for choosing pages to remove is determined from the replacement algorithm that is
used.
A hardware device or circuit that supports virtual memory and paging by translating virtual
addresses into physical addresses.
SEGMENTATION:
- A segment is a set of logically related instructions
or data elements associated with a given name
- Variable size
SEGMENTATION EXAMPLE
- A memory management scheme which supports
user's view of memory
- A logical address space is a collection of segments
- Each segment has a name and a length
- Address specify both the segment name and the
offset within the segment.
- For simplicity of implementations, segments are numbered