CO C4 Hardware and Software
RECALL
The organization of a computer:
Introduction & Logic Design Conventions
recall
CPU performance factors:
- Instruction count determined by ISA and compiler;
- CPI and Cycle time determined by CPU hardware.
Simple subset shows most aspects.
- Memory reference
- Arithmetic / Logical
- Control transfer
Instruction execution
-
IF: Fetch the instruction from the memory.
-
ID: Decode and read the registers at the same time.
Read the data at
rs1
,rs2
of R-type instruction under all circumstances.Drop the data read if the instruction doesn’t require reading data.
-
EX: Use ALU to calculate
- Arithmetic result
- Memory address for load/store
- Branch comparison to judge
-
MEM,WB: Access data memory for
load
/store
. -
UPC: Update
PC
withPC + 4
or target address( branch or jump).
A simple implementation
单周期CPU的特点:由于部件访问以来时钟信号,无法在一个时钟周期内访问两次相同部件。故导致部件冗余。
- Instruction memory, Data memory
- Adder, ALU
- Program Counter
- Immediate generator
- Multiplexer
- Register Files
ALU
- Input: A(32),B(32),Operation(4)
- Output: Result(32),Overflow(1),Zero(1)
slt
, Set on less than means
1
2
3
4If A < B then
Result = 1;
else
Result = 0;
Register
- Input: In(32),Write(1)
- Output: Out(32)
State element controlled by Write
signal:
- 0: remains constant;
- 1: store the input into register when positive edge of
clk
comes.
Register Files
Register Files consists of 32 32/64-bit Registers.
- Input: ReadR1(5),ReadR2(5),WriteR(5),WriteData(32),RegWrite(1)
- Output: ReadD1(32),ReadD2(32)
1 |
|
Memory
Instruction memory, read only
- Input: Address(32)
- Output: Instruction(32)
Data memory
- Input: Address(32),WriteData(32),MemWrite/MemRead(1)
- Output: ReadData(32)
Immediate generation unit
- Input: Instruction(32)
- Output: Immediate(32)
1 |
|
CPU Overview
A simple overview and MUX
Overview with Control
Logic Design Conventions
Information encoded in binary Low voltage = 0, High voltage = 1 One wire per bit Multi-bit data encoded on multi-wire buses
Combinational element Operate on data Output is a function of input
State (sequential) elements
Store information
Clocking Methodology: Edge triggered
- read contents of some state elements;
- send values through some combinational logic
- write results to one or more state elements
Building a datapath
Datapath: Elements that process data and addresses in the CPU such as Registers, ALUs, mux’s, memories, …
Instruction fetching
Take instructions from the instruction memory and Modify PC to point the next instruction (But PC not updated until the end of the clock cycle!).
Path Built using Multiplexer
R-type instruction Datapath
- Read 2 register operands.
- Perform arithmetic or logical operation.
- Write register result.
(/img/posts/CO/4_7.png)
I-type instruction Datapath
- For ALU
1. - For load