Presentation is loading. Please wait.

Presentation is loading. Please wait.

1  1998 Morgan Kaufmann Publishers Chapter Five The Processor: Datapath and Control.

Similar presentations

Presentation on theme: "1  1998 Morgan Kaufmann Publishers Chapter Five The Processor: Datapath and Control."— Presentation transcript:

1 1  1998 Morgan Kaufmann Publishers Chapter Five The Processor: Datapath and Control

2 2  1998 Morgan Kaufmann Publishers We're ready to look at an implementation of the MIPS Simplified to contain only: –memory-reference instructions: lw, sw –arithmetic-logical instructions: add, sub, and, or, slt –control flow instructions: beq, j Generic Implementation: –use the program counter (PC) to supply instruction address –get the instruction from memory –read registers –use the instruction to decide exactly what to do All instructions use the ALU after reading the registers Why? memory-reference? arithmetic? control flow? The Processor: Datapath & Control

3 3  1998 Morgan Kaufmann Publishers Abstract / Simplified View: Two types of functional units: –elements that operate on data values (combinational) –elements that contain state (sequential) More Implementation Details

4 4  1998 Morgan Kaufmann Publishers Unclocked vs. Clocked Clocks used in synchronous logic – when should an element that contains state be updated? cycle time rising edge falling edge State Elements

5 5  1998 Morgan Kaufmann Publishers The set-reset latch –output depends on present inputs and also on past inputs An unclocked state element

6 6  1998 Morgan Kaufmann Publishers Latches and flip-flops are the simplest memory elements. Output is equal to the stored value inside the element (don't need to ask for permission to look at the value) Change of state (value) is based on the clock Latches: whenever the inputs change, and the clock is asserted Flip-flop: state changes only on a clock edge (edge-triggered methodology) "logically true", ?could mean electrically low A clocking methodology defines when signals can be read and written Wouldn't want to read a signal at the same time it was being written Latches and Flip-flops

7 7  1998 Morgan Kaufmann Publishers Two inputs: –the data value to be stored (D) –the clock signal (C) indicating when to read & store D Two outputs: –the value of the internal state (Q) and it's complement When the latch is open (C asserted), the value of Q changes as D changes  transparent latch. D-latch

8 8  1998 Morgan Kaufmann Publishers D flip-flop Flip-flops are not transparent Output changes only on the clock edge The first latch, called the master, is open and follows the input D when C is asserted. When the clock input falls, the first latch is closed, but the 2 nd latch, called the slave, is open and gets its input from the output of the master latch. QQ _ Q Q _ Q D latch D C D latch DD C C

9 9  1998 Morgan Kaufmann Publishers Set-up time and Hold time Set-up time: the minimum time that the input must remain valid before the clock edge Hold time: the minimum time that the input must be valid after the clock edge (usually very small) D C Set-up timeHold time

10 10  1998 Morgan Kaufmann Publishers Our Implementation An edge triggered methodology Typical execution: –read contents of some state elements, –send values through some combinational logic –write results to one or more state elements Clock cycle State element 1 Combinational logic State element 2

11 11  1998 Morgan Kaufmann Publishers A register file consists of a set of registers that can be read and written by supplying a register number to be accessed. Built using D flip-flops and decoders (specify register number) Read part (left) : supply a register number as input, and the output is the information stored in that register. A register file with 2 read ports and 1 write ports. (right) Register File M u x Register 0 Register 1 Register n 1 Register n M u x Read data 1 Read data 2 Read register number 1 Read register number 2 Read register number 1 Read data 1 Read data 2 Read register number 2 Register file Write register Write dataWrite

12 12  1998 Morgan Kaufmann Publishers Register File Write part: need 3 inputs: a register number, the data to write, and a clock that controls the writing into the register. Note: we still use the real clock to determine when to write n-to-1 decoder Register 0 Register 1 Register n 1 C C D D Register n C C D D Register number Write Register data 0 1 n 1 n

13 13  1998 Morgan Kaufmann Publishers Simple Implementation Basic components: –two state elements instruction memory and program counter are needed to store and access instructions. –An adder is needed to compute the next instruction address. Since the instruction memory is read-only, we can treat it as combinational logic. PC Instruction memory Instruction address Instruction a. Instruction memoryb. Program counter AddSum c. Adder

14 14  1998 Morgan Kaufmann Publishers Fetching instruction and incrementing PC A portion of the datapath used for fetching instructions and incrementing Program Counter PC Instruction memory Read address Instruction 4 Add

15 15  1998 Morgan Kaufmann Publishers R-Format ALU operations R-format instruction has 3 register operands, 2 read and 1 write 3

16 16  1998 Morgan Kaufmann Publishers Datapath for R-type Instruction Instruction Registers Write register Read data 1 Read data 2 Read register 1 Read register 2 Write data ALU result ALU Zero RegWrite ALU operation 3

17 17  1998 Morgan Kaufmann Publishers Load and Store Instructions Load and store instructions compute a memory address by adding the base register, to a 16-bit signed offset field contained in the instruction. 1632 Sign extend b. Sign-extension unit MemRead MemWrite Data memory Write data Read data a. Data memory unit Address

18 18  1998 Morgan Kaufmann Publishers Datapath for load and store instructions MemRead MemWrite RegWrite ALU operation 3

19 19  1998 Morgan Kaufmann Publishers J-type Instruction Branch datapath –Needs to compute the branch target address PC+4 is the address of the next instruction Offset field is left-shifted two bits to make a world offset. –Needs to compare register contents

20 20  1998 Morgan Kaufmann Publishers Branch Datapath register 1 Read register 2 Write data RegWrite ALU operation 3

21 21  1998 Morgan Kaufmann Publishers Building the Datapath Use multiplexors to stitch them together

Download ppt "1  1998 Morgan Kaufmann Publishers Chapter Five The Processor: Datapath and Control."

Similar presentations

Ads by Google