Professional Documents
Culture Documents
CH4 1
CH4 1
The Processor
§4.1 Introduction
Introduction
processor design رح نحكي بهاد التشابتر عن ال ◼
الي رح نتعامل معهم ومهم نرجع نتزكر الinstruction بس هاي ال ◼
الهم ونكون فاهمينها وحافظينهاformat
Lilas qawasmeh
Instruction Execution
؟instruction كيف بنفذ ال ◼
1. fetch instruction
النو ماCPU للmemory من الinstruction ◼ هي عملية انو اقراء ال
memory ح اشتغل عليه وهو بال
هاد الaddress بديmemory من الinstruction ◼ طيب الجيب ال
PC بكون موجود بالaddress
◼ PC (program counter ) : instruction memory , Store
◼ PC target address or PC + 4
Lilas qawasmeh
Instruction Execution
2. Decoding
control ويحدد قيم الinstruction للdecoding هون رح ينعمل ◼
◼ Arithmetic result :
arithmetic/logical operation وبنستخدم الaddمثل ال ◼
و بنحتاجaddress والعمليه الي رح تصير هون هي حساب الsw وlw مثل ال ◼
memory عل الaccess
◼ Branch target address
Lilas qawasmeh
CPU Overview
▪ هال رح نبلش نتعلم designال CPU
Lilas qawasmeh
CPU Overview
رح نبلش بال add instraction ◼
S2
S2+S3
S3 +
Lilas qawasmeh
CPU Overview
هالء نيجي لل lw instraction ◼
address
وعرفنا انو ال 32بنحصل عليها من ال instruction ◼
S2
S2+32
32 +
الي رح نعمله انو رح نستخدم ALUوحده وندخل ال two inputونصير نختار اي وحده ◼
M
u
x
S
instruction
Lilas qawasmeh
Combinational Elements
: الي رح نستخدمهمgate بعض ال ◼
◼ AND-gate ◼ Adder A
Y
+
◼ Y=A&B ◼ Y=A+B B
A
Y
B
◼ Arithmetic/Logic Unit
◼ Multiplexer ◼ Y = F(A, B)
◼ Y = S ? I1 : I0
A
I0 M
u Y ALU Y
I1 x
B
S F
Lilas qawasmeh
Sequential Elements
◼ Register: stores data in a circuit
◼ Uses a clock signal to determine when to update the
stored value
◼ Edge-triggered: update when Clk changes from 0 to 1
register
Clk
D Q D
Clk Q
Lilas qawasmeh
◼
Sequential Elements
◼ Register with write control
Only updates on clock edge when write control input
◼
is 1
◼ Used when stored value is required later
Clk
D Q
Write
Write
Clk D
◼Lilas qawasmeh
Clocking Methodology
◼ Combinational logic transforms data during
clock cycles
◼ Between clock edges
◼ Input from state elements, output to state
element
◼ Longest delay determines clock period
Instruction Fetch
increment رح تعملinstruction وعرفنا اول ما يبلش تنفيذ الpc حكينا عن ال ◼
next instruction لتروح ع ال4 بمقدار
pc والناتج رح يرجع ع الadd بستخدام4 معpc ف رح اجمع ال ◼
Increment by
4 for next
instruction
32-bit
register
◼Lilas qawasmeh
R-Format Instructions
◼ Add $s1,$s2,$s3 tow register ال
read الي ح اعمللهم
registerال
الي ح ينعمله
write
op Rs Rt Rd …
input اول
/ 1 بتكونflag هاي
32-bit لما يكون ال
input تاني result =0
/
/ 32-bit
32-bit ناتج ال, output ال
operation
◼Lilas qawasmeh
Load/Store Instructions
بتحكمControl store والload ال ◼
بالكتابه على ع الaccess بيعملو
write registerال
memory
اليaddress ال
بدي اخزن عليه بتاخد الmemory ال ◼
32-bit
اخزنها Memwrite
رح اعملload و بال ◼
Memread للactive
بتحكمControl
بالقراءه من
read registerال
◼Lilas qawasmeh
Load/Store Instructions
◼ Lw $s1 , 64($s2)
op Rs Rt Offset
32_bit , rs ال ◼
مره16
◼Lilas qawasmeh
Branch Instructions
◼ Beq $s1,$s2,labels
◼Lilas qawasmeh
Branch Instructions
Pc+4 >
increment pc
Target address
pc
Offset*4
Lilas qawasmeh
◼
: ** الي رح يصير
Branch Instructions register من الrt وrs رح يقراء ال
ويشيكALU وبعدين رح يطرحهم بالfile
zero controlع ال
ما بعمل0 واذاbranch بعمل1 اذا كان
branch
op Rs Rt Offset
Just
re-routes
wires
Sign-bit wire
replicated
◼Lilas qawasmeh
Branch Instructions
رح يحط اول بدنا نوضح الي بصير بال sign-extendوال shift ◼
> tow bit
zero ال siftعملية اعادة ترتيب االسالك ◼
0
0
0 bit
0 bit
15 bit
◼Lilas qawasmeh
هيك بنكون حكينا عن 3انواع من ال instructionكل واحد لحال ◼
◼Lilas qawasmeh
R-Type/Load/Store Datapath
lw/sw مع الR-type للdatapath هاي بتمثل ال ◼
◼Lilas qawasmeh
هاي بتمثل ال datapathالسابق مع ال branch ◼
OpCode / ALUOP /
6-bit 2-bit
/ ALU
Control
funCode / 4-bit
6-bit
◼Lilas qawasmeh
§4.4 A Simple Implementation Scheme
ALU Control
◼ ALU used for
◼ Load/Store: F = add
◼ Branch: F = subtract
◼ R-type: F depends on funct field
6-function رح تعملALU حكينا انو ال ◼
shift ال ح نوضحها تحت, بطريقه مختلفهinstruction بجزء محتوى الformat هالء كل ◼
Load/
35 or 43 rs rt address
Store
31:26 25:21 20:16 15:0
Branch 4 rs rt address
31:26 25:21 20:16 15:0
Rs
Rt
الaddress في
اليinstruction Rd
بدي انفذه
offset
رح نقراء
منinstructionال
instruction
memory
رح اقراء او اكتب
memory ع ال
رح يتجزء ال ح يقراء قيم ال sign رح نعمل رح ينفذ ال
instruction register للextend operation
wire على ال المطلوبه offset المطلوبه
Datapath With Control
رح تتحكم بال bitالي داخلين ع ال write registerبحيث بحالة ال
R-Typeبناخد جزء ال rdاما بال lo/swبناخد جزء rt
بتتحكم بالكتابه ع
ال memory
بتتحكم بالكتابه ع
ال Register
◼Lilas qawasmeh
R-Type Instruction
كونا بال R-typeرح يكون ال
branch=0بحيث رح ناخد
كونا بال R-typeرح يكون
قيمة ال pc+4لل pc
ال ALUSrc=0بحيث رح
يكون تاني inputلل ALU
من ال register file
مباشره بدون اي شرطlabel اعرفنا انو رح ينقلنا ع مكان ال, jump ال ◼
عنpc ونوديه للjump الaddress الشي الوحيد الي ح نعمله انو نزبط ◼
◼Lilas qawasmeh
Datapath With Jumps Added
0
للinput تاني
رح يكونALU
Reg file من ال
s2 0
0
s3
address
instruction
add s1 رح ناخد ناتج ال
ALU=
S2+S3
رح نقراء 1 ويخزنها بال
منinstructionال Register file
instruction
memory