08 CompOrg
08 CompOrg
Structure of a Computer
Block diagram view
Processor address read/write Memory System
data
Control
control signals
data conditions
Data Path
Registers
Selectively loaded EN or LD input Output enable OE input
CLK
LD asserted during a lo-to-hi clock transition loads new data into FFs
Register Transfer
Point-to-point connection
Dedicated wires Muxes on inputs of each register Load enables for each register Control signals for multiplexer
Output enables and load enables for each register
MUX rs MUX rt MUX rd MUX R4
rd
R4
Register Files
Collections of registers in one package
Two-dimensional array of FFs Address used as index to a particular word Separate read and write addresses so can do both at same time
4 by 4 register file
16 D-FFs Organized as four words of four bits each Write-enable (load) Read-enable (output enable)
RE RB RA WE WB WA D3 D2 D1 D0
CS 150 - Fakk 2000 - Computer Organization - 5
Q3 Q2 Q1 Q0
Memories
Larger Collections of Storage Elements
Implemented not as FFs but as much more efficient latches High-density memories use 1-5 switches (transitors) per bit Once written, memory holds forever (not true for denser dynamic RAM) Address lines to select word (10 lines for 1024 words) RD Read enable
Same as output enable Often called chip select Permits connection of many chips into larger array
WR A9 A8 A7 A6 A5 A4 A3 A2 A2 A1 A0
Instruction Sequencing
Example an instruction to add the contents of two registers (Rx and Ry) and place result in a third register (Rz)
Step 1: Get 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 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
CS 150 - Fakk 2000 - Computer Organization - 7
Instruction Types
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
Inputs/Outputs
Outputs control elements of data path Inputs from data path used to alter flow of program (test if zero)
CS 150 - Fakk 2000 - Computer Organization - 9
Instruction Execution
Control State Diagram (for each diagram)
Reset Fetch instruction Decode Execute
Init Reset
Initialize Machine
Fetch Instr.
Load/ Store
XEQ Instr.
Registerto-Register
Incr. PC
Sum
Cout
16
Operation 16 N S Z
16
One-address instructions
Operation and address of one operand Other operand and destination is accumulator register AC < AC op Mem[addr] Single address instructions OP (AC implicit operand)
16 REG 16 AC 16
Multiple registers
Part of instruction used to choose register operands
N Z
16
CO
ALU AC
CI
CO
ALU AC
ALU AC
CI
R0 rs rt rd
R0 rs rt rd
R0 rs rt rd
from memory
1 bit wide
from memory
2 bits wide
CS 150 - Fakk 2000 - Computer Organization - 14
from memory
Instruction Path
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
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
Address from PC or IR Memory output to instruction and data registers Memory input from ALU output
CS 150 - Fakk 2000 - Computer Organization - 16
Single memory
PC 16
16 16 PC 16
addr
Modeled after MIPS rt000 (used in 378 textbook by Patterson & Hennessy)
Really a 32 bit machine Well do a 16 bit version CS 150 - Fakk 2000 - Computer Organization - 19
Processor Control
Synchronous Mealy machine Multiple cycles per instruction
Processor Instructions
Three principal types (16 bits in each instruction)
type op R(egister) 3 I(mmediate) 3 J(ump) 3
add sub and or slt lw 0 0 0 0 0 1 sw 3 4 5 7
rs 3 3 13
rt 3 3
rd 3 7
funct 4
r3 = r1 + r2
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
CS 150 - Fakk 2000 - Computer Organization - 22
r3 = r1 + r2
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)
to controller
Register-Transfer-Level Description
Control
Transfer data btwn registers by asserting appropriate control signals
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)
CS 150 - Fakk 2000 - Computer Organization - 27
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)
fetch step 1
IR mem[PC]; PC PC + 1;
decode step 2
A rs B rt
execute step 3
rd A + B
to configure the data-path to do this here, when do we set the control signals?
instruction execution
instruction fetch
add
add
instruction execution
add
instruction execution