EECS 150 - Components and Design Techniques for Digital Systems
Download
1 / 38

David Culler Electrical Engineering and Computer Sciences University of California, Berkeley - PowerPoint PPT Presentation


  • 106 Views
  • Uploaded on

EECS 150 - Components and Design Techniques for Digital Systems Lec 22 – Designing an Instruction Set Interpreter 11/18/2004. David Culler Electrical Engineering and Computer Sciences University of California, Berkeley http://www.eecs.berkeley.edu/~culler

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' David Culler Electrical Engineering and Computer Sciences University of California, Berkeley' - kylee-wallace


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

EECS 150 - Components and Design Techniques for Digital Systems Lec 22 – Designing anInstruction Set Interpreter11/18/2004

David Culler

Electrical Engineering and Computer Sciences

University of California, Berkeley

http://www.eecs.berkeley.edu/~culler

http://www-inst.eecs.berkeley.edu/~cs150


Review datapath vs control

signals Systems

Review: Datapath vs Control

Datapath

Controller

  • Datapath: Storage, FU, interconnect sufficient to perform the desired functions

    • Inputs are Control Points

    • Outputs are signals

  • Controller: State machine to orchestrate operation on the data path

    • Based on desired function and signals

Control Points


Resource utilization charts
Resource Utilization Charts Systems

  • One way to visualize datapath optimizations is through the use of a resource utilization charts.

  • These are used in high-level design to help schedule operations on shared resources.

  • Resources are listed on the y-axis. Time (in cycles) on the x-axis.

  • Example:

    memory fetch A1 fetch A2

    bus fetch A1 fetch A2

    register-file read B1 read B2

    ALU A1+B1 A2+B2

    cycle 1 2 3 4 5 6 7

  • Our list processor has two shared resources: memory and adder


List example resource scheduling
List Example Resource Scheduling Systems

  • Unoptimized solution: 1. SUMSUM + Memory[NEXT+1]; 2. NEXTMemory[NEXT];

    memory fetch x fetch next fetch x fetch next

    adder1 next+1 next+1

    adder2 sum sum

    1 2 1 2

  • Optimized solution: 1. SUMSUM + Memory[NUMA];

    2. NEXTMemory[NEXT], NUMAMemory[NEXT]+1;

    memory fetch x fetch next fetch x fetch next

    adder sum numa sum numa

  • How about the other combination: add x register

    memory fetch x fetch next fetch x fetch next

    adder numa sum numa sum

    1. XMemory[NUMA], NUMANEXT+1;

    2. NEXTMemory[NEXT], SUMSUM+X;

  • Does this work? If so, a very short clock period. Each cycle could have independent fetch and add. T = max(Tmem, Tadd) instead of Tmem+ Tadd.


Outline
Outline Systems

  • Review: high level optimization of the list processor

  • General notion of instruction execution cycle and the pieces that perform it

  • ISA => implementation

  • Example

  • Generalize and discuss


Approaching an isa
Approaching an ISA Systems

  • Instruction Set Architecture

    • Defines set of operations, instruction format, hardware supported data types, named storage, addressing modes, sequencing

  • Meaning of each instruction is described by RTL on architected registers and memory

  • Given technology constraints assemble adequate datapath

    • Architected storage mapped to actual storage

    • Function units to do all the required operations

    • Possible additional storage (eg. MAR, MBR, …)

    • Interconnect to move information among regs and FUs

  • Map each instruction to sequence of RTLs

  • Collate sequences into symbolic controller STD

  • Lower symbolic STD to control points

  • Implement controller


Instruction sequencing
Instruction Sequencing Systems

  • Example – an instruction to add the contents of two registers (Rx and Ry) and place result in a third register (Rz)

  • Step 1: Fetch the ADD instruction from memory into an instruction register

  • Step 2: Decode instruction

    • Instruction in IR has the code of an ADD instruction

    • Register indices used to generate output enables for registers Rx and Ry

    • Register index used to generate load signal for register Rz

  • Step 3: Execute instruction

    • Enable Rx and Ry output and direct to ALU

    • Setup ALU to perform ADD operation

    • Direct result to Rz so that it can be loaded into register


