1. 程式人生 > >計組---指令、中斷、連線、匯流排、PCI(二)

計組---指令、中斷、連線、匯流排、PCI(二)

目錄

Computer Components - Top Level View   計算機組成頂層檢視

Instruction Cycle 指令週期

1)Fetch Cycle

2)Execute Cycle

Example of Program Execution  程式執行示例

Interrupts 中斷

Program Flow Control 程式流程控制

Interrupt Cycle 中斷週期

Multiple Interrupts

Connecting 連線

Buses 匯流排

Bus Interconnection Scheme 匯流排互連方案

Physical Realization of Bus Architecture 匯流排結構的物理實現

匯流排型別:

Bus Arbitration 匯流排仲裁

PCI(Peripheral Component Interconnection) Bus 外設元件互連標準


Computer Components - Top Level View   計算機組成頂層檢視

Instruction Cycle 指令週期

Two steps: 1)Fetch 2)Execute

 Halt:停止,暫停

1)Fetch Cycle

程式計數器(Program Counter, PC)儲存要取出的指令的地址;

處理器(Processor)從記憶體(memory)中取出PC所指向的指令;

指令載入進指令暫存器(Instruction Register, IR);

處理器翻譯指令並執行相應操作

2)Execute Cycle

Processor-memory(處理機-儲存器):Data transfer between CPU and main memory

Processor I/O(處理器輸入輸出):Data transfer between CPU and I/O module

Data processing:Some arithmetic or logical operation on data

Control:Alteration of sequence of operations

Combination of above

Instruction Cycle State Diagram 指令迴圈狀態圖

 Operand:運算元


Example of Program Execution  程式執行示例

圖中Memory中:

Step1:300~302為指令儲存的地址 --> 指令載入進IR(指令暫存器);指令300 -> 取出運算元0003

Step2:940~941為運算元地址 --> 運算元載入進AC

Step3:載入指令301進IR;指令301 -> 取出運算元相加

Step4:取出運算元0002,與0003相加後,結果儲存在AC中

Step5:載入指令302進IR;指令302 -> 將AC中的結果存入941(原運算元0002的地址)

Step6:將結果存入地址941中
 

 

Interrupts 中斷

中斷:其他模組(例如I/O)可能中斷正常處理順序的機制

Interrupts:Mechanism by which other modules (e.g. I/O) may interrupt normal sequence of processing

Program:overflow / division by zero

Timer(計時器):Generated by internal processor timer(由內部處理器定時器生成 )/ Used in pre-emptive multi-tasking(用於搶佔式多工處理 )

I/O:from I/O controller

Hardware failure:memory parity error(儲存器奇偶誤差 )

Program Flow Control 程式流程控制

Interrupt Cycle 中斷週期

新增到指令迴圈中  ->  處理器檢查中斷(用中斷訊號表示)  ->  如果沒有中斷,獲取下一條指令  ->  如果中斷未決  ->  暫停執行當前程式  ->  儲存上下文 ->  將PC設定為中斷處理程式的起始地址 ->  程序中斷 ->  恢復上下文並繼續中斷程式 

Instruction Cycle with Interrupts 包含中斷的指令週期

Instruction Cycle with Interrupts -  State Diagram 

Multiple Interrupts

1. Disable Interrupt 禁用中斷

處理器在處理一箇中斷時將忽略其他中斷。 中斷保持未決,並在第一個中斷被處理後進行檢查。中斷按發生的順序進行處理。

2. Define priorities 定義優先順序

低優先順序的中斷可以被高優先順序的中斷所中斷(Low priority interrupts can be interrupted by higher priority interrupts)

當優先順序較高的中斷被處理完後,處理器就返回到之前的中斷。

Multiple Interrupts - Sequential                                  Multiple Interrupts – Nested(巢狀)

                 

ISR:中斷服務程式

 

Connecting 連線

 

Buses 匯流排

匯流排:連線兩個或多個裝置的通訊路徑(A communication pathway connecting two or more devices)

Usually broadcast ; Often grouped

Data Bus:

Carries data:Remember that there is no difference between “data” and “instruction” at this level

Width is a key determinant of performance(寬度是效能的關鍵決定因素 ):8, 16, 32, 64 bit

Address Bus:

Identify the source or destination of data:e.g. CPU needs to read an instruction (data) from a given location in memory

Bus width determines maximum memory capacity of system:e.g. 8080 has 16 bit address bus giving 64K address space

Control Bus:

Control and timing information  /  Memory read/write signal  /  Interrupt request  /  Clock signals

Bus Interconnection Scheme 匯流排互連方案

匯流排的外觀:電路板上的平行線,帶狀電纜,母板上的帶狀聯結器 (例如PCI(周邊元件擴充套件介面)),成套電線 

Physical Realization of Bus Architecture 匯流排結構的物理實現

單匯流排(single bus)存在的問題:

傳播延遲(Propagation delays):長資料路徑意味著匯流排使用的協調(co-ordination of bus use)會對效能產生不利影響(If aggregate data transfer approaches bus capacity)

大多數系統都使用多匯流排來克服這種問題

匯流排型別:

dedicated(專用):分開的資料匯流排與地址匯流排 (Separate data & address lines)

Multiplexed(多路複用):Shared lines,Address valid or data valid control line

優點:fewer lines   

缺點:More complex control,Ultimate performance(最大效能)

Bus Arbitration 匯流排仲裁

多個模組同時控制匯流排(如, CPU and DMA(直接儲存器存取) controller)

一次只能有一個模組可以控制匯流排,仲裁可以是集中的,也可以是分散的(Arbitration may be centralised or distributed)

Centralised:Single hardware device controlling bus access; May be part of CPU or separate

Distributed:Each module may claim the bus; Control logic on all modules

 

PCI(Peripheral Component Interconnection) Bus 外設元件互連標準

PCI Bus Lines:

(required)

Systems lines:Including clock and reset

Address & Data:32 time mux lines for address/data(用於地址/資料的32time多路複用線路 )

Interrupt & validate lines (中斷和驗證線):Interface Control(介面控制)

Arbitration:Not shared,Direct connection to PCI bus arbiter (直接連線到PCI匯流排仲裁器)

Error lines

(Optional)

Interrupt lines:Not shared

Cache support (快取支援)

64-bit Bus Extension (64位匯流排擴充套件):Additional 32 lines,Time multiplexed (時間複用),2 lines to enable devices to agree to use 64-bit transfer

JTAG/Boundary Scan (JTAG / 邊界掃描):For testing procedures