Single-cycle Datapath and pipelining Flashcards
What are the 5 steps in the datapath when executing an instruction?
1.
Use PC to fetch instruction from instruction memory.
Next PC is also computed as either (PC + 4) or target address
2.
Grab registers from instruction and accesses the register file to read registers that needs to be read
- Instruction is executed.
ALI (arithmetic result, calculate address for load/store, calculate target of branch address)
4.
Access memory (if necessary)
5.
Write result to register file (if there is a result)
What are multiplexers used for?
Can’t join wires together, so combine multiplexers with control signals to determine which input is used
What logical value does Low voltage/ground have?
0
How many bits are there per wire?
One bit per wire
How are multi-bit data encoded?
On multi-wire buses
What are to types of circuit elements used in creating a data path
Combinational element
State (sequential) element
What is an combinational element?
Operate on data
The output is a function of input.
AND, Adder, Multiplexer, ALU
What is an state (sequential) element?
Stores data
Basic unit is a flip flop.
Stores values on its input, and does it on the rising edge of the clock.
It is common to assemble flip flops into registers to be able to store multibit values that has something to do with each other
What does an adder do?
Binary addition of two binary numbers
Y = A + B
How does a multiplexer compute its outout?
Y = S ? I1 : I0
I1: Input 1
I0: Input 0
S: Selector signal
What is a critical path?
The worst case latency between two state elements.
The latency the signal must traverse within a clock cycle.
Avoids for example storing values before the input is comletely ready.
What is the data path?
Elements that process data and addresses in the CPU (Registers, ALUs, mux’s, memories)
How are instructions fetched using a PC?
PC is a 32-bit register (addresses are 32 bit)
Output of PC is addresses in instruction memory
PC output are used to fetch instruction from instruction memory
What happens in parallell during instruction fetch
While the PC is used to fetch the instruction from instruction memory,
The current PC is incremented by 4 to get the address of the next instruction.
How are ALU instructions executed?
- Need to read 2 register operands
- Perform the operation
- Write result
Components: Register file, ALU
What are the components of a register file?
2 read ports:
- both 5 bit wide (instruction format have 5 bits for specifying registers)
2 output (ports?) that go into the input of ALU
write input port: write registers
write data input port: to write data
RegWrite signal: Makes sure we don’t write register unless we need to.
What are the components of the ALU?
Two inputs
Input signal: Tells which operation to perform (4 bit gives 16 possible ops, dependent on architecture)
Results
Zero bit: Not used for arithmetic, but for branching
What is needed to be able to execute load/store instructions?
- Read register operands
2.
Calculate address (ALU): Need to sign extend the offset because it is not the full 32 bit (is an immediate supplied in the instruction)
3.
Finish instruction by providing address and the write data (on stores), or grab data (on loads).
2 signals:
MEMRead signal: Tell that we need to read.
MemWrite: tell we need to write
What is needed to support branch instructions?
1.
Read register operands (register file)
- Compare operands (ALU)
3.
Calculate target address
- sign-extend displacement
- Shift left 2 places (because we know we are branching to a 32 bit value)
- Add to PC + 4
How to decide if we should branch
Take values from register and send them to ALU.
Provide ALU with operation signal for subtract.
If result of subtraction is zero, they are equal and we should branch.
What is a single-cycle architecture
An architecture where all of the stages in the datapath is executed within one clock cycle
In a MIPS datapath, what are the ALU used for
Load/store: function signal ‘add’
Branch: function signal ‘sub’
R-type: function depends of funct field in instruction
What is the ALUOp control signal?
Come from main control unit, derived it from opcode.
00: load or store
01: Branch equal
10: R-types
ALU control is set based on ALUOp and funct.
For 00 and 01, it doesn’t matter what the funct field is.
For R-types (add, sub, and, or), the funct field are as defined in instruction