Instruction types
Instruction Types Systems

  • Data Manipulation

    • Add, subtract

    • Increment, decrement

    • Multiply

    • Shift, rotate

    • Immediate operands

  • Data Staging

    • Load/store data to/from memory

    • Register-to-register move

  • Control

    • Conditional/unconditional branches in program flow

    • Subroutine call and return


Elements of the control unit aka instruction unit
Elements of the Control Unit (aka Instruction Unit) Systems

  • Standard FSM Elements

    • State register

    • Next-state logic

    • Output logic (datapath/control signaling)

    • Moore or synchronous Mealy machine to avoid loops unbroken by FF

  • Plus Additional ”Control" Registers (in DP)

    • Instruction register (IR)

    • Program counter (PC)

  • Inputs/Outputs

    • Outputs control elements of data path

    • Inputs from data path used to alter flow of program (test if zero)


Instruction execution
Instruction Execution Systems

  • Control State Diagram (for each diagram)

    • Reset

    • Fetch instruction

    • Decode

    • Execute

  • Instructions partitioned into three classes

    • Branch

    • Load/store

    • Register-to-register

  • Different sequencethrough diagram for each instruction type

  • Controller manipulates the data path to perform the instruction

Reset

Init

InitializeMachine

FetchInstr.

Load/Store

XEQInstr.

Branch

Register-to-Register

Branch Taken

BranchNot Taken

Incr.PC


Data path hierarchy

Cin Systems

Ain

FA

Sum

Bin

Cout

Ain

Sum

HA

Bin

Cout

HA

Cin

Data Path (Hierarchy)

  • Arithmetic circuits constructed in hierarchical and iterative fashion

    • each bit in datapath is functionally identical

    • 4-bit, 8-bit, 16-bit, 32-bit datapaths


Data path alu

A Systems

B

16

16

Operation

16

N

S

Z

Data Path (ALU)

  • ALU Block Diagram

    • Input: data and operation to perform

    • Output: result of operation and status information


Data path alu registers interconnect

16 Systems

REG

AC

16

16

OP

N

16

Z

Data Path (ALU + Registers + interconnect)

  • Accumulator

    • Special register

    • One of the inputs to ALU

    • Output of ALU stored back in accumulator

  • One-address instructions

    • Operation and address of one operand

    • Other operand and destinationis accumulator register

    • AC <– AC op Mem[addr]

    • ”Single address instructions”(AC implicit operand)

  • Multiple registers

    • Part of instruction usedto choose register operands


Data path bit slice

CO Systems

CO

ALU

CI

ALU

ALU

CI

AC

AC

AC

rt

R0

rs

rt

rd

rd

rs

rt

rd

R0

rs

R0

frommemory

frommemory

frommemory

Data Path (Bit-slice)

  • Bit-slice concept: iterate to build n-bit wide datapaths

1 bit wide

2 bits wide


Instruction path
Instruction Path Systems

  • Program Counter

    • Keeps track of program execution

    • Address of next instruction to read from memory

    • May have auto-increment feature or use ALU

  • Instruction Register

    • Current instruction

    • Includes ALU operation and address of operand

    • Also holds target of jump instruction

    • Immediate operands

  • Relationship to Data Path

    • Contents of IR may also be required as input to ALU

      • Literals, address offsets

    • Contents of PC used in branch target calculation

  • Relationship to controller

    • Causes IR <= mem[[PC]]

    • IR contains OPCODE, which dictate controller outputs


Data path memory interface
Data Path (Memory Interface) Systems

  • Memory

    • Separate data and instruction memory (Harvard architecture)

      • Two address busses, two data busses

    • Single combined memory (Princeton architecture)

      • Single address bus, single data bus

  • Separate memory

    • ALU output goes to data memory input

    • Register input from data memory output

    • Data memory address from instruction register

    • Instruction register from instruction memory output

    • Instruction memory address from program counter

  • Single memory

    • Address from PC or IR

    • Memory output to instruction and data registers

    • Memory input from ALU output


