You are on page 1of 35

DIGITAL LOGIC AND

COMPUTER ORGANIZATION
Lecture 16: Single Cycle Microprocessor (P2)
ELEC3010
ACKNOWLEGEMENT

I would like to express my special thanks to Professor Zhiru Zhang


School of Electrical and Computer Engineering, Cornell University
and Prof. Rudy Lauwereins, KU Leuven for sharing their teaching
materials.

2
COVERED IN THIS COURSE
❑ Binary numbers and logic gates
❑ Boolean algebra and combinational logic
❑ Sequential logic and state machines
❑ Binary arithmetic
Digital logic
❑ Memories

❑ Instruction set architecture


❑ Processor organization Computer
❑ Caches and virtual memory
❑ Input/output Organization
❑ Advanced topics
3
LET’S BUILD A MICROPROCESSOR!

4
RF REVIEW

What need to be
changed if the RF
has 32 registers?

5
CONTROL UNIT (CU)
❑ Regulates the interaction between data and operations on
data (i.e., datapath)
❑ Series of control words control the datapath to perform a
sequence of operations
❑ The sequence of operations performed by the CU may be
affected by the ALU Condition Codes
▪ Z: Zero
▪ N: Negative
▪ Also V: Overflow and C: Carry out
6
DATAPATH + CONTROL UNIT

7
SEQUENCE OF OPERATIONS

8
SEQUENCE OF OPERATIONS

9
SEQUENCE OF OPERATIONS

10
SEQUENCE OF OPERATIONS

11
CAN YOU DO IT?

What are the values of different fields in the instruction when executing the following instructions:
ADD R2, R3, R7
ADDI R4, R6, 2
LOAD R2, 2(R1)
12
UNSIGNED MULTIPLICATION
❑ Form each partial product by multiplying a single digit of
the multiplier by the multiplicand
❑ Add shifted partial products to get result

13
ITERATIVE (SHIFT AND ADD) MULTIPLICATION

14
ITERATIVE (SHIFT AND ADD) MULTIPLICATION

15
CAN YOU DO IT?

16
OPERATION SEQUENCE FOR ITERATIVE MULTIPLICATION

17
PROGRAMMABLE CONTROL UNIT
❑ Datapath (RF, ALU, RAM, muxes) is flexible
❑ However, FSM-based multiplier control unit is “hardwired”
▪ New operation sequence would require new state machine
❑ Programmable control unit
▪ Control words stored in RAM
▪ State machine replaced by a Program Counter plus branch
operations
▪ Flexible: Can run different sequences of control words
(programs)

18
PROGRAM COUNTER (PC)
❑ Special register that points to the location (address) in
RAM of the next control word
❑ Updated every clock cycle
❑ Sequential execution (default behavior)
▪ Control words read from sequential RAM locations
▪ PC increments after each control word read
❑ Branch operations
▪ Special control flow operations
▪ Condition code determines whether to branch or not
▪ If so, next RAM address is PC + branch offset

19
PC-BASED CONTROL UNIT

Assumption: each RAM row can store 1 control word


20
BRANCH OPERATIONS
❑ Used to jump to a different part of the program
❑ Consists of a condition and an offset
❑ Condition
▪ Checks to see whether the result of the last instruction met a
specified criteria, such as
• Zero (Z = 1), Negative (N = 1)
❑ Offset
▪ How far ahead, or back, to jump within the program if the
condition is met

21
BRANCH OPERATIONS

22
BRANCH OPERATIONS

23
CAN YOU DO IT?

24
PROGRAMMABLE MULTIPLICATION

25
PROVIDING EVEN MORE FLEXIBILITY
❑ Replace control words with
instructions
▪ More intuitive and not specific to
particular hardware
▪ Shorter than control words
▪ Instruction decoder (hardwired
logic) creates the control words
from the instruction

26
OUR INSTRUCTION FORMATS

27
R-TYPE INSTRUCTIONS

28
I-TYPE: ALU WITH IMMEDIATE

What is Min/Max of IMM?

How many Opcodes?

29
I-TYPE: LOAD AND STORE

30
MEMORY OPERATIONS
❑ The smallest addressable quantity in a modern memory
system is a byte (8 bits)
▪ A memory address points to a byte

❑ LB (Load Byte): reads the byte at this address

❑ LW (Load Word): reads a word this address, which in our


case is 2 bytes

31
I-TYPE: BRANCH

32
ITERATIVE MULTIPLICATION REVISITED

Assumption: One
instruction is stored in 2
rows (i.e., 2 bytes) of
the instruction memory

33
PROGRAMMABLE SINGLE-CYCLE PROCESSOR

❑ Instruction RAM holds the program to be run


▪ Here, each instruction is 16 bits (2 bytes)
❑ Decoder derives control word from the instruction
34
BEFORE NEXT CLASS

• Textbook: 7.5.1-7.5.2
• Next time:
Pipelined Microprocessor

35

You might also like