dce

2009

Thiết kế mạch số dùng HDL

Chương 7 Thiết kế và tổng hợp bộ điều khiển dòng dữ liệu

Nội dung chính

• Máy tuần tự phân hoạch • Các ví dụ thiết kế

i

9 0 0 2 g n i r e e n g n E r e t u p m o C

2 ©2009, Pham Quoc Cuong Advanced Digital Design with the Verilog HDL – chapter 7

Phân loại hệ thống số

• Control-dominated

 Là hệ thống đáp ứng đáp lại tác động bên

ngoài

• Data-dominated

i

 Yêu cầu tính toán và truyền nhận dữ liệu với

hiệu suất cao

 Hệ thống thông tin liên lạc, xử lý tín hiệu,…  Máy tuần được phân loại và phân hoạch thành bộ dòng dữ liệu và bộ điều khiển

9 0 0 2 g n i r e e n g n E r e t u p m o C

3 ©2009, Pham Quoc Cuong Advanced Digital Design with the Verilog HDL – chapter 7

Bộ dòng dữ liệu – datapaths unit

• Bộ số học luận lý (arithmetic logic unit -

i

ALU) • Bộ cộng • Bộ nhân • Bộ xử lý tín hiệu số • Quản lý tài nguyên (registers) • …

9 0 0 2 g n i r e e n g n E r e t u p m o C

4 ©2009, Pham Quoc Cuong Advanced Digital Design with the Verilog HDL – chapter 7

Mô hình điều khiển cho dòng dữ liệu

i

9 0 0 2 g n i r e e n g n E r e t u p m o C

5 ©2009, Pham Quoc Cuong Advanced Digital Design with the Verilog HDL – chapter 7

Các bước thiết kế

• Application-driven • Lựa chọn cấu trúc hỗ trợ cho tập lệnh trong ứng dụng

i

• Định nghĩa các trạng thái điều khiển hỗ trợ tập lệnh

• Xây dựng FSM sinh ra tín hiệu điều khiển

9 0 0 2 g n i r e e n g n E r e t u p m o C

6 ©2009, Pham Quoc Cuong Advanced Digital Design with the Verilog HDL – chapter 7

Ví dụ thiết kế bộ đếm nhị phân

• Máy trạng thái không tường minh

 count <= count + 1

• Phân hoạch thành bộ điều khiển và bộ dòng dữ liệu (Binary_Counter_Arch)

i

• Máy trạng thái tường minh (Binary_Counter_STG)

• ASM • RTL

9 0 0 2 g n i r e e n g n E r e t u p m o C

7 ©2009, Pham Quoc Cuong Advanced Digital Design with the Verilog HDL – chapter 7

Binary_Counter_Arch

i

9 0 0 2 g n i r e e n g n E r e t u p m o C

8 ©2009, Pham Quoc Cuong Advanced Digital Design with the Verilog HDL – chapter 7

Binary_Counter_STG

i

9 0 0 2 g n i r e e n g n E r e t u p m o C

9 ©2009, Pham Quoc Cuong Advanced Digital Design with the Verilog HDL – chapter 7

ASM

i

ASM

ASMD cho bộ dòng dữ liệu được điều khiển bởi máy trạng thái

9 0 0 2 g n i r e e n g n E r e t u p m o C

10 ©2009, Pham Quoc Cuong Advanced Digital Design with the Verilog HDL – chapter 7

Binary_Counter_Part_RTL

i

9 0 0 2 g n i r e e n g n E r e t u p m o C

11 ©2009, Pham Quoc Cuong Advanced Digital Design with the Verilog HDL – chapter 7

Tổng hợp mạch Binary_Counter_Part_RTL

i

Tổng hợp bằng Actel Libero IDE 8.2

9 0 0 2 g n i r e e n g n E r e t u p m o C

12 ©2009, Pham Quoc Cuong Advanced Digital Design with the Verilog HDL – chapter 7

Tổng hợp mạch Binary_Counter_Part_RTL

i

Datapaths unit

Tổng hợp bằng Actel Libero IDE 8.2

9 0 0 2 g n i r e e n g n E r e t u p m o C

13 ©2009, Pham Quoc Cuong Advanced Digital Design with the Verilog HDL – chapter 7

Ví dụ thiết kế máy RISC

• RISC: Reduced instruction-set computers

 Tập lệnh đơn giản  Số chu kỳ clock cho mỗi lệnh là nhỏ

i

9 0 0 2 g n i r e e n g n E r e t u p m o C

14 ©2009, Pham Quoc Cuong Advanced Digital Design with the Verilog HDL – chapter 7

Kiến trúc của RISC_SPM

i

9 0 0 2 g n i r e e n g n E r e t u p m o C

15 ©2009, Pham Quoc Cuong Advanced Digital Design with the Verilog HDL – chapter 7

Trình tự thực thi

• Lấy lệnh từ bộ nhớ • Giải mã lệnh và lấy toán hạng • Thực thi lệnh

i

 Các tác vụ trên bộ ALU  Cập nhật giá trị thanh ghi lưu trữ  Cập nhật bộ đếm chương trình (PC)  Cập nhật thanh ghi lệnh (IR)  Cập nhật thanh ghi địa chỉ (ADD_R)  Cập nhật bộ nhớ  Điều khiển dòng dữ liệu

