Professional Documents
Culture Documents
NKK-HUST Kin Truc May Tinh Thit K B PDF
NKK-HUST Kin Truc May Tinh Thit K B PDF
Thiết kế bộ xử lý
theo kiến trúc MIPS
Nội dung
n
Instruction Instruction
address address
on Instruction Instruction
y memory memory
FIGURE 4.5 Two state elements are needed to store and access instructions, and an
o state elements are needed to store and access adder is needed to compute
instructions, and an the next instruction address. The state elements are the instruction
n
to compute the next instruction Thanh ghi 32-bit chứa địa chỉ của lệnh hiện tại
adder is needed to compute
address. Th e state
memory and the program counter.
memory
elements
the next
andare
thetheinstruction
program
The instruction
address.
counter.
instruction
memory need
The state elements
The instruction memory needare the instruction
only provide read access because the
datapath does not write instructions. Sinceonly provide read
the instruction accessonly
memory because
reads, the
we treat it as combinational
rogram counter. The instruction datapath
memorydoes neednotonly
writeprovide readSince
access because thememory only reads, we treat it as combinational
Địa chỉ khởi động = 0xBFC0 0000
n instruction
rite instructions. Since the memory
logic: the output only
instructions.
at anyreads, weects
timecontrol
refl treat
signal
the
theitcontents
as
instruction
logic: the output at any time reflects the contents of the location specified by the address input, and no read
combinational
is needed. of the
(Welocation
will needspecifi ed by
to write thethe address input,
instruction memory andwhen
no read
we load the program; this is
any time reflects the contents of the location
control signalspecifi ed by(We
is needed. the address
will need input,
to write and
the no read
instruction memory when we load the program;
not hard to add, and we ignore it for simplicity.) The program counter is a 32-bit register this is that is written at the
ded. (We will need to
n writeBộ nhớ lệnh (Instruction memory):
the instruction
not hard to
end of every
we ignore it for simplicity.) The program
memory
add, and we
clockiscycle
counter
when
ignorewe
end
andadd
a 32-bit
it
thus
load
for
of
itsdoes
register
the
not
twothat
program;
simplicity.)
every clock
need
32-bit
Th
cycle eandthis
program
a write
is inputs
written and
is
thus counter
does
atcontrol
not
the thesignal.
place
is
need
sum on
a 32-bit
Thits
a register
write
e adder
controlthat is written
signal. Th e at
adder
is an ALU wired to always
output.
the
is an ALU wired to always
add its two 32-bit inputs and place the sum on its output.
n
puts and place the sum on its output.
Chứa các lệnh của chương trình
ycle and thus does not need a write control signal. The adder is an ALU wired to always
n Khiwhich
có were which từ
địaintroduced
chỉ lệnh werePC introduced
đưa inđến
Chapter 2. Recall
thì lệnh that a typicalđọc
được instance
ra of such an
in Chapter
instruction is add2. Recall that a typical
$t1,$t2,$t3, instance
which of such
reads $t2 an and writes $t1.
and $t3
instruction is add $t1,$t2,$t3, The processor’s which reads $t2 and registers
32 general-purpose $t3 andare writes $t1.
stored in a structure called a
roduced in Chapter n Bộ2.register
cộng
Recall
Th (Add):
that a typical
fiele processor’s
A state được
instance
32register sử
of suchdụng
file. A register
general-purpose
an
registers
file isare tăng nội dung
stored inofa registers
a collection structureincalled
which PCaany register can be
ddregister
$t1,$t2,$t3, which
element reads
register $t2
that consists and $t3
file. A register
read and writes
fileoriswritten $t1.
by specifying
a collection the number
of registers in whichofany
the register in thebefile. The register file
can
or’selement
32 general-purpose thêm
file A state
that consists of a 4
registers
set of để are
registers trỏ
stored
that tới
read or written by specifying in alệnh
structure
containsthe kế
thenumber tiếp
called
register of a
state
theofregister
the computer. In Th
in the file. addition, wefiwill
e register le need an ALU to
register file
of a set of registers
Jan2015 that can
is a collection be read and
of registers written
in which any
Computerregister canread
Architecturebe
- MIPS 11
contains the register operate
state of on
thethe values
computer. In from the registers.
addition, we will need an ALU to
by supplying a register
bycan be read andthe
specifying written
numberoperate
of the on register in the
the values file.
read fromThethe
R-format register filehave three register operands, so we will need to read two
instructions
registers.
NKK-HUST
Increment by
4 for next
instruction
32-bit
register
a. Registers
n Tập thanh ghi (Registers): có 32 thanhb. ALU ghi 32-bit, mỗi thanh
ghi được xác định bởi số hiệu 5-bit
FIGURE 4.7 The two elements needed to implement R-format ALU operations are the
register file and the ALU. The register file contains all the registers and has two read ports and one write
n Read register 1, ofRead register 2: tocác đầu
port. The design of multiported register files is discussed in Section C.8 of
always outputs the contents the registers corresponding the Read vào đểonchọn các
Appendix C. The register file
register inputs the outputs; no thanh ghi
cần
other đọc
control inputs are needed. In contrast, a register write must be explicitly indicated by asserting the
write control signal. Remember that writes are edge-triggered, so that all the write inputs (i.e., the value to
n Write register:
be written, đầuandvào
the register number, đểcontrol
the write chọn thanh
signal) ghiatcần
must be valid ghi
the clock edge. Since writes to
the register file are edge-triggered, our design can legally read and write the same register within a clock cycle:
n Read data
the read will get the1, Read
value written indata
an earlier2: hai
clock cycle,đầu ravalue
while the dữwritten
liệuwillđọc từ tothanh
be available a read in ghi (32-bit)
a subsequent clock cycle. The inputs carrying the register number to the register file are all 5 bits wide, whereas
n Write
the lines Data:
carrying data đầu
valuesvào dữwide.
are 32 bits liệu ghi vào
The operation to bethanh
performed ghi
by the (32-bit)
ALU is controlled with
the ALU operation signal, which will be 4 bits wide, using the ALU designed in Appendix C. We will
n RegWrite: tín output
use the Zero detection hiệuof điều
the ALU khiển ghi dữbranches.
shortly to implement liệu vào thanh
The overflow outputghi
will not be
needed until Section 4.9, when we discuss exceptions; we omit it until then.
n ALU để thực hiện các phép toán số học/logic
Jan2015 Computer Architecture - MIPS 14
NKK-HUST
Just
re-routes
wires
Sign-bit wire
replicated
à Địa chỉ đích = (PC+4) + (hằng số đã mở rộng 32-bit, dịch trái 2 bit)
n Điều kiện đúng: PC ß địa chỉ đích rẽ nhánh (rẽ nhánh xảy
ra)
n Điều kiện sai: PC ß PC+4 (chuyển sang lệnh kế tiếp)
Jan2015 Computer Architecture - MIPS 22
NKK-HUST
nhớ dữ liệu
n Sử dụng các bộ chọn kênh để chọn dữ
liệu nguồn cho các lệnh khác nhau
• ALUSrc: tín hiệu điều khiển chọn toán hạng đưa đến ALU:
• Lệnh kiểu R: toán hạng từ thanh ghi nguồn thứ hai
• Lệnh lw/sw: Hằng số imm 16-bit được mở rộng thành 32-bit (tính địa chỉ)
• MemtoReg: tín hiệu điều khiển chọn dữ liệu đưa về thanh ghi đích:
• Lệnh kiểu R: lấy kết quả từ ALU result
• Lệnh lw: dữ liệu đọc (Read data) từ bộ nhớ dữ liệu
Jan2015 Computer Architecture - MIPS 24
NKK-HUST
• PCSrc: tín hiệu điều khiển chọn giá trị cập nhật PC
• Không rẽ nhánh: PC ß PC+4
• Rẽ nhánh: PC ß (PC+4) + (hằng số imm đã mở rộng thành 32-bit << 2)
Jan2015 Computer Architecture - MIPS 25
NKK-HUST
lw/sw 35 or 43 rs rt imm
31:26 25:21 20:16 15:0
beq 4 rs rt imm
31:26 25:21 20:16 15:0
Tên tín hiệu Hiệu ứng khi tín hiệu = 0 Hiệu ứng khi tín hiệu = 1
MemRead Không làm gì cả Nội dung ngăn nhớ dữ liệu, được xác
định bởi địa chỉ do ALU tính, được đưa
ra đầu ra Read data của bộ nhớ dữ
liệu
MemWrite Không làm gì cả Dữ liệu trên đầu vào Write Data của bộ
nhớ dữ liệu được ghi vào ngăn nhớ có
địa chỉ do ALU tính
MemtoReg Giá trị được đưa đến đầu Giá trị được đưa đến đầu vào Write
vào Write data của tập thanh data của tập thanh ghi là từ bộ nhớ dữ
ghi là từ ALU result liệu
Hazard dữ liệu
n Lệnh phụ thuộc vào việc hoàn thành truy
cập dữ liệu của lệnh trước đó
add $s0, $t0, $t1
sub $t2, $s0, $t3
Dự đoán rẽ nhánh
n Những đường ống dài hơn không thể
sớm xác định dễ dàng kết quả rẽ nhánh
n Cách trì hoãn không đáp ứng được
n Dự đoán kết quả rẽ nhánh
n Chỉ trì hoãn khi dự đoán là sai
n Với MIPS
n Có thể dự đoán rẽ nhánh không xẩy ra
n Nhận lệnh ngay sau lệnh rẽ nhánh (không
làm trễ)
Prediction
correct
Prediction
incorrect
MEM
WB
Nhận xét
n Các lệnh và các dữ liệu được chuyển từ
trái sang phải qua 5 công đoạn.
n Có hai ngoại lệ từ phải sang trái:
n Công đoạn write-back đặt kết quả về thanh
ghi ở giữa datapath à dẫn đến data hazard
n Chọn giá trị tiếp theo của PC là PC+4 hay địa
Wrong
register
number
Hết