当前位置:网站首页>1.14 - assembly line

1.14 - assembly line

2022-07-05 06:10:00 It's Li sticky duck

One 、 The concept of pipeline

  • The so-called assembly line , It refers to the execution of the program , Multiple instructions overlap A quasi parallel processing implementation technology .

Two 、 Pipeline workflow

  • When an instruction is executed , It can usually be divided into several stages , Each stage is realized by different components ;
  • Divide into 3 Take the first stage as an example : Fingering 、 analysis 、 perform ;
Fingering : Realized by the finger taking part , Responsible for fetching instructions from memory CPU in ;
analysis : The analysis instruction is carried out by the analysis part ;
perform : Implemented by the execution part , Be responsible for decoding instructions , Execution instruction ;

3、 ... and 、 No pipeline is used to execute instructions

1、 Execution process

  • When the assembly line is not used , When the fetching part of the first instruction fetches , The analysis part and the execution part are idle ;
  • When the finger picking part is finished , The analysis part starts the analysis instruction , At this time, the referring part and the executing part are idle ;
  • When the execution of the analysis part is completed , The execution part executes instructions after compilation , At this time, the finger taking part and the analysis part are idle ;

2、 Conclusion

  • Thus we can see that , When instructions are executed without pipeline , Take the finger part , Analyze components , The utilization of execution parts is not high ; 

Four 、 Use pipeline to execute instructions

1、 Execution process

  • When the first instruction starts to execute , Take the finger part and start working , Analysis part and execution part are idle ;
  • When the first instruction fetch is completed , The analysis part starts to work ; At this time, the finger taking part is idle , At this point, you can get the second instruction ;
  • When the first instruction analysis is completed , The execution part starts working ; At this time, the analysis unit is idle , At this point, you can analyze the second instruction just taken ; And since the second instruction fetching is completed , So at this time, the finger taking part is free again , So now you can get the third instruction ;

2、 Conclusion

  • thus it can be seen , Use pipeline to execute instructions , It can effectively improve the utilization rate of components , It effectively improves the execution efficiency of instructions ;

5、 ... and 、 pipeline cycle

  • At each stage of the instruction , The time of this stage with the longest execution time , Is the cycle of the assembly line ;
analysis :
(1) For example, the workers on the assembly line , Three people work together to complete an item ; The first person needs 2 second , The second person needs 4 second , The third person needs 1 second ;
(2) If the period for completing this item is set as 1 second , So first 、 The second person can't finish his work ;
(3) Only set the period as 4 seconds , These three talents can complete their own work ;
(4) So we will generally Complete an item The time of the phase that takes the longest to execute , Set as cycle , The period in the example is 4 second ;

6、 ... and 、 Pipeline calculation formula

  • Time required for a single instruction +(n-1)*( pipeline cycle
(1) It can be seen from the picture that , When executing the first instruction , need 3 Stages ;
(2) At the end of the first instruction , The second order zh The analysis phase has been completed , Only one execution stage is needed to complete the execution of the second instruction ;
(3) When the execution of the second instruction is completed , The third instruction has finished the analysis stage , Only one execution stage is needed to complete the execution of the third instruction ;
(4) So execute n Instruction time , Just use the time of a single instruction ( The sum of the three phases of the first instruction )+(n-1) The time required to execute an instruction ;
  • Be careful :n Indicates the number of instructions ;

7、 ... and 、 Throughput of the pipeline

8、 ... and 、 Test method 1: Pipeline related calculation

原网站

版权声明
本文为[It's Li sticky duck]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/186/202207050544075576.html