9 0 0 2 g n i r e e n g n E r e t u p m o C

16 ©2009, Pham Quoc Cuong Advanced Digital Design with the Verilog HDL – chapter 7

Bộ điều khiển – Controller (1)

• Chức năng bộ điều khiển

i

 Định thời tất cả các hoạt động  Lựa chọn đường dữ liệu từ các bộ multiplexer  Giám sát trạng thái của bộ xử lý (Processing Unit) và quyết định giá trị tín hiệu điều khiển

 Điều khiển các bus 3 trạng thái

9 0 0 2 g n i r e e n g n E r e t u p m o C

17 ©2009, Pham Quoc Cuong Advanced Digital Design with the Verilog HDL – chapter 7

Bộ điều khiển – Controller (2)

Tín hiệu Load_Add_Reg Load _PC Load_IR Inc_PC Sel_Bus_1_Mux

Chức năng Loads the address register Loads Bus_2 to the program counter Loads Bus_2 to the instruction register Increments the program counter Selects among the Program_Counter, R0, R1,

R2, and R3 to drive Bus_1

i

Sel_Bus_2_Mux

Selects among Alu_out, Bus_1, and memory to

drive Bus_2

Load_R0 Load_R1 Load_R2 Load_R3 Load_Reg_Y Load Reg_Z write

Loads general purpose register R0 Loads general purpose register R1 Loads general purpose register R2 Loads general purpose register R3 Loads Bus_2 to the register Reg_Y Stores output of ALU in register Reg_Z Loads Bus_1 into the SRAM memory

9 0 0 2 g n i r e e n g n E r e t u p m o C

18 ©2009, Pham Quoc Cuong Advanced Digital Design with the Verilog HDL – chapter 7

RISC_SPM: Tập lệnh (1)

• Thiết kế controller phụ thuộc vào tập lệnh • Có hai dạng thứ lệnh

 Lệnh ngắn

i

 Lệnh dài

9 0 0 2 g n i r e e n g n E r e t u p m o C

19 ©2009, Pham Quoc Cuong Advanced Digital Design with the Verilog HDL – chapter 7

RISC_SPM: Tập lệnh (2)

i

* Lệnh dài, ? Don’t care

9 0 0 2 g n i r e e n g n E r e t u p m o C

20 ©2009, Pham Quoc Cuong Advanced Digital Design with the Verilog HDL – chapter 7

Thiết kế bộ controller

• RISC có 3 pha xử lý: fetch, decode và

i

execute  fetch: lấy 1 lệnh từ bộ nhớ (2 chu kỳ clock)  decode: giải mã lệnh, tính toán dòng dữ liệu và load giá trị vào thanh ghi (1 chu kỳ clock)  execute: sinh ra kết quả câu lệnh (0, 1, 2 chu

kỳ clock)

9 0 0 2 g n i r e e n g n E r e t u p m o C

21 ©2009, Pham Quoc Cuong Advanced Digital Design with the Verilog HDL – chapter 7

Các trạng thái của controller (1)

S_idle State entered after reset is asserted. No action. S_fet1 Load the Add_R with the contents of the PC S_fet2 Load the IR with the word addressed by the Add_R,

Increment the PC

S_dec Decode the IR

Assert signals to control datapaths and register transfers.

S_ex1 Execute the ALU operation for a single-byte instruction,

i

Conditionally assert the zero flag, Load the destination register

S_rd1 Load Add_R with the second byte of an RD instruction

Increment the PC.

S_rd2 Load the destination register with memory[Add_R] S_wr1 Load Add_R with the second byte of a WR instruction,

Increment the PC.

S_wr2 Write memory[Add_R] with the source register S_br1 Load Add_R with the second byte of a BR instruction

Increment the PC.

S_br2 Load the PC with the memory[Add_R] S_halt Default state to trap failure to decode a valid instruction

9 0 0 2 g n i r e e n g n E r e t u p m o C

22 ©2009, Pham Quoc Cuong Advanced Digital Design with the Verilog HDL – chapter 7

Controller ASM: NOP/ADD/SUB/AND

i

9 0 0 2 g n i r e e n g n E r e t u p m o C

23 ©2009, Pham Quoc Cuong Advanced Digital Design with the Verilog HDL – chapter 7

Controller ASM: NOT

i

9 0 0 2 g n i r e e n g n E r e t u p m o C

24 ©2009, Pham Quoc Cuong Advanced Digital Design with the Verilog HDL – chapter 7

Controller ASM: RD

i

9 0 0 2 g n i r e e n g n E r e t u p m o C

25 ©2009, Pham Quoc Cuong Advanced Digital Design with the Verilog HDL – chapter 7

Controller ASM: WR

i

9 0 0 2 g n i r e e n g n E r e t u p m o C

26 ©2009, Pham Quoc Cuong Advanced Digital Design with the Verilog HDL – chapter 7

Controller ASM: BR/BRZ

i

9 0 0 2 g n i r e e n g n E r e t u p m o C

27 ©2009, Pham Quoc Cuong Advanced Digital Design with the Verilog HDL – chapter 7

RISC_SPM

i

9 0 0 2 g n i r e e n g n E r e t u p m o C

28 ©2009, Pham Quoc Cuong Advanced Digital Design with the Verilog HDL – chapter 7