Hardware Notes
Hardware Notes
Computer System
ELEC 2607
Sept. 23, 2015 3 Sept. 23, 2015 4
AND
Symbols, functionality truth tables Assume: 0 V = Lo, +V = Hi A T
R1
Moore: outputs based on state (only) NOT Logically: Out = NOT(A) A Out
Mealy: outputs based on state & inputs
Describe using state tables
Binary values 0 and 1 can be used Lo (0) Hi (1)
E EA EB EC
E
n n A0 B0
Bus
...
inputs outputs n
E
An-1 Bn-1 ED EE
n n
E = 1: n outputs = n inputs D E
E = 0: n outputs = Hi-Z (floating) How to get values at A to E? from C to D and E? can A go to D while B go to E?
Feedback !!
to K-Maps and then circuits of gates Memory: read and write binary values
to generate next state inputs to flip n-bit word
flops and outputs Bank of addressable n-bit words
In 3006: Processor Datapath: execute an instruction
Will use State Tables to specify FSM behaviour Microarchitecture: fetch instruction from memory
Will use a different implementation approach and execute using datapath SYSC 2006
n n-bit Word
D Q
Bank of n-bit
OE words
Dn – 1 Qn – 1
n-bit Word
CE
Sept. 23, 2015 27 Sept. 23, 2015 28
Write?
used in
Address bus to the bank to identify specific word in operation
A0
Data
operation Dn-1 … D0
n-bit Data bus to move data to/from the bank
some control signals for data operations n
Read, Write, Clock n
Data Bus
Recall: a bus is just a bundle of wires
Data used in operation
Sept. 23, 2015 29 Sept. 23, 2015 Build up circuits to realize the bank … 30
Addressing Sub-Circuit for Read Sub-Circuit for
A Bank of 8 x n-bit Words A Bank of 8 x n-bit Words
Need 8 unique addresses (each word has unique address)
Use Word Select signal (from decoder) AND Read
Each digital signal has 2 possible values: 0 or 1 control signal to enable the outputs
recall: 8 = 23 (000, 001, 010, 011 … , 111)
Read Control Signal n-bit data
Need 3 digital signals to encode 8 unique addresses latch
A word’s address is its unique binary name! 7
Word Address
Each address must select a unique word (n-bit data latch) Word Select Signal
e.g. input = 1012 5
OE
1
Recall a simple Decoder: 0 Decoder
Word Select (outputs): 1 Word “at”
7 0 Address
Address signals (input): 0 Unique output selected n
n
select unique output 5 1 by encoded input is set 0 D 1012 Q
1 0
e.g. input = 1012 0 Decoder to 1
1 0
activates output 5 0 (all other outputs = 0) NOTE: the address is not “saved” anywhere … it selects
Recall: 1012 = 510 0 the decoder output that is wired to a particular word! CE
0 0
Sept. 23, 2015 31 Sept. 23, 2015 32
3 A2
A1 8 x n-bit Words this different from the
Decoder
A0 previous slide?
CLK W
Data
WS n-bit Word 0 Dn-1 … D0
0
R Data
n
n n
Read
n
n Data Data Bus
Data Bus
W R CLK
Sometimes it is obvious which interpretation is m
2m x n-bit Can this abstraction
Address Bus
A
When necessary to be exact: A0 without revisiting
Dn-1 … D0 the internal details?
Use 1K for 103 (1000) D
A word’s address is determined by how the circuit Memory: read and write binary values
decodes an address value to select a particular word
Processor Datapath: execute an instruction
There is a data value stored in a word
ALU
Called the contents of the word
Processor & Datapath
A word contains the last value written into the word
Put the Pieces Together! Execute an instruction!
Reading a word obtains the contents of the word
Microarchitecture: fetch instruction from memory
Multiple words may have the same contents (value) and execute using datapath SYSC 2006
Size of contents is not related to size of address
Computer System
Processor 1 ALU
(introduced in 2607)
A computing engine that manipulates binary values A computer uses an Arithmetic and Logic Unit (ALU)
The binary values represent (encoded) information to manipulate (binary) data values
Processor E.G. ADD, SUB, OR, AND, NOT
Registers Recall that ELEC 2607 included a lab that involved
2
Control FSM
2607 and Lab 1 ?
(memory words)3006
designing a simple ALU: 3-bit Adder/Subtracter
Internal Buses 3006 X (3 bits)
1
1 = subtract Sum (4 bits) switch = 0 Y+X
ALU Adder/Subtracter
2607 ?
0 = add switch = 1 Y–X
1 0
Later (Lab 2): add more flag outputs from ALU Could you build circuits for each of the operations? Then could you
Carry, oVerflow, Zero, Negative design an ALU circuit that uses Opr signals to select which
operation circuit to use (hints: decoder, tri-state buffers)? Lab 2 ☺
Sept. 23, 2015 67 Sept. 23, 2015 68
2
Putting the Pieces Together A Simple Processing System
Processor
X Y
14 output bits!
Outputs Outputs Outputs
while in E0 while in E1 while in E2
Sept. 23, 2015 73 Sept. 23, 2015 74
Recall Clock-driven FSM’s from ELEC 2607!
W4 W1 + W7 state E0 Clock
Example: W4 W1 + W7 CLK
Add the values stored in word 1 and word 7, and store Addr 4
Address Bus A 16 x 32-bit Words
the result in word 4 WordR R
WordW word 1 CLK
Involves 3 data values each must go on the Data W
Data
Bus separately! 32
Control FSM
E2: Read T2 onto Data Bus and Write value into W4 T2CE
CE D
T2OE 32-bit Latch
OE Q
Sept. 23, 2015 75 Sept. 23, 2015 T2 76
Addr 4 Addr 4
Address Bus A 16 x 32-bit Words Address Bus A 16 x 32-bit Words
WordR R WordR R
WordW word 7 CLK WordW word 4 CLK
W W
Data Data
32 32
Control FSM
Control FSM
State Addr WordR WordW T1CE T1OE T2CE T2OE Opr Next WordR
(4) (4) State WordW into W4
E0 0001 1 0 1 0 0 0 NOP E1
T1CE into T1
E1 0111 1 0 0 1 1 0 ADD E2
T1OE
E2 0100 0 1 0 0 0 1 NOP –
T2CE into R2
Could you design an FSM to implement this?
T2OE
Consider activity in each state …
Opr NOP 0000
Sept. 23, 2015 79 Sept. 23, 2015 ADD x 80
State Addr WordR WordW T1CE T1OE T2CE T2OE Opr Next State Addr WordR WordW T1CE T1OE T2CE T2OE Opr Next
State Clock E1 State
E0
CLK
E0 0001 1 0 1 0 0 0 NOP E1 E1 0111 1 0 0 1 1 0 ADD E2
CLK
Addr 4
Address Bus 0001 A
Read W7 onto Data Bus, perform addition, Write
16 x 32-bit Words
WordR R result into T2 (since W7 value is on Data Bus)
WordW word 1 CLK
W
Clock
Data State E0 E1 S2
32 Enter E0 on rising edge Addr 0001 0111 100
Control FSM
Data Bus word 1 of clock Data Bus contents of word 1 contents of word 7 word 1 + word 7
T1
T1CE D WordR
CE
T1OE word 1
OE Q 32 WordW into W4
32
X Y
Contents of word 1 is put T1CE into T1
ALU on Data Bus “immediately”
NOP 32 T1OE
Opr
OP so it can be latched in T1
(0000) 4 VCR on falling clock edge T2CE into T2
T2CE T2OE
CE D
T2OE 32-bit Latch
OE Q
Stay in E0 until next rising Opr NOP ADD 0001
Sept. 23, 2015 T2 81 Sept. 23, 2015 x 82
clock edge then go to E1
State Addr WordR WordW T1CE T1OE T2CE T2OE Opr Next State Addr WordR WordW T1CE T1OE T2CE T2OE Opr Next
State Clock State
E1 E2
CLK
E1 0111 1 0 0 1 1 0 ADD E2 E2 0100 0 1 0 0 0 1 NOP –
CLK Addr
4
Address Bus 0111 A 16 x 32-bit Words Read T2 onto Data Bus and Write value into W4
WordR R
WordW word 7 CLK
W
Clock
Data State E0 E1 E2
32 Contents of word 7 is put on Addr 0001 0111 0100
Control FSM
Data Bus w1 + w7
T1
T1CE D
CE
T1OE word 1
OE Q 32
32
The result from T2 is put on
Data Bus “immediately” so
X Y
ALU it can be latched into word 4
NOP 32 on falling clock edge
OP
Opr (0000) 4 VCR
T2CE
CE D
T2OE w1 + w7
OE Q
Sept. 23, 2015 T2 85 Sept. 23, 2015 86
Most of the ALU operations involve 3 data values What would change in the FSM table from before?
2 source values (operands)
E0: Read W1 W0 onto Data Bus and Write value into T1
1 destination value (result)
NOTY and RY only involve 2 data values (1 source, 1 E1: Read W7 W5 onto Data Bus, perform addition,
destination) Write result into T2
What use is RY ???? E2: Read T2 onto Data Bus and Write value into W4 W3
Does no manipulation of any data?
Could use to copy a value from one register to another! State Addr WordR WordW T1CE T1OE T2CE T2OE Opr Next
State
Copy source word to T2 first (using RY), then copy to
E0 0001 1 0 1 0 0 0 NOP E1
destination word 0000
• Still uses the Data Bus twice! discussed more later! E1 0111 1 0 0 1 1 0 ADD E2
Exercise: develop FSM tables for the other operations 0101
E2 0100 0 1 0 0 0 1 NOP –
Sept. 23, 2015 89
0011
Sept. 23, 2015 90
W3 W0 – W5 W3 W0 + W5
W3 W5
W3 W0 – W 5
What would change in the FSM table on previous slide? Copy word 5 to word 3
E0: Read W0 onto Data Bus and Write value into T1 What would change in the FSM table on previous slide?
E1: Read W5 onto Data Bus, perform addition E0: Read W0 onto Data Bus and Write value into T1
subtraction (OPR = 0010), Write result into T2 E1: Read W5 onto Data Bus, perform subtraction RY
E2: Read T2 onto Data Bus and Write value into W3 (OPR = 0011), Write result into T2
E2: Read T2 onto Data Bus and Write value into W3
State Addr WordR WordW T1CE T1OE T2CE T2OE Opr Next
State State Addr WordR WordW T1CE T1OE T2CE T2OE Opr Next
State
E0 0000 1 0 1 0 0 0 NOP E1
E0 0000 1 0 1 0 0 0 NOP E1
E1 0101 1 0 0 1 1 0 ADD E2
SUB E1 0101 1 0 0 1 1 0 SUB E2
RY
E2 0011 0 1 0 0 0 1 NOP –
E2 0011 0 1 0 0 0 1 NOP –
Sept. 23, 2015 91 Sept. 23, 2015 92
W3 = W1 AND W6
Encoded Operation Input to FSM NOTE ON PREVIOUS SLIDE
Control FSM Other signals
NOP encoding 4
In the Simple Processing System the registers and
0000
4
Address Bus operations involved were encoded as outputs for
ANOP
(assert in E0 and E2)
specific states
4 Each operation needed its own unique FSM!
Opr
Now: registers and operation involved are input to FSM
AOP (assert in E1)
SYW (assert in E1) and the FSM can output them
0 SXW (assert in E0)
OneSourceOp
DW (assert in E2)
They are not encoded in the FSM!
Q15-12 4 Q11-8 4 Q7-4 4 Q3-0 4
• One FSM can do many operations!
0 1 0 0 0 0 1 1 0 0 0 1 0 1 1 0
16-bit latch contains Encoded Operation
Sept. 23, 2015 105 Sept. 23, 2015 106
1
Interconnection Bus
Clock
IBWrite Used later Main
Processor
IBRead Used now! Memory
Processor Main Memory
32
Interconnection Address Bus
32
Interconnection Data Bus
Interconnection Bus
Sept. 23, 2015 111 Sept. 23, 2015 112
1 1
2
Circuit 7: 2
Address Size?
Main Memory Component Main Memory size = 1 M words
Just a bigger memory … for now, let’s assume: Need 20 address bits!
32-bit words Interconnection Address Bus = 32 bits
1M words [1MB = 220] Use the 20 least signif. bits for the address
What about the most signif. (high) 12 bits?
1M x 32-bit Words
Will assume that IF most signif. 12 bits = 0x000
Main THEN accessing Main Memory!
Clock CLK
Memory Will assume most signif. 12 bits ≠ 0x000
IBWrite W
Address Data
IBRead R
A19…A0 D31…D0
then accessing some other component on bus I/O!
Interconnection Later: Will use most signif. 12 bits ≠ 0x000 to select I/O!
Bus ? 20 32
32 Introduce Selection signal SEL to Memory Component
Interconnection Address Bus
32 component participates in bus cycle iff SEL = 1
Interconnection Data Bus
Sept. 23, 2015 117 Sept. 23, 2015 118
2 2
Memory Mapped Access Main Memory Component with SEL
Using Memory address ranges to select components to SEL = 0 ignore Interconnect Bus Cycle
be accessed is called Memory Mapped Access
SEL = 1 participate in Interconnection Bus Cycle
Common in computer systems!
1M x 32-bit Words
In this case addresses with the most signif bits = 0x000
Main
are used to access Main Memory Clock CLK
Memory
1M words of Main Memory address range: IBWrite W
Address Data
IBRead R
SEL A19…A0 D31…D0
• 0x000 00000 Interconnection
20 32
to Bus = 0x000?
• 0x000 FFFFF 12
32 32
Interconnection Address Bus
32
Sept. 23, 2015 119 Sept. 23, 2015 Interconnection Data Bus 120
3 3
Here we go again! A Few Changes in the Design
Remember: memory words and latches in the processor
Extend Processor’s capability: are called registers distinguish from Main Memory
Read instruction from Main
words
Memory and copy into the
Instruction Register (IR) In the Processor, the WordR and WordW control
signals renamed: RegR and RegW
Some new hardware To set up for more instructions (later), will expand
circuits inside Processor. encoded operations input to FSM from 16 bits to 32 bits
Let’s go!
3 2 The encoded operations will be called instructions
1
Expand Control FSM: 32 D flip flop latch used to hold instructions
Main more states & more
Processor
Memory outputs
referred to as the Instruction Register (IR)
Interconnection Bus
Sept. 23, 2015 121 Sept. 23, 2015 122
Processor
Also Need to Adjust PC Control FSM Register Address Bus (4 bits)
CLK
To execute multiple instructions (program): After PCOE
Const1
0000000000000000 Address A3…A0 CLK
0000000000000001
loading an instruction, PC must be incremented to point C1OE
16 x 32-bit Registers
1111 RegR
to the “next” instruction R Data
PC Addrs RegW
W D31…D0
Fundamental Microarchitecture Assumption: IR Q D
CE
“next” instruction is stored in “next” sequential IRCE Internal Data Bus (32 bits)
(ascending) Main Memory word
T1CE D
Adjusting the PC is part of fetching an instruction CE
T1OE OE T1
Q
Must expand FSM to do this too!
X Y
For incrementing PC: New 32-bit constant called Const1 ALU
OP
Holds constant value 1 Opr 4
VCR
Used to adjust (increment) the PC using ALU T2CE
CE D
T2OE T2
Will select using C1OE signal from FSM OE Q
Sept. 23, 2015 131 Sept. 23, 2015 132
Interconnection Bus Interface Interconnection Bus Interface
Some interface circuity is needed to allow the 2 new 32-bit registers (latches) added to interface with the
Processor to read an instruction from Main Memory Interconnection Data and Interconnect Address Buses
and copy the retrieved instruction onto the Internal MAR: Memory Address Register
Data Bus MDR: Memory Data Register
Need some buffering (temporary) registers for MAR: holds the address to be accessed output onto the
the instruction address and the instruction data Interconnection Address Bus
Need some control signals to request a read (and MDR: holds data exchanged on the Interconnection Data
Bus (read from Main Memory, or written to Main Memory)
later a write) operation on Main Memory
FSM will be augmented to control the new registers and
generate the IBRead and IBWrite signals on the
Interconnection Bus (in addition to RegR and RegW)
Processor
Control FSM Register Address Bus (4 bits) Interconnection Bus Interface Details
CLK
Const1 CLK
PCOE 0000000000000000 Address A3…A0 MAR: “easy” need to read address from Internal
0000000000000001
16 x 32-bit Registers
1111
C1OE RegR R Data Bus and output address to Interconnection Bus
PC Addrs RegW
W D31…D0
IR Q D MDR: has two sources/destinations for data
CE
IRCE Internal Data Bus (32 bits)
Details 1. Internal Data Bus
coming!
2. Interconnection Data Bus
T1CE D Interconnection
CE
T1OE OE T1
Q
Bus
MAR
Must be able to Read and Write to either bus
Interface
Must accomplish this using single MDR
X Y MDR
ALU
OP
Opr 4
C R
Interconnection Address Bus
T2CE D
CE Interconnection Data Bus
T2OE T2
OE Q
IBRead
Sept. 23, 2015 IBWrite 135 Sept. 23, 2015 136
Cycle Write (to Memory) IBWrite Cycle Write (to Memory) IBWrite
1 Load MAR from Reg 1 Load MAR from Reg
2 Load MDR from Reg Interconnection Address Bus 2 Load MDR from Reg Interconnection Address Bus
3 Memory Write Clock Interconnection Data Bus 3 Memory Write Clock Interconnection Data Bus
Cycle Cycle
Sept. 23, 2015 141 Sept. 23, 2015 142
1
RECALL MDR: Must be able to
MAR: Only need read
internal bus and output
read/write from/to both buses
Protocol: Memory Read Clock Cycle to Interconnection Bus
The Processor must keep the IBRead signal stable for Internal Data Bus (32 bits)
IR Encoded Instruction
Processor
Control FSM Register Address Bus (4 bits)
F0 F1 (very busy!)
CLK
MAR onto Interconnect Address Bus (MAROE)
PCOE 0000000000000000 Address A3…A0 CLK IBRead (to Main Memory, and to Interconnect Bus Interface)
0000000000000001
C1OE
16 x 32-bit Registers Read instruction into MDR (MDRCE, IBRead, falling clock)
1111 RegR R Data
PC Addrs RegW PC (R15)
Q W D31…D0 T1 (PC value) to X (T1OE) & constant 1 to Y (C1OE)
IR D
CE PC ALU: R = PC + 1 (AADD)
IRCE Internal Data Bus (32 bits) IBRead Save PC + 1 in T2 (T2CE)
IBWrite
T1CE Interconnection MARCE I
CE D M M I
T1OE OE PC Bus MAR MAROE MMM M B
Q R R A T T T T A C P D D B I
Interface = PC MDRCE A A D D W
e e N 1 1 2 2 A 1 C R R R R Next
MDROE State R R R R r Other
X Y g g O C O C O D O O p g e C State
ALU MDR MDRget C O C O i
NOP R W P E E E E D E E u e a E
MDRput E E E E t
Opr 4 OP t t d
VCR e
Interconnection Address Bus
T2CE F1 1 1 1 1 1 1 1 0 F2
CE D
T2OE T2 Interconnection Data Bus
OE Q
IBRead
Sept. 23, 2015 IBWrite 159 Sept. 23, 2015 160
Processor
Control FSM Register Address Bus (4 bits)
F1 F2
CLK
PCOE CLK
0000000000000000
0000000000000001
Address A3…A0 MDR contains instruction drive MDR onto the
16 x 32-bit Registers
1111
C1OE RegR R Data Internal Data Bus (MDROE, MDRget)
PC Addrs RegW
W D31…D0
IR Q D Load instruction into IR (IRCE)
CE
IRCE Internal Data Bus (32 bits) IBRead
ANOP = 1 since ALU is not involved
IBWrite I
MARCE M M I
T1CE D Interconnection MMM M B
CE 1 R R A T T T T A C P D D B I
T1OE OE PC Bus MAR MAROE A A D D W
Q MDRCE e e N 1 1 2 2 A 1 C R R R R Next
Interface = PC State R R R R r Other
MDROE g g O C O C O D O O p g e C State
MDR C O C O i
X Y MDRget R W P E E E E D E E u e a E
ALU = MMem( PC ) E E E E t
ADD MDRput t t d
OP e
Opr 4
VCR F2 1 1 1 1 0 Decode
Interconnection Address Bus
T2CE D
CE Interconnection Data Bus
T2OE PC + 1
OE Q
IBRead
Sept. 23, 2015 IBWrite 161 Sept. 23, 2015 162
Processor
Control FSM Register Address Bus (4 bits)
F2 Decode
CLK
PCOE CLK
0000000000000000
0000000000000001
Address A3…A0 Drive T2 (adjusted PC value) onto Internal Data Bus
16 x 32-bit Registers
1111
C1OE RegR R Data (T2OE)
PC Addrs RegW
W D31…D0
Q
MMem(PC) D
Load into PC (RegW, PCOE)
CE
IRCE Internal Data Bus (32 bits) IBRead
ANOP = 1 since ALU is not involved
IBWrite
I
T1CE Interconnection MARCE M M I
CE D MMM M B
T1OE OE T1 Bus MAROE R R A T T T T A C P D D B I
Q MAR A A D D W
Interface MDRCE e e N 1 1 2 2 A 1 C R R R R
State R R R R r Other Next State
MDROE g g O C O C O D O O p g e C
X Y MDR C O C O i
ALU MDRget R W P E E E E D E E u e a E
NOP = MMem( PC ) E E E E t
MDRput t t d
Opr 4 OP e
VCR
Interconnection Address Bus
T2CE Decode 1 1 1 1 0 ???
CE D
T2OE PC + 1 Interconnection Data Bus
OE Q
IBRead
Sept. 23, 2015 IBWrite 163 Sept. 23, 2015 164
Processor Decode
Control FSM Register Address Bus (4 bits) Repeating Mechanism
CLK
PCOE 0000000000000000 Address A3…A0 CLK Loop to get next instruction execute a program
0000000000000001
C1OE
16 x 32-bit Registers
1111 RegR R Data
PC Addrs RegW PC (R15)
Q W D31…D0
IR D Fetch Fetch Fetch
CE
State F0 State F1 State F2
IRCE Internal Data Bus (32 bits) IBRead
IBWrite
T1CE Interconnection MARCE
CE D
T1OE OE T1 Bus MAROE
Q MAR Decode
Interface MDRCE
State
MDROE
X Y (and F3)
ALU MDR MDRget
NOP MDRput OneSourceOp
OP OneSourceOp
Opr 4
VCR
Interconnection Address Bus
T2CE D Execution Execution Execution
CE Interconnection Data Bus
T2OE PC + 1 State E0 State E1 State E2
OE Q
IBRead
Sept. 23, 2015 IBWrite 165 Sept. 23, 2015 166
R0 01 R0 01
R4 03 R4 03 01 Obvious (?)
R12 FF R12 FF
given the
instruction
R15 0600 R15 0600 0601
Memory Memory Most likely to
be missed on
Addrs Value Addrs Value
midterm or
0600 0440C000 0600 0440C000 final
Microarchitecture … WOW!
Sept. 23, 2015 183 Sept. 23, 2015 184