TWI873481B - Clock synchronization method and device, electronic equipment and storage medium - Google Patents
Clock synchronization method and device, electronic equipment and storage medium Download PDFInfo
- Publication number
- TWI873481B TWI873481B TW111144130A TW111144130A TWI873481B TW I873481 B TWI873481 B TW I873481B TW 111144130 A TW111144130 A TW 111144130A TW 111144130 A TW111144130 A TW 111144130A TW I873481 B TWI873481 B TW I873481B
- Authority
- TW
- Taiwan
- Prior art keywords
- processing module
- clock
- count value
- timer
- phase
- Prior art date
Links
- 238000000034 method Methods 0.000 title claims abstract description 161
- 238000003860 storage Methods 0.000 title claims abstract description 27
- 238000012545 processing Methods 0.000 claims abstract description 769
- 230000001360 synchronised effect Effects 0.000 claims abstract description 95
- 230000008569 process Effects 0.000 claims description 48
- 230000010355 oscillation Effects 0.000 claims description 32
- 230000004044 response Effects 0.000 claims description 22
- 230000001427 coherent effect Effects 0.000 claims description 9
- 238000010586 diagram Methods 0.000 description 26
- 238000004891 communication Methods 0.000 description 17
- 239000013078 crystal Substances 0.000 description 16
- 230000006870 function Effects 0.000 description 15
- 238000004590 computer program Methods 0.000 description 8
- 230000005540 biological transmission Effects 0.000 description 7
- 238000004364 calculation method Methods 0.000 description 7
- 101001121408 Homo sapiens L-amino-acid oxidase Proteins 0.000 description 4
- 102100026388 L-amino-acid oxidase Human genes 0.000 description 4
- 230000008859 change Effects 0.000 description 4
- 230000002452 interceptive effect Effects 0.000 description 4
- 238000012423 maintenance Methods 0.000 description 4
- 230000003287 optical effect Effects 0.000 description 4
- 239000000758 substrate Substances 0.000 description 4
- 230000000694 effects Effects 0.000 description 3
- 238000005259 measurement Methods 0.000 description 3
- 101000827703 Homo sapiens Polyphosphoinositide phosphatase Proteins 0.000 description 2
- 102100023591 Polyphosphoinositide phosphatase Human genes 0.000 description 2
- 101100233916 Saccharomyces cerevisiae (strain ATCC 204508 / S288c) KAR5 gene Proteins 0.000 description 2
- 238000013459 approach Methods 0.000 description 2
- 230000007246 mechanism Effects 0.000 description 2
- 230000000737 periodic effect Effects 0.000 description 2
- 230000001960 triggered effect Effects 0.000 description 2
- 101100012902 Saccharomyces cerevisiae (strain ATCC 204508 / S288c) FIG2 gene Proteins 0.000 description 1
- XUIMIQQOPSSXEZ-UHFFFAOYSA-N Silicon Chemical compound [Si] XUIMIQQOPSSXEZ-UHFFFAOYSA-N 0.000 description 1
- 238000003491 array Methods 0.000 description 1
- 239000004020 conductor Substances 0.000 description 1
- 238000005520 cutting process Methods 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 239000004744 fabric Substances 0.000 description 1
- 239000011521 glass Substances 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 239000000463 material Substances 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 238000003672 processing method Methods 0.000 description 1
- 230000001105 regulatory effect Effects 0.000 description 1
- 230000000630 rising effect Effects 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 229910052710 silicon Inorganic materials 0.000 description 1
- 239000010703 silicon Substances 0.000 description 1
- 230000001052 transient effect Effects 0.000 description 1
Images
Landscapes
- Synchronisation In Digital Transmission Systems (AREA)
- Signal Processing For Digital Recording And Reproducing (AREA)
Abstract
一種時脈同步方法及裝置、電子設備和儲存介質。該時脈同步方法包括:向第二處理模組發送觸發訊號,同時記錄發送觸發訊號時第一計時器當前的計數值作為第一計數值,其中,第二處理模組與第一處理模組屬於不同的時脈領域;從第二處理模組讀取第二計數值,其中,第二計數值為第二處理模組在接收到觸發訊號時,第二處理模組的第二計時器當前的計數值,第二計時器的計數值作為第二處理模組的定時基準且順序遞增;其中,第一計數值和第二計數值用於時脈補償,以使得第一處理模組所在的第一時脈領域與第二處理模組所在的第二時脈領域同步。A clock synchronization method and device, an electronic device and a storage medium. The clock synchronization method comprises: sending a trigger signal to a second processing module, and recording the current count value of a first timer when the trigger signal is sent as a first count value, wherein the second processing module and the first processing module belong to different clock domains; reading a second count value from the second processing module, wherein the second count value is the current count value of a second timer of the second processing module when the second processing module receives the trigger signal, and the count value of the second timer is used as a timing reference of the second processing module and increases sequentially; wherein the first count value and the second count value are used for clock compensation, so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located.
Description
本發明的實施例涉及一種時脈同步方法、系統時脈同步方法、時脈同步裝置、電子設備和非暫態性電腦可讀儲存介質。 The embodiments of the present invention relate to a clock synchronization method, a system clock synchronization method, a clock synchronization device, an electronic device and a non-transitory computer-readable storage medium.
由於受到大型積體電路的系統限制,時常需要在多個不同的時脈頻率系統之間交換資料、在不同的時脈頻率系統之間通過輸入介面和輸出介面來接收、發送資料或處理非同步訊號等,也即在積體電路中可能存在多個時脈領域(Clock Domain),每個時脈領域為積體電路中由同一個時脈訊號控制的區域。 Due to the system limitations of large integrated circuits, it is often necessary to exchange data between multiple different clock frequency systems, receive and send data or process asynchronous signals between different clock frequency systems through input and output interfaces, etc., that is, there may be multiple clock domains in the integrated circuit, and each clock domain is an area in the integrated circuit controlled by the same clock signal.
不同時脈領域對應的時脈訊號稱為非同步時脈。對於積體電路中相連的兩個模組,例如,每個模組可以由一些完成特定功能的電路邏輯構成,如果兩個模組分別由不同的時脈(也即非同步時脈)驅動,則兩個模組的時脈訊號稱為非同步時脈訊號(Asynchronous Interface),兩個模組屬於不同的時脈領域;如果兩個模組由同一個時脈驅動,則兩個模組的時脈訊號稱為同步時脈訊號(Synchronous Interface),兩個模組屬於一個時脈領域。 The clock signals corresponding to different clock domains are called asynchronous clocks. For two modules connected in an integrated circuit, for example, each module can be composed of some circuit logic to complete specific functions. If the two modules are driven by different clocks (that is, asynchronous clocks), the clock signals of the two modules are called asynchronous clock signals (Asynchronous Interface), and the two modules belong to different clock domains; if the two modules are driven by the same clock, the clock signals of the two modules are called synchronous clock signals (Synchronous Interface), and the two modules belong to the same clock domain.
提供該內容部分以便以簡要的形式介紹構思,這些構思將在後面的具體實施方式部分被詳細描述。該內容部分並不旨在標識要求保護的技術方案的關鍵特徵或必要特徵,也不旨在用於限制所要求的保護的技術方案的範圍。 This content section is provided to introduce the concepts in a concise form, which will be described in detail in the specific implementation section below. This content section is not intended to identify the key features or essential features of the technical solution claimed for protection, nor is it intended to be used to limit the scope of the technical solution claimed for protection.
本發明至少一實施例提供一種時脈同步方法,用於第一處理模組,其中,所述第一處理模組包括第一計時器,所述第一計時器的計數值作為所述第一處理模組的定時基準且順序遞增,所述時脈同步方法包括:向第二處理模組發送觸發訊號,同時記錄發送所述觸發訊號時所述第一計時器當前的計數值作為第一計數值,其中,所述第二處理模組與所述第一處理模組屬於不同的時脈領域;從所述第二處理模組讀取第二計數值,其中,所述第二計數值為所述第二處理模組在接收到所述觸發訊號時,所述第二處理模組的第二計時器當前的計數值,所述第二計時器的計數值作為所述第二處理模組的定時基準且順序遞增;其中,所述第一計數值和所述第二計數值用於時脈補償,以使得所述第一處理模組所在的第一時脈領域與所述第二處理模組所在的第二時脈領域同步。 At least one embodiment of the present invention provides a clock synchronization method for a first processing module, wherein the first processing module includes a first timer, and the count value of the first timer is used as a timing reference of the first processing module and increases in sequence. The clock synchronization method includes: sending a trigger signal to a second processing module, and recording the current count value of the first timer when the trigger signal is sent as a first count value, wherein the second processing module and the first processing module belong to different clock domains. ; Read a second count value from the second processing module, wherein the second count value is the current count value of the second timer of the second processing module when the second processing module receives the trigger signal, and the count value of the second timer is used as the timing reference of the second processing module and increases sequentially; wherein the first count value and the second count value are used for clock compensation, so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located.
本發明至少一實施例提供一種時脈同步方法,用於第二處理模組,其中,所述第二處理模組包括第二計時器,所述第二計時器的計數值作為所述第二處理模組的定時基準且順序遞增,所述時脈同步方法包括:回應於接收到第一處理模組發送的觸發訊號,記錄所述第二計時器當前的計數值作為第二計數值,其中,所 述第二處理模組與所述第一處理模組屬於不同的時脈領域;其中,所述第二計數值用於結合第一計數值進行時脈補償,以使得所述第一處理模組所在的第一時脈領域與所述第二處理模組所在的第二時脈領域同步,所述第一計數值為所述第一處理模組向所述第二處理模組發送觸發訊號時,所述第一處理模組的第一計時器當前的計數值,所述第一計時器的計數值用於作為所述第一處理模組的定時基準且順序遞增。 At least one embodiment of the present invention provides a clock synchronization method for a second processing module, wherein the second processing module includes a second timer, and the count value of the second timer is used as a timing reference of the second processing module and increases in sequence. The clock synchronization method includes: in response to receiving a trigger signal sent by the first processing module, recording the current count value of the second timer as a second count value, wherein the second processing module and the first processing module belong to different Clock domain; wherein the second count value is used to combine with the first count value for clock compensation, so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located, the first count value is the current count value of the first timer of the first processing module when the first processing module sends a trigger signal to the second processing module, and the count value of the first timer is used as the timing reference of the first processing module and increases sequentially.
本發明至少一實施例提供一種系統時脈同步方法,其中,所述系統包括第一處理模組和第二處理模組,所述第一處理模組包括第一計時器,所述第一計時器的計數值作為所述第一處理模組的定時基準且順序遞增,所述第二處理模組包括第二計時器,所述第二計時器的計數值作為所述第二處理模組的定時基準且順序遞增,所述第一處理模組和所述第二處理模組屬於不同的時脈領域,所述系統時脈同步方法包括:所述第一處理模組向所述第二處理模組發送觸發訊號,所述第一處理模組記錄在發送所述觸發訊號時所述第一計時器當前的計數值作為第一計數值,所述第二處理模組記錄在接收到所述觸發訊號時所述第二計時器當前的計數值作為第二計數值;其中,所述第一計數值和所述第二計數值用於時脈補償,以使得所述第一處理模組所在的第一時脈領域與第二處理模組所在的第二時脈領域同步。 At least one embodiment of the present invention provides a system clock synchronization method, wherein the system includes a first processing module and a second processing module, the first processing module includes a first timer, the count value of the first timer is used as a timing reference of the first processing module and increases sequentially, the second processing module includes a second timer, the count value of the second timer is used as a timing reference of the second processing module and increases sequentially, the first processing module and the second processing module belong to different clock domains, and the system clock synchronization The method includes: the first processing module sends a trigger signal to the second processing module, the first processing module records the current count value of the first timer when sending the trigger signal as the first count value, and the second processing module records the current count value of the second timer when receiving the trigger signal as the second count value; wherein the first count value and the second count value are used for clock compensation, so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located.
本發明至少一實施例提供一種時脈同步裝置,用於第一處理模組,其中,所述第一處理模組包括第一計時器,所述第一計 時器的計數值作為所述第一處理模組的定時基準且順序遞增,所述時脈同步裝置包括:第一記錄單元,配置為向第二處理模組發送觸發訊號,同時記錄發送所述觸發訊號時所述第一計時器當前的計數值作為第一計數值,其中,所述第二處理模組與所述第一處理模組屬於不同的時脈領域;讀取單元,配置為從所述第二處理模組讀取第二計數值,其中,所述第二計數值為所述第二處理模組在接收到所述觸發訊號時,所述第二處理模組的第二計時器當前的計數值,所述第二計時器的計數值作為所述第二處理模組的定時基準且順序遞增;其中,所述第一計數值和所述第二計數值用於時脈補償,以使得所述第一處理模組所在的第一時脈領域與所述第二處理模組所在的第二時脈領域同步。 At least one embodiment of the present invention provides a clock synchronization device for a first processing module, wherein the first processing module includes a first timer, the count value of the first timer is used as a timing reference of the first processing module and increases in sequence, and the clock synchronization device includes: a first recording unit, configured to send a trigger signal to a second processing module, and simultaneously record the current count value of the first timer when the trigger signal is sent as a first count value, wherein the second processing module and the first processing module belong to different clocks. domain; a reading unit configured to read a second count value from the second processing module, wherein the second count value is the current count value of the second timer of the second processing module when the second processing module receives the trigger signal, and the count value of the second timer is used as the timing reference of the second processing module and increases sequentially; wherein the first count value and the second count value are used for clock compensation, so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located.
本發明至少一實施例提供一種時脈同步裝置,用於第二處理模組,其中,所述第二處理模組包括第二計時器,所述第二計時器的計數值作為所述第二處理模組的定時基準且順序遞增,所述時脈同步裝置包括:第二記錄單元,配置為回應於接收到第一處理模組發送的觸發訊號,記錄所述第二計時器當前的計數值作為第二計數值,其中,所述第二處理模組與所述第一處理模組屬於不同的時脈領域;其中,所述第二計數值用於結合第一計數值進行時脈補償,以使得所述第一處理模組所在的第一時脈領域與所述第二處理模組所在的第二時脈領域同步,所述第一計數值為所述第一處理模組向第二處理模組發送觸發訊號時,所述第一處理模組的第一計時器當前的計數值,所述第一計時器的計數值用於作為 所述第一處理模組的定時基準且順序遞增。 At least one embodiment of the present invention provides a clock synchronization device for a second processing module, wherein the second processing module includes a second timer, and the count value of the second timer is used as a timing reference of the second processing module and increases in sequence. The clock synchronization device includes: a second recording unit, configured to respond to receiving a trigger signal sent by the first processing module, and record the current count value of the second timer as a second count value, wherein the second processing module and the first processing module are synchronized. Belong to different clock domains; wherein the second count value is used to combine with the first count value for clock compensation, so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located, the first count value is the current count value of the first timer of the first processing module when the first processing module sends a trigger signal to the second processing module, and the count value of the first timer is used as the timing reference of the first processing module and increases sequentially.
本發明至少一實施例提供一種電子設備,包括第一處理模組和第二處理模組,其中,所述第一處理模組包括第一計時器,所述第一計時器的計數值作為所述第一處理模組的定時基準且順序遞增,所述第二處理模組包括第二計時器,所述第二計時器的計數值作為所述第二處理模組的定時基準且順序遞增,所述第一處理模組和所述第二處理模組屬於不同的時脈領域,其中,所述第一處理模組配置為向所述第二處理模組發送觸發訊號,以及記錄在發送所述觸發訊號時所述第一計時器當前的計數值作為第一計數值,所述第二處理模組配置為記錄在接收到所述觸發訊號時所述第二計時器當前的計數值作為第二計數值;其中,所述第一計數值和所述第二計數值用於時脈補償,以使得所述第一處理模組所在的第一時脈領域與第二處理模組所在的第二時脈領域同步。 At least one embodiment of the present invention provides an electronic device, comprising a first processing module and a second processing module, wherein the first processing module comprises a first timer, the count value of the first timer is used as a timing reference of the first processing module and increases sequentially, the second processing module comprises a second timer, the count value of the second timer is used as a timing reference of the second processing module and increases sequentially, the first processing module and the second processing module belong to different clock domains, wherein the first The processing module is configured to send a trigger signal to the second processing module, and record the current count value of the first timer when sending the trigger signal as the first count value, and the second processing module is configured to record the current count value of the second timer when receiving the trigger signal as the second count value; wherein the first count value and the second count value are used for clock compensation, so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located.
本發明至少一實施例提供一種電子設備,包括:記憶體,非暫態性地儲存有電腦可執行指令;處理器,配置為運行所述電腦可執行指令,其中,所述電腦可執行指令被所述處理器運行時實現根據本發明任一實施例所述的時脈同步方法或系統時脈同步方法。 At least one embodiment of the present invention provides an electronic device, comprising: a memory, which non-temporarily stores computer executable instructions; a processor, which is configured to execute the computer executable instructions, wherein the computer executable instructions, when executed by the processor, implement the clock synchronization method or system clock synchronization method according to any embodiment of the present invention.
本發明至少一實施例提供一種非暫態性電腦可讀儲存介質,其中,所述非暫態性電腦可讀儲存介質儲存有電腦可執行指令,所述電腦可執行指令被處理器執行時實現根據本發明任一實施例所述的時脈同步方法或系統時脈同步方法。 At least one embodiment of the present invention provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, the clock synchronization method or system clock synchronization method described in any embodiment of the present invention is implemented.
100:時脈同步裝置 100: Clock synchronization device
101:第一記錄單元 101: First recording unit
102:讀取單元 102: Reading unit
103:第一時脈補償單元 103: First-time compensation unit
200:時脈同步裝置 200: Clock synchronization device
201:第二記錄單元 201: Second recording unit
202:第二時脈補償單元 202: Second time compensation unit
300:電子設備 300: Electronic equipment
310:第一處理模組 310: First processing module
320:第二處理模組 320: Second processing module
400:電子設備 400: Electronic equipment
410:處理器 410:Processor
420:記憶體 420:Memory
500:儲存介質 500: Storage medium
510:電腦可讀指令 510: Computer readable instructions
S10、S20、S301、S302、S401、S402、S50、S601、S602、S603:步驟 S10, S20, S301, S302, S401, S402, S50, S601, S602, S603: Steps
T0~Tn+1、T0’~Tn+1’:時刻 T0~Tn+1, T0’~Tn+1’: time
為了更清楚地說明本發明實施例的技術方案,下面將對實施例的附圖作簡單地介紹,顯而易見地,下面描述中的附圖僅僅涉及本發明的一些實施例,而非對本發明的限制。 In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings of the embodiments will be briefly introduced below. Obviously, the drawings described below only involve some embodiments of the present invention, rather than limiting the present invention.
圖1為一種中央處理器的層次結構示意圖;圖2為一種時脈同步過程示意圖;圖3為本發明至少一實施例提供的一種時脈同步方法的示意性流程圖;圖4為本發明至少一實施例提供的時脈同步方法的流程圖;圖5為本發明至少一實施例提供的時脈同步方法的交互過程示意圖;圖6為本發明至少一實施例提供的時脈同步方法的流程圖;圖7為本發明至少一實施例提供的另一種時脈同步方法的示意性流程圖;圖8A為本發明至少一實施例提供的系統時脈同步方法的交互過程示意圖;圖8B為本發明至少一實施例提供的補償處理模組之間傳輸延遲的示意性方塊圖;圖9A為本發明至少一實施例提供的一種時脈同步裝置的示意性方塊圖;圖9B為本發明至少一實施例提供的另一種時脈同步裝置的 示意性方塊圖;圖9C為本發明至少一實施例提供的一種電子設備的示意性方塊圖;圖10為本發明至少一實施例提供的一種電子設備的示意性方塊圖;圖11為本發明至少一實施例提供的一種非暫態性電腦可讀儲存介質的示意圖。 FIG1 is a schematic diagram of a hierarchical structure of a central processing unit; FIG2 is a schematic diagram of a clock synchronization process; FIG3 is a schematic flow chart of a clock synchronization method provided by at least one embodiment of the present invention; FIG4 is a flow chart of a clock synchronization method provided by at least one embodiment of the present invention; FIG5 is a schematic diagram of an interactive process of a clock synchronization method provided by at least one embodiment of the present invention; FIG6 is a flow chart of a clock synchronization method provided by at least one embodiment of the present invention; FIG7 is a schematic flow chart of another clock synchronization method provided by at least one embodiment of the present invention; FIG8A is a flow chart of a system clock synchronization method provided by at least one embodiment of the present invention; Schematic diagram of the interaction process; FIG. 8B is a schematic block diagram of the transmission delay between the compensation processing modules provided by at least one embodiment of the present invention; FIG. 9A is a schematic block diagram of a clock synchronization device provided by at least one embodiment of the present invention; FIG. 9B is a schematic block diagram of another clock synchronization device provided by at least one embodiment of the present invention; FIG. 9C is a schematic block diagram of an electronic device provided by at least one embodiment of the present invention; FIG. 10 is a schematic block diagram of an electronic device provided by at least one embodiment of the present invention; FIG. 11 is a schematic diagram of a non-transient computer-readable storage medium provided by at least one embodiment of the present invention.
為了使得本發明實施例的目的、技術方案和優點更加清楚,下面將結合本發明實施例的附圖,對本發明實施例的技術方案進行清楚、完整地描述。顯然,所描述的實施例是本發明的一部分實施例,而不是全部的實施例。基於所描述的本發明的實施例,本領域具通常知識者在無需創造性勞動的前提下所獲得的所有其他實施例,都屬於本發明保護的範圍。 In order to make the purpose, technical solution and advantages of the embodiment of the present invention clearer, the technical solution of the embodiment of the present invention will be described clearly and completely in conjunction with the attached drawings of the embodiment of the present invention. Obviously, the described embodiment is a part of the embodiment of the present invention, not all of the embodiments. Based on the described embodiment of the present invention, all other embodiments obtained by a person of ordinary knowledge in the field without creative labor are within the scope of protection of the present invention.
除非另外定義,本發明使用的技術術語或者科學術語應當為本發明所屬領域內具有一般技能的人士所理解的通常意義。本發明中使用的“第一”、“第二”以及類似的詞語並不表示任何順序、數量或者重要性,而只是用來區分不同的組成部分。“包括”或者“包含”等類似的詞語意指出現該詞前面的元件或者物件涵蓋出現在該詞後面列舉的元件或者物件及其等同,而不排除其他元件或者物件。“連接”或者“相連”等類似的詞語並非限 定於物理的或者機械的連接,而是可以包括電性的連接,不管是直接的還是間接的。“上”、“下”、“左”、“右”等僅用於表示相對位置關係,當被描述物件的絕對位置改變後,則該相對位置關係也可能相應地改變。為了保持本發明實施例的以下說明清楚且簡明,本發明省略了部分已知功能和已知部件的詳細說明。 Unless otherwise defined, the technical or scientific terms used in the present invention should be understood by people with ordinary skills in the field to which the present invention belongs. The words "first", "second" and similar words used in the present invention do not indicate any order, quantity or importance, but are only used to distinguish different components. The words "include" or "comprise" and similar words mean that the elements or objects appearing before the word include the elements or objects listed after the word and their equivalents, but do not exclude other elements or objects. The words "connected" or "connected" and similar words are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly. In order to keep the following description of the embodiments of the present invention clear and concise, the present invention omits the detailed description of some known functions and known components.
對於非同步時脈領域,在一些場景下需要各個非同步時脈領域能夠同步調度和協助操作,也即需要保持各個非同步時脈領域的同步。 For the asynchronous clock domain, in some scenarios, each asynchronous clock domain needs to be able to synchronize scheduling and assist operations, that is, it is necessary to maintain the synchronization of each asynchronous clock domain.
例如,對於中央處理器(Central Processing Unit,簡稱CPU),其實體層次結構示意圖如圖1所示。 For example, for the central processing unit (CPU), its physical layer structure diagram is shown in Figure 1.
如圖1所示,中央處理器包括2個物理插槽(socket),每個物理插槽可以插入一個CPU封裝(CPU Package或CPU socket),例如圖1中的Socket0和Socket1。 As shown in Figure 1, the CPU includes two physical slots (sockets), each of which can be inserted with a CPU package (CPU Package or CPU socket), such as Socket0 and Socket1 in Figure 1.
每個CPU封裝可以包括一個或多個CPU Die,CPU Die指的是處理器在生產過程中,從晶圓(Silicon Wafer)上切割下來的一個個小方塊,在切割下來之前,每個小方塊(Die)都需要經過各種加工,將電路邏輯刻到該Die上面,每個CPU Die可以看作一個帶有電路邏輯的處理單元。如圖1所示,每個CPU封裝包括兩個Die,例如Socket0包括Die0和Die1。 Each CPU package can include one or more CPU Dies. CPU Dies refer to small blocks cut from the silicon wafer during the production process of the processor. Before cutting, each small block (Die) needs to go through various processes to engrave the circuit logic onto the Die. Each CPU Die can be regarded as a processing unit with circuit logic. As shown in Figure 1, each CPU package includes two Dies, for example, Socket0 includes Die0 and Die1.
每個CPU Die可以包括一個或多個處理核(CPU Core),例如,如圖1所示,DIE0包括處理核Core0和處理核Core1。 Each CPU Die may include one or more processing cores (CPU Core). For example, as shown in Figure 1, DIE0 includes processing core Core0 and processing core Core1.
當然,圖1僅給出一種中央處理器的示意,不同CPU的 CPU封裝數量、每個CPU封裝中CPU Die的數量、每個CPU Die中的處理核的數量可能不同,這裡不再贅述。 Of course, Figure 1 only shows a schematic diagram of a central processing unit. The number of CPU packages, the number of CPU Dies in each CPU package, and the number of processing cores in each CPU Die may be different for different CPUs, which will not be elaborated here.
例如,由於各個CPU Die或者CPU Socket在物理上彼此獨立,通常各個CPU Die或者CPU Socket有自己的鎖相迴路(Phase Locked Loop,簡稱PLL)用於生成工作時脈訊號或參考時脈訊號。 For example, since each CPU Die or CPU Socket is physically independent of each other, each CPU Die or CPU Socket usually has its own phase-locked loop (PLL) to generate a working clock signal or a reference clock signal.
例如,鎖相迴路可以接收時脈源提供的時脈訊號(例如100MHz),對時脈訊號倍頻生成工作時脈訊號(例如2.4GHz),CPU Die或者CPU Socket結合工作時脈訊號執行操作。例如,鎖相迴路還根據時脈訊號為系統計時器(system timer)在內的器件提供參考時脈訊號(例如100MHz),以供這些器件正常工作。 For example, the phase-locked loop can receive a clock signal (e.g., 100MHz) provided by a clock source, multiply the clock signal to generate a working clock signal (e.g., 2.4GHz), and the CPU Die or CPU Socket performs operations in conjunction with the working clock signal. For example, the phase-locked loop also provides a reference clock signal (e.g., 100MHz) to devices including the system timer based on the clock signal, so that these devices can work normally.
例如,CPU上的每個處理模組(例如CPU Die或者CPU Socket)包括各自的系統計時器,系統計時器用於提供定時參考。例如,系統計時器通常選擇晶片上最高準確度的計時器作為系統時間的定時基準,以避免在系統運行較長時間後出現大的時間偏移。例如,系統計時器的計數值作為所在處理模組的定時基準且順序遞增。例如,在系統重啟後,可以從RTC(real_time clock)重新獲取時間,以該時間為基準繼續進行週期性計數,以用於設置系統時脈,提供報警器或週期性的計時器。 For example, each processing module on the CPU (such as CPU Die or CPU Socket) includes its own system timer, which is used to provide a timing reference. For example, the system timer usually selects the timer with the highest accuracy on the chip as the timing basis of the system time to avoid large time offsets after the system has been running for a long time. For example, the count value of the system timer is used as the timing basis of the processing module and increases sequentially. For example, after the system is restarted, the time can be re-obtained from the RTC (real_time clock), and periodic counting can continue based on this time to set the system clock, provide an alarm or a periodic timer.
例如,對於對稱多處理結構(Symmetrical Multi-Processing,簡稱SMP),多個處理模組(例如CPU Die或者CPU Socket)之間共用記憶體和匯流排結構,為了讓多個處理模組具有更好的同步調度和協助操作效率,需要讓多個處理模組的系統計 時器保持一樣的計數值,以滿足計時器(system tick)觸發調度的需求、IPC(Inter-Process Communication,進程間通訊)等待超時同步的需求、調試階段增加時間戳記(time stamp)的需求等。 For example, for symmetric multi-processing (SMP), multiple processing modules (such as CPU Die or CPU Socket) share memory and bus structure. In order to make multiple processing modules have better synchronization scheduling and assist operation efficiency, it is necessary to keep the system timers of multiple processing modules with the same count value to meet the needs of timer (system tick) trigger scheduling, IPC (Inter-Process Communication) waiting timeout synchronization, and the need to add time stamps during the debugging phase.
圖2為一種時脈同步過程示意圖。應用於主處理模組(例如Master CPU Die)和從處理模組(例如Slave CPU Die)之間。 Figure 2 is a schematic diagram of a clock synchronization process. It is applied between the main processing module (such as Master CPU Die) and the slave processing module (such as Slave CPU Die).
如圖2所示,在T0時刻,從處理模組向主處理模組發起同步請求,申請同步,T1時刻主處理模組收到請求並向從處理模組回應接受請求。在T2時刻,主處理模組開始發起同步,向從處理模組發送同步請求,T3時刻從處理模組接受到請求並向主處理模組回應接受主處理模組的請求。在T4時刻主處理模組接受到從處理模組的回應,完成一次握手。 As shown in Figure 2, at time T0, the slave processing module initiates a synchronization request to the master processing module to apply for synchronization. At time T1, the master processing module receives the request and responds to the slave processing module to accept the request. At time T2, the master processing module starts to initiate synchronization and sends a synchronization request to the slave processing module. At time T3, the slave processing module receives the request and responds to the master processing module to accept the master processing module's request. At time T4, the master processing module receives the slave processing module's response, completing a handshake.
在T5時刻,主處理模組發送同步計數值給從處理模組,在T6時刻從處理模組接收到該計數值,計數值與T5時刻、通訊延遲等有關。 At time T5, the master processing module sends a synchronous count value to the slave processing module, and the slave processing module receives the count value at time T6. The count value is related to time T5, communication delay, etc.
在T7時刻,主處理模組再次發送同步請求,T8時刻從處理模組接受請求並回應主處理模組,同時更新自身的計數值。 At time T7, the main processing module sends a synchronization request again. At time T8, the slave processing module receives the request and responds to the main processing module, while updating its own count value.
例如,若從處理模組接收到了同步計數值,但同步失敗了(例如等待超時仍未收到對方回應),則在T9時刻重新開始一輪同步過程。 For example, if the synchronization count value is received from the processing module, but the synchronization fails (for example, the waiting timeout has not received a response from the other party), then a new round of synchronization process will be restarted at time T9.
在圖2所示的同步過程中,需要先通過多個階段才能完成同步,同步失敗風險較高,而且由於處理模組之間的通訊需要通過晶片上匯流排或互聯匯流排實現,多個階段的通訊會增加匯流 排上的時脈抖動、延遲帶來的影響,同步準確度較低。 In the synchronization process shown in Figure 2, multiple stages are required to complete the synchronization, and the risk of synchronization failure is high. In addition, since the communication between processing modules needs to be realized through the bus on the chip or the interconnect bus, the communication in multiple stages will increase the impact of clock jitter and delay on the bus, and the synchronization accuracy is low.
此外,在為主處理模組和從處理模組提供時脈訊號的時脈源為非同源時脈時,缺乏對於非同源時脈的高效處理方案。例如,對於非同源時脈,測量某操作所花費的時間時,執行該操作的執行緒可能從處理模組A變為處理模組B,則測量操作開始時間是基於處理模組A的時脈訊號,測量操作的結束時間是基於處理模組B的時脈訊號,這會由於處理模組A的時脈訊號與處理模組B的時脈訊號為非同步時脈訊號而產生時脈測量問題。例如,對於非同源時脈需要經常進行校準,當執行操作過程中進行了時間校準時,與時間測量/延遲相關的應用都會發生錯誤。 In addition, when the clock sources that provide clock signals to the master processing module and the slave processing module are non-coherent clocks, there is a lack of efficient processing solutions for non-coherent clocks. For example, for non-coherent clocks, when measuring the time taken for a certain operation, the execution thread of the operation may change from processing module A to processing module B, and the start time of the measured operation is based on the clock signal of processing module A, and the end time of the measured operation is based on the clock signal of processing module B. This will cause clock measurement problems because the clock signal of processing module A and the clock signal of processing module B are asynchronous clock signals. For example, non-cognate clocks require frequent calibration, and when time calibration is performed during operation, applications related to time measurement/delay will experience errors.
本發明至少一實施例提供一種時脈同步方法、時脈同步裝置、系統時脈同步方法、電子設備和非暫態性電腦可讀儲存介質。 At least one embodiment of the present invention provides a clock synchronization method, a clock synchronization device, a system clock synchronization method, an electronic device, and a non-transitory computer-readable storage medium.
該系統時脈同步方法包括:向第二處理模組發送觸發訊號,同時記錄發送觸發訊號時第一計時器當前的計數值作為第一計數值,其中,第二處理模組與第一處理模組屬於不同的時脈領域;從第二處理模組讀取第二計數值,其中,第二計數值為第二處理模組在接收到觸發訊號時,第二處理模組的第二計時器當前的計數值,第二計時器的計數值作為第二處理模組的定時基準且順序遞增;其中,第一計數值和第二計數值用於時脈補償,以使得第一處理模組所在的第一時脈領域與第二處理模組所在的第二時脈領域同步。 The system clock synchronization method includes: sending a trigger signal to the second processing module, and recording the current count value of the first timer when the trigger signal is sent as the first count value, wherein the second processing module and the first processing module belong to different clock domains; reading the second count value from the second processing module, wherein the second count value is the current count value of the second timer of the second processing module when the second processing module receives the trigger signal, and the count value of the second timer is used as the timing reference of the second processing module and increases sequentially; wherein the first count value and the second count value are used for clock compensation, so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located.
在至少一個實施例中,第一處理模組和第二處理模組基於同一個觸發訊號凍結系統計時器當前的計數值,並分別將該當前的計數值記錄下來,從而通過各個系統計時器的計數值即可瞭解各個計時器之間的關係及偏差,利用該計數值即可完成時脈補償。該時脈同步方法大大減少了時脈同步所需要的階段,通過同一個觸發訊號將各個計時器的計數值記錄下來,得到計時器之間的關係和偏差,即使後續出現通訊失敗問題,也不會導致同步失敗,並且同步準確度大大提升,消除軟體干預,減少匯流排上的時脈抖動、延遲帶來的影響,將用於時脈同步的介面由兩個減少為1個,減少介面佔用,提高資源利用率。 In at least one embodiment, the first processing module and the second processing module freeze the current count value of the system timer based on the same trigger signal, and record the current count value respectively, so that the relationship and deviation between each timer can be understood through the count value of each system timer, and the clock compensation can be completed using the count value. This clock synchronization method greatly reduces the stages required for clock synchronization. The count values of each timer are recorded through the same trigger signal to obtain the relationship and deviation between the timers. Even if communication failure occurs later, it will not cause synchronization failure. In addition, the synchronization accuracy is greatly improved, eliminating software intervention and reducing the impact of clock jitter and delay on the bus. The interface used for clock synchronization is reduced from two to one, reducing interface occupancy and improving resource utilization.
下面結合附圖對本發明的實施例進行詳細說明,但是本發明並不限於這些具體的實施例。 The following is a detailed description of the embodiments of the present invention in conjunction with the attached drawings, but the present invention is not limited to these specific embodiments.
圖3為本發明至少一實施例提供的一種時脈同步方法的示意性流程圖。 Figure 3 is a schematic flow chart of a clock synchronization method provided by at least one embodiment of the present invention.
例如,該時脈同步方法用於第一處理模組,第一處理模組包括第一計時器,第一計時器的計數值作為第一處理模組的定時基準且順序遞增。例如,第一計時器為第一處理模組的系統計時器。 For example, the clock synchronization method is used for a first processing module, the first processing module includes a first timer, and the count value of the first timer is used as a timing reference of the first processing module and increases sequentially. For example, the first timer is a system timer of the first processing module.
如圖3所示,本發明至少一實施例提供的時脈同步方法包括步驟S10至步驟S20。 As shown in FIG3 , the clock synchronization method provided by at least one embodiment of the present invention includes steps S10 to S20.
例如,在步驟S10,向第二處理模組發送觸發訊號,同時記錄發送觸發訊號時第一計時器當前的計數值作為第一計數值。 For example, in step S10, a trigger signal is sent to the second processing module, and the current count value of the first timer when the trigger signal is sent is recorded as the first count value.
例如,第一計數值記錄在第一處理模組的暫存器中。 For example, the first count value is recorded in the register of the first processing module.
例如,在步驟S20,從第二處理模組讀取第二計數值。 For example, in step S20, the second count value is read from the second processing module.
例如,第二計數值為第二處理模組在接收到觸發訊號時,第二處理模組的第二計時器當前的計數值,第二計時器的計數值作為第二處理模組的定時基準且順序遞增。 For example, the second count value is the current count value of the second timer of the second processing module when the second processing module receives the trigger signal. The count value of the second timer serves as the timing reference of the second processing module and increases sequentially.
例如,第二計時器為第二處理模組的系統計時器。 For example, the second timer is a system timer of the second processing module.
例如,第二計數值記錄在第二處理模組的暫存器中。 For example, the second count value is recorded in a register of the second processing module.
例如,第一計數值和第二計數值用於時脈補償,以使得第一處理模組所在的第一時脈領域與第二處理模組所在的第二時脈領域同步。 For example, the first count value and the second count value are used for clock compensation so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located.
例如,第一處理模組和第二處理模組可以為CPU Die或CPU Socket。例如,第一處理模組可以為圖1中的Die0,第二處理模組可以為圖1中的Die1,例如,第一處理模組可以為圖1中的Socket0,第二處理模組可以為圖1中的Socket1。當然,第一處理模組和第二處理模組可以為其他需要進行時脈同步的硬體模組。本發明對第一處理模組、第二處理模組的結構、功能不作具體限制。 For example, the first processing module and the second processing module can be CPU Die or CPU Socket. For example, the first processing module can be Die0 in Figure 1, and the second processing module can be Die1 in Figure 1. For example, the first processing module can be Socket0 in Figure 1, and the second processing module can be Socket1 in Figure 1. Of course, the first processing module and the second processing module can be other hardware modules that need to be synchronized with the clock. The present invention does not impose specific restrictions on the structure and function of the first processing module and the second processing module.
例如,第二處理模組與第一處理模組屬於不同的時脈領域。 For example, the second processing module and the first processing module belong to different clock domains.
例如,積體電路包括基於第一時脈源確定的第一時脈領域和基於第二時脈源確定的第二時脈領域。例如,第一時脈領域為由第一時脈源控制的區域,第一處理模組位於第一時脈領域。例 如,第二時脈領域為由第二時脈源控制的區域,第二處理模組位於第二時脈領域。例如,圖1中的Die0和Die1屬於兩個不同的時脈領域,例如,Die0位於第一時脈領域,根據第一時脈源提供的第一參考時脈訊號工作,Die1位於第二時脈領域,根據第二時脈源提供的第二參考時脈訊號工作。 For example, the integrated circuit includes a first clock domain determined based on a first clock source and a second clock domain determined based on a second clock source. For example, the first clock domain is a region controlled by the first clock source, and the first processing module is located in the first clock domain. For example, the second clock domain is a region controlled by the second clock source, and the second processing module is located in the second clock domain. For example, Die0 and Die1 in FIG1 belong to two different clock domains, for example, Die0 is located in the first clock domain and works according to the first reference clock signal provided by the first clock source, and Die1 is located in the second clock domain and works according to the second reference clock signal provided by the second clock source.
例如,第二處理模組與第一處理模組屬於不同的時脈領域表示它們屬於非同步時脈領域,產生原因可能有以下兩種: For example, the second processing module and the first processing module belong to different clock domains, which means they belong to asynchronous clock domains. There may be two reasons for this:
1、第一處理模組包括第一鎖相迴路,第一鎖相迴路配置為接收第一時脈源提供的第一參考時脈訊號,並根據第一參考時脈訊號生成第一工作時脈訊號提供給第一處理模組;第二處理模組包括第二鎖相迴路,第二鎖相迴路配置為接收第一時脈源提供的第一參考時脈訊號,並根據第一參考時脈訊號生成第二工作時脈訊號提供給第二處理模組。也即,第一處理模組和第二處理模組具有各自的鎖相迴路,但鎖相迴路接收同源時脈訊號。由於通電時鎖定的時間相位關係是隨機的,不同鎖相迴路之間觸發緣(launch edge)和捕獲緣(capture edge)的相位關係也是隨機的,所以即使第一處理模組和第二處理模組本質上接收是的同源時脈訊號,但也需要作為非同步時脈領域來處理。 1. The first processing module includes a first phase-locked loop, which is configured to receive a first reference clock signal provided by a first clock source, and to generate a first working clock signal according to the first reference clock signal and provide it to the first processing module; the second processing module includes a second phase-locked loop, which is configured to receive a first reference clock signal provided by a first clock source, and to generate a second working clock signal according to the first reference clock signal and provide it to the second processing module. That is, the first processing module and the second processing module have their own phase-locked loops, but the phase-locked loops receive the same source clock signal. Since the time phase relationship of the lock at power-on is random, the phase relationship between the launch edge and the capture edge between different phase-locked loops is also random, so even if the first processing module and the second processing module essentially receive the same source clock signal, they still need to be processed as asynchronous clock domains.
2、第一處理模組由第一時脈源提供參考時脈訊號,第二處理模組由第二時脈源提供參考時脈訊號,第一時脈源與第二時脈源為非同源時脈源。此時,第一處理模組包括第一鎖相迴路,第一鎖相迴路配置為接收第一時脈源提供的第一參考時脈訊號,並 根據第一參考時脈訊號生成第一工作時脈訊號提供給第一處理模組;第二處理模組包括第二鎖相迴路,第二鎖相迴路配置為接收第二時脈源提供的第二參考時脈訊號,並根據第二參考時脈訊號生成第二工作時脈訊號提供給第二處理模組。第一時脈訊號和第二時脈訊號為非同步時脈訊號。例如,對於非同源時脈源,儘管鎖相迴路能夠進行相位跟隨,由於不可能存在兩個晶振的頻率完全相同,因此非同源時脈源不僅相位不同,時脈頻率也不同。 2. The first processing module is provided with a reference clock signal by the first clock source, and the second processing module is provided with a reference clock signal by the second clock source. The first clock source and the second clock source are non-coherent clock sources. At this time, the first processing module includes a first phase-locked loop, which is configured to receive a first reference clock signal provided by the first clock source, and generate a first working clock signal according to the first reference clock signal and provide it to the first processing module; the second processing module includes a second phase-locked loop, which is configured to receive a second reference clock signal provided by the second clock source, and generate a second working clock signal according to the second reference clock signal and provide it to the second processing module. The first clock signal and the second clock signal are asynchronous clock signals. For example, for non-cognate clock sources, although the phase-locked loop can perform phase tracking, since it is impossible for two crystal oscillators to have exactly the same frequency, non-cognate clock sources not only have different phases, but also different clock frequencies.
需要說明的是,積體電路還可以包括第三時脈領域、第四時脈領域等,也即積體電路可以包括多個時脈領域,在進行時脈同步時,從多個處理模組中選擇由非同步時脈控制的兩個處理模組作為第一處理模組和第二處理模組,並基於本發明所提供的時脈同步方法對這兩個處理模組對應的非同步時脈進行時脈同步。 It should be noted that the integrated circuit may also include a third clock domain, a fourth clock domain, etc., that is, the integrated circuit may include multiple clock domains. When performing clock synchronization, two processing modules controlled by asynchronous clocks are selected from multiple processing modules as the first processing module and the second processing module, and the asynchronous clocks corresponding to the two processing modules are synchronized based on the clock synchronization method provided by the present invention.
在本發明至少一實施例提供的時脈同步方法中,實現了第一計時器和第二計時器的快拍功能(snapshot),例如第一計時器和第二計時器接收到同一個觸發訊號(例如計時器trigger訊號或者通用輸入輸出介面的訊號)的上升邊緣,將當前第一計時器的計數值凍結至第一處理模組中的一個暫存器,將當前第二計時器的計數值凍結至第二處理模組中的一個暫存器,由於多個計時器只由一個訊號同步觸發,因而讀取各計時器用於儲存記錄的計數值的暫存器即可得到各個計時器的關係及偏差,從而確定補償值以進行時脈補償。例如,根據第一計數值和第二計數值的偏差進行時脈補償,以使得第一處理模組所在的第一時脈領域與第二處理模 組所在的第二時脈領域同步。 In the clock synchronization method provided in at least one embodiment of the present invention, a snapshot function of the first timer and the second timer is implemented. For example, when the first timer and the second timer receive the rising edge of the same trigger signal (such as a timer trigger signal or a signal of a universal input/output interface), the current count value of the first timer is frozen in a register in the first processing module, and the current count value of the second timer is frozen in a register in the second processing module. Since multiple timers are synchronously triggered by only one signal, the relationship and deviation of each timer can be obtained by reading the register used to store the recorded count value of each timer, thereby determining the compensation value for clock compensation. For example, clock compensation is performed based on the deviation between the first count value and the second count value, so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located.
對於不同原因導致的非同步時脈領域,在時脈同步時的處理方法也不同,下面分別針對兩種不同原因導致的非同步時脈領域,結合附圖具體說明處理過程。 For asynchronous clock domains caused by different reasons, the processing methods are also different when the clock is synchronized. The following is a detailed description of the processing process for two asynchronous clock domains caused by different reasons, combined with the attached diagrams.
例如,以CPU為例,多個處理模組通常包括一個主處理模組(Master)和多個從處理模組,主處理模組通常進行調度和協助,將服務的執行委託給不同的從處理模組。 For example, taking the CPU as an example, multiple processing modules usually include a master processing module (Master) and multiple slave processing modules. The master processing module usually performs scheduling and assistance, entrusting the execution of services to different slave processing modules.
例如,以下實施例中以第一處理模組為從處理模組,第二處理模組為主處理模組為例進行描述。當然,本發明不限於此,本領域技術人員也可以根據實際需要選擇第一處理模組為主處理模組,第二處理模組為從處理模組,或者,第一處理模組和第二處理模組之間也可以沒有主從關係。 For example, in the following embodiments, the first processing module is described as a slave processing module and the second processing module is described as a master processing module. Of course, the present invention is not limited to this, and technicians in this field can also select the first processing module as the master processing module and the second processing module as the slave processing module according to actual needs, or there can be no master-slave relationship between the first processing module and the second processing module.
對於第一處理模組和第二處理模組採用同源時脈源提供參考時脈訊號,但分別具有不同的鎖相迴路的情形下,經過鎖相迴路處理後,第一處理模組和第二處理模組所接收的參考時脈訊號頻率相同,但存在固定的相位差。因此,第一處理模組只需要獲取第一計數值和第二計數值,根據第一計數值和第二計數值的差異補償第一計時器,補償後第一計時器和第二計時器會一直保持一致,非斷電重啟否則不需要再進行維護。例如,時脈補償可以在需要時,由軟體觸發執行一次,例如設置標誌位元,在標誌位元有效時進行補償,由於計數值的偏差已經通過同一觸發訊號記錄在暫存器中,消除了同步失敗問題。 In the case where the first processing module and the second processing module use the same clock source to provide a reference clock signal, but have different phase-locked loops, after being processed by the phase-locked loop, the reference clock signals received by the first processing module and the second processing module have the same frequency, but a fixed phase difference. Therefore, the first processing module only needs to obtain the first count value and the second count value, and compensate the first timer according to the difference between the first count value and the second count value. After compensation, the first timer and the second timer will always be consistent, and no maintenance is required unless the power is turned off and restarted. For example, clock compensation can be triggered by software once when needed, such as setting a flag bit, and compensation is performed when the flag bit is valid. Since the deviation of the count value has been recorded in the register through the same trigger signal, the synchronization failure problem is eliminated.
例如,時脈同步在第一處理模組處於通電階段時執行,也即在第一處理模組剛剛通電、還沒有執行任何具體操作前執行。此時,由於第一處理模組還沒有執行具體操作,因此時脈補償可以不需考慮維持時間單調遞增問題。 For example, the clock synchronization is performed when the first processing module is in the power-on stage, that is, when the first processing module is just powered on and before any specific operation is performed. At this time, since the first processing module has not yet performed any specific operation, the clock compensation does not need to consider the problem of maintaining monotonic increase in time.
當然,若時脈同步在第一處理模組工作時執行,也即第一處理模組已經執行具體操作,則需要考慮時間單調遞增問題,具體過程可以參考後文中非同源時脈源中的相關說明,這裡不再贅述。 Of course, if the clock synchronization is performed when the first processing module is working, that is, the first processing module has already performed a specific operation, then the problem of monotonic increase in time needs to be considered. The specific process can be referred to in the relevant description of the non-homologous clock source in the following text, and will not be elaborated here.
圖4為本發明至少一實施例提供的時脈同步方法的流程圖。 Figure 4 is a flow chart of a clock synchronization method provided by at least one embodiment of the present invention.
如圖4所示,在步驟S20後,該時脈同步方法還包括步驟S301和步驟S302。 As shown in FIG4 , after step S20, the clock synchronization method further includes step S301 and step S302.
步驟S301,確定第一計數值和第二計數值的偏差。 Step S301, determine the deviation between the first count value and the second count value.
步驟S302,根據偏差,對第一計時器進行補償,以使得第一處理模組所在的第一時脈領域與第二處理模組所在的第二時脈領域同步。 Step S302, based on the deviation, the first timer is compensated so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located.
例如,在步驟S301,偏差為第一計數值和第二計數值的差值。 For example, in step S301, the deviation is the difference between the first count value and the second count value.
例如,步驟S302可以包括:獲取第一計時器當前的計數值作為第三計數值;將偏差與第三計數值進行加和處理,得到更新計數值;將第一計時器的計數值更新為更新計數值,以使得第一處理模組所在的第一時脈領域與第二處理模組所在的第二時脈領域同步。 For example, step S302 may include: obtaining the current count value of the first timer as the third count value; adding the deviation to the third count value to obtain an updated count value; updating the count value of the first timer to the updated count value, so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located.
例如,第一計數值為N1,第二計數值為N2,N1和N2為正整數。第一計數值和第二計數值的偏差例如為N1-N2。 For example, the first count value is N1, the second count value is N2, and N1 and N2 are positive integers. The deviation between the first count value and the second count value is, for example, N1-N2.
例如,計算得到偏差後,可以在需要時進行時脈補償。例如,當指示進行時脈補償的標誌位元有效時,獲取第一計時器當前的計數值N3作為第三計數值,計算N3+N1-N2作為更新計數值,並將第一計時器的計數值更新為該更新計數值N3+N1-N2。例如,在指示進行時脈補償的標誌位元無效時,第一計時器的計數值按照參考時脈訊號頻率持續遞增,例如每個時脈週期加1。 For example, after the deviation is calculated, clock compensation can be performed when necessary. For example, when the flag bit indicating clock compensation is valid, the current count value N3 of the first timer is obtained as the third count value, N3+N1-N2 is calculated as the updated count value, and the count value of the first timer is updated to the updated count value N3+N1-N2. For example, when the flag bit indicating clock compensation is invalid, the count value of the first timer continues to increase according to the reference clock signal frequency, for example, by 1 for each clock cycle.
例如,觸發訊號還配置為同時觸發第一處理模組的中斷,以執行時脈補償。例如,由於在時脈同源情況下,第一處理模組調整第一計時器的計數值即可,因此只需要第一處理模組觸發中斷,中斷當前的應用服務,執行時脈補償後再繼續執行應用服務。 For example, the trigger signal is also configured to simultaneously trigger the interruption of the first processing module to perform clock compensation. For example, since the first processing module only needs to adjust the count value of the first timer when the clocks are of the same source, the first processing module only needs to trigger an interruption to interrupt the current application service, perform clock compensation, and then continue to execute the application service.
圖5為本發明至少一實施例提供的時脈同步方法的交互過程示意圖。 Figure 5 is a schematic diagram of the interactive process of the clock synchronization method provided by at least one embodiment of the present invention.
如圖5所示,在T0時刻,第一處理模組向第二處理模組發起“assert trigger”,此時,第一處理模組在發送觸發訊號時記錄第一計時器當前的計數值作為第一計數值並儲存在第一暫存器中,例如,第一暫存器位於第一處理模組且可以靜態儲存數值;同時,第二處理模組在接收到該觸發訊號時記錄第二計時器當前的計數值作為第二計數值並儲存在第二暫存器中,例如,第二暫存器位於第二處理模組且可以靜態儲存數值。並且,觸發訊號還同時觸發了第一處理模組的中斷。 As shown in Figure 5, at time T0, the first processing module sends an "assert trigger" to the second processing module. At this time, the first processing module records the current count value of the first timer as the first count value and stores it in the first register when sending the trigger signal. For example, the first register is located in the first processing module and can statically store values. At the same time, the second processing module records the current count value of the second timer as the second count value and stores it in the second register when receiving the trigger signal. For example, the second register is located in the second processing module and can statically store values. In addition, the trigger signal also triggers the interruption of the first processing module at the same time.
之後,在T1時刻,第一處理模組讀取第二處理模組中的第二暫存器的值,得到第二計數值,參考如上步驟S301和步驟S302的過程,進行時脈補償,具體過程不再贅述。 Afterwards, at time T1, the first processing module reads the value of the second register in the second processing module to obtain the second count value, and performs clock compensation with reference to the process of step S301 and step S302 above. The specific process will not be described in detail.
在該實施例中,由於時脈同源,所以第一處理模組和第二處理模組之間存在固定的相位差,根據第一計數值和第二計數值的偏差可以補償該固定相位差,並且補償一次即可,非掉電重啟不需要再維護,實現方式簡單有效,消除了同步失敗情況,大幅減少了時脈同步階段,第一處理模組和第二處理模組之間的通訊次數大大減少,降低了由於網路線或晶片上網路的時脈抖動、延遲等帶來的影響,時脈同步準確度得到了提升。 In this embodiment, since the clocks are of the same source, there is a fixed phase difference between the first processing module and the second processing module. The fixed phase difference can be compensated according to the deviation between the first count value and the second count value, and the compensation only needs to be done once. No maintenance is required unless power is turned off and restarted. The implementation method is simple and effective, and synchronization failure is eliminated. The clock synchronization stage is greatly reduced. The number of communications between the first processing module and the second processing module is greatly reduced, and the influence of clock jitter and delay caused by the network line or the network on the chip is reduced, and the accuracy of clock synchronization is improved.
對於第一處理模組和第二處理模組採用非同源時脈源提供參考時脈訊號的情形下,時脈頻率和時脈相位都需要進行調整,並且隨時間增長時脈頻率會產生漂移。因此,在這種情況下需要定期進行時脈同步。 When the first processing module and the second processing module use non-coherent clock sources to provide reference clock signals, both the clock frequency and the clock phase need to be adjusted, and the clock frequency will drift over time. Therefore, in this case, clock synchronization needs to be performed regularly.
例如,時脈同步在第一處理模組處於工作狀態時定期執行,這裡工作狀態表示,第一處理模組已經完成通電初始化,能夠執行計算等任意操作。例如,這裡定期執行的時脈同步包括記錄第一計數值、第二計數值、時脈補償整個過程。 For example, the clock synchronization is performed periodically when the first processing module is in a working state. Here, the working state means that the first processing module has completed power-on initialization and can perform any operation such as calculation. For example, the clock synchronization performed periodically here includes recording the first count value, the second count value, and the entire process of clock compensation.
在時脈同步的整個過程中,也即在第一處理模組和第二處理模組的整個工作過程中,第一計時器和所述第二計時器的計數值始終保持單調遞增。不同于同源時脈源執行一次時脈同步即可,在非同源時脈源情況下,時脈同步需要定期執行,且第一處理 模組或第二處理模組的時脈需要始終保持單調遞增,否則對於時脈測量、延遲相關的應用服務會出現錯誤。 During the entire process of clock synchronization, that is, during the entire working process of the first processing module and the second processing module, the count values of the first timer and the second timer always keep monotonically increasing. Unlike the same source clock source, clock synchronization only needs to be performed once. In the case of non-same source clock sources, clock synchronization needs to be performed regularly, and the clock of the first processing module or the second processing module needs to keep monotonically increasing at all times, otherwise errors will occur in clock measurement and delay-related application services.
因此,在該實施例中,進行時脈同步時,獲得基於同一觸發訊號記錄的第一計數值和第二計數值後,需要根據第一計數值和第二計數值判斷第一處理模組和第二處理模組中時脈較快的一方,選擇較慢的一方進行時脈補償,以使得時脈向較快的一方靠攏。 Therefore, in this embodiment, when performing clock synchronization, after obtaining the first count value and the second count value based on the same trigger signal record, it is necessary to determine the first processing module and the second processing module with a faster clock according to the first count value and the second count value, and select the slower one to perform clock compensation so that the clock is closer to the faster one.
圖6為本發明至少一實施例提供的時脈同步方法的流程圖。 Figure 6 is a flow chart of a clock synchronization method provided by at least one embodiment of the present invention.
如圖6所示,在步驟S20後,該時脈同步方法還包括步驟S401和步驟S402。 As shown in FIG6 , after step S20, the clock synchronization method further includes step S401 and step S402.
在步驟S401,比較第一計數值和第二計數值的大小關係。 In step S401, the magnitude relationship between the first count value and the second count value is compared.
在步驟S402,回應於第一計數值小於第二計數值,根據第一計數值和第二計數值的偏差進行時脈補償,以使得第一處理模組所在的第一時脈領域與第二處理模組所在的第二時脈領域同步。 In step S402, in response to the first count value being less than the second count value, clock compensation is performed according to the deviation between the first count value and the second count value, so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located.
例如,若第一計數值小於第二計數值,表示第一處理模組的時脈慢於第二處理模組的時脈,需要調整第一處理模組的時脈以向第二處理模組的時脈靠攏。 For example, if the first count value is less than the second count value, it means that the clock of the first processing module is slower than the clock of the second processing module, and the clock of the first processing module needs to be adjusted to approach the clock of the second processing module.
例如,步驟S402可以包括:確定第一計數值和第二計數值的偏差;根據偏差,對第一計時器進行補償,以使得第一處理模組所在的第一時脈領域與第二處理模組所在的第二時脈領域同步。 For example, step S402 may include: determining the deviation between the first count value and the second count value; and compensating the first timer according to the deviation so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located.
根據時脈源的類型不同,時脈補償的具體操作略有不同。下面針對不同類型的時脈源分別說明具體補償過程。 The specific operation of clock compensation is slightly different depending on the type of clock source. The following describes the specific compensation process for different types of clock sources.
例如,對於能夠通過電壓控制時脈源的振盪頻率的晶振,例如壓控晶振(Voltage Control Crystal Oscillator,簡稱VCXO)或壓控溫補晶振(Voltage Control Temperature Compensate Crystal Oscillator,簡稱VCTCXO),通過向晶振的電壓控制管腳輸入調整電壓,可以控制晶振的輸出頻率,使得晶振的振盪頻率不斷向目標振盪頻率收斂,可以達到ppb(億分之一)級別準確度。 For example, for a crystal oscillator that can control the oscillation frequency of a clock source by voltage, such as a voltage-controlled crystal oscillator (VCXO) or a voltage-controlled temperature-compensated crystal oscillator (VCTCXO), the output frequency of the crystal oscillator can be controlled by inputting an adjustment voltage to the voltage control pin of the crystal oscillator, so that the oscillation frequency of the crystal oscillator continuously converges to the target oscillation frequency, and can achieve ppb (parts per billion) level accuracy.
例如,在該實施例中,首先得到第一計數值和第二計數值的偏差,例如,偏差為第一計數值和第二計數值之差。 For example, in this embodiment, the deviation between the first count value and the second count value is first obtained, for example, the deviation is the difference between the first count value and the second count value.
例如,在該實施例中,步驟S402可以包括:根據偏差,對第一計時器進行補償;根據偏差,確定調整電壓;根據調整電壓,對第一時脈源進行補償,以使得第一處理模組所在的第一時脈領域與第二處理模組所在的第二時脈領域同步。 For example, in this embodiment, step S402 may include: compensating the first timer according to the deviation; determining the adjustment voltage according to the deviation; and compensating the first clock source according to the adjustment voltage so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located.
例如,根據偏差,對第一計時器進行補償的過程與同源時脈源類似,首先獲取第一計時器當前的計數值作為第三計數值;之後,將偏差與第三計數值進行加和處理,得到更新計數值;最後,將第一計時器的計數值更新為更新計數值。具體過程這裡不再贅述。 For example, the process of compensating the first timer according to the deviation is similar to that of the same source clock source. First, the current count value of the first timer is obtained as the third count value; then, the deviation and the third count value are added to obtain the updated count value; finally, the count value of the first timer is updated to the updated count value. The specific process will not be repeated here.
例如,根據偏差,確定調整電壓,可以包括:根據偏差,計算第一時脈源相對於第二時脈源的單位時間頻率偏差;根據單位時間頻率偏差,確定調整電壓。 For example, determining the adjustment voltage based on the deviation may include: calculating the unit time frequency deviation of the first clock source relative to the second clock source based on the deviation; and determining the adjustment voltage based on the unit time frequency deviation.
例如,單位時間頻率偏差以ppm(百萬分之一)或ppb為單位,例如,單位時間頻率偏差可以為偏差與第一計時器的工作頻率的比值。 For example, the unit time frequency deviation is in ppm (parts per million) or ppb. For example, the unit time frequency deviation can be the ratio of the deviation to the operating frequency of the first timer.
對於壓控振盪器,例如通過調整電壓可以改變變容二極體的電容,從而可以“牽引”晶振的頻率,達到頻率調製的目的。由此,根據單位時間頻率偏差,可以確定調整電壓,調整電壓與晶振自身的參數和單位時間頻率偏差相關。 For voltage-controlled oscillators, for example, the capacitance of the varactor diode can be changed by adjusting the voltage, thereby "pulling" the frequency of the crystal oscillator to achieve the purpose of frequency modulation. Therefore, the adjustment voltage can be determined based on the unit time frequency deviation, and the adjustment voltage is related to the parameters of the crystal oscillator itself and the unit time frequency deviation.
例如,在一些實施例中,根據偏差,確定調整電壓,可以包括:獲取歷史頻率偏差,其中,歷史頻率偏差為最近一次用於計算調整電壓的單位時間頻率偏差;計算歷史頻率偏差和基於偏差計算的單位時間頻率偏差的加權和;根據加權和的計算結果確定調整電壓。 For example, in some embodiments, determining the adjustment voltage based on the deviation may include: obtaining a historical frequency deviation, wherein the historical frequency deviation is the unit time frequency deviation used to calculate the adjustment voltage most recently; calculating a weighted sum of the historical frequency deviation and the unit time frequency deviation calculated based on the deviation; and determining the adjustment voltage based on the calculation result of the weighted sum.
例如,調整電壓的計算公式如下:latest_ppm=(1.0-ema)*latest_ppm+ema*current_observed_ppm adj_vlt=f(latest_ppm)(公式1) For example, the calculation formula for adjusting the voltage is as follows: latest_ppm=(1.0-ema)*latest_ppm+ema*current_observed_ppm adj_vlt=f(latest_ppm)(Formula 1)
其中,latest_ppm表示歷史頻率偏差,current_observed_ppm表示基於偏差計算的單位時間頻率偏差,ema表示權值係數,這裡“=”表示賦值,例如將歷史頻率偏差和基於偏差計算的單位時間頻率偏差計算的加權和賦值給(更新)歷史頻率偏差,adj_vlt表示調整電壓,f(*)表示調整電壓與時脈偏差(加 權和)的函數關係。 Among them, latest_ppm represents the historical frequency deviation, current_observed_ppm represents the unit time frequency deviation calculated based on the deviation, ema represents the weight coefficient, and here "=" represents assignment, for example, the weighted sum of the historical frequency deviation and the unit time frequency deviation calculated based on the deviation is assigned to (updated) the historical frequency deviation, adj_vlt represents the adjustment voltage, and f(*) represents the functional relationship between the adjustment voltage and the clock deviation (weighted sum).
例如,對於第一次執行調整電壓計算時,直接根據當前偏差計算調整電壓,並將當前偏差計算的單位時間頻率偏差作為歷史頻率偏差;在第二次執行調整電壓計算時,計算當前偏差計算的單位時間頻率偏差和歷史頻率偏差的加權和,根據加權和確定調整電壓,並將歷史頻率偏差更新為加權和;以此類推。 For example, when the adjustment voltage calculation is performed for the first time, the adjustment voltage is calculated directly based on the current deviation, and the unit time frequency deviation calculated by the current deviation is used as the historical frequency deviation; when the adjustment voltage calculation is performed for the second time, the weighted sum of the unit time frequency deviation calculated by the current deviation and the historical frequency deviation is calculated, the adjustment voltage is determined based on the weighted sum, and the historical frequency deviation is updated to the weighted sum; and so on.
在該實施例中,根據權重係數可以調整歷史頻率偏差或當前的單位時間頻率偏差的比重,平緩調整電壓變化,平緩時脈變化,避免發生劇烈的時脈抖動。 In this embodiment, the weight of the historical frequency deviation or the current unit time frequency deviation can be adjusted according to the weight coefficient to smoothly adjust the voltage change and the pulse change to avoid severe clock jitter.
例如,根據調整電壓,對第一時脈源進行補償,以使得第一處理模組所在的第一時脈領域與第二處理模組所在的第二時脈領域同步,可以包括:將調整電壓輸入第一時脈源的電壓控制管腳,以使得第一時脈源的振盪頻率向第二時脈源的振盪頻率方向收斂,並使得第一時脈源和第二時脈源同步。 For example, compensating the first clock source according to the adjustment voltage so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located may include: inputting the adjustment voltage into the voltage control pin of the first clock source so that the oscillation frequency of the first clock source converges toward the oscillation frequency of the second clock source, and the first clock source is synchronized with the second clock source.
例如,將調整電壓輸入第一時脈源的電壓控制管腳後,第一時脈源的振盪頻率會向第二時脈源的振盪頻率方向收斂,收斂可以達到ppb級別準確度,由此維護及時脈補償的週期也可以放鬆到比較久才做一次,例如間隔1秒執行一次時脈同步。例如,在收斂準確度達到50ppb時,對於工作頻率為100MHz的系統時脈,1秒做一次會產生5個週期(cycle)的誤差。 For example, after the adjustment voltage is input to the voltage control pin of the first clock source, the oscillation frequency of the first clock source will converge towards the oscillation frequency of the second clock source. The convergence can achieve ppb level accuracy, so the cycle of maintaining timely clock compensation can be relaxed to a longer period, such as performing clock synchronization once every 1 second. For example, when the convergence accuracy reaches 50ppb, for a system clock with an operating frequency of 100MHz, performing it once per second will produce an error of 5 cycles.
例如,觸發訊號還配置為同時觸發第一處理模組和第二處理模組的中斷,以執行時脈補償。例如,由於在時脈非同源情況 下,第一處理模組和第二處理模組都存在調整自身計時器的計數值及時脈頻率的可能性,因此需要第一處理模組和第二處理模組都觸發中斷,中斷各自當前的應用服務,執行時脈補償後再繼續執行應用服務。 For example, the trigger signal is also configured to simultaneously trigger the interruption of the first processing module and the second processing module to perform clock compensation. For example, since the clocks are not of the same source, the first processing module and the second processing module may adjust the count value and clock frequency of their own timers. Therefore, the first processing module and the second processing module need to trigger interruption to interrupt their current application services, perform clock compensation, and then continue to execute the application service.
在上述實施例中,由於可以通過電壓調控晶振的頻率,例如在第一處理模組的時脈慢於第二處理模組的時脈時,通過電壓控制使得第一時脈源的振盪頻率向第二時脈源的振盪頻率方向收斂,因此“定期”執行時脈同步的間隔可以設置較長,例如可以達到秒級,這對系統性能影響較小,不需要頻繁產生中斷影響系統性能,也不需要頻繁產生觸發訊號在第一處理模組和第二處理模組之間通訊,不會佔用晶片上網路或網路線的通訊資源。此外,消除了同步失敗情況,大幅減少了時脈同步階段,第一處理模組和第二處理模組之間的通訊次數大大減少,降低了由於網路線或晶片上網路的時脈抖動、延遲等帶來的影響,時脈同步準確度得到了提升。 In the above embodiment, since the frequency of the crystal oscillator can be regulated by voltage, for example, when the clock of the first processing module is slower than the clock of the second processing module, the oscillation frequency of the first clock source is converged toward the oscillation frequency of the second clock source by voltage control. Therefore, the interval of "regular" clock synchronization can be set longer, for example, it can reach the second level, which has little impact on system performance, and does not need to frequently generate interruptions to affect system performance, nor does it need to frequently generate trigger signals for communication between the first processing module and the second processing module, and will not occupy the communication resources of the network or network line on the chip. In addition, synchronization failures are eliminated, the clock synchronization phase is greatly reduced, the number of communications between the first processing module and the second processing module is greatly reduced, and the impact of clock jitter and delay caused by network cables or on-chip networks is reduced, and the accuracy of clock synchronization is improved.
例如,對於不能通過電壓控制時脈源的振盪頻率的晶振,例如簡單的XO(Crystal Oscillator)晶振,XO晶振的穩定性完全由晶體諧振器本身的固有特性決定。在這種情況下,時脈同步仍然在第一處理模組處於工作狀態時定期執行,在確定需要由第一處理模組進行時脈補償時,對第一計時器進行補償即可,具體過程與時脈源同源時相似,首先獲取第一計時器當前的計數值作為第三計數值;之後,將偏差與第三計數值進行加和處理,得到更新計數 值;最後,將第一計時器的計數值更新為更新計數值,完成一次時脈補償。具體過程這裡不再贅述。 For example, for a crystal oscillator whose oscillation frequency of the clock source cannot be controlled by voltage, such as a simple XO (Crystal Oscillator) crystal oscillator, the stability of the XO crystal oscillator is completely determined by the inherent characteristics of the crystal resonator itself. In this case, the clock synchronization is still performed regularly when the first processing module is in working state. When it is determined that the first processing module needs to perform clock compensation, the first timer can be compensated. The specific process is similar to that when the clock source is the same source. First, the current count value of the first timer is obtained as the third count value; then, the deviation is added to the third count value to obtain the updated count value; finally, the count value of the first timer is updated to the updated count value to complete a clock compensation. The specific process will not be described here.
此外,在該實施例中,觸發訊號還配置為同時觸發第一處理模組和第二處理模組的中斷,以執行時脈補償。 In addition, in this embodiment, the trigger signal is also configured to simultaneously trigger the interruption of the first processing module and the second processing module to perform clock compensation.
例如,在該實施例中,執行時脈同步的間隔時間與第一時脈源和第二時脈源之間的頻率差異有關,若第一時脈源和第二時脈源的頻率偏差較大,則補償間隔相對於能夠進行電壓控制的時脈源來說較短。 For example, in this embodiment, the interval time for executing clock synchronization is related to the frequency difference between the first clock source and the second clock source. If the frequency deviation between the first clock source and the second clock source is large, the compensation interval is shorter than the clock source capable of voltage control.
例如,本發明至少一實施例還提供另一種時脈同步方法。圖7為本發明至少一實施例提供的另一種時脈同步方法的示意性流程圖。 For example, at least one embodiment of the present invention also provides another clock synchronization method. Figure 7 is a schematic flow chart of another clock synchronization method provided by at least one embodiment of the present invention.
例如,該時脈同步方法應用於第二處理模組,第二處理模組包括第二計時器,第二計時器的計數值作為第二處理模組的定時基準且順序遞增。例如,第二計時器為第二處理模組的系統計時器。 For example, the clock synchronization method is applied to the second processing module, the second processing module includes a second timer, and the count value of the second timer is used as the timing reference of the second processing module and increases sequentially. For example, the second timer is the system timer of the second processing module.
關於第二處理模組和第二計時器的內容可以參考前述實施例中關於第一處理模組和第一計時器的相關介紹,這裡不再贅述。 For the contents of the second processing module and the second timer, please refer to the relevant introduction of the first processing module and the first timer in the aforementioned embodiment, which will not be elaborated here.
例如,如圖7所示,本發明至少一實施例提供的時脈同步方法至少包括步驟S50。 For example, as shown in FIG. 7, the clock synchronization method provided by at least one embodiment of the present invention includes at least step S50.
在步驟S50,回應於接收到第一處理模組發送的觸發訊號,記錄第二計時器當前的計數值作為第二計數值,這裡,第二處理模 組與第一處理模組屬於不同的時脈領域。 In step S50, in response to receiving the trigger signal sent by the first processing module, the current count value of the second timer is recorded as the second count value. Here, the second processing module and the first processing module belong to different clock domains.
例如,第二計數值用於結合第一計數值進行時脈補償,以使得第一處理模組所在的第一時脈領域與第二處理模組所在的第二時脈領域同步,第一計數值為第一處理模組向第二處理模組發送觸發訊號時,第一處理模組的第一計時器當前的計數值,第一計時器的計數值用於作為第一處理模組的定時基準且順序遞增。 For example, the second count value is used to combine with the first count value for clock compensation, so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located. The first count value is the current count value of the first timer of the first processing module when the first processing module sends a trigger signal to the second processing module. The count value of the first timer is used as the timing reference of the first processing module and increases sequentially.
關於第一處理模組、第一計時器、第一計數值的相關內容可以參考前述實施例中第一處理模組、第一計時器、第一計數值的相關描述,這裡不再贅述。 For the relevant contents of the first processing module, the first timer, and the first count value, please refer to the relevant descriptions of the first processing module, the first timer, and the first count value in the aforementioned embodiment, which will not be repeated here.
例如,參考前述實施例中的相關描述,第一處理模組和第二處理模組屬於不同時脈領域的形成原因有兩種。 For example, referring to the relevant description in the aforementioned embodiment, there are two reasons why the first processing module and the second processing module belong to different clock domains.
例如,在第一處理模組和第二處理模組具有各自的鎖相迴路,但鎖相迴路接收同源時脈訊號的情況下,如步驟S301和步驟S302所述,時脈補償由第一處理模組執行,第二處理模組只需記錄在接收到同一個觸發訊號時第二計時器的計數值即可,第二處理模組無需中斷,可以繼續執行所需要的操作。實現過程簡單,無需中斷,且在第一處理模組和第二處理模組處於帶電狀態時執行一次補償即可,非掉電重啟不需要維護,對系統性能影響很小,同步準確度高。 For example, when the first processing module and the second processing module have their own phase-locked loops, but the phase-locked loops receive the same source clock signal, as described in step S301 and step S302, the clock compensation is performed by the first processing module, and the second processing module only needs to record the count value of the second timer when receiving the same trigger signal. The second processing module does not need to be interrupted and can continue to perform the required operation. The implementation process is simple, no interruption is required, and compensation is performed once when the first processing module and the second processing module are in a powered state. No maintenance is required for non-power-off restart, and the impact on system performance is small, and the synchronization accuracy is high.
例如,第一處理模組由第一時脈源提供參考時脈訊號,第二處理模組由第二時脈源提供參考時脈訊號,第一時脈源與第二時脈源為非同源時脈源時,如前所述,這種情況下,非同源時脈源 不僅相位不同,時脈頻率也不同,需要定期執行時脈同步,並且第一計時器和第二計時器的計數值在整個時脈同步過程始終保持單調遞增。需要說明的是,這裡整個時脈同步過程不僅指單次時脈同步,而是指定期執行的多次時脈同步裡,第一計時器和第二計時器的計數值,始終保持單調遞增。 For example, the first processing module is provided with a reference clock signal by the first clock source, and the second processing module is provided with a reference clock signal by the second clock source. When the first clock source and the second clock source are non-coherent clock sources, as mentioned above, in this case, the non-coherent clock sources not only have different phases, but also different clock frequencies, and need to perform clock synchronization regularly, and the count values of the first timer and the second timer always keep monotonically increasing during the entire clock synchronization process. It should be noted that the entire clock synchronization process here does not only refer to a single clock synchronization, but also to the count values of the first timer and the second timer in multiple clock synchronizations performed regularly, which always keep monotonically increasing.
為保持時脈單調遞增,如前所述,首先需要判斷第一處理模組和第二處理模組中時脈較快的一方,選擇較慢的一方進行時脈補償,以使得時脈向較快的一方靠攏。 To keep the clock monotonically increasing, as mentioned above, it is necessary to first determine which of the first and second processing modules has a faster clock, and select the slower one for clock compensation so that the clock converges to the faster one.
例如,如圖7所示,在步驟S50後,該時脈同步方法還包括步驟S601至步驟S603。 For example, as shown in FIG7 , after step S50, the clock synchronization method further includes steps S601 to S603.
在步驟S601,從第一處理模組讀取第一計數值。 In step S601, the first count value is read from the first processing module.
在步驟S602,比較第一計數值和第二計數值的大小關係。 In step S602, the magnitude relationship between the first count value and the second count value is compared.
在步驟S603,回應於第二計數值小於第一計數值,根據第一計數值和第二計數值的偏差進行時脈補償,以使得第一處理模組所在的第一時脈領域與第二處理模組所在的第二時脈領域同步。 In step S603, in response to the second count value being less than the first count value, clock compensation is performed according to the deviation between the first count value and the second count value, so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located.
例如,觸發訊號還配置為同時觸發第一處理模組和第二處理模組的中斷,以執行時脈補償。 For example, the trigger signal is also configured to simultaneously trigger the interruption of the first processing module and the second processing module to perform clock compensation.
例如,若第二計數值小於第一計數值,表示第二處理模組的時脈慢於第一處理模組的時脈,需要調整第二處理模組的時脈以向第一處理模組的時脈靠攏。 For example, if the second count value is less than the first count value, it means that the clock of the second processing module is slower than the clock of the first processing module, and the clock of the second processing module needs to be adjusted to approach the clock of the first processing module.
例如,步驟S603可以包括:確定第一計數值和第二計數 值的偏差;根據偏差,對第二計時器進行補償,以使得第一處理模組所在的第一時脈領域與第二處理模組所在的第二時脈領域同步。 For example, step S603 may include: determining the deviation between the first count value and the second count value; and compensating the second timer according to the deviation so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located.
如前所述,根據時脈源的類型不同,時脈補償的具體操作略有不同。 As mentioned above, the specific operation of clock compensation is slightly different depending on the type of clock source.
例如,回應於第二時脈源能夠利用電壓對振盪頻率進行調整,根據偏差,對第二計時器進行補償,以使得第一處理模組所在的第一時脈領域與第二處理模組所在的第二時脈領域同步,可以包括:根據偏差,對第二計時器進行補償;根據偏差,確定調整電壓;根據調整電壓,對第二時脈源進行補償,以使得第一處理模組所在的第一時脈領域與第二處理模組所在的第二時脈領域同步。 For example, in response to the second clock source being able to use voltage to adjust the oscillation frequency, compensating the second timer according to the deviation so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located, may include: compensating the second timer according to the deviation; determining the adjustment voltage according to the deviation; compensating the second clock source according to the adjustment voltage so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located.
例如,根據調整電壓,對第二時脈源進行補償,以使得第一處理模組所在的第一時脈領域與第二處理模組所在的第二時脈領域同步,可以包括:將調整電壓輸入第二時脈源的電壓控制管腳,以使得第二時脈源的振盪頻率向第一時脈源的振盪頻率方向收斂,並使得第一時脈源和第二時脈源同步。 For example, compensating the second clock source according to the adjustment voltage so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located may include: inputting the adjustment voltage into the voltage control pin of the second clock source so that the oscillation frequency of the second clock source converges toward the oscillation frequency of the first clock source, and synchronizing the first clock source with the second clock source.
例如,偏差可以為第一計數值和第二計數值的差值。 For example, the deviation can be the difference between the first count value and the second count value.
例如,根據偏差,對第二計時器進行補償的具體過程可以參考前述步驟S302以及步驟S402中的“根據偏差,對第一計時器進行補償”的具體過程,這裡不再贅述。 For example, the specific process of compensating the second timer according to the deviation can refer to the specific process of "compensating the first timer according to the deviation" in the aforementioned step S302 and step S402, which will not be elaborated here.
例如,調整電壓的確定過程,以及利用調整電壓調整第二時脈源的具體過程也可以參考前述利用調整電壓調整第一時脈源的相關說明,這裡不再贅述。 For example, the process of determining the adjustment voltage and the specific process of adjusting the second clock source using the adjustment voltage can also refer to the aforementioned description of adjusting the first clock source using the adjustment voltage, which will not be elaborated here.
由此,通過偏差對第二計時器進行補償,根據偏差計算得到調整電壓,通過向第二時脈源的電壓控制管腳輸入調整電壓,使得第二時脈源的振盪頻率向第一時脈源的振盪頻率方向收斂,類似的,由於收斂可以達到ppb級別準確度,維護及時脈補償的週期也可以放鬆到比較久才做一次,例如間隔1秒執行一次時脈同步。這種方式對系統性能影響較小,不需要頻繁產生中斷影響系統性能,也不需要頻繁產生觸發訊號在第一處理模組和第二處理模組之間通訊,不會佔用晶片上網路或網路線的通訊資源。此外,消除了同步失敗情況,大幅減少了時脈同步階段,第一處理模組和第二處理模組之間的通訊次數大大減少,降低了由於網路線或晶片上網路的時脈抖動、延遲等帶來的影響,時脈同步準確度得到了提升。 Thus, the second timer is compensated by the deviation, and an adjustment voltage is calculated according to the deviation. By inputting the adjustment voltage into the voltage control pin of the second clock source, the oscillation frequency of the second clock source converges toward the oscillation frequency of the first clock source. Similarly, since the convergence can achieve ppb level accuracy, the maintenance and clock compensation cycle can also be relaxed to a longer period, for example, performing clock synchronization once every 1 second. This method has a small impact on system performance. It does not need to frequently generate interruptions to affect system performance, nor does it need to frequently generate trigger signals for communication between the first processing module and the second processing module. It will not occupy the communication resources of the network or network cable on the chip. In addition, it eliminates synchronization failures, greatly reduces the clock synchronization stage, and greatly reduces the number of communications between the first processing module and the second processing module. It reduces the impact of clock jitter and delay caused by the network cable or the network on the chip, and improves the accuracy of clock synchronization.
例如,對於不能通過電壓控制時脈源的振盪頻率的晶振,其時脈補償的具體執行過程與前述相同場景下,第一處理模組執行時脈補償的過程相似,這裡不再贅述。 For example, for a crystal oscillator whose oscillation frequency of the clock source cannot be controlled by voltage, the specific execution process of its clock compensation is similar to the process of the first processing module executing clock compensation in the same scenario mentioned above, and will not be elaborated here.
例如,本發明至少一實施例還提供一種系統時脈同步方法。 For example, at least one embodiment of the present invention also provides a system clock synchronization method.
例如,該系統可以包括第一處理模組和第二處理模組,第一處理模組包括第一計時器,第一計時器的計數值作為第一處理模組的定時基準且順序遞增,第二處理模組包括第二計時器,第二計時器的計數值作為第二處理模組的定時基準且順序遞增,第一處理模組和第二處理模組屬於不同的時脈領域。 For example, the system may include a first processing module and a second processing module, the first processing module includes a first timer, the count value of the first timer serves as a timing reference of the first processing module and increases sequentially, the second processing module includes a second timer, the count value of the second timer serves as a timing reference of the second processing module and increases sequentially, and the first processing module and the second processing module belong to different clock domains.
例如,系統可以是如圖1所示的CPU,第一處理模組和第二處理模組可以是圖1中的任意兩個CPU Die或CPU Socket。當然,本發明對此不作具體限制,也可以是其它需要執行時脈同步的處理模組。 For example, the system can be a CPU as shown in FIG1, and the first processing module and the second processing module can be any two CPU Dies or CPU Sockets in FIG1. Of course, the present invention does not impose specific restrictions on this, and it can also be other processing modules that need to execute clock synchronization.
例如,第一計時器可以是第一處理模組的系統計時器,第二計時器可以是第二處理模組的系統計時器。關於第一計時器和第二計時器的相關描述可以參考前文內容,這裡不再贅述。 For example, the first timer may be a system timer of the first processing module, and the second timer may be a system timer of the second processing module. For the description of the first timer and the second timer, please refer to the previous content, which will not be repeated here.
例如,第一處理模組和第二處理模組屬於非同步時脈領域,其形成原因如前文所述,這裡不再贅述。 For example, the first processing module and the second processing module belong to the field of asynchronous clocks. The reasons for this are as described above and will not be elaborated here.
例如,在一些實施例中,系統時脈同步方法可以包括:第一處理模組向第二處理模組發送觸發訊號,第一處理模組記錄在發送觸發訊號時第一計時器當前的計數值作為第一計數值,第二處理模組記錄在接收到觸發訊號時第二計時器當前的計數值作為第二計數值。這裡,第一計數值和第二計數值用於時脈補償,以使得第一處理模組所在的第一時脈領域與第二處理模組所在的第二時脈領域同步。 For example, in some embodiments, the system clock synchronization method may include: the first processing module sends a trigger signal to the second processing module, the first processing module records the current count value of the first timer when sending the trigger signal as the first count value, and the second processing module records the current count value of the second timer when receiving the trigger signal as the second count value. Here, the first count value and the second count value are used for clock compensation, so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located.
例如,關於第一計數值和第二計數值用於時脈補償的具體過程可以參考前述應用於第一處理模組的時脈同步方法和應用於第二處理模組的時脈同步方法的相關描述。 For example, the specific process of using the first count value and the second count value for clock compensation can refer to the related description of the clock synchronization method applied to the first processing module and the clock synchronization method applied to the second processing module.
例如,針對時脈源同源,但第一處理模組和第二處理模組具有各自的鎖相迴路的情況,根據第一計數值和第二計數值的偏差,對第一計時器進行補償,以使得第一時脈領域和第二時脈領域 同步。例如,此時時脈同步的具體過程可以參考前述應用於第一處理模組的時脈同步方法和應用於第二處理模組的時脈同步方法的相關描述,這裡不再贅述。 For example, in the case where the clock sources are the same but the first processing module and the second processing module have their own phase-locked loops, the first timer is compensated according to the deviation between the first count value and the second count value, so that the first clock domain and the second clock domain are synchronized. For example, the specific process of this clock synchronization can refer to the related description of the clock synchronization method applied to the first processing module and the clock synchronization method applied to the second processing module, which will not be repeated here.
圖8A為本發明至少一實施例提供的系統時脈同步方法的交互過程示意圖。下面結合圖8A,說明在第一時脈源和第二時脈源為非同源時脈源的情況下,系統時脈同步方法的執行過程。 FIG8A is a schematic diagram of the interactive process of the system clock synchronization method provided by at least one embodiment of the present invention. The following is combined with FIG8A to explain the execution process of the system clock synchronization method when the first clock source and the second clock source are non-co-origin clock sources.
如圖8A所示,在T0時刻,第一處理模組向第二處理模組發起“assert trigger”,此時,第一處理模組在發送觸發訊號時記錄第一計時器當前的計數值作為第一計數值並儲存在第一暫存器中,例如,第一暫存器位於第一處理模組且可以靜態儲存數值;同時,第二處理模組在接收到觸發訊號時(T0’時刻)記錄第二計時器當前的計數值作為第二計數值並儲存在第二暫存器中,例如,第二暫存器位於第二處理模組且可以靜態儲存數值。並且,觸發訊號還同時觸發了第一處理模組和第二處理模組的中斷。 As shown in FIG8A, at time T0, the first processing module sends an "assert trigger" to the second processing module. At this time, the first processing module records the current count value of the first timer as the first count value and stores it in the first register when sending the trigger signal. For example, the first register is located in the first processing module and can statically store values. At the same time, the second processing module records the current count value of the second timer as the second count value and stores it in the second register when receiving the trigger signal (T0'). For example, the second register is located in the second processing module and can statically store values. In addition, the trigger signal also triggers the interruption of the first processing module and the second processing module at the same time.
之後,在T1時刻,第一處理模組讀取第二處理模組中的第二暫存器的值,得到第二計數值,在T1’時刻,第二處理模組讀取第一處理模組中的第一暫存器的值,得到第一計數值,這裡,T1可以和T1’相等,也可以不等。 Afterwards, at time T1, the first processing module reads the value of the second register in the second processing module to obtain the second count value. At time T1', the second processing module reads the value of the first register in the first processing module to obtain the first count value. Here, T1 can be equal to T1' or different.
之後,第一處理模組和第二處理模組比較自身記錄的計數值和讀取的計數值的大小關係,若自身記錄的計數值小於讀取的計數值,則執行時脈補償,否則不執行時脈補償。 Afterwards, the first processing module and the second processing module compare the magnitude of the count value recorded by themselves and the count value read. If the count value recorded by themselves is less than the count value read, clock compensation is performed, otherwise clock compensation is not performed.
例如,對於第一處理模組,在得到第二計數值後,在步驟 S401,比較第一計數值和第二計數值,若第一計數值小於第二計數值,參考步驟S402進行時脈補償,具體過程可以參考步驟S402的相關內容,這裡不再贅述。 For example, for the first processing module, after obtaining the second count value, in step S401, the first count value and the second count value are compared. If the first count value is less than the second count value, refer to step S402 for clock compensation. The specific process can refer to the relevant content of step S402, which will not be repeated here.
例如,對於第二處理模組,在得到第一計數值後,在步驟S602,比較第一計數值和第二計數值,若第二計數值小於第一計數值,參考步驟S603進行時脈補償,具體過程可以參考步驟S603的相關內容,這裡不再贅述。 For example, for the second processing module, after obtaining the first count value, in step S602, the first count value and the second count value are compared. If the second count value is less than the first count value, refer to step S603 to perform clock compensation. The specific process can refer to the relevant content of step S603, which will not be repeated here.
由此,在時脈同步過程中時脈始終保持單調遞增。 Therefore, the clock always keeps monotonically increasing during the clock synchronization process.
之後,在Tn時刻,第一處理模組再次向第二處理模組發起“assert trigger”,第一處理模組在發送觸發訊號時(Tn時刻)記錄第一計時器當前的計數值作為第一計數值並儲存在第一暫存器中,第二處理模組在接收到觸發訊號(Tn’時刻)時記錄第二計時器當前的計數值作為第二計數值並儲存在第二暫存器中。並且,觸發訊號還同時觸發了第一處理模組和第二處理模組的中斷。 Afterwards, at time Tn, the first processing module again sends an "assert trigger" to the second processing module. When the first processing module sends the trigger signal (at time Tn), it records the current count value of the first timer as the first count value and stores it in the first register. When the second processing module receives the trigger signal (at time Tn'), it records the current count value of the second timer as the second count value and stores it in the second register. In addition, the trigger signal also triggers the interruption of the first processing module and the second processing module at the same time.
之後,在Tn+1時刻,第一處理模組讀取第二處理模組中的第二暫存器的值,得到第二計數值,在Tn+1’時刻,第二處理模組讀取第一處理模組中的第一暫存器的值,得到第一計數值,之後第一處理模組和第二處理模組比較自身記錄的計數值和讀取的計數值的大小關係,若自身記錄的計數值小於讀取的計數值,則執行時脈補償,否則不執行時脈補償,具體過程與T0時刻相似,這裡不再贅述。 Afterwards, at time Tn+1, the first processing module reads the value of the second register in the second processing module to obtain the second count value. At time Tn+1’, the second processing module reads the value of the first register in the first processing module to obtain the first count value. Afterwards, the first processing module and the second processing module compare the count value recorded by themselves and the count value read. If the count value recorded by themselves is less than the count value read, clock compensation is performed, otherwise, clock compensation is not performed. The specific process is similar to that at time T0, and will not be repeated here.
例如,Tn時刻和T0時刻的差異可以根據時脈源類型、 第一時脈源和第二時脈源之間的時脈頻率偏差確定。 For example, the difference between the Tn moment and the T0 moment can be determined based on the type of clock source, the clock frequency deviation between the first clock source and the second clock source.
在上述實施例中,由於時脈源非同源,所以第一處理模組和第二處理模組之間存在相位差和時脈頻率偏差,且相位差和時脈頻率偏差可能跟隨時間推移發生漂移,因此需要定期執行時脈同步,包括通過同一個觸發訊號獲取第一計數值和第二計數值,根據第一計數值和第二計數值進行時脈補償。該實現方式簡單有效,消除了同步失敗情況,大幅減少了時脈同步階段,第一處理模組和第二處理模組之間的通訊次數大大減少,減少了用於時脈同步的通訊連接埠數量,降低了由於網路線或晶片上網路的時脈抖動、延遲等帶來的影響,時脈同步準確度得到了提升。 In the above embodiment, since the clock sources are not the same, there is a phase difference and a clock frequency deviation between the first processing module and the second processing module, and the phase difference and the clock frequency deviation may drift over time. Therefore, it is necessary to perform clock synchronization regularly, including obtaining the first count value and the second count value through the same trigger signal, and performing clock compensation according to the first count value and the second count value. This implementation method is simple and effective, eliminating synchronization failures, greatly reducing the clock synchronization stage, greatly reducing the number of communications between the first processing module and the second processing module, reducing the number of communication ports used for clock synchronization, reducing the impact of clock jitter and delay caused by network cables or on-chip networks, and improving clock synchronization accuracy.
例如,觸發訊號由第一處理模組發送至第二處理模組的過程中,需要通過模組之間的通訊匯流排傳輸,例如通過PCB(Printed Circuit Board,印製電路板)或基板(substrate)來傳輸。電訊號在PCB/基板中傳送速率與材質的介電常數有關,如電訊號在玻璃布基板(FR)的傳送速率約為光速的一半,在Rogers(羅傑斯)板材傳送速率約為光速的70%,按照傳輸距離30cm來算由於Die之間通訊造成的偏差在ns級,該時間差異(例如T0和T0’的差異)較小,對於時脈補償來說可以忽略不計。 For example, when the trigger signal is sent from the first processing module to the second processing module, it needs to be transmitted through the communication bus between the modules, such as through a PCB (Printed Circuit Board) or substrate. The transmission rate of electrical signals in PCB/substrate is related to the dielectric constant of the material. For example, the transmission rate of electrical signals in glass cloth substrate (FR) is about half the speed of light, and the transmission rate in Rogers board is about 70% of the speed of light. Based on the transmission distance of 30cm, the deviation caused by communication between dies is at the ns level. The time difference (such as the difference between T0 and T0') is small and can be ignored for clock compensation.
例如,在一些示例中,也可以對觸發訊號在處理模組之間傳遞造成的延遲進行補償,也即補償T0和T0’之間的差異。 For example, in some examples, it is also possible to compensate for the delay caused by the trigger signal being transmitted between processing modules, that is, to compensate for the difference between T0 and T0'.
圖8B為本發明至少一實施例提供的補償處理模組之間傳輸延遲的示意性方塊圖。 FIG8B is a schematic block diagram of the transmission delay between compensation processing modules provided by at least one embodiment of the present invention.
如圖8B所示,在第一處理模組的基板或PCB上,為觸發訊號建立回授通路,例如觸發訊號從第一計時器通過晶片上網路或互聯匯流排發送至第二計時器時,該觸發訊號通過回授通路傳遞回第一計時器,根據觸發訊號經回授通路傳遞回第一計時器的回授訊號的時間進行時脈補償。 As shown in FIG8B , a feedback path is established for the trigger signal on the substrate or PCB of the first processing module. For example, when the trigger signal is sent from the first timer to the second timer through the on-chip network or the interconnect bus, the trigger signal is transmitted back to the first timer through the feedback path, and clock compensation is performed according to the time when the trigger signal is transmitted back to the first timer through the feedback path.
具體來說,記錄第一計時器接收到回授通路傳遞的回授訊號時第一計時器當前的計數值作為第一計數值,記錄第二計時器接收到觸發訊號時的值作為第二計數值,由此補償處理模組之間傳輸延遲。 Specifically, the current count value of the first timer when the first timer receives the feedback signal transmitted by the feedback path is recorded as the first count value, and the value of the second timer when it receives the trigger signal is recorded as the second count value, thereby compensating for the transmission delay between the processing modules.
本發明至少一實施例還提供一種時脈同步裝置,圖9A為本發明至少一實施例提供的一種時脈同步裝置的示意性方塊圖。 At least one embodiment of the present invention also provides a clock synchronization device. FIG. 9A is a schematic block diagram of a clock synchronization device provided by at least one embodiment of the present invention.
例如,該時脈同步裝置用於第一處理模組。例如,第一處理模組包括第一計時器,第一計時器的計數值作為所述第一處理模組的定時基準且順序遞增。 For example, the clock synchronization device is used for the first processing module. For example, the first processing module includes a first timer, and the count value of the first timer serves as the timing reference of the first processing module and increases sequentially.
關於第一處理模組、第一計時器等說明可以參考前述應用於第一處理模組的時脈同步方法的相關介紹,這裡不再贅述。 For the description of the first processing module, the first timer, etc., please refer to the related introduction of the clock synchronization method applied to the first processing module, which will not be elaborated here.
如圖9A示,時脈同步裝置100可以包括第一記錄單元101、讀取單元102。這些元件通過匯流排系統和/或其它形式的連接機構(未示出)互連。應當注意,圖9A所示的時脈同步裝置100的元件和結構只是示例性的,而非限制性的,根據需要,時脈同步裝置100也可以具有其他元件和結構。
As shown in FIG9A , the clock synchronization device 100 may include a
第一記錄單元101,配置為向第二處理模組發送觸發訊號,
同時記錄發送觸發訊號時第一計時器當前的計數值作為第一計數值。
The
例如,第二處理模組與第一處理模組屬於不同的時脈領域。 For example, the second processing module and the first processing module belong to different clock domains.
讀取單元102,配置為從第二處理模組讀取第二計數值。
The
例如,第二計數值為第二處理模組在接收到觸發訊號時,第二處理模組的第二計時器當前的計數值,第二計時器的計數值作為第二處理模組的定時基準且順序遞增。 For example, the second count value is the current count value of the second timer of the second processing module when the second processing module receives the trigger signal. The count value of the second timer serves as the timing reference of the second processing module and increases sequentially.
例如,第一計數值和第二計數值用於時脈補償,以使得第一處理模組所在的第一時脈領域與第二處理模組所在的第二時脈領域同步。 For example, the first count value and the second count value are used for clock compensation so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located.
例如,如圖9A所示,時脈同步裝置還包括第一時脈補償單元103。
For example, as shown in FIG9A , the clock synchronization device further includes a first
例如,在一些實施例中,第一處理模組包括第一鎖相迴路,第一鎖相迴路配置為接收第一時脈源提供的第一時脈訊號,並根據第一時脈訊號為第一處理模組提供第一參考時脈訊號,第二處理模組包括第二鎖相迴路,第二鎖相迴路配置為接收第一時脈源提供的第一時脈訊號,並根據第一時脈訊號為第二處理模組提供第二參考時脈訊號,第一鎖相迴路與第二鎖相迴路不同,時脈補償在第一處理模組處於通電階段時執行。 For example, in some embodiments, the first processing module includes a first phase-locked loop, the first phase-locked loop is configured to receive a first clock signal provided by a first clock source, and provide a first reference clock signal to the first processing module according to the first clock signal, the second processing module includes a second phase-locked loop, the second phase-locked loop is configured to receive a first clock signal provided by a first clock source, and provide a second reference clock signal to the second processing module according to the first clock signal, the first phase-locked loop is different from the second phase-locked loop, and the clock compensation is performed when the first processing module is in the power-on stage.
例如,在上述實施例中,第一時脈補償單元103配置為執行以下操作:確定第一計數值和第二計數值的偏差;根據偏差,
對第一計時器進行補償,以使得第一處理模組所在的第一時脈領域與第二處理模組所在的第二時脈領域同步。
For example, in the above embodiment, the first
例如,第一時脈補償單元103執行根據所述偏差,對所述第一計時器進行補償,以使得所述第一處理模組所在的所述第一時脈領域與所述第二處理模組所在的所述第二時脈領域同步時,包括執行以下操作:獲取所述第一計時器當前的計數值作為第三計數值;將所述偏差與所述第三計數值進行加和處理,得到更新計數值;將所述第一計時器的計數值更新為所述更新計數值,以使得所述第一處理模組所在的所述第一時脈領域與所述第二處理模組所在的所述第二時脈領域同步。
For example, when the first
例如,觸發訊號還配置為同時觸發所述第一處理模組的中斷,以執行所述時脈補償。 For example, the trigger signal is also configured to simultaneously trigger an interruption of the first processing module to execute the clock compensation.
例如,在另一些實施例中,第一處理模組由第一時脈源提供參考時脈訊號,第二處理模組由第二時脈源提供參考時脈訊號,第一時脈源與第二時脈源為非同源時脈源,時脈同步在第一處理模組處於工作狀態時定期執行,在時脈同步的整個過程中,第一計時器和第二計時器的計數值始終保持單調遞增。 For example, in other embodiments, the first processing module is provided with a reference clock signal by a first clock source, and the second processing module is provided with a reference clock signal by a second clock source. The first clock source and the second clock source are non-cognate clock sources. The clock synchronization is performed periodically when the first processing module is in a working state. During the entire process of clock synchronization, the count values of the first timer and the second timer always keep monotonically increasing.
在上述實施例中,第一時脈補償單元103配置為執行以下操作:比較第一計數值和第二計數值的大小關係;回應於第一計數值小於第二計數值,根據第一計數值和第二計數值的偏差進行時脈補償,以使得第一處理模組所在的第一時脈領域與第二處理模組所在的第二時脈領域同步。
In the above embodiment, the first
例如,在上述實施例中,第一時脈補償單元103執行根據所述第一計數值和所述第二計數值的偏差進行時脈補償,以使得所述第一處理模組所在的所述第一時脈領域與所述第二處理模組所在的所述第二時脈領域同步時,包括執行以下操作:確定所述第一計數值和所述第二計數值的偏差;根據所述偏差,對所述第一計時器進行補償,以使得所述第一處理模組所在的所述第一時脈領域與第二處理模組所在的所述第二時脈領域同步。
For example, in the above embodiment, when the first
例如,在上述實施例中,第一時脈補償單元103執行回應於所述第一時脈源能夠利用電壓對振盪頻率進行調整,根據所述偏差,對所述第一計時器進行補償,以使得所述第一處理模組所在的第一時脈領域與第二處理模組所在的第二時脈領域同步,包括執行以下操作:根據所述偏差,對所述第一計時器進行補償;根據所述偏差,確定調整電壓;根據所述調整電壓,對所述第一時脈源進行補償,以使得所述第一處理模組所在的所述第一時脈領域與所述第二處理模組所在的第二時脈領域同步。
For example, in the above embodiment, the first
例如,在一些示例中,第一時脈補償單元103執行根據所述偏差,確定調整電壓時,包括執行以下操作:根據所述偏差,計算所述第一時脈源相對於所述第二時脈源的單位時間頻率偏差;根據所述單位時間頻率偏差,確定所述調整電壓。
For example, in some examples, when the first
例如,在另一些示例中,第一時脈補償單元103執行根據所述偏差,確定調整電壓時,包括執行以下操作:獲取歷史頻率偏差,其中,所述歷史頻率偏差為最近一次用於計算調整電壓的單
位時間頻率偏差;計算所述歷史頻率偏差和基於所述偏差計算的單位時間頻率偏差的加權和;根據所述加權和的計算結果確定所述調整電壓。
For example, in other examples, when the first
例如,第一時脈補償單元103執行根據所述調整電壓,對所述第一時脈源進行補償,以使得所述第一處理模組所在的所述第一時脈領域與所述第二處理模組所在的第二時脈領域同步時,包括執行以下操作:將所述調整電壓輸入所述第一時脈源的電壓控制管腳,以使得所述第一時脈源的振盪頻率向所述第二時脈源的振盪頻率方向收斂,並使得所述第一時脈源和所述第二時脈源同步。
For example, when the first
例如,在上述實施例中,所述觸發訊號還配置為同時觸發所述第一處理模組和所述第二處理模組的中斷,以執行所述時脈補償。 For example, in the above embodiment, the trigger signal is also configured to simultaneously trigger the interruption of the first processing module and the second processing module to perform the clock compensation.
例如,所述第一計數值儲存在所述第一處理模組的暫存器中,所述第二計數值儲存在所述第二處理模組的暫存器中。關於第一記錄單元101、讀取單元102和第一時脈補償單元103的具體說明可以參考上述應用於第一處理模組的時脈同步方法的相關步驟描述,這裡不再贅述。
For example, the first count value is stored in the register of the first processing module, and the second count value is stored in the register of the second processing module. The specific description of the
例如,時脈同步裝置100可以實現與前述應用於第一處理模組的時脈同步方法相似的技術效果,在此不再贅述。 For example, the clock synchronization device 100 can achieve technical effects similar to the clock synchronization method applied to the first processing module mentioned above, which will not be elaborated here.
本發明至少一實施例還提供另一種時脈同步裝置,圖9B為本發明至少一實施例提供的另一種時脈同步裝置的示意性方塊 圖。 At least one embodiment of the present invention also provides another clock synchronization device. FIG. 9B is a schematic block diagram of another clock synchronization device provided by at least one embodiment of the present invention.
例如,該時脈同步裝置用於第二處理模組。例如,第二處理模組包括第二計時器,第二計時器的計數值作為第二處理模組的定時基準且順序遞增。 For example, the clock synchronization device is used for the second processing module. For example, the second processing module includes a second timer, and the count value of the second timer serves as the timing reference of the second processing module and increases sequentially.
關於第二處理模組、第二計時器等說明可以參考前述應用於第二處理模組的時脈同步方法的相關介紹,這裡不再贅述。 For the description of the second processing module, the second timer, etc., please refer to the related introduction of the clock synchronization method applied to the second processing module, which will not be elaborated here.
如圖9B示,時脈同步裝置200可以包括第二記錄單元201。這些元件通過匯流排系統和/或其它形式的連接機構(未示出)互連。應當注意,圖9B所示的時脈同步裝置200的元件和結構只是示例性的,而非限制性的,根據需要,時脈同步裝置200也可以具有其他元件和結構。
As shown in FIG9B , the clock synchronization device 200 may include a
例如,第二記錄單元201,配置為回應於接收到第一處理模組發送的觸發訊號,記錄第二計時器當前的計數值作為第二計數值,其中,第二處理模組與第一處理模組屬於不同的時脈領域。
For example, the
例如,第二計數值用於結合第一計數值進行時脈補償,以使得第一處理模組所在的第一時脈領域與第二處理模組所在的第二時脈領域同步,第一計數值為第一處理模組向第二處理模組發送觸發訊號時,第一處理模組的第一計時器當前的計數值,第一計時器的計數值用於作為第一處理模組的定時基準且順序遞增。 For example, the second count value is used to combine with the first count value for clock compensation, so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located. The first count value is the current count value of the first timer of the first processing module when the first processing module sends a trigger signal to the second processing module. The count value of the first timer is used as the timing reference of the first processing module and increases sequentially.
如圖9B所示,時脈同步裝置200還可以包括第二時脈補償單元202。
As shown in FIG9B , the clock synchronization device 200 may further include a second
例如,在一些實施例中,第一處理模組由第一時脈源提供 參考時脈訊號,第二處理模組由第二時脈源提供參考時脈訊號,第一時脈源與第二時脈源為非同源時脈源,時脈同步在第一處理模組處於工作狀態時定期執行,在時脈同步的整個過程中,第一計時器和第二計時器的計數值始終保持單調遞增。 For example, in some embodiments, the first processing module is provided with a reference clock signal by a first clock source, and the second processing module is provided with a reference clock signal by a second clock source. The first clock source and the second clock source are non-cognate clock sources. The clock synchronization is performed periodically when the first processing module is in a working state. During the entire process of clock synchronization, the count values of the first timer and the second timer always keep monotonically increasing.
在上述實施例中,第二時脈補償單元202配置為執行以下操作:從第一處理模組讀取第一計數值;比較第一計數值和第二計數值的大小關係;回應於第二計數值小於第一計數值,根據第一計數值和第二計數值的偏差進行時脈補償,以使得第一處理模組所在的第一時脈領域與第二處理模組所在的第二時脈領域同步。
In the above embodiment, the second
例如,第二時脈補償單元202執行根據所述第一計數值和所述第二計數值的偏差進行所述時脈補償,以使得所述第一處理模組所在的所述第一時脈領域與所述第二處理模組所在的所述第二時脈領域同步時,包括執行以下操作:確定所述第一計數值和所述第二計數值的偏差;根據所述偏差,對所述第二計時器進行補償,以使得所述第一處理模組所在的所述第一時脈領域與所述第二處理模組所在的所述第二時脈領域同步。
For example, when the second
例如,回應於所述第二時脈源能夠利用電壓對振盪頻率進行調整,第二時脈補償單元202執行根據所述偏差,對所述第二計時器進行補償,以使得所述第一處理模組所在的所述第一時脈領域與所述第二處理模組所在的所述第二時脈領域同步時,包括執行以下操作:根據所述偏差,對所述第二計時器進行補償;根據所述偏差,確定調整電壓;根據所述調整電壓,對所述第二時脈
源進行補償,以使得所述第一處理模組所在的所述第一時脈領域與所述第二處理模組所在的所述第二時脈領域同步。
For example, in response to the second clock source being able to adjust the oscillation frequency using voltage, the second
例如,第二時脈補償單元202執行根據所述調整電壓,對所述第二時脈源進行補償,以使得所述第一處理模組所在的所述第一時脈領域與所述第二處理模組所在的所述第二時脈領域同步時,包括執行以下操作:將所述調整電壓輸入所述第二時脈源的電壓控制管腳,以使得所述第二時脈源的振盪頻率向所述第一時脈源的振盪頻率方向收斂,並使得所述第一時脈源和所述第二時脈源同步。
For example, when the second
關於第二記錄單元201和第二時脈補償單元202的具體說明可以參考上述應用於第二處理模組的時脈同步方法的相關步驟描述,這裡不再贅述。
For the specific description of the
例如,時脈同步裝置200可以實現與前述應用於第二處理模組的時脈同步方法相似的技術效果,在此不再贅述。 For example, the clock synchronization device 200 can achieve technical effects similar to the clock synchronization method applied to the second processing module mentioned above, which will not be elaborated here.
本發明至少一實施例還提供一種電子設備,圖9C為本發明至少一實施例提供的一種電子設備的示意性結構圖。 At least one embodiment of the present invention also provides an electronic device, and FIG. 9C is a schematic structural diagram of an electronic device provided by at least one embodiment of the present invention.
如圖9C所示,電子設備300包括第一處理模組310和第二處理模組320。
As shown in FIG. 9C , the electronic device 300 includes a
例如,第一處理模組包括第一計時器,第一計時器的計數值作為第一處理模組的定時基準且順序遞增,第二處理模組包括第二計時器,第二計時器的計數值作為第二處理模組的定時基準且順序遞增,第一處理模組和第二處理模組屬於不同的時脈領域。 For example, the first processing module includes a first timer, the count value of the first timer serves as the timing reference of the first processing module and increases sequentially, the second processing module includes a second timer, the count value of the second timer serves as the timing reference of the second processing module and increases sequentially, and the first processing module and the second processing module belong to different clock domains.
例如,第一處理模組配置為向第二處理模組發送觸發訊號,以及記錄在發送觸發訊號時第一計時器當前的計數值作為第一計數值。 For example, the first processing module is configured to send a trigger signal to the second processing module, and record the current count value of the first timer when the trigger signal is sent as the first count value.
例如,第二處理模組配置為記錄在接收到觸發訊號時第二計時器當前的計數值作為第二計數值。 For example, the second processing module is configured to record the current count value of the second timer when the trigger signal is received as the second count value.
例如,第一計數值和第二計數值用於時脈補償,以使得第一處理模組所在的第一時脈領域與第二處理模組所在的第二時脈領域同步。 For example, the first count value and the second count value are used for clock compensation so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located.
例如,電子設備可以為CPU等處理設備,第一處理模組和第二處理模組可以為CPU Die或CPU Socket。當然,本發明不限於此。需要說明的是,圖9C所示的電子設備300的元件和結構只是示例性的,而非限制性的,根據需要,電子設備300也可以具有其他元件和結構。 For example, the electronic device may be a processing device such as a CPU, and the first processing module and the second processing module may be a CPU Die or a CPU Socket. Of course, the present invention is not limited thereto. It should be noted that the components and structures of the electronic device 300 shown in FIG. 9C are only exemplary and not restrictive. The electronic device 300 may also have other components and structures as needed.
例如,關於第一處理模組和第二處理模組執行時脈同步的具體過程可以參考前述系統時脈同步方法的相關說明,這裡不再贅述。 For example, the specific process of executing clock synchronization between the first processing module and the second processing module can refer to the relevant description of the aforementioned system clock synchronization method, which will not be elaborated here.
例如,電子設備300可以實現與前述系統時脈同步方法相似的技術效果,在此不再贅述。 For example, the electronic device 300 can achieve a technical effect similar to the aforementioned system clock synchronization method, which will not be elaborated here.
本發明一些實施例還提供一種電子設備。圖10為本發明至少一實施例提供的一種電子設備的示意性方塊圖。 Some embodiments of the present invention also provide an electronic device. Figure 10 is a schematic block diagram of an electronic device provided by at least one embodiment of the present invention.
例如,如圖10所示,電子設備400包括處理器410和記憶體420。應當注意,圖10所示的電子設備400的元件只是示例 性的,而非限制性的,根據實際應用需要,該電子設備400還可以具有其他元件。 For example, as shown in FIG. 10 , the electronic device 400 includes a processor 410 and a memory 420. It should be noted that the components of the electronic device 400 shown in FIG. 10 are only exemplary and not restrictive. The electronic device 400 may also have other components according to actual application requirements.
例如,處理器410和記憶體420之間可以直接或間接地互相通訊。 For example, the processor 410 and the memory 420 may communicate with each other directly or indirectly.
例如,處理器410和記憶體420可以通過網路進行通訊。網路可以包括無線網路、有線網路、和/或無線網路和有線網路的任意組合。處理器410和記憶體420之間也可以通過系統匯流排實現相互通訊,本發明對此不作限制。 For example, the processor 410 and the memory 420 can communicate through a network. The network may include a wireless network, a wired network, and/or any combination of a wireless network and a wired network. The processor 410 and the memory 420 can also communicate with each other through a system bus, which is not limited by the present invention.
例如,在一些實施例中,記憶體420用於非暫態性地儲存電腦可讀指令。處理器410用於運行電腦可讀指令時,電腦可讀指令被處理器410運行時實現根據上述任一實施例所述的時脈同步方法或根據上述任一實施例所述的系統時脈同步方法。關於該時脈同步方法的各個步驟的具體實現以及相關解釋內容可以參見上述時脈同步方法的實施例,關於該系統時脈同步方法的各個步驟的具體實現以及相關解釋內容可以參見上述系統時脈同步方法的實施例,重複之處在此不作贅述。 For example, in some embodiments, the memory 420 is used to store computer-readable instructions non-transitorily. When the processor 410 is used to execute the computer-readable instructions, the computer-readable instructions are executed by the processor 410 to implement the clock synchronization method described in any of the above embodiments or the system clock synchronization method described in any of the above embodiments. For the specific implementation of each step of the clock synchronization method and the related explanation content, please refer to the above embodiment of the clock synchronization method. For the specific implementation of each step of the system clock synchronization method and the related explanation content, please refer to the above embodiment of the system clock synchronization method. The repetition will not be repeated here.
例如,處理器410可以控制電子設備400中的其它元件以執行期望的功能。處理器410可以是中央處理器(CPU)、圖形處理器(Graphics Processing Unit,GPU)、網路處理器(NP)等;還可以是數位訊號處理器(DSP)、專用積體電路(ASIC)、現場可程式設計閘陣列(FPGA)或者其他可程式設計邏輯器件、分立門或者電晶體邏輯器件、分立硬體元件。中央處理元(CPU)可以為 X86或ARM架構等。 For example, the processor 410 can control other components in the electronic device 400 to perform the desired functions. The processor 410 can be a central processing unit (CPU), a graphics processing unit (GPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The central processing unit (CPU) can be X86 or ARM architecture, etc.
例如,記憶體420可以包括一個或多個電腦程式產品的任意組合,電腦程式產品可以包括各種形式的電腦可讀儲存介質,例如易失性記憶體和/或非易失性記憶體。易失性記憶體例如可以包括隨機存取記憶體(RAM)和/或高速緩衝記憶體(cache)等。非易失性記憶體例如可以包括唯讀記憶體(ROM)、硬碟、可擦除可程式設計唯讀記憶體(EPROM)、可擕式緊致盤唯讀記憶體(CD-ROM)、USB記憶體、快閃記憶體等。在所述電腦可讀儲存介質上可以儲存一個或多個電腦可讀指令,處理器410可以運行所述電腦可讀指令,以實現電子設備400的各種功能。在儲存介質中還可以儲存各種應用程式和各種資料等。 For example, the memory 420 may include any combination of one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and/or non-volatile memory. Volatile memory may include, for example, random access memory (RAM) and/or cache memory, etc. Non-volatile memory may include, for example, read-only memory (ROM), hard disk, erasable programmable read-only memory (EPROM), portable compact disk read-only memory (CD-ROM), USB memory, flash memory, etc. One or more computer-readable instructions can be stored on the computer-readable storage medium, and the processor 410 can run the computer-readable instructions to implement various functions of the electronic device 400. Various applications and various data can also be stored in the storage medium.
例如,在一些實施例中,電子設備400可以為手機、平板電腦、電子紙、電視機、顯示器、筆記型電腦、數碼相框、導航儀、可穿戴電子設備、智慧家居設備等。 For example, in some embodiments, the electronic device 400 may be a mobile phone, a tablet computer, an electronic paper, a television, a display, a notebook computer, a digital photo frame, a navigator, a wearable electronic device, a smart home device, etc.
例如,電子設備400可以包括顯示面板,顯示面板可以用於顯示交互內容等。例如,顯示面板可以為矩形面板、圓形面板、橢圓形面板或多邊形面板等。另外,顯示面板不僅可以為平面面板,也可以為曲面面板,甚至球面面板。 For example, the electronic device 400 may include a display panel, which may be used to display interactive content, etc. For example, the display panel may be a rectangular panel, a circular panel, an elliptical panel, or a polygonal panel, etc. In addition, the display panel may be not only a flat panel, but also a curved panel, or even a spherical panel.
例如,電子設備400可以具備觸控功能,即電子設備400可以為觸控裝置。 For example, the electronic device 400 may have a touch function, that is, the electronic device 400 may be a touch device.
例如,關於電子設備400執行時脈同步方法的過程的詳細說明可以參考時脈同步方法的實施例中的相關描述,關於電子 設備400執行系統時脈同步方法的過程的詳細說明可以參見上述系統時脈同步方法的實施例中的相關描述,重複之處不再贅述。 For example, the detailed description of the process of the electronic device 400 executing the clock synchronization method can refer to the relevant description in the embodiment of the clock synchronization method, and the detailed description of the process of the electronic device 400 executing the system clock synchronization method can refer to the relevant description in the embodiment of the above-mentioned system clock synchronization method, and the repeated parts will not be repeated.
圖11為本發明至少一實施例提供的一種非暫態性電腦可讀儲存介質的示意圖。例如,如圖11所示,在儲存介質500上可以非暫時性地儲存一個或多個電腦可讀指令510。例如,當電腦可讀指令510由處理器執行時可以執行根據上文所述的時脈同步方法中的一個或多個步驟,或者,當電腦可讀指令510由處理器執行時可以執行根據上文所述的系統時脈同步方法中的一個或多個步驟。 FIG11 is a schematic diagram of a non-transitory computer-readable storage medium provided by at least one embodiment of the present invention. For example, as shown in FIG11 , one or more computer-readable instructions 510 can be stored non-transitorily on the storage medium 500. For example, when the computer-readable instruction 510 is executed by the processor, one or more steps in the clock synchronization method described above can be executed, or, when the computer-readable instruction 510 is executed by the processor, one or more steps in the system clock synchronization method described above can be executed.
例如,該儲存介質500可以應用於上述電子設備400中。例如,儲存介質500可以包括電子設備400中的記憶體420。 For example, the storage medium 500 may be applied to the above-mentioned electronic device 400. For example, the storage medium 500 may include the memory 420 in the electronic device 400.
例如,關於儲存介質500的說明可以參考電子設備400的實施例中對於記憶體420的描述,重複之處不再贅述。 For example, the description of the storage medium 500 can refer to the description of the memory 420 in the embodiment of the electronic device 400, and the repeated parts will not be repeated.
特別地,根據本發明的實施例,上文參考流程圖描述的過程可以被實現為電腦軟體程式。例如,本發明的實施例包括一種電腦程式產品,其包括承載在非暫態電腦可讀介質上的電腦程式,該電腦程式包含用於執行流程圖所示的方法的程式碼。在這樣的實施例中,該電腦程式可以通過通訊裝置從網路上被下載和安裝,或者從儲存裝置被安裝,或者從ROM被安裝。在該電腦程式被處理裝置執行時,執行本發明實施例的方法中限定的上述功能。 In particular, according to an embodiment of the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present invention includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, the computer program containing a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through a communication device, or installed from a storage device, or installed from a ROM. When the computer program is executed by a processing device, the above functions defined in the method of the embodiment of the present invention are executed.
需要說明的是,在本發明的上下文中,電腦可讀介質可以是有形的介質,其可以包含或儲存以供指令執行系統、裝置或設備 使用或與指令執行系統、裝置或設備結合地使用的程式。電腦可讀介質可以是電腦可讀訊號介質或者電腦可讀儲存介質或者是上述兩者的任意組合。電腦可讀儲存介質例如可以是,但不限於:電、磁、光、電磁、紅外線、或半導體的系統、裝置或器件,或者任意以上的組合。電腦可讀儲存介質的更具體的例子可以包括但不限於:具有一個或多個導線的電連接、可擕式電腦磁片、硬碟、隨機訪問記憶體(RAM)、唯讀記憶體(ROM)、可擦式可程式設計唯讀記憶體(EPROM或快閃記憶體)、光纖、可擕式緊湊磁片唯讀記憶體(CD-ROM)、光記憶體件、磁記憶體件、或者上述的任意合適的組合。在本發明中,電腦可讀儲存介質可以是任何包含或儲存程式的有形介質,該程式可以被指令執行系統、裝置或者器件使用或者與其結合使用。而在本發明中,電腦可讀訊號介質可以包括在基帶中或者作為載波一部分傳播的資料訊號,其中承載了電腦可讀的程式碼。這種傳播的資料訊號可以採用多種形式,包括但不限於電磁訊號、光訊號或上述的任意合適的組合。電腦可讀訊號介質還可以是電腦可讀儲存介質以外的任何電腦可讀介質,該電腦可讀訊號介質可以發送、傳播或者傳輸用於由指令執行系統、裝置或者器件使用或者與其結合使用的程式。電腦可讀介質上包含的程式碼可以用任何適當的介質傳輸,包括但不限於:電線、光纜、RF(射頻)等等,或者上述的任意合適的組合。 It should be noted that in the context of the present invention, a computer-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device or equipment. A computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium or any combination thereof. A computer-readable storage medium may be, for example, but not limited to: an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to, an electrical connection with one or more conductors, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical memory device, a magnetic memory device, or any suitable combination thereof. In the present invention, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In the present invention, the computer-readable signal medium may include a data signal transmitted in the baseband or as part of a carrier wave, which carries a computer-readable program code. Such a transmitted data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program used by or in conjunction with an instruction execution system, device, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
上述電腦可讀介質可以是上述電子設備中所包含的;也可以是單獨存在,而未裝配入該電子設備中。 The above-mentioned computer-readable medium may be contained in the above-mentioned electronic device; or it may exist alone without being assembled into the electronic device.
可以以一種或多種程式設計語言或其組合來編寫用於執行本發明的操作的電腦程式代碼,上述程式設計語言包括但不限於物件導向的程式設計語言,諸如Java、Smalltalk、C++,還包括常規的過程式程式設計語言,諸如“C”語言或類似的程式設計語言。程式碼可以完全地在使用者電腦上執行、部分地在使用者電腦上執行、作為一個獨立的套裝軟體執行、部分在使用者電腦上部分在遠端電腦上執行、或者完全在遠端電腦或伺服器上執行。在涉及遠端電腦的情形中,遠端電腦可以通過任意種類的網路(,包括局域網(LAN)或廣域網路(WAN))連接到使用者電腦,或者,可以連接到外部電腦(例如利用網際網路服務提供者來通過網際網路連接)。 Computer program code for performing operations of the present invention may be written in one or more programming languages or combinations thereof, including but not limited to object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In situations involving remote computers, the remote computer can be connected to the user computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (such as through the Internet using an Internet service provider).
附圖中的流程圖和方塊圖,圖示了按照本發明各種實施例的系統、方法和電腦程式產品的可能實現的體系架構、功能和操作。在這點上,流程圖或方塊圖中的每個方框可以代表一個模組、程式段、或代碼的一部分,該模組、程式段、或代碼的一部分包含一個或多個用於實現規定的邏輯功能的可執行指令。也應當注意,在有些作為替換的實現中,方框中所標注的功能也可以以不同於附圖中所標注的順序發生。例如,兩個接連地表示的方框實際上可以基本並行地執行,它們有時也可以按相反的循序執行,這依所涉及的功能而定。也要注意的是,方塊圖和/或流程圖中的每個方框、以及方塊圖和/或流程圖中的方框的組合,可以用執行規定的功能或操作的專用的基於硬體的系統來實現,或者可以用專用硬體與 電腦指令的組合來實現。 The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram may represent a module, a program segment, or a portion of a code, which contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the boxes may also occur in a different order than the order marked in the accompanying drawings. For example, two boxes represented in succession may actually be executed substantially in parallel, and they may sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and/or flowchart, and combinations of boxes in the block diagram and/or flowchart, can be implemented by a dedicated hardware-based system that performs the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.
描述於本發明實施例中所涉及到的單元可以通過軟體的方式實現,也可以通過硬體的方式來實現。其中,單元的名稱在某種情況下並不構成對該單元本身的限定。 The units involved in the embodiments of the present invention can be implemented by software or hardware. In some cases, the name of the unit does not constitute a limitation on the unit itself.
本文中以上描述的功能可以至少部分地由一個或多個硬體邏輯部件來執行。例如,非限制性地,可以使用的示範類型的硬體邏輯部件包括:現場可程式設計閘陣列(FPGA)、專用積體電路(ASIC)、專用標準產品(ASSP)、片上系統(SOC)、複雜可程式設計邏輯裝置(CPLD)等等。 The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
根據本發明的一個或多個實施例,一種時脈同步方法,其中,所述第一處理模組包括第一計時器,所述第一計時器的計數值作為所述第一處理模組的定時基準且順序遞增,所述時脈同步方法包括:向第二處理模組發送觸發訊號,同時記錄發送所述觸發訊號時所述第一計時器當前的計數值作為第一計數值,其中,所述第二處理模組與所述第一處理模組屬於不同的時脈領域;從所述第二處理模組讀取第二計數值,其中,所述第二計數值為所述第二處理模組在接收到所述觸發訊號時,所述第二處理模組的第二計時器當前的計數值,所述第二計時器的計數值作為所述第二處理模組的定時基準且順序遞增;其中,所述第一計數值和所述第二計數值用於時脈補償,以使得所述第一處理模組所在的第一時脈領域與所述第二處理模組所在的第二時脈領域同步。 According to one or more embodiments of the present invention, a clock synchronization method is provided, wherein the first processing module includes a first timer, the count value of the first timer is used as a timing reference of the first processing module and increases sequentially, and the clock synchronization method includes: sending a trigger signal to a second processing module, and recording the current count value of the first timer when the trigger signal is sent as a first count value, wherein the second processing module and the first processing module belong to different clock domains; The second processing module reads a second count value, wherein the second count value is the current count value of the second timer of the second processing module when the second processing module receives the trigger signal, and the count value of the second timer is used as the timing reference of the second processing module and increases sequentially; wherein the first count value and the second count value are used for clock compensation, so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located.
根據本發明的一個或多個實施例,所述第一處理模組包 括第一鎖相迴路,所述第一鎖相迴路配置為接收第一時脈源提供的第一時脈訊號,並根據所述第一時脈訊號為所述第一處理模組提供第一參考時脈訊號,所述第二處理模組包括第二鎖相迴路,所述第二鎖相迴路配置為接收所述第一時脈源提供的所述第一時脈訊號,並根據所述第一時脈訊號為所述第二處理模組提供第二參考時脈訊號,所述第一鎖相迴路與所述第二鎖相迴路不同,所述時脈補償在所述第一處理模組處於通電階段時執行。 According to one or more embodiments of the present invention, the first processing module includes a first phase-locked loop, the first phase-locked loop is configured to receive a first clock signal provided by a first clock source, and provide a first reference clock signal to the first processing module according to the first clock signal, the second processing module includes a second phase-locked loop, the second phase-locked loop is configured to receive the first clock signal provided by the first clock source, and provide a second reference clock signal to the second processing module according to the first clock signal, the first phase-locked loop is different from the second phase-locked loop, and the clock compensation is executed when the first processing module is in the power-on stage.
根據本發明的一個或多個實施例,所述時脈同步方法還包括:確定所述第一計數值和所述第二計數值的偏差;根據所述偏差,對所述第一計時器進行補償,以使得所述第一處理模組所在的所述第一時脈領域與所述第二處理模組所在的所述第二時脈領域同步。 According to one or more embodiments of the present invention, the clock synchronization method further includes: determining the deviation between the first count value and the second count value; and compensating the first timer according to the deviation so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located.
根據本發明的一個或多個實施例,根據所述偏差,對所述第一計時器進行補償,以使得所述第一處理模組所在的所述第一時脈領域與所述第二處理模組所在的所述第二時脈領域同步,包括:獲取所述第一計時器當前的計數值作為第三計數值;將所述偏差與所述第三計數值進行加和處理,得到更新計數值;將所述第一計時器的計數值更新為所述更新計數值,以使得所述第一處理模組所在的所述第一時脈領域與所述第二處理模組所在的所述第二時脈領域同步。 According to one or more embodiments of the present invention, the first timer is compensated according to the deviation so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located, including: obtaining the current count value of the first timer as the third count value; adding the deviation and the third count value to obtain an updated count value; updating the count value of the first timer to the updated count value so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located.
根據本發明的一個或多個實施例,所述觸發訊號還配置為同時觸發所述第一處理模組的中斷,以執行所述時脈補償。 According to one or more embodiments of the present invention, the trigger signal is also configured to simultaneously trigger an interruption of the first processing module to perform the clock compensation.
根據本發明的一個或多個實施例,所述第一處理模組由第一時脈源提供參考時脈訊號,所述第二處理模組由第二時脈源提供參考時脈訊號,所述第一時脈源與所述第二時脈源為非同源時脈源,所述時脈同步在所述第一處理模組處於工作狀態時定期執行,在所述時脈同步的整個過程中,所述第一計時器和所述第二計時器的計數值始終保持單調遞增。 According to one or more embodiments of the present invention, the first processing module is provided with a reference clock signal by a first clock source, and the second processing module is provided with a reference clock signal by a second clock source, the first clock source and the second clock source are non-cognate clock sources, and the clock synchronization is performed periodically when the first processing module is in a working state. During the entire process of the clock synchronization, the count values of the first timer and the second timer always keep monotonically increasing.
根據本發明的一個或多個實施例,所述時脈同步方法還包括:比較所述第一計數值和所述第二計數值的大小關係;回應於所述第一計數值小於所述第二計數值,根據所述第一計數值和所述第二計數值的偏差進行時脈補償,以使得所述第一處理模組所在的所述第一時脈領域與所述第二處理模組所在的所述第二時脈領域同步。 According to one or more embodiments of the present invention, the clock synchronization method further includes: comparing the magnitude relationship between the first count value and the second count value; in response to the first count value being less than the second count value, clock compensation is performed according to the deviation between the first count value and the second count value, so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located.
根據本發明的一個或多個實施例,根據所述第一計數值和所述第二計數值的偏差進行時脈補償,以使得所述第一處理模組所在的所述第一時脈領域與所述第二處理模組所在的所述第二時脈領域同步,包括:確定所述第一計數值和所述第二計數值的偏差;根據所述偏差,對所述第一計時器進行補償,以使得所述第一處理模組所在的所述第一時脈領域與第二處理模組所在的所述第二時脈領域同步。 According to one or more embodiments of the present invention, clock compensation is performed according to the deviation between the first count value and the second count value so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located, including: determining the deviation between the first count value and the second count value; and compensating the first timer according to the deviation so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located.
根據本發明的一個或多個實施例,響應於所述第一時脈源能夠利用電壓對振盪頻率進行調整,根據所述偏差,對所述第一計時器進行補償,以使得所述第一處理模組所在的第一時脈領域 與第二處理模組所在的第二時脈領域同步,包括:根據所述偏差,對所述第一計時器進行補償;根據所述偏差,確定調整電壓;根據所述調整電壓,對所述第一時脈源進行補償,以使得所述第一處理模組所在的所述第一時脈領域與所述第二處理模組所在的第二時脈領域同步。 According to one or more embodiments of the present invention, in response to the first clock source being able to adjust the oscillation frequency using voltage, the first timer is compensated according to the deviation so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located, including: compensating the first timer according to the deviation; determining an adjustment voltage according to the deviation; and compensating the first clock source according to the adjustment voltage so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located.
根據本發明的一個或多個實施例,根據所述偏差,確定調整電壓,包括:根據所述偏差,計算所述第一時脈源相對於所述第二時脈源的單位時間頻率偏差;根據所述單位時間頻率偏差,確定所述調整電壓。 According to one or more embodiments of the present invention, determining the adjustment voltage according to the deviation includes: calculating the unit time frequency deviation of the first clock source relative to the second clock source according to the deviation; and determining the adjustment voltage according to the unit time frequency deviation.
根據本發明的一個或多個實施例,根據所述偏差,確定調整電壓,包括:獲取歷史頻率偏差,其中,所述歷史頻率偏差為最近一次用於計算調整電壓的單位時間頻率偏差;計算所述歷史頻率偏差和基於所述偏差計算的單位時間頻率偏差的加權和;根據所述加權和的計算結果確定所述調整電壓。 According to one or more embodiments of the present invention, determining the adjustment voltage according to the deviation includes: obtaining a historical frequency deviation, wherein the historical frequency deviation is the unit time frequency deviation used to calculate the adjustment voltage most recently; calculating the weighted sum of the historical frequency deviation and the unit time frequency deviation calculated based on the deviation; and determining the adjustment voltage according to the calculation result of the weighted sum.
根據本發明的一個或多個實施例,根據所述調整電壓,對所述第一時脈源進行補償,以使得所述第一處理模組所在的所述第一時脈領域與所述第二處理模組所在的第二時脈領域同步,包括:將所述調整電壓輸入所述第一時脈源的電壓控制管腳,以使得所述第一時脈源的振盪頻率向所述第二時脈源的振盪頻率方向收斂,並使得所述第一時脈源和所述第二時脈源同步。 According to one or more embodiments of the present invention, the first clock source is compensated according to the adjustment voltage so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located, including: inputting the adjustment voltage into the voltage control pin of the first clock source so that the oscillation frequency of the first clock source converges toward the oscillation frequency of the second clock source, and the first clock source and the second clock source are synchronized.
根據本發明的一個或多個實施例,所述觸發訊號還配置為同時觸發所述第一處理模組和所述第二處理模組的中斷,以執 行所述時脈補償。 According to one or more embodiments of the present invention, the trigger signal is also configured to simultaneously trigger the interruption of the first processing module and the second processing module to perform the clock compensation.
根據本發明的一個或多個實施例,所述第一計數值儲存在所述第一處理模組的暫存器中,所述第二計數值儲存在所述第二處理模組的暫存器中。 According to one or more embodiments of the present invention, the first count value is stored in a register of the first processing module, and the second count value is stored in a register of the second processing module.
根據本發明的一個或多個實施例,一種時脈同步方法,用於第二處理模組,其中,所述第二處理模組包括第二計時器,所述第二計時器的計數值作為所述第二處理模組的定時基準且順序遞增,所述時脈同步方法包括:回應於接收到第一處理模組發送的觸發訊號,記錄所述第二計時器當前的計數值作為第二計數值,其中,所述第二處理模組與所述第一處理模組屬於不同的時脈領域;其中,所述第二計數值用於結合第一計數值進行時脈補償,以使得所述第一處理模組所在的第一時脈領域與所述第二處理模組所在的第二時脈領域同步,所述第一計數值為所述第一處理模組向所述第二處理模組發送觸發訊號時,所述第一處理模組的第一計時器當前的計數值,所述第一計時器的計數值用於作為所述第一處理模組的定時基準且順序遞增。 According to one or more embodiments of the present invention, a clock synchronization method is provided for a second processing module, wherein the second processing module includes a second timer, and the count value of the second timer is used as a timing reference of the second processing module and increases sequentially. The clock synchronization method includes: in response to receiving a trigger signal sent by the first processing module, recording the current count value of the second timer as a second count value, wherein the second processing module and the first processing module are different. The second count value is used to combine with the first count value to perform clock compensation, so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located. The first count value is the current count value of the first timer of the first processing module when the first processing module sends a trigger signal to the second processing module. The count value of the first timer is used as the timing reference of the first processing module and increases sequentially.
根據本發明的一個或多個實施例,所述第一處理模組由第一時脈源提供參考時脈訊號,所述第二處理模組由第二時脈源提供參考時脈訊號,所述第一時脈源與所述第二時脈源為非同源時脈源,所述時脈同步在所述第一處理模組處於工作狀態時定期執行,在所述時脈同步的整個過程中,所述第一計時器和所述第二計時器的計數值始終保持單調遞增。 According to one or more embodiments of the present invention, the first processing module is provided with a reference clock signal by a first clock source, and the second processing module is provided with a reference clock signal by a second clock source, the first clock source and the second clock source are non-cognate clock sources, and the clock synchronization is performed periodically when the first processing module is in a working state. During the entire process of the clock synchronization, the count values of the first timer and the second timer always keep monotonically increasing.
根據本發明的一個或多個實施例,所述時脈同步方法還包括:從所述第一處理模組讀取所述第一計數值;比較所述第一計數值和所述第二計數值的大小關係;回應於所述第二計數值小於所述第一計數值,根據所述第一計數值和所述第二計數值的偏差進行所述時脈補償,以使得所述第一處理模組所在的所述第一時脈領域與所述第二處理模組所在的所述第二時脈領域同步。 According to one or more embodiments of the present invention, the clock synchronization method further includes: reading the first count value from the first processing module; comparing the magnitude relationship between the first count value and the second count value; in response to the second count value being less than the first count value, performing the clock compensation according to the deviation between the first count value and the second count value, so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located.
根據本發明的一個或多個實施例,根據所述第一計數值和所述第二計數值的偏差進行所述時脈補償,以使得所述第一處理模組所在的所述第一時脈領域與所述第二處理模組所在的所述第二時脈領域同步,包括:確定所述第一計數值和所述第二計數值的偏差;根據所述偏差,對所述第二計時器進行補償,以使得所述第一處理模組所在的所述第一時脈領域與所述第二處理模組所在的所述第二時脈領域同步。 According to one or more embodiments of the present invention, the clock compensation is performed according to the deviation between the first count value and the second count value, so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located, including: determining the deviation between the first count value and the second count value; and compensating the second timer according to the deviation, so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located.
根據本發明的一個或多個實施例,響應於所述第二時脈源能夠利用電壓對振盪頻率進行調整,根據所述偏差,對所述第二計時器進行補償,以使得所述第一處理模組所在的所述第一時脈領域與所述第二處理模組所在的所述第二時脈領域同步,包括:根據所述偏差,對所述第二計時器進行補償;根據所述偏差,確定調整電壓;根據所述調整電壓,對所述第二時脈源進行補償,以使得所述第一處理模組所在的所述第一時脈領域與所述第二處理模組所在的所述第二時脈領域同步。 According to one or more embodiments of the present invention, in response to the second clock source being able to adjust the oscillation frequency using voltage, the second timer is compensated according to the deviation so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located, including: compensating the second timer according to the deviation; determining an adjustment voltage according to the deviation; and compensating the second clock source according to the adjustment voltage so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located.
根據本發明的一個或多個實施例,根據所述調整電壓,對 所述第二時脈源進行補償,以使得所述第一處理模組所在的所述第一時脈領域與所述第二處理模組所在的所述第二時脈領域同步,包括:將所述調整電壓輸入所述第二時脈源的電壓控制管腳,以使得所述第二時脈源的振盪頻率向所述第一時脈源的振盪頻率方向收斂,並使得所述第一時脈源和所述第二時脈源同步。 According to one or more embodiments of the present invention, the second clock source is compensated according to the adjustment voltage so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located, including: inputting the adjustment voltage into the voltage control pin of the second clock source so that the oscillation frequency of the second clock source converges toward the oscillation frequency of the first clock source, and the first clock source and the second clock source are synchronized.
根據本發明的一個或多個實施例,一種系統時脈同步方法,其中,所述系統包括第一處理模組和第二處理模組,所述第一處理模組包括第一計時器,所述第一計時器的計數值作為所述第一處理模組的定時基準且順序遞增,所述第二處理模組包括第二計時器,所述第二計時器的計數值作為所述第二處理模組的定時基準且順序遞增,所述第一處理模組和所述第二處理模組屬於不同的時脈領域,所述系統時脈同步方法包括:所述第一處理模組向所述第二處理模組發送觸發訊號,所述第一處理模組記錄在發送所述觸發訊號時所述第一計時器當前的計數值作為第一計數值,所述第二處理模組記錄在接收到所述觸發訊號時所述第二計時器當前的計數值作為第二計數值;其中,所述第一計數值和所述第二計數值用於時脈補償,以使得所述第一處理模組所在的第一時脈領域與第二處理模組所在的第二時脈領域同步。 According to one or more embodiments of the present invention, a system clock synchronization method is provided, wherein the system includes a first processing module and a second processing module, the first processing module includes a first timer, the count value of the first timer is used as a timing reference of the first processing module and increases sequentially, the second processing module includes a second timer, the count value of the second timer is used as a timing reference of the second processing module and increases sequentially, the first processing module and the second processing module belong to different clock domains, and the system clock is synchronized. The synchronization method includes: the first processing module sends a trigger signal to the second processing module, the first processing module records the current count value of the first timer when sending the trigger signal as the first count value, and the second processing module records the current count value of the second timer when receiving the trigger signal as the second count value; wherein the first count value and the second count value are used for clock compensation, so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located.
根據本發明的一個或多個實施例,一種時脈同步裝置,用於第一處理模組,其中,所述第一處理模組包括第一計時器,所述第一計時器的計數值作為所述第一處理模組的定時基準且順序遞增,所述時脈同步裝置包括:第一記錄單元,配置為向第二處理模 組發送觸發訊號,同時記錄發送所述觸發訊號時所述第一計時器當前的計數值作為第一計數值,其中,所述第二處理模組與所述第一處理模組屬於不同的時脈領域;讀取單元,配置為從所述第二處理模組讀取第二計數值,其中,所述第二計數值為所述第二處理模組在接收到所述觸發訊號時,所述第二處理模組的第二計時器當前的計數值,所述第二計時器的計數值作為所述第二處理模組的定時基準且順序遞增;其中,所述第一計數值和所述第二計數值用於時脈補償,以使得所述第一處理模組所在的第一時脈領域與所述第二處理模組所在的第二時脈領域同步。 According to one or more embodiments of the present invention, a clock synchronization device is used for a first processing module, wherein the first processing module includes a first timer, and the count value of the first timer is used as a timing reference of the first processing module and increases in sequence. The clock synchronization device includes: a first recording unit, configured to send a trigger signal to a second processing module, and record the current count value of the first timer when the trigger signal is sent as a first count value, wherein the second processing module and the first processing module belong to different Clock domain; a reading unit configured to read a second count value from the second processing module, wherein the second count value is the current count value of the second timer of the second processing module when the second processing module receives the trigger signal, and the count value of the second timer is used as the timing reference of the second processing module and increases sequentially; wherein the first count value and the second count value are used for clock compensation, so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located.
根據本發明的一個或多個實施例,一種時脈同步裝置,用於第二處理模組,其中,所述第二處理模組包括第二計時器,所述第二計時器的計數值作為所述第二處理模組的定時基準且順序遞增,所述時脈同步裝置包括:第二記錄單元,配置為回應於接收到第一處理模組發送的觸發訊號,記錄所述第二計時器當前的計數值作為第二計數值,其中,所述第二處理模組與所述第一處理模組屬於不同的時脈領域;其中,所述第二計數值用於結合第一計數值進行時脈補償,以使得所述第一處理模組所在的第一時脈領域與所述第二處理模組所在的第二時脈領域同步,所述第一計數值為所述第一處理模組向第二處理模組發送觸發訊號時,所述第一處理模組的第一計時器當前的計數值,所述第一計時器的計數值用於作為所述第一處理模組的定時基準且順序遞增。 According to one or more embodiments of the present invention, a clock synchronization device is provided for a second processing module, wherein the second processing module includes a second timer, and the count value of the second timer is used as a timing reference of the second processing module and increases in sequence. The clock synchronization device includes: a second recording unit, configured to respond to receiving a trigger signal sent by the first processing module, and record the current count value of the second timer as a second count value, wherein the second processing module is synchronized with the first processing module. The processing modules belong to different clock domains; wherein the second count value is used to combine with the first count value for clock compensation, so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located; the first count value is the current count value of the first timer of the first processing module when the first processing module sends a trigger signal to the second processing module; the count value of the first timer is used as the timing reference of the first processing module and increases sequentially.
根據本發明的一個或多個實施例,一種電子設備,包括第 一處理模組和第二處理模組,其中,所述第一處理模組包括第一計時器,所述第一計時器的計數值作為所述第一處理模組的定時基準且順序遞增,所述第二處理模組包括第二計時器,所述第二計時器的計數值作為所述第二處理模組的定時基準且順序遞增,所述第一處理模組和所述第二處理模組屬於不同的時脈領域,其中,所述第一處理模組配置為向所述第二處理模組發送觸發訊號,以及記錄在發送所述觸發訊號時所述第一計時器當前的計數值作為第一計數值,所述第二處理模組配置為記錄在接收到所述觸發訊號時所述第二計時器當前的計數值作為第二計數值;其中,所述第一計數值和所述第二計數值用於時脈補償,以使得所述第一處理模組所在的第一時脈領域與第二處理模組所在的第二時脈領域同步。 According to one or more embodiments of the present invention, an electronic device includes a first processing module and a second processing module, wherein the first processing module includes a first timer, the count value of the first timer is used as a timing reference of the first processing module and increases sequentially, the second processing module includes a second timer, the count value of the second timer is used as a timing reference of the second processing module and increases sequentially, the first processing module and the second processing module belong to different clock domains, wherein the The first processing module is configured to send a trigger signal to the second processing module, and record the current count value of the first timer when sending the trigger signal as the first count value, and the second processing module is configured to record the current count value of the second timer when receiving the trigger signal as the second count value; wherein the first count value and the second count value are used for clock compensation, so that the first clock domain where the first processing module is located is synchronized with the second clock domain where the second processing module is located.
根據本發明的一個或多個實施例,一種電子設備,包括:記憶體,非暫態性地儲存有電腦可執行指令;處理器,配置為運行所述電腦可執行指令,其中,所述電腦可執行指令被所述處理器運行時實現根據本發明任一實施例所述的時脈同步方法或本發明任一實施例所述的系統時脈同步方法。 According to one or more embodiments of the present invention, an electronic device includes: a memory that non-temporarily stores computer executable instructions; a processor that is configured to execute the computer executable instructions, wherein the computer executable instructions, when executed by the processor, implement the clock synchronization method described in any embodiment of the present invention or the system clock synchronization method described in any embodiment of the present invention.
根據本發明的一個或多個實施例,一種非暫態性電腦可讀儲存介質,其中,所述非暫態性電腦可讀儲存介質儲存有電腦可執行指令,所述電腦可執行指令被處理器執行時實現根據本發明任一實施例所述的時脈同步方法或本發明任一實施例所述的系統時脈同步方法。 According to one or more embodiments of the present invention, a non-transitory computer-readable storage medium is provided, wherein the non-transitory computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, the clock synchronization method described in any embodiment of the present invention or the system clock synchronization method described in any embodiment of the present invention is implemented.
以上描述僅為本發明的較佳實施例以及對所運用技術原 理的說明。本領域技術人員應當理解,本發明中所涉及的公開範圍,並不限於上述技術特徵的特定組合而成的技術方案,同時也應涵蓋在不脫離上述公開構思的情況下,由上述技術特徵或其等同特徵進行任意組合而形成的其它技術方案。例如上述特徵與本發明中公開的(但不限於)具有類似功能的技術特徵進行互相替換而形成的技術方案。 The above description is only a preferred embodiment of the present invention and an explanation of the technical principle used. Those skilled in the art should understand that the disclosure scope involved in the present invention is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above public concept. For example, the above features are replaced with the technical features disclosed in the present invention (but not limited to) with similar functions to form a technical solution.
此外,雖然採用特定次序描繪了各操作,但是這不應當理解為要求這些操作以所示出的特定次序或以順序次序執行來執行。在一定環境下,多工和並行處理可能是有利的。同樣地,雖然在上面論述中包含了若干具體實現細節,但是這些不應當被解釋為對本發明的範圍的限制。在單獨的實施例的上下文中描述的某些特徵還可以組合地實現在單個實施例中。相反地,在單個實施例的上下文中描述的各種特徵也可以單獨地或以任何合適的子組合的方式實現在多個實施例中。 Furthermore, although the operations are depicted in a particular order, this should not be construed as requiring that the operations be performed in the particular order shown or in a sequential order. Multiplexing and parallel processing may be advantageous in certain circumstances. Likewise, although several specific implementation details are included in the above discussion, these should not be construed as limitations on the scope of the invention. Certain features described in the context of separate embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented in multiple embodiments, either individually or in any suitable subcombination.
儘管已經採用特定於結構特徵和/或方法邏輯動作的語言描述了本主題,但是應當理解所附請求項書中所限定的主題未必侷限於上面描述的特定特徵或動作。相反,上面所描述的特定特徵和動作僅僅是實現請求項書的示例形式。 Although the subject matter has been described using language specific to structural features and/or methodological logic acts, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are merely example forms of implementing the claims.
對於本發明,還有以下幾點需要說明: Regarding this invention, there are a few points that need to be explained:
(1)本發明實施例附圖只涉及到與本發明實施例涉及到的結構,其他結構可參考通常設計。 (1) The drawings of the embodiments of the present invention only involve the structures involved in the embodiments of the present invention. Other structures can refer to the usual design.
(2)在不衝突的情況下,本發明的實施例及實施例中的 特徵可以相互組合以得到新的實施例。 (2) In the absence of conflict, the embodiments of the present invention and the features in the embodiments may be combined with each other to obtain new embodiments.
以上所述僅為本發明的具體實施方式,但本發明的保護範圍並不侷限於此,本發明的保護範圍應以所述請求項的保護範圍為准。 The above is only a specific implementation method of the present invention, but the protection scope of the present invention is not limited thereto. The protection scope of the present invention shall be based on the protection scope of the above-mentioned claim.
S10、S20:步驟 S10, S20: Steps
Claims (19)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| TW111144130A TWI873481B (en) | 2022-11-18 | 2022-11-18 | Clock synchronization method and device, electronic equipment and storage medium |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| TW111144130A TWI873481B (en) | 2022-11-18 | 2022-11-18 | Clock synchronization method and device, electronic equipment and storage medium |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| TW202422266A TW202422266A (en) | 2024-06-01 |
| TWI873481B true TWI873481B (en) | 2025-02-21 |
Family
ID=92539972
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| TW111144130A TWI873481B (en) | 2022-11-18 | 2022-11-18 | Clock synchronization method and device, electronic equipment and storage medium |
Country Status (1)
| Country | Link |
|---|---|
| TW (1) | TWI873481B (en) |
Citations (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN102265237A (en) * | 2008-08-21 | 2011-11-30 | 克罗诺洛吉克有限公司 | Synchronisation and timing method and apparatus |
| CN112260789A (en) * | 2020-10-20 | 2021-01-22 | 哲库科技(北京)有限公司 | Clock source system, clock synchronization system and clock synchronization method |
-
2022
- 2022-11-18 TW TW111144130A patent/TWI873481B/en active
Patent Citations (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN102265237A (en) * | 2008-08-21 | 2011-11-30 | 克罗诺洛吉克有限公司 | Synchronisation and timing method and apparatus |
| CN112260789A (en) * | 2020-10-20 | 2021-01-22 | 哲库科技(北京)有限公司 | Clock source system, clock synchronization system and clock synchronization method |
Also Published As
| Publication number | Publication date |
|---|---|
| TW202422266A (en) | 2024-06-01 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| WO2024104321A1 (en) | Clock synchronization method and apparatus, electronic device, and storage medium | |
| US11609598B2 (en) | Network card, time synchronization methods and devices, and computer storage media | |
| CN111385050B (en) | Clock synchronization method, device and storage medium | |
| US10739814B2 (en) | Time-synchronizing a group of nodes | |
| CN111385051B (en) | Clock synchronization method, device and storage medium | |
| Najafi et al. | Graham: Synchronizing clocks by leveraging local clock properties | |
| CN115801175B (en) | Time-frequency synchronization method, system, storage medium and electronic equipment | |
| CN108023723A (en) | The method of Frequency Synchronization and from clock | |
| US9568944B2 (en) | Distributed timer subsystem across multiple devices | |
| TWI873481B (en) | Clock synchronization method and device, electronic equipment and storage medium | |
| CN117176285A (en) | PTP time synchronization method and device based on FPGA | |
| US11853114B1 (en) | Virtualized hardware clocks for providing highly accurate time information in hosted machine instances | |
| Kinali et al. | Fault-tolerant clock synchronization with high precision | |
| TW202322635A (en) | Network switch and circuit board | |
| CN117792558B (en) | Method, apparatus, device and medium for integrating high precision time | |
| CN110071778B (en) | A time synchronization method, device, equipment and medium | |
| CN111291011A (en) | File synchronization method and device, electronic device and readable storage medium | |
| WO2024230480A1 (en) | Clock synchronization method and apparatus, computer-readable medium, and electronic device | |
| Neville-Neil | Time is an illusion lunchtime doubly so | |
| CN115397004B (en) | A clock synchronization method, device, network equipment, converter and storage medium | |
| CN113268105B (en) | Clock synchronization implementation method, device, electronic device and storage medium | |
| Girela-López et al. | Ultra-accurate Ethernet time-transfer with programmable carrier-frequency based on White Rabbit solution | |
| CN107241365A (en) | A kind of cloud platform method for synchronizing time | |
| Rusetskiy et al. | Architecture for time synchronization in an onboard SpaceWire network of ARINC 653 nodes | |
| US20250337556A1 (en) | Maintaining timing synchronization in network devices |