Block diagram of processor
Block Diagram of Processor Systems

  • Register Transfer View of Princeton Architecture

    • Which register outputs are connected to which register inputs

    • Arrows represent data-flow, other are control signals from control FSM

    • MAR may be a simple multiplexerrather than separate register

    • MBR is split in two(REG and IR)

    • Load control for each register

load

path

16

REG

AC

rd wr

storepath

16

16

data

Data Memory

(16-bit words)

OP

addr

N

16

Z

ControlFSM

MAR

16

IR

PC

16

16

OP

16


Block diagram of processor1

load Systems

path

16

REG

AC

rd wr

storepath

16

16

data

Data Memory

(16-bit words)

OP

addr

N

16

Z

ControlFSM

16

IR

PC

data

Inst Memory

(8-bit words)

16

16

OP

addr

16

Block Diagram of Processor

  • Register transfer view of Harvard architecture

    • Which register outputs are connected to which register inputs

    • Arrows represent data-flow, other are control signals from control FSM

    • Two MARs (PC and IR)

    • Two MBRs (REG and IR)

    • Load control for each register


A simplified processor data path and memory
A simplified Processor Data-path and Memory Systems

  • Princeton architecture

  • Register file

  • Instruction register

  • PC incremented through ALU

  • Modeled afterMIPS rt000(used in 61Ctextbook byPatterson &Hennessy)

    • Really a 32 bitmachine

    • We’ll do a 16 bitversion

memory has only 255 wordswith a display on the last one


Processor control

Datapath Systems

Control Points

Signals

(conditions)

Processor Control

  • Synchronous Mealy machine

  • Multiple cycles per instruction


Announcements
Announcements Systems

  • Reading: 11.3 and 12.1

  • HW 9 due Monday 2:10 pm

    • Check updated handout

  • Digital Design in the News:

    • NY Times, NPR etc. 11-15 RFID on wholesale pill bottles

    • J. Stephen Smith – fluidic self-assembly for low-cost RFID tags

    • Another side of Moore’s Law

    • Power, power, power…


Example processor instructions
Example: Processor Instructions Systems

  • Three principal types (16 bits in each instruction) type op rs rt rd funct R(egister) 3 3 3 3 4 I(mmediate) 3 3 3 7 J(ump) 3 13

  • Some of the instructionsadd 0 rs rt rd 0 rd = rs + rt sub 0 rs rt rd 1 rd = rs - rt and 0 rs rt rd 2 rd = rs & rt or 0 rs rt rd 3 rd = rs | rt slt 0 rs rt rd 4 rd = (rs < rt) lw 1 rs rt offset rt = mem[rs + offset] sw 2 rs rt offset mem[rs + offset] = rt beq 3 rs rt offset pc = pc + offset, if (rs == rt) addi 4 rs rt offset rt = rs + offset j 5 target address pc = target address halt 7 - stop execution until reset

R

I

J


Tracing an instruction s execution
Tracing an Instruction's Execution Systems

  • Instruction: r3 = r1 + r2R 0 rs=r1 rt=r2 rd=r3 funct=0

  • 1. Instruction fetch

    • Move instruction address from PC to memory address bus

    • Assert memory read

    • Move data from memory data bus into IR

    • Configure ALU to add 1 to PC

    • Configure PC to store new value from ALUout

  • 2. Instruction decode

    • Op-code bits of IR are input to control FSM

    • Rest of IR bits encode the operand addresses (rs and rt)

      • These go to register file


Tracing an instruction s execution cont d
Tracing an Instruction's Execution (cont’d) Systems

  • Instruction: r3 = r1 + r2R 0 rs=r1 rt=r2 rd=r3 funct=0

  • 3. Instruction execute

    • Set up ALU inputs

    • Configure ALU to perform ADD operation

    • Configure register file to store ALU result (rd)



Tracing an instruction s execution cont d2

to controller Systems

Tracing an Instruction's Execution (cont’d)

  • Step 2



