Beruflich Dokumente
Kultur Dokumente
Chidhambaranathan Rajamanikkam(canr1g09)
24 September 2010
PowerPC processor is designed by IBM. It is widely used in many embedded systems because
of its low power consumption. PowerPC processor is designed using the RISC (Reduced Instruction
Set Computing) instruction set architecture.
This project gives an overview of the implementation of a 32-bit pipelined processor. The
designed pipelined processor is capable of executing PowerPC instructions. The instructions include
PowerPC fixed point integer instructions, branch instructions and integer load/store instructions. The
processor is designed using Verilog description language. These modules are successfully tested using
NC Verilog simulator.
This report gives the information of the instruction set and their forms and architecture of the
PowerPC processor. It also covers the information on the pipelining approach adopted and the data
and control hazards associated with it. The designed processor overcomes both data and control
hazards.
Canr1g09
1
I would like to thank my project supervisor, B Iain McNally for his valuable guidance and
support for doing this project. I would to extend my gratitude to my second examiner Dr. Koushik
Maharatna for his support.
Canr1g09
2
ABSTRACT ------------------------------------------------------------------------------------------------------------------------------------- 1
ACKNOWLEDGEMENT --------------------------------------------------------------------------------------------------------------------- 2
CONTENTS ------------------------------------------------------------------------------------------------------------------------------------- 3
LIST OF FIGURES ----------------------------------------------------------------------------------------------------------------------------- 5
LIST OF TABLES------------------------------------------------------------------------------------------------------------------------------- 6
CHAPTER 1: INTRODUCTION ------------------------------------------------------------------------------------------------------------- 7
CHAPTER 2: BACKGROUND -------------------------------------------------------------------------------------------------------------- 8
2.1 POWERPC: ------------------------------------------------------------------------------------------------------------------------------ 8
2.2 POWERPC REGISTERS: ----------------------------------------------------------------------------------------------------------------- 8
2.2.1 General Purpose Registers: ------------------------------------------------------------------------------------------------ 8
2.2.2 Exception Register: ----------------------------------------------------------------------------------------------------------- 8
2.2.3 Count Register: ---------------------------------------------------------------------------------------------------------------- 9
2.2.4 Condition Register: ----------------------------------------------------------------------------------------------------------- 9
2.2.5 Link Register: ----------------------------------------------------------------------------------------------------------------- 10
2.3 POWERPC DATA TYPES:-------------------------------------------------------------------------------------------------------------- 10
2.4 POWERPC BRANCH INSTRUCTIONS: ------------------------------------------------------------------------------------------------- 10
2.4.1Addressing Modes: ---------------------------------------------------------------------------------------------------------- 11
2.5 POWERPC LOAD/STORE INSTRUCTIONS: ------------------------------------------------------------------------------------------- 11
2.5.1 Addressing Modes: --------------------------------------------------------------------------------------------------------- 11
2.5.2 Load Instructions: ----------------------------------------------------------------------------------------------------------- 12
2.5.3 Store Instructions: ---------------------------------------------------------------------------------------------------------- 13
2.6 POWERPC FIXED POINT INTEGER INSTRUCTIONS: ---------------------------------------------------------------------------------- 13
2.6.1 Arithmetic Instructions: --------------------------------------------------------------------------------------------------- 13
2.6.2 Logical Instructions: -------------------------------------------------------------------------------------------------------- 14
2.6.3 Sign- Extension Instructions: --------------------------------------------------------------------------------------------- 14
2.6.4 Rotate Instructions: -------------------------------------------------------------------------------------------------------- 14
2.6.4.2 PowerPC Rotate Instructions: --------------------------------------------------------------------------------------------------- 15
Canr1g09
3
Canr1g09
4
Canr1g09
5
Canr1g09
6
The main aim of the project is to design a 32-bit pipelined PowerPC processor. Verilog HDL
is used as the hardware description language for writing the modules. The length of an instruction and
registers are 32 bit long. The modules are simulated and the final results of the simulation are
analysed. The designed processor runs fixed point integer instructions, branch instructions, integer
load/store instructions, and sign-extension instructions. The fixed point integer instructions include
arithmetic, logical, compare, shift, and rotate instructions.
The chapter 2 covers the background study of the PowerPC processor. The registers and the
instruction format of PowerPC processor are covered in this chapter. The pipeline approach and
hazards occurring in the pipelined processor are also included in this chapter.
The chapter 3 in this report covers the design architecture for different instructions. The
datapath for fixed point integer instructions, load/store instructions, branch instructions are designed
and explained in this chapter.
The chapter 4 in this report covers the testing the design in NC Verilog simulator. The final
result of datapath design is discussed with their waveform.
List of implemented instructions shown in Appendix [3] and instructions which are not
implemented in the design are shown in the Appendix [4] section of the report. The program which is
used for testing is also shown in the Appendix [5].
Canr1g09
7
2.1 PowerPC:
PowerPC processor is a 32 bit processor which is capable of doing floating point, fixed point,
control instructions and also memory management instructions. The fixed point instructions include
arithmetic, logical, compare, shift and rotate instructions. PowerPC consists of general purpose
registers and various special purpose registers such as Program counter, also called as Next
Instruction Pointer (NIP)/ Instruction Address Pointer, Link register, and count register [5]. Some
PowerPC processors also have 32 (64 or 32 bit) floating point registers. PowerPC is an example of the
RISC architecture. The RISC architecture in the PowerPC allows [5]:
All the instructions in the PowerPC processor are fixed 32 bit length Instructions [5].
In PowerPC, data from the memory is retrieved and stored in registers and then written back
to the memory. There are some instructions (except load and store instructions) that
manipulate memory directly [5].
Canr1g09
8
Canr1g09
9
Canr1g09
10
2.4.1Addressing Modes:
Branch instructions uses three addressing modes for calculating the branch target address. The
three addressing modes are explained in this section. Both the conditional and unconditional branch
instruction uses the absolute addressing [3]. For the unconditional branch, the effective address of
the next instruction is calculated by the 24-bit immediate value within the instruction. This immediate
value is extended to 32 bit length by adding two 0-bits in the right and sign extending the left. For the
conditional branch, the effective address of the next instruction is calculated by the 16-bit immediate
value within the instruction [3]. This 16-bit is extended to 32 bit by adding two 0-bit in the right and
sign extending to the left.
As like absolute addressing, relative addressing is also used for both conditional and
unconditional branching. The effective address calculation is same as the absolute addressing. The
resulting address is added with the current instruction address to produce next instruction address [3].
Indexed Addressing is used only by the conditional branch instructions. The effective
address of the next instruction is taken from either link register or count register [3]. In this case, the
count register is used to hold the address of the branch instruction. This is also can be used to hold the
count for looping.
Canr1g09
11
Signed Displacement
16
disp
+
With update
Logical Address
To address translation
+
With update
Logical Address
To address translation
Canr1g09
13
1 1 1 1 1 11
MB
0 0 0 0 0.0
ME
31
000000000.......0
ME
1 1 1 1 1. . . 1
MB
31
Canr1g09
16
CLK
Inst 1
IF
Inst 2
Inst 3
ID
EX
MEM
WB
IF
ID
EX
MEM
WB
ID
EX
MEM
IF
ID
EX
IF
ID
IF
Inst 4
Inst 5
Canr1g09
17
IF
ID
EX
Inst 2
Inst 1
Inst
Instruction Flushed
MEM
Branch is taken
Figure 6: Control Hazards
ID
EX
MEM
WB
Dataforwarding
Forward to the dataforwarding unit [9]. Now the r2 is available for the next instruction shown in
figure 7.
2.7.1.3.2 Load-Use Hazard:
For example, lwz r15, 0010h and or r10, r15, r12
The load-use hazard occur when instruction is depends on previous load instruction result. To avoid
this hazard, the ID stage is stalled for 1 clock cycle. The result of the load instruction is available in
Canr1g09
18
IF
ID
EX
MEM
WB
Canr1g09
19
The 32-bit PowerPC Processor is designed using the verilog description language modules.
The initial Datapath is designed and expanded accordingly to suitable for the PowerPC instruction set.
The main aim of the project is to design the Pipelined processor which supports PowerPC instruction
set. But with the given time limit, the designed processor supports the fixed point integer instructions,
load/store instructions, and branch instructions. The design is started with implementing the basic
arithmetic and logical instructions and tested. The design is then expanded by adding the load/store
instructions, data forwarding and load-use.
Canr1g09
20
IF/ID
ID/EX
EX/MEM
MEM/WB
32
Immediate value
4
A
+
Result
IP
L
32
Inst[0:31]
Memory
address
op0
32
32
Data
Memory
Data
Data
Input
op1
Instruction
Memory
Reg1_add
Reg0_add
Write Back
Data
NIP
Out
Register Bank
Mem_data
32
32
Mem_data
Regshift_add 1
Mem_data
Write Back
Data
Write Back
Reg
IF_Phase
Regshift_add
Reg0_add
Write Back
Reg
5
Write Back
Reg
ID_Phase
MEM_Phase
WB_Phase
EX_Phase
Canr1g09
21
Canr1g09
22
IF/ID
ID/EX
Opcode[0:5]
EX/MEM
MEM/WB
simm[0:31]
Wb_reg[0:4]
32
32
ID_Wb_reg[0:4]
32
Imm_is[0:31]
Regshift_add[0:4]
EX_Wb_reg[0:4]
op0[0:31]
5
ID_op1[0:31]
32
Alu_operands
A
op1[0:31]
5
5
EX_out[0:31] 32
32
L
U
ID_op2[0:31]
MEM_wb_data[0:31]
CR0
Field
32
CR
Reg_bank
Wb_reg[0:4]
IF_Phase
Wb_data[0:31]
MEM_Wb_reg[0:4]
32
out[0:31]
32
32
Reg1_add[0:4]
Reg0_add[0:4]
Value_op0[0:31]
Value_op1[0:31]
Inst[0:31]
Control
ID_Phase
EX_Phase
MEM_Phase
Canr1g09
23
Canr1g09
24
IF/ID
ID/EX
Opcode[0:5]
EX/MEM
MEM/WB
uimm[0:31]
Wb_reg[0:4]
32
Imm_is[0:31]
Reg0_add[0:4]
op0[0:31]
32
32
ID_Wb_reg[0:4]
EX_Wb_reg[0:4]
ID_op1[0:31]
32
Alu_operands
A
op1[0:31]
out[0:31]
32
EX_out[0:31] 32
32
U
ID_op2[0:31]
MEM_wb_data[0:31]
32
Reg_bank
CR0
Field
CR
Wb_reg[0:4]
Wb_data[0:31]
MEM_Wb_reg[0:4]
32
32
Reg1_add[0:4]
Regshift_add[0:4]
Value_rs[0:31]
Value_op1[0:31]
Inst[0:31]
Control
32
IF_Phase
ID_Phase
EX_Phase
MEM_Phase
Canr1g09
25
Canr1g09
26
IF/ID
ID/EX
Opcode[0:5]
Extended opcode[0:9]
6
Wb_reg[0:4]
op0[0:31]
EX_Wb_reg[0:4]
ID_Wb_reg[0:4]
ID_op1[0:31]
32
Alu_operands
A
op1[0:31]
EX_out[0:31] 32
32
U
ID_op2[0:31]
MEM_wb_data[0:31]
32
out[0:31]
32
32
CR0
Field
Reg_bank
CR
Wb_reg[0:4]
Wb_data[0:31]
MEM_Wb_reg[0:4]
Reg1_add[0:4]
Regshift_add[0:4]
Value_rs[0:31]
Value_op1[0:31]
Inst[0:31]
Control
Reg0_add[0:4]
MEM/WB
32
32
Sh[0:4]
EX/MEM
32
5
IF_Phase
ID_Phase
EX_Phase
MEM_Phase
Canr1g09
27
Canr1g09
28
IF/ID
ID/EX
ID_ME[0:4]
5
5
ID_MB[0:4]
6
Sh[0:4]
Reg0_add[0:4]
op0[0:31]
Regshift_add[0:4]
Reg1_add[0:4]
ID_op1[0:31]
32
op1[0:31]
Reg1_add[0:4]
Regshift_add[0:4]
Reg0_add[0:4]
32
32
32
EX_out[0:31]
32
32
32
Rotate
Value_op0[0:31]
Reg0_add[0:4]
out[0:31]
Alu_operands Wb_reg[0:4]
MEM_wb_data[0:31]
32
Opcode[0:5]
Value_op1[0:31]
Value_rs[0:31]
Inst[0:31]
Control
Mask
Generation
MEM/WB
Mask[0:31]
ME[0:4]
MB[0:4]
EX/MEM
ID_op2[0:31]
5
EX_Wb_reg[0:4]
ID_Wb_reg[0:4]
Reg_bank
Wb_data[0:31]
MEM_Wb_reg[0:4]
CR0
Field
CR
Wb_reg[0:4]
IF_Phase
ID_Phase
EX_Phase
MEM_Phase
Canr1g09
29
Canr1g09
30
IF/ID
ID/EX
Opcode[0:5]
simm[0:31]
CrfD[0:2]
Inst[0:31]
Control
32
Wb_cr[0:2]
op0[0:31]
ID_Wb_cr[0:2]
ID_op1[0:31]
Alu_operands
5
lt
gt
op1[0:31]
Value_op0[0:31]
Value_op1[0:31]
Reg1_add[0:4]
Reg0_add[0:4]
Reg_bank
EQ
SO
ID_op2[0:31]
32
32
EX_Wb_cr[0:2]
32
CR
CRn
field
IF_Phase
ID_Phase
EX_Phase
Canr1g09
31
Canr1g09
32
IF/ID
ID/EX
Opcode[0:5]
10
Wb_reg[0:4]
Regshift_add[0:4]
ID_Wb_reg[0:4]
EX_Wb_reg[0:4]
op0[0:31]
Disp[0:31]
32
ID_op1[0:31]
32
Alu_operands
op1[0:31]
32
ld
32
32
32
Address
Data
Memory
ID_op2[0:31]
ID_ld
ld
Data out
Reg_bank
Wb_reg[0:4]
Wb_data[0:31]
ID_update
Upd_add[0:4]
EX_EA[0:31]
ID_Phase
MEM_wb_data[0:31]
32
EA[0:31]
MEM_Wb_reg[0:4]
Reg1_add[0:4]
Reg0_add[0:4]
32
Update
Value_op1[0:31]
Value_op0[0:31]
32
IF_Phase
EX_EA[0:31]
Inst[0:31]
MEM/WB
Extendedopcode[0:9]
Control
EX/MEM
EX_EA[0:31]
EX_Phase
MEM_Phase
Canr1g09
33
Canr1g09
34
IF/ID
ID/EX
Opcode[0:5]
Extendedopcode[0:9]
Control
Disp[0:31]
10
32
op0[0:31]
Regshift_add[0:4]
Inst[0:31]
EX/MEM
ID_op1[0:31]
Alu_operands
32
Reg1_add[0:4]
Reg0_add[0:4]
Regshift_add[0:4]
32
32
st
ID_op2[0:31]
ID_st
Update
32
Value_op1[0:31]
Value_op0[0:31]
EA[0:31]
EX_EA[0:31]
op1[0:31]
Address
Data
Memory
st
Data in
Reg_bank
Mem_data[0:31]
32
ID_update
Upd_add[0:4]
5
IF_Phase
ID_Mem_data[0:31]
ID_Phase
EX_EA[0:31]
EX_Phase
MEM_Phase
Canr1g09
35
Canr1g09
36
IF/ID
EX/MEM
ID/EX
PC_addr
IP
4
+
32
Inst[0:31]
AA 1
NIP
ID_PC_addr
Data
32
control
LI[0:31]
BD[0:31]
MB[0:5]
ME[0:5]
32
brtgt_addr
32
32
5
LK
32
Branch_cond
Branch_addr[0:31]
32
Link
register
Instruction
Memory
Branch_
check
1
CR
Canr1g09
37
Canr1g09
38
IF/ID
EX/MEM
MEM/WB
4
+
32
Stall_PC
out
EX_out 32
32
Op0_sel
Op1_sel
Load-Use
NIP
1
1
1
rs_sel
32
inst
control
Regshift_add
IP
32
EX_out
32
32
0
Mem_data
32
MEM_Wb_reg
NIP
32
32
32
32
Alu_op0
32
Data in
32
Data out
A
out
32
L
0 32
1
Alu_op1
Data
Memory
MEM_wb_data
Wb_data
Wb_reg
op0
Address
MEM_wb_data
Register
bank
Value_rs
IP
Data Forward
{value_op0, valu_op1}
32
0
1
{file_op0, file_op1}
{Reg0_add, reg1_add}
32
Ins_mem
Alu_operands
op1
Wb_reg
5
ID_Wb_reg
IF_Phase
EX_Wb_reg
MEM_Wb_reg
5
32
ID_Phase
EX_Phase
MEM_Phase
Canr1g09
39
Canr1g09
40
This chapter covers how to create the PowerPC processor instructions, simulating the
instructions and final result of the each design. The NC Verilog simulator is used to simulate the
instruction and the output signal waveform is verified and the design is not synthesized.
Canr1g09
41
Canr1g09
42
Canr1g09
43
Canr1g09
44
Canr1g09
45
Canr1g09
46
Canr1g09
47
Canr1g09
48
Canr1g09
49
Canr1g09
50
Canr1g09
51
Canr1g09
52
Canr1g09
53
Canr1g09
54
Canr1g09
55
Canr1g09
56
Canr1g09
57
Canr1g09
58
Canr1g09
59
Canr1g09
60
Canr1g09
61
Canr1g09
62
Two Gantt chart is shown in the table 1 and table 2. The table 1 shows the Gantt chart for the
project at the beginning stage. The work for the project is planned and weekly milestones are set. The task
plans and weekly milestones are shown in the gantt chart. During the later part of the project, the gannt
chart is modified and the final gantt chart is shown in the table 2. The project task plan and milestones
was completed successfully.
Canr1g09
63
14/06 -
21/06 -
28/06 -
5/07 -
12/07 -
19/07 -
26/07 -
2/08 -
9/08 -
16/08 -
23/08 -
30/08 -
6/09 -
13/09 -
20/09 -
19/06
25/06
2/07
9/07
16/07
23/07
30/07
6/08
13/08
20/08
27/08
3/09
10/09
17/09
27/09
Supervisor Holiday
Topic Selection
ACTIVITIES
Background
Research
PowerPC
Instruction set
Initial Datapath
Pipelining
Tasks
Initial Datapath
Behavioural Level ALU
Behavioural Level
Condition Codes
Canr1g09
64
*
*
ALU
Behavioural Level
Condition Codes
Behavioural Level -
Memory
Behavioural Level -
Processor
End of Practical
Work
Canr1g09
65
Milestone
demonstrate
to
sup/examiner
Milestone
dissertation
draft
complete
Final corrections
Milestone Hand-in
Canr1g09
66
14/06 21/06
28/06
5/07
12/07
19/07
26/07
2/08
9/08
16/08
13/09 20/09
2/07
9/07
16/07
23/07
30/07
6/08
13/08
20/08
27/08 3/09
19/06 25/06
Supervisor Holiday
Topic Selection
ACTIVITIES
Background Research
PowerPC
Instruction set
Initial Datapath
Pipelining
Tasks
Initial Datapath
Behavioural Modules
Arithmetic
and
Logical Instructions
Canr1g09
67
and
Store
Instructions
Pipeline
Implementation
Data Forwarding and
load-use
Branch Instructions
conditional
and
unconditional
Rotate
and
Shift
Instructions
Sign-Extension
Instructions
Final Design
Writing-up
MILESTONES
Initial Datapath
Arithmetic
*
and
Logical Instructions
Canr1g09
68
and
Store
Instructions
Pipelining
Implementation
Pipelining with data
forwarding and Load-
use Implementation
Branch Instructions
Rotate and Shift
*
*
Instructions
End of Practical Work
Final Design
Milestone
demonstrate to
sup/examiner
Milestone
dissertation draft
complete
Final corrections
Milestone Hand-in
Canr1g09
69
The aim of the project is to design the 32-bit pipelined processor. The pipelined processor is
designed and it can execute the PowerPC instructions. The pipelined processor can execute fixed
point integer instructions, load/store instructions, and branch instructions. The fixed integer
instructions include arithmetic, logical, compare, rotate and shift instructions. Each instruction takes
five clock cycles for its complete execution. The data hazard is encountered in the pipelined processor
and it is eliminated by implementing data forwarding and load-use module. The pipelined processor
also supports PowerPC branch instructions. The control hazard is eliminated by flushing the
instruction in IF and ID stages of the pipeline. The pipelined processor also supports the PowerPC
integer load/store instructions.
6.1 Achievements:
Pipeline is implemented in the processor design and fully working.
All the instructions which are implemented executes successfully.
The hazards such as data hazards and the control hazards are encountered in earlier part of the
design and they are been eliminated at the later part of the design.
Within the time period given, the pipelined processor is able to execute fixed point
instructions, branch instructions, and load/store instructions.
6.2 Limitations:
Due to time limit, the system call instructions are not implemented.
The design is not synthesized because of the limited time period.
The design will not execute floating point instructions, memory management instructions,
load/store multiple instructions, load/store string instructions, and processor control
instructions.
Canr1g09
70
With the given amount of time period, the processor can able to run the fixed point integer
instructions, integer load store instructions, and branch instructions. The system call instructions are
mot implemented because of the given time period.
In future, the processor can be expanded with implementing floating point instructions
load/store multiple instructions, load/store byte reverse instructions, system linkage instructions, trap
instructions, condition register logical instructions, integer load/store string instructions, branch
conditional-count register, branch conditional-link register, TLB Management instructions, processor
control instructions, cache management instructions, and synchronization instructions.
If I would have an additional one more month, I could able to implement system call
instructions, condition register logical instructions, branch conditional-link register, and branchconditional to count register in the design.
Canr1g09
71