module 4-Processor & Data Path_1
module 4-Processor & Data Path_1
• Instruction count,
• Clock cycle time, and
• Clock cycles per instruction (CPI).
Processor- Introduction
• There are multiple versions of MIPS: including MIPS I, II, III, IV, and V
• datapath and control are the two components that come together to be
collectively known as the processor
Data Path
• Datapath consists of the functional units of the processor.
• Adder : The adder is responsible for incrementing the PC to hold the address of the
next instruction.
• It takes two input values, adds them together and outputs the result
Components Involved
• Register File:A collection of registers in which any register can be read
or written by specifying the address of the register.
• Arithmetic & logical instructions are R type
• These type of instructions have 3 registers:2 source & one destination
Register.
Combinational elements:
• Their outputs depend only on the current input.
• The ALU is an example of combinational element.
• Given the same input, a combinational element always produces the
same output because it has no internal storage.
Logic Design Conventions
State elements:
• An element contains state if it has some internal storage.
• The instruction and data memories, as well as the registers, are all
examples of state elements.
• A state element has at least two inputs and one output. The required
inputs are the data value to be written into the element and the clock.
• The clock is used to determine when the state element should be written:
• Logic components that contain state are also called sequential because
their outputs depend on both their input and the contents of the internal
state.
Basic MIPS implementation
• All instructions except jump, use the arithmetic-logical unit (ALU) after
reading the registers.
An Overview of MIPS
Implementation
• The memory-reference instructions use the ALU for an address
calculation.
• A memory-reference instruction will need to access the memory either to read data for a
load or write data for a store.
• An arithmetic-logical or load instruction must write the data from the ALU or memory back
into a register.
• For a branch instruction, we may need to change the next instruction address based on the
comparison.
• Otherwise the PC should be incremented by 4 to get the address of the next instruction.(32
bit word)
Basic MIPS implementation
An abstract view of the implementation of the MIPS subset showing the major functional units
and the major connections between them.
An Overview of MIPS
Implementation
• All instructions start by using the program counter to supply the instruction
address to the instruction memory.
• Once the register operands have been fetched, they can be operated on to
• compute a memory address(for load & store) or
• compute an arithmetic result (for an integer arithmetic-logical instruction),
• or a compare(for branch)
An Overview of MIPS
Implementation
• If the instruction is an arithmetic-logical instruction, the result from
the ALU must be written to a register.
• The result from the ALU or memory is written back into the register.
An Overview of MIPS
Implementation
• Branches require the use of the ALU output to determine the next
instruction address, which comes either from the ALU (or from an
adder that increments the current PC by 4.
.
2
3
An Overview of MIPS
Implementation
• The multiplexor 1 controls what value replaces the PC
(PC + 4 or the branch destination address).
• The multiplexor is controlled by the gate that “ANDs” together the Zero output of the
ALU and a control signal that indicates that the instruction is a branch.
• Multiplexer 2 returns to the register file, is used to steer the output of the ALU (in the
case of an arithmetic-logical instruction) or the output of the data memory (in the case
of a load) for writing into the register file.
• Multiplexor 3 is used to determine whether the second ALU input is from the registers
(for an arithmetic-logical instruction or a branch) or from the offset field of the
instruction (for a load or store).
An Overview of MIPS
Implementation
• The added control lines are straightforward and determine:
• MIPS has 32 registers, numbered from 0 to 31, each with 32 bits. To identify
a register in MIPS we thus need 5 bits
• The two operands and the destination of the result are specified by
locations in the register file.
R-format instructions
• An R-Type instruction contains 6 fields:
• Shift (shamt) used with the shift and rotate instructions, specifies the amount by
which the source operand rs is rotated/shifted. This field is 5 bits long
• three 5 bit register addresses (rd, rt, rs), register source, register target and register
destination.
• Because several functions can have the same opcode, R-Type instructions need a
function (Func) code to identify what exactly is being done - for example, 0x00 refers
to an ALU operation and 0x20 refers to ADDing specifically. (6 bits)
J-Type instructions
• J instructions are used when a jump needs to be performed.
• The J instruction has the most space for an immediate value, because
addresses are large number
• For each data word to be read from the registers, we need an input to the
register fi le that specifies the register number to be read.
• The register file always outputs the contents of whatever register number
that are on the Read register inputs.
Building a Data path- R-type
Instructions
• To write a data word, we will need two inputs: one to specify the
register number to be written and one to supply the data to be
written into the register.
• Load instruction: the value read from memory must be written into the
register file in the specified register, which is $t1.
• The two units needed to implement loads and stores, in addition to the
register file and ALU, are the data memory unit and the sign extension unit
Building a Data path- Load/Store
Instructions
Building a Data path-
Load/Store Instructions
• The memory unit is a state element with inputs for the address and the
write data, and a single output for the read result.
• To add the 16 bit immediate field to a 32-bit register, the computer must
convert that 16- bit number to its 32-bit equivalent.(Memory [$t2 + offset] )
• sign extension unit is used to sign-extend the 16-bit off set field in the
instruction to a 32-bit signed value.
Building a Data path-
Load/Store Instructions
• The memory unit is a state element with inputs for the address and the
write data, and a single output for the read result.
• To add the 16 bit immediate field to a 32-bit register, the computer must
convert that 16- bit number to its 32-bit equivalent.(Memory [$t2 + offset] )
• Sign extension unit is used to sign-extend the 16-bit off set field in the
instruction to a 32-bit signed value.
Building a Data path- Branch-on-
Equal Instruction
• The beq branch instruction has three operands:
• 16-bit offset used to compute the branch target address relative to the branch
instruction address.
• Compute branch target address by adding the sign-extended off set fi eld of the
instruction to the PC
• The unit labeled Shift left 2 is simply a routing of the signals between
input and output that adds 00 two to the low-order end of the sign-
extended offset field
Building a Data path- Branch-on-
Equal Instruction
• Control logic is used to decide whether the incremented PC or branch
target should replace the PC, based on the Zero output of the ALU
Creating a Single Data path
Creating a Single Data path
• The simple data path for the core MIPS architecture combines the
elements required by different instruction classes.
• This data path can execute the basic instructions (load-store word,
ALU operations, and branches