Register transfer level description
Register-Transfer-Level Description Systems

  • Control

    • Transfer data btwn registers by asserting appropriate control signals

  • Register transfer notation: work from register to register

    • Instruction fetch:mabus  PC; – move PC to memory address bus (PCmaEN, ALUmaEN) memory read; – assert memory read signal (mr, RegBmdEN) IR  memory; – load IR from memory data bus (IRld) op  add – send PC into A input, 1 into B input, add (srcA, srcB0, scrB1, op) PC  ALUout – load result of incrementing in ALU into PC (PCld, PCsel)

    • Instruction decode: IR to controller values of A and B read from register file (rs, rt)

    • Instruction execution: op  add – send regA into A input, regB into B input, add (srcA, srcB0, scrB1, op) rd  ALUout – store result of add into destination register (regWrite, wrDataSel, wrRegSel)


Register transfer level description cont d
Register-Transfer-Level Description (cont’d) Systems

  • How many states are needed to accomplish these transfers?

    • Data dependencies (where do values that are needed come from?)

    • Resource conflicts (ALU, busses, etc.)

  • In our case, it takes three cycles

    • One for each step

    • All operation within a cycle occur between rising edges of the clock

  • How do we set all of the control signals to be output by the state machine?

    • Depends on the type of machine (Mealy, Moore, synchronous Mealy)


Review of fsm timing

decode Systems

execute

fetch

step 1

step 2

step 3

IR  mem[PC];

PC  PC + 1;

A  rs

B  rt

rd  A + B

to configure the data-path to do this here,

when do we set the control signals?

Review of FSM Timing


Fsm controller for cpu skeletal moore fsm
FSM Controller for CPU (skeletal Moore FSM) Systems

  • First pass at deriving the state diagram (Moore machine)

    • These will be further refined into sub-states

reset

instructionfetch

instructiondecode

SW

J

ADD

instructionexecution

LW


Fsm controller for cpu reset and instruction fetch
FSM Controller for CPU (reset and instruction fetch) Systems

  • Assume Moore machine

    • Outputs associated with states rather than arcs

  • Reset state and instruction fetch sequence

  • On reset (go to Fetch state)

    • Start fetching instructions

    • PC will set itself to zero mabus  PC; memory read; IR  memory data bus; PC  PC + 1;

reset

instructionfetch

Fetch


Fsm controller for cpu decode
FSM Controller for CPU (decode) Systems

  • Operation Decode State

    • Next state branch based on operation code in instruction

    • Read two operands out of register file

      • What if the instruction doesn’t have two operands?

instructiondecode

Decode

branch based on value ofInst[15:13] and Inst[3:0]

add


Fsm controller for cpu instruction execution
FSM Controller for CPU (Instruction Execution) Systems

  • For add instruction

    • Configure ALU and store result in registerrd  A + B

    • Other instructions may require multiple cycles

instructionexecution

add


Fsm controller for cpu add instruction

reset Systems

instructionfetch

Fetch

instructiondecode

Decode

add

instructionexecution

add

FSM Controller for CPU (Add Instruction)

  • Putting it all togetherand closing the loop

    • the famousinstructionfetchdecodeexecutecycle


Fsm controller for cpu
FSM Controller for CPU Systems

  • Now we need to repeat this for all the instructions of our processor

    • Fetch and decode states stay the same

    • Different execution states for each instruction

      • Some may require multiple states if available register transfer paths require sequencing of steps


Approach an isa
Approach an ISA Systems

  • Instruction Set Architecture

    • Defines set of operations, instruction format, hardware supported data types, named storage, addressing modes, sequencing

  • Meaning of each instruction is described by RTL on architected registers and memory

  • Given technology constraints assemble adequate datapath

    • Architected storage mapped to actual storage

    • Function units to do all the required operations

    • Possible additional storage (eg. MAR, MBR, …)

    • Interconnect to move information among regs and FUs

  • Map each instruction to sequence of RTLs

  • Collate sequences into symbolic controller STD

  • Lower symbolic STD to control points

  • Implement controller


Discussion
Discussion Systems

  • How would enhancing the datapath simplify control

    • Instruction and data access

    • PC arithmetic separate from ALU

    • Register file ports

  • What determines the cycle time


ad