Module 5
Module 5
Module 5
The processing unit which executes machine instructions and coordinates the
activities of other units of computer is called the Instruction Set Processor (ISP) or
processor or Central Processing Unit (CPU).
• Here the processor contain only a single bus for the movement of data, address and
instructions.
• ALU and all the registers are interconnected via a Single Common Bus (Figure 7.1).
• Data & address lines of the external memory-bus is connected to the internal
processor-bus via MDR & MAR respectively.
(MDR -> Memory Data Register, MAR -> Memory Address Register).
• MDR has 2 inputs and 2 outputs. Data may be loaded
→ into MDR either from memory-bus (external) or
→ from processor-bus (internal).
• MAR‟s input is connected to internal-bus; MAR‟s output is connected to external-
bus. (address sent from processor to memory only)
REGISTER TRANSFERS
• Instruction execution involves a sequence of steps in which data are transferred
from one register to another.
• For each register, two control-signals are used: Riin & Riout. These are called
Gating Signals.
• Riin=1 data on bus is loaded into Ri. Riout=1
content of Ri is placed on bus.
Riout=0, bus can be used for transferring data from other registers.
• For example, Move R1, R2; This transfers the contents of register R1 to register R2.
This can be accomplished as follows:
1) Enable the output of registers R1 by setting R1out to 1 (Figure 7.2). This places the
contents of R1 on processor-bus.
2) Enable the input of register R2 by setting R2out to 1.
This loads data from processor-bus into register R4.
• All operations and data transfers within the processor take place within time-
periods defined by the
processor-clock.
5-33
Module V
clock cycle.
Input & Output Gating for one Register Bit
• A 2-input multiplexer is used to select the data applied to the input of an edge-
triggered D flip-flop.
• Riin=1 mux selects data on bus. This data will be loaded into flip-flop at rising-edge
of clock. Riin=0 mux feeds back the value currently stored in flip-flop (Figure 7.3).
• Q output of flip-flop is connected to bus via a tri-state gate. Riout=0 gate's output is
in the high-impedance state.
Riout=1 the gate drives the bus to 0 or 1, depending on the value of Q.
5-33
Module V
5-33
Module V
CONTROL-SIGNALS OF MDR
• The MDR register has 4 control-signals (Figure 7.4):
1) MDRin & MDRout control the connection to the internal processor data bus &
2) MDRinE & MDRoutE control the connection to the memory Data bus.
• MAR register has 2 control-signals.
1) MARin controls the connection to the internal processor address bus &
2) MARout controls the connection to the memory address bus.
5-33
Module V
5-33
Module V
5-33
Module V
5-33
Module V
5-33
Module V
BRANCHING INSTRUCTIONS
• Control sequence for an unconditional branch instruction is as follows:
5-33
Module V
5-33
Module V
Step4--> The instruction is decoded and add operation takes place in a single step.
5-33
Module V
COMPLETE PROCESSOR
• This has separate processing-units to deal with integer data and floating-point data.
Integer Unit To process integer data. (Figure 7.14).
Floating Unit To process floating –point data.
• Data-Cache is inserted between these processing-units & main-memory. The integer
and floating unit gets data from data cache.
• Instruction-Unit fetches instructions
→ from an instruction-cache or
→ from main-memory when desired instructions are not already in cache.
• Processor is connected to system-bus &
hence to the rest of the computer by means of a Bus Interface.
• Using separate caches for instructions & data is common practice in many
processors today.
• A processor may include several units of each type to increase the potential for
concurrent operations.
• The 80486 processor has 8-kbytes single cache for both instruction and data.
Whereas the Pentium processor has two separate 8 kbytes caches for instruction and
data.
5-33
Module V
Note:
To execute instructions, the processor must have some means of generating the
control-signals. There are two approaches for this purpose:
1) Hardwired control and 2) Microprogrammed control.
5-33
Module V
HARDWIRED CONTROL
• Hardwired control is a method of control unit design (Figure 7.11).
• The control-signals are generated by using logic circuits such as gates, flip-flops,
decoders etc.
• Decoder/Encoder Block is a combinational-circuit that generates required control-
outputs depending on state of all its inputs.
• Instruction Decoder
➢ It decodes the instruction loaded in the IR.
➢ If IR is an 8 bit register, then instruction decoder generates 28(256 lines); one
for each instruction.
➢ It consists of a separate output-lines INS1 through INSm for each machine
instruction.
➢ According to code in the IR, one of the output-lines INS1 through INSm is set to
1, and all other lines are set to 0.
• Step-Decoder provides a separate signal line for each step in the control sequence.
• Encoder
➢ It gets the input from instruction decoder, step decoder, external inputs and
condition codes.
➢ It uses all these inputs to generate individual control-signals: Yin, PCout, Add, End
and so on.
➢ For example (Figure 7.12), Zin=T1+T6.ADD+T4.BR
;This signal is asserted during time-slot T1 for all instructions.
during T6 for an Add instruction.
during T4 for unconditional branch instruction
• When RUN=1, counter is incremented by 1 at the end of every clock cycle. When
RUN=0, counter stops counting.
• After execution of each instruction, end signal is generated. End signal resets step
counter.
• Sequence of operations carried out by this machine is determined by wiring of logic
circuits, hence the name “hardwired”.
• Advantage: Can operate at high speed.
• Disadvantages:
1) Since no. of instructions/control-lines is often in hundreds, the complexity of
control unit is very high.
2) It is costly and difficult to design.
3) The control unit is inflexible because it is difficult to change the design.
5-33
Module V
5-33
Module V
5-33
Module V
5-33
Module V
MICROPROGRAMMED CONTROL
• Microprogramming is a method of control unit design (Figure 7.16).
• Control-signals are generated by a program similar to machine language programs.
• Control Word(CW) is a word whose individual bits represent various control-signals
(like Add, PCin).
• Each of the control-steps in control sequence of an instruction defines a unique
combination of 1s & 0s in CW.
• Individual control-words in microroutine are referred to as microinstructions
(Figure 7.15).
• A sequence of CWs corresponding to control-sequence of a machine instruction
constitutes the
microroutine.
• The microroutines for all instructions in the instruction-set of a computer are
stored in a special memory called the Control Store (CS).
• Control-unit generates control-signals for any instruction by sequentially reading
CWs of corresponding microroutine from CS.
• µPC is used to read CWs sequentially from CS. (µPC Microprogram Counter).
• Every time new instruction is loaded into IR, o/p of Starting Address Generator is
loaded into µPC.
• Then, µPC is automatically incremented by clock;
causing successive microinstructions to be read from CS.
Hence, control-signals are delivered to various parts of processor in correct sequence.
Advantages
• It simplifies the design of c unit. Thus it is both, cheaper and less er ror prone implement.
ontrol
emented
Control functions are impl in software rather than hardware.
erly and systematic.
The design process is ordnged to accommodate new system specifications
More flexible, can be cha or to correct the
loating
design errors quickly and cheaply. point arithmetic can be realized efficient
5-33
Module V
5-33
Module V
5-33
Module V
5-33
Module V
MICROPROGRAM SEQUENCING
• The task of microprogram sequencing is done by microprogram sequencer.
• Two important factors must be considered while designing the microprogram
sequencer:
1) The size of the microinstruction &
2) The address generation time.
• The size of the microinstruction should be minimum so that the size of control
memory required to store microinstructions is also less.
• This reduces the cost of control memory.
• With less address generation time, microinstruction can be executed in less time
resulting better throughout.
• During execution of a microprogram the address of the next microinstruction to be
executed has 3 sources:
1) Determined by instruction register.
2) Next sequential address &
5-33
Module V
5-33
Module V
5-33
Module V
5-33
Module V
5-33
Module V
in the IR into a second decoder, which produces the gating-signals for the actual
registers R0 to R15.
5-33
Module V
5-33
Module V
5-33
Module V
5-33
Module V
5-33
Module V
PREFETCHING MICROINSTRUCTIONS
• Disadvantage of Microprogrammed Control: Slower operating-speed because of
the time it takes to fetch microinstructions from the control-store.
Solution: Faster operation is achieved if the next microinstruction is pre-fetched
while the current one is being executed.
Emulation
• The main function of microprogrammed control is to provide a means for simple,
flexible and relatively inexpensive execution of machine instruction.
• Its flexibility in using a machine's resources allows diverse classes of instructions to
be implemented.
• Suppose we add to the instruction-repository of a given computer M1, an entirely
new set of instructions that is in fact the instruction-set of a different computer M2.
• Programs written in the machine language of M2 can be then be run on computer
M1 i.e. M1 emulates M2.
• Emulation allows us to replace obsolete equipment with more up-to-date machines.
• If the replacement computer fully emulates the original one, then no software
changes have to be made to run existing programs.
• Emulation is easiest when the machines involved have similar architectures.
5-33
Module V
Problem 1:
Why is the Wait-for-memory-function-completed step needed for reading from or
writing to the main memory?
Solution:
The WMFC step is needed to synchronize the operation of the processor and the main
memory.
Problem 2:
For the single bus organization, write the complete control sequence for the
instruction: Move (R1), R1
Solution:
PCout, MARin, Read, Select4, Add, Zin
2) Zout, PCin, Yin, WMFC
3) MDRout, IRin
4) R1out, MARin, Read
5) MDRinE, WMFC
6) MDRout, R2in, End
Prob
lem
3:
1)
Write the sequence of control steps required for the single bus organization in each of
the following instructions:
a) Add the immediate number NUM to register R1.
b) Add the contents of memory-location NUM to register R1.
c) Add the contents of the memory-location whose address is at memory-location
NUM to register R1.
Assume that each instruction consists of two words. The first word specifies the
operation andN the addressing mode, and the second word contains the number
NUM
Solution:
5-33
Module V
Problem 4:
Show the control steps for the Branch on Negative instruction for a processor with
three-bus organization of the data path
Solution:
5-33
Module V
MICROWAVE OVEN
• Microwave-oven is one of the examples of embedded-system.
• This appliance is based on magnetron power-unit that generates the microwaves
used to heat food.
• When turned-on, the magnetron generates its maximum power-output.
Lower power-levels can be obtained by turning the magnetron on & off for controlled
time-intervals.
• Cooking Options include:
→ Manual selection of the power-level and cooking-time.
→ Manual selection of the sequence of different cooking-steps.
→ Automatic melting of food by specifying the weight.
• Display (or Monitor) can show following information:
→ Time-of-day clock.
→ Decrementing clock-timer while cooking.
→ Information-messages to the user.
• I/O Capabilities include:
→ Input-keys that comprise a 0 to 9 number pad.
→ Function-keys such as Start, Stop, Reset, Power-level etc.
→ Visual output in the form of a LCD.
→ Small speaker that produces the beep-tone.
• Computational Tasks executed are:
→ Maintaining the time-of-day clock.
→ Determining the actions needed for the various cooking-options.
→ Generating the control-signals needed to turn on/off devices.
→ Generating display information.
5-33
Module V
• Non-volatile ROM is used to store the program required to implement the desired
actions. So, the program will not be lost when the power is turned off (Figure 10.1).
• Most important requirement: The microcontroller must have sufficient I/O
capability.
Parallel I/O Ports are used for dealing with the external I/O signals.
Basic I/O Interfaces are used to connect to the rest of the system.
5-33
Module V
5-33
Module V
DIGITAL CAMERA
• Digital Camera is one of the examples of embedded system.
• An array of Optical Sensors is used to capture images (Figure 10.2).
• The optical-sensors convert light into electrical charge.
• Each sensing-element generates a charge that corresponds to one pixel. One pixel is
one point of a pictorial image.
The number of pixels determines the quality of pictures that can be recorded &
displayed.
• ADC is used to convert the charge which is an analog quantity into a digital
representation.
• Processor
→ manages the operation of the camera.
→ processes the raw image-data obtained from the ADCs to generate images.
• The images are represented in standard-formats, so that they are suitable for use in
computers.
• Two standard-formats are:
5-33
Module V
5-33
Module V
5-33
Module V
5-33
Module V
5-33
Module V
• Each parallel port has an associated 8-bit DDR (Data Direction Register) (Figure
10.4).
• DDR can be used to configure individual data lines as either input or output.
5-33
Module V
• If the data direction flip-flop contains a 0, then Port pin PAi is treated as an input
(Figure 10.5). If the data direction flip-flop contains a 1, then Port pin PAi is treated
as an output.
• Activation of control-signal Read_Port, places the logic value on the port-pin onto the
data line Di. Activation of control-signal Write_Port, places value loaded into output
data flip-flop onto port-pin.
• Addressable Registers are (Figure 10.6):
1) Input registers (PAIN for port A, PBIN for port B)
2) Output registers (PAOUT for port A, PBOUT for port B)
3) Direction registers (PADIR for port A, PBDIR for port B)
4) Status-register (PSTAT) &
5) Control register (PCONT).
5-33
Module V
5-33
Module V
5-33
Module V
5-33
Module V
5-33
Module V
5-33
Module V
COUNTER/TIMER
• A 32-bit down-counter-circuit is provided for use as either a counter or a timer.
• Basic operation of the circuit involves
→ loading a starting value into the counter and
→ then decrementing the counter-contents using either
i) Internal system clock or
ii) External clock signal.
• The circuit can be programmed to raise an interrupt when the counter-contents
reach 0.
• Counter/Timer Register (CNTM) can be loaded with an initial value (Figure 10.9).
• The initial value is then transferred into the counter-circuit.
• The current contents of the counter can be read by accessing memory-address
FFFFFFD4.
• Control Register (CTCON) is used to specify the operating mode of the
counter/timer circuit.
• The control register provides a mechanism for
→ starting & stopping the counting-process &
→ enabling interrupts when the counter-contents are decremented to 0.
• Status Register (CTSTAT) reflects the state of the circuit.
• There are 2 modes: 1) Counter mode 2) Timer mode.
Counter Mode
• CTCON7 = 0 When the counter mode is selected.
• The starting value is loaded into the counter by writing it into register
CNTM.
• The counting-process begins when bit CTCON0 is set to 1 by a program.
5-33
Module V
5-33
Module V
5-33
Module V
5-33
Module V
5-33