A cross-clock domain communication circuit and a data reading and writing method

Through the level expansion and synchronization processing in the cross-clock domain communication circuit, the power consumption and write time inconsistency introduced by high-frequency clocks is solved, and low power consumption and reliable write in the asynchronous clock domain are realized, ensuring that multiple bytes write time is consistent, and suitable for cross-clock domain communication.

CN120045018BActive Publication Date: 2025-07-18BEIJING JUXUAN INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510527696.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-04-25
Publication Date
2025-07-18
Estimated Expiration
2045-04-25

AI Technical Summary

Technical Problem

In cross-clock domain communication, the prior art requires the additional introduction of high-frequency clocks to increase power consumption and increase layout and routing complexity. At the same time, the write time is difficult to reasonably determine, especially when multiple bytes are written, each byte writes inconsistently, which cannot meet the scenarios where the write time requirements are high.

Method used

A cross-clock domain communication circuit is designed, including a level expansion unit, a write flag signal generation unit, a synchronization unit and a write enable signal generation unit. Through signal processing under the asynchronous clock, an additional high-frequency clock is avoided, and a write time is determined using the communication end flag signal, and a synchronous write enable signal under the second clock to ensure that the write time of multiple bytes is consistent.

Benefits of technology

The power consumption is reduced, the write time of multiple bytes is reasonably determined, and reliable communication is ensured in the asynchronous clock domain. The target data writing time of multiple bytes is the same, which improves the reliability and efficiency of communication.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120045018B_ABST
    Figure CN120045018B_ABST
Patent Text Reader

Abstract

The present invention discloses a cross-clock domain communication circuit and a data reading and writing method, which relate to the field of cross-clock domain communication. In this circuit, a level expansion unit outputs a level signal according to an original write enable signal and a communication end flag signal under a first clock. The communication end flag signal is in an active state when the current write communication instruction has ended and the target data of N bytes has been written into the cache. A write flag signal generation unit is used to output a write flag signal under the first clock. When the write flag signal is in an inactive state, it is set to an active state and maintained when both the level signal and the communication end flag signal are in an active state. A synchronization unit synchronizes the write flag signal under a second clock to obtain a synchronization signal, so that a write enable signal generation unit generates a write enable signal under the second clock. This solution does not require an additional high-frequency clock to be started, which is beneficial to reducing power consumption; it is beneficial to reasonably determine the writing moment of multi-byte target data under the second clock and the corresponding writing moments are the same.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of cross-clock domain communication, and in particular to a cross-clock domain communication circuit and a data reading and writing method. Background Art

[0002] Data interaction in an asynchronous clock domain is a common situation during inter-module communication. Especially when writing from a relatively high-frequency communication clock to a relatively low-frequency system clock, data synchronization and write enable signal synchronization are key issues to be solved. For this purpose, the current solutions mainly include the following two:

[0003] The first method is to additionally introduce a high-frequency clock and a corresponding clock tree outside the communication clock and the system clock. Then, for the write instruction sent by the communication interface, the high-frequency clock is used for decoding to obtain the write data and the write enable, and the write data is written into the cache. Subsequently, a handshake signal is sent to the module that follows the system clock to transfer the write enable to the relatively low-frequency system clock domain through a handshake mechanism, so that the module in the system clock domain can complete data writing from the cache according to the corresponding clock frequency. However, in this method, the high-frequency clock needs to be started every time a write instruction is received for writing, which increases power consumption, and the introduction of the high-frequency clock also correspondingly increases the layout and wiring complexity and the timing analysis difficulty.

[0004] The second method is to set a write flag signal and obtain the write enable signal accordingly. However, the disadvantage of this solution is that it is difficult to determine the writing moment. Specifically, in this method, when each byte is written into the system clock domain, it depends on the corresponding write enable signal. Usually, the moment corresponding to the write enable signal is regarded as the writing moment of this byte. However, when there are multiple bytes to be written in the communication, the generation times of the write enable signals corresponding to each byte are different, resulting in differences between the writing moments corresponding to each byte. Such differences are not allowed in scenarios with high requirements for the write operation time. For example, in the scenario of writing a log, multiple bytes that should originally correspond to the same moment, but according to the above method, the writing moments corresponding to each byte in the system clock domain are not the same. It can be seen that when facing multiple bytes, the current solution for determining the writing moment in the system clock domain is not reasonable.

[0005] Therefore, how to provide a cross-clock domain communication scheme with a more reasonable determination of the writing moment for multiple bytes is an urgent problem to be solved currently. Summary of the Invention

[0006] In view of this, the present invention provides a cross-clock domain communication circuit and a data reading and writing method, which do not need to additionally start a high-frequency clock, are beneficial to reducing power consumption, are beneficial to reasonably determining the writing moment of the target data of multiple bytes under the second clock, and can ensure that the writing moments corresponding to the target data of multiple bytes in one communication are the same.

[0007] To solve the above technical problems, the present application provides a cross-clock domain communication circuit, which includes a level expansion unit, a write flag signal generation unit, a synchronization unit, and a write enable signal generation unit connected in sequence;

[0008] The level expansion unit is configured to perform level expansion on the received original write enable signal and communication end flag signal under the first clock to output a level signal; the original write enable signal is in an effective state when a write communication instruction is received under the first clock, and the communication end flag signal is in an effective state when the write communication instruction has ended and the target data of N bytes has been written into the buffer, where N is an integer not less than 1;

[0009] The write flag signal generation unit is configured to output a write flag signal under the first clock according to the received level signal and communication end flag signal; the write flag signal is configured to be set to an effective state and maintained when both the level signal and the communication end flag signal are in an effective state in the case of being in an invalid state;

[0010] The synchronization unit is configured to synchronize the write flag signal under the second clock to obtain a synchronization signal, so that the write enable signal generation unit performs edge extraction according to the synchronization signal to generate a write enable signal under the second clock; wherein, the first clock and the second clock are asynchronous clocks;

[0011] The level expansion unit includes a trigger logic circuit and a first flip-flop;

[0012] The first input terminal of the trigger logic circuit is configured to receive the original write enable signal, the second input terminal is configured to receive the communication end flag signal, the third input terminal is connected to the data output terminal of the first flip-flop and the common connection end is connected to the write flag signal generation unit, and the output terminal is connected to the data input terminal of the first flip-flop, and is configured to output a first level when the original write enable signal changes from an invalid state to an effective state, and maintain the output of the first level until the communication end flag signal changes from an effective state to an invalid state and then output a second level;

[0013] The clock signal input terminal of the first flip-flop is connected to the first clock, and is configured to output a level signal in an effective state when receiving the first level, and output a level signal in an invalid state when receiving the second level;

[0014] The trigger logic circuit includes a sixth NOT gate, a seventh NOT gate, a fifth AND gate, and a second OR gate; the input terminal of the sixth NOT gate is used to connect to the first input terminal of the second OR gate, and the common connection terminal is used as the first input terminal of the trigger logic circuit, and the output terminal is connected to the first input terminal of the fifth AND gate; the input terminal of the seventh NOT gate is used as the second input terminal of the trigger logic circuit, and the output terminal is connected to the second input terminal of the fifth AND gate; the third input terminal of the fifth AND gate is used as the third input terminal of the trigger logic circuit, and the output terminal is connected to the second input terminal of the second OR gate; the output terminal of the second OR gate is used as the output terminal of the trigger logic circuit.

[0015] Further, the write flag signal generation unit includes a first AND gate, a first NOT gate, a second AND gate, a first OR gate, and a second flip-flop;

[0016] The first input terminal of the first AND gate is connected to the output terminal of the level expansion unit, the second input terminal is used to receive the communication end flag signal, and the output terminal is respectively connected to the input terminal of the first NOT gate and the first input terminal of the first OR gate;

[0017] The first input terminal of the second AND gate is connected to the data output terminal of the second flip-flop, and the common connection terminal is connected to the synchronization unit, the second input terminal is connected to the output terminal of the first NOT gate, and the output terminal is connected to the second input terminal of the first OR gate;

[0018] The data input terminal of the second flip-flop is connected to the output terminal of the first OR gate, and the clock signal input terminal is connected to the first clock.

[0019] Further, the synchronization unit includes M third flip-flops connected in sequence, where M is an integer not less than 3;

[0020] The clock signal input terminals of each of the third flip-flops are connected to the second clock, the data input terminal of the first third flip-flop is connected to the data output terminal of the second flip-flop, the data output terminal of the (M - 1)-th third flip-flop is respectively connected to the data input terminal of the M-th third flip-flop and the first input terminal of the write enable signal generation unit, and the data output terminal of the M-th third flip-flop is connected to the second input terminal of the write enable signal generation unit.

[0021] Further, the write enable signal generation unit includes a second NOT gate and a third AND gate;

[0022] The input terminal of the second NOT gate is used as the second input terminal of the write enable signal generation unit;

[0023] The first input terminal of the third AND gate serves as the first input terminal of the write enable signal generation unit. The second input terminal is connected to the output terminal of the second NOT gate, and the output terminal is used to output the generated write enable signal under the second clock.

[0024] Furthermore, the cross-clock domain communication circuit further includes a status reset unit;

[0025] The input terminal of the status reset unit is connected to the data output terminal of the Mth third flip-flop, and the output terminal is connected to the third input terminal of the second AND gate. It is used to synchronize the received synchronization signal output by the Mth third flip-flop under the first clock to output a status reset signal. Among them, the status reset signal is in an effective state after synchronization when the synchronization signal is in an effective state, so as to convert the currently effective write flag signal into an ineffective state.

[0026] Furthermore, the status reset unit includes a third NOT gate, a fourth NOT gate, a fourth AND gate, and S fourth flip-flops, where S is an integer not less than 3;

[0027] The S fourth flip-flops are connected in sequence, and the clock signal input terminals of each of the fourth flip-flops are connected to the first clock. The data input terminal of the first fourth flip-flop serves as the input terminal of the status reset unit. The data output terminal of the (S - 1)th fourth flip-flop is respectively connected to the data input terminal of the Sth fourth flip-flop and the first input terminal of the fourth AND gate. The data output terminal of the Sth fourth flip-flop is connected to the input terminal of the third NOT gate;

[0028] The second input terminal of the fourth AND gate is connected to the output terminal of the third NOT gate, and the output terminal is connected to the input terminal of the fourth NOT gate;

[0029] The output terminal of the fourth NOT gate serves as the output terminal of the status reset unit.

[0030] Furthermore, the cross-clock domain communication circuit further includes a reset unit;

[0031] The reset terminal of the reset unit is used to receive the original write enable signal. The input terminal is used to receive a reference signal. The first output terminal is connected to the reset terminal of the write flag signal generation unit, and the second output terminal is connected to the reset terminal of the synchronization unit. It is used to output a first reset signal through its first output terminal according to the original write enable signal received by its reset terminal under the second clock, and output a second reset signal through its second output terminal according to the original write enable signal and the reference signal;

[0032] Among them, the first reset signal is in an invalid state when the original write enable signal is in an invalid state, and is in a valid state when the original write enable signal is in a valid state, so as to reset the write flag signal generation unit, so as to reset the currently valid write flag signal to an invalid state;

[0033] The second reset signal is synchronized and remains in an invalid state when the original write enable signal is in an invalid state, and is in a valid state when the original write enable signal is in a valid state, so as to reset the synchronization unit, so that the synchronization unit re-synchronizes the received write flag signal under the second clock.

[0034] Furthermore, the reset unit includes a fifth NOT gate and T fifth flip-flops, where T is an integer not less than 2;

[0035] The T fifth flip-flops are connected in sequence, and the clock signal input terminals of each fifth flip-flop are connected to the second clock. The reset terminals of each fifth flip-flop are connected to the output terminal of the fifth NOT gate, and the common connection end is used as the first output terminal of the reset unit;

[0036] The input terminal of the fifth NOT gate is used as the reset terminal of the reset unit; the data input terminal of the first fifth flip-flop is used as the input terminal of the reset unit, and the output terminal of the T-th fifth flip-flop is used as the second output terminal of the reset unit.

[0037] To solve the above technical problems, the present invention also provides a data reading and writing method, which is applied to an electronic device. The electronic device includes the cross-clock domain communication circuit as described above; the data reading and writing method includes:

[0038] When receiving a write communication instruction, write the target data into the cache under the first clock, and based on the write enable signal generated by the cross-clock domain communication circuit, write the target data from the cache into the register under the second clock;

[0039] When receiving a read communication instruction, obtain the write flag signal output by the write flag signal generation unit in the cross-clock domain communication circuit;

[0040] Judge whether the write flag signal is in a valid state;

[0041] If so, perform data reading from the cache in response to the read communication instruction;

[0042] If not, perform data reading from the register in response to the read communication instruction.

[0043] The present application provides a cross-clock domain communication circuit and a data reading and writing method. In this circuit, a level expansion unit is used to perform level expansion according to an original write enable signal and a communication end flag signal under a first clock to output a level signal. The communication end flag signal is in an effective state when the current write communication instruction has ended and the target data of N bytes has been written into the cache. A write flag signal generation unit is used to output a write flag signal according to the level signal and the communication end flag signal under the first clock. When the write flag signal is in an invalid state, it is set to an effective state and maintained when both the level signal and the communication end flag signal are in an effective state for subsequent synchronization. A synchronization unit is used to synchronize the write flag signal under a second clock to obtain a synchronization signal, so that a write enable signal generation unit can perform edge extraction according to the synchronization signal to generate a write enable signal under the second clock, and then write the target data into a register under the second clock based on the write enable signal. It can be seen that this solution does not require an additional high-frequency clock to be started, which is beneficial to reducing power consumption. When the write communication instruction has ended and the target data of N bytes has been written into the cache, a communication end flag signal is generated, and the moment when the communication end flag signal is received is determined, which is beneficial to reasonably determining the writing moment of the target data of multiple bytes under the second clock accordingly, and can ensure that the writing moments corresponding to the target data of multiple bytes in one communication are the same, which is beneficial to reliable communication across clock domains in practical applications.

[0044] The above description is only an overview of the technical solution of the present application. In order to be able to understand the technical means of the present application more clearly, it can be implemented according to the content of the specification. And in order to make the above and other purposes, features and advantages of the present application more obvious and understandable, the following specifically gives the specific implementation manners of the present application. Brief Description of the Drawings

[0045] The drawings described herein are used to provide a further understanding of the present application, and constitute a part of the present application. The schematic embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation to the present application. In the drawings:

[0046] Figure 1 is a schematic structural diagram of a cross-clock domain communication circuit provided by the present invention;

[0047] Figure 2 is a schematic diagram of the level waveform change of each signal in a cross-clock domain communication circuit provided by the present invention;

[0048] Figure 3 is a schematic structural diagram of another cross-clock domain communication circuit provided by the present invention;

[0049] Figure 4 is a flowchart of a data reading and writing method provided by the present invention. Detailed Description of the Invention

[0050] The core of the present invention is to provide a cross-clock domain communication circuit and a data reading and writing method, which do not require an additional high-frequency clock to be started, facilitating power consumption reduction; facilitating the reasonable determination of the writing time of the target data of multiple bytes under the second clock, and ensuring that the writing times corresponding to the target data of multiple bytes in one communication are the same.

[0051] Next, the technical solutions in the embodiments of the present application will be clearly described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art belong to the scope of protection of the present application.

[0052] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, rather than to describe a specific order or sequence. It should be understood that such used data can be interchanged under appropriate circumstances so that the embodiments of the present application can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first", "second", etc. are generally of the same category, and the number of objects is not limited. For example, the first object can be one or multiple. In addition, "and / or" in the specification and claims means at least one of the connected objects, and the character " / " generally means an "or" relationship between the associated objects before and after.

[0053] Please refer to Figure 1 , Figure 1 , which is a schematic structural diagram of a cross-clock domain communication circuit provided by the present invention.

[0054] The cross-clock domain communication circuit includes a level expansion unit 1, a write flag signal generation unit 2, a synchronization unit 3, and a write enable signal generation unit 4 connected in sequence;

[0055] The level expansion unit 1 is configured to perform level expansion according to the received original write enable signal and communication end flag signal under the first clock to output a level signal; the original write enable signal is in an effective state when a write communication instruction is received under the first clock, and the communication end flag signal is in an effective state when the write communication instruction has ended and the target data of N bytes has been written into the buffer, where N is an integer not less than 1;

[0056] The write flag signal generation unit 2 is configured to output a write flag signal according to the received level signal and communication end flag signal under the first clock; the write flag signal is configured to be set to an effective state and maintained when both the level signal and the communication end flag signal are in an effective state in a case of being in an invalid state;

[0057] The synchronization unit 3 is used to synchronize the write flag signal under the second clock to obtain a synchronization signal, so that the write enable signal generation unit 4 can perform edge extraction according to the synchronization signal to generate a write enable signal under the second clock; wherein, the first clock and the second clock are asynchronous clocks.

[0058] In this embodiment, the cross-clock domain communication circuit can be applied to the cross-clock domain data communication between the first module under the first clock and the second module under the second clock in an electronic device. Here, the first clock and the second clock are asynchronous clocks, which means that the clock frequencies corresponding to the first clock and the second clock are different, and the phase relationship between the first clock and the second clock is not fixed. With the help of this cross-clock domain communication circuit, reliable writing of target data can be achieved; specifically, the first clock can be generated by a corresponding first clock signal generation circuit, and the specific structure of the first clock signal generation circuit is not particularly limited here; the second clock can be generated by a corresponding second clock signal generation circuit, and the structure of the second clock signal generation circuit is not particularly limited here; more specifically, the first clock here can be a communication clock, and the second clock can be a system clock. The clock frequency of the communication clock is higher than the clock frequency of the system clock and there is no fixed phase relationship between the two.

[0059] Specifically, when an instruction is received under the first clock and it is determined that the instruction is a write communication instruction by decoding the instruction, the original write enable signal is in an effective state; otherwise, the original write enable signal is in an invalid state. Please refer to Figure 2 , Figure 2 which is a schematic diagram of the level waveform changes of various signals in a cross-clock domain communication circuit provided by the present invention. It should be noted that Figure 2 in order to show various situations of the level waveform changes as much as possible, part of the level schematic of each signal is omitted in the form of a wavy line; Figure 2 in which rtxclk represents the first clock and sysclk represents the second clock. It can be seen that the clock frequency corresponding to the first clock rtxclk is higher than the clock frequency corresponding to the second clock sysclk; the original write enable signal is represented by wen_rtx. Being in an effective state means that the level state corresponding to the original write enable signal wen_rtx is 1, and being in an invalid state means that the level state corresponding to the original write enable signal wen_rtx is 0.

[0060] The write communication instruction is used to indicate writing target data under the first clock into a register under the second clock. For this cross-clock-domain communication, when the write communication instruction is received, the target data is written into the cache under the first clock. A single write communication instruction may indicate that N bytes of target data need to be written this time. The communication end flag signal is used to indicate whether the write communication instruction has ended and whether the N bytes of target data have been written into the cache. This communication end flag signal can specifically come from the main control unit. The main control unit receives the write communication instruction through the communication interface, and the communication process essentially follows different communication protocols, so there is a corresponding end flag signal, such as the chip select signal for serial communication or the stop bit signal for I2C communication (Inter-Integrated Circuit, two-wire serial communication). Based on the end flag signal, it can be determined whether the write instruction has ended; the level expansion here is used to make the output level signal become valid and last for a period of time after the original write enable signal is in the valid state, and the level state of the level signal is controlled by the change of the level states of the original write enable signal and the communication end flag signal. Further, the level expansion is essentially to ensure that even if there are multiple bytes of target data to be written, the valid state of the level signal can be maintained long enough to ensure that it can be reliably collected later for setting the write flag signal. As Figure 2 shown Figure 2 in which the communication end flag signal is represented by end_flag. Being in the valid state means that the level state corresponding to the communication end flag signal end_flag is 1, and being in the invalid state means that the level state corresponding to the communication end flag signal end_flag is 0; the level signal is represented by wr_level. Being in the valid state means that the level state corresponding to the level signal wr_level is 1, and being in the invalid state means that the level state corresponding to the level signal wr_level is 0.

[0061] The write flag signal generation unit 2 outputs a write flag signal under the first clock. And when the write flag signal is in its own invalid state, it is set to the valid state when both the level signal and the communication end flag signal are in the valid state, and then maintains this valid state until it is converted and reset to the invalid state by the state reset unit later in response to the next write communication instruction, or until it is reset to the invalid state by the reset unit later in response to the second write communication instruction adjacent to the first write communication instruction. See the specific description in the following embodiments, which will not be elaborated here; please refer to Figure 2, if the write flag signal is represented by wr_ctrl, being in the valid state means that the write flag signal wr_ctrl is set so that the corresponding level state is 1, and being in the invalid state means that the level state corresponding to the write flag signal wr_ctrl is 0; it can be understood that since the write flag signal wr_ctrl in the invalid state is only valid when both the level signal wr_level and the communication end flag signal end_flag are in the valid state to initiate the write operation, it also helps prevent the communication end flag signal unrelated to the current write communication instruction from wrongly starting the write process.

[0062] It should also be noted that according to the generated write enable signal in the valid state, N bytes of target data are written from the cache into the register at the second clock, so that the target data at the first clock is written into the register at the second clock; as Figure 2 shown, if the write enable signal is represented by wen_sys, being in the valid state means that the level state corresponding to the write enable signal wen_sys is 1, and being in the invalid state means that the level state corresponding to the write enable signal wen_sys is 0.

[0063] In addition, for the determination of the specific writing time of N bytes of target data, preferably, it can be considered as the time when the communication end flag signal is received. Of course, it can also be considered as the time when the write enable signal in the valid state is generated (the specific calculation method of this time is described in the following embodiments), and no special limitation is made here.

[0064] In summary, the present application provides a cross-clock domain communication circuit, which does not require an additional high-frequency clock to be started, helping to reduce power consumption; when the write communication instruction has ended and all N bytes of target data have been written into the cache, a communication end flag signal is generated, and the time when the communication instruction end flag signal is received is determined, so as to help reasonably determine the writing time of multiple bits of data at the second clock accordingly, and it can ensure that the writing times corresponding to multiple bits of data in one communication are the same, which is beneficial to reliable communication in the cross-clock domain in practical applications.

[0065] Based on the above embodiments:

[0066] In some embodiments, the level expansion unit 1 includes a trigger logic circuit 11 and a first flip-flop D1;

[0067] The first input terminal of the trigger logic circuit 11 is used to receive the original write enable signal, the second input terminal is used to receive the communication end flag signal, the third input terminal is connected to the data output terminal of the first flip-flop D1, and the common connection end is connected to the write flag signal generation unit 2. The output terminal is connected to the data input terminal of the first flip-flop D1, and is used to output a first level when the original write enable signal changes from an invalid state to a valid state, and maintain the output of the first level until the communication end flag signal changes from a valid state to an invalid state and then output a second level;

[0068] The clock signal input terminal of the first flip-flop D1 is connected to the first clock, and is used to output a level signal in a valid state when receiving the first level, and output a level signal in an invalid state when receiving the second level.

[0069] In this embodiment, the first flip-flop D1 here can be a D flip-flop; when receiving a write communication instruction, the original write enable signal changes from an invalid state to a valid state. At this time, the trigger logic circuit 11 outputs a first level. Specifically, the first level here is a high level; the first level is maintained when the original write enable signal changes from the valid state to the invalid state and the communication end flag signal is still in the invalid state; the first level is still maintained when the communication end flag signal changes from the invalid state to the valid state; and a second level is output when the communication end flag signal changes from a valid state to an invalid state, and the second level here is a low level.

[0070] Corresponding to Figure 2 , when the original write enable signal wen_rtx is in the valid state for the first time, the level state of the original write enable signal wen_rtx changes from 0 to 1, and the level state of the level signal wr_level output by the data output terminal of the first flip-flop D1 is 1 and is maintained; when the level state of the subsequent communication end flag signal end_flag changes from 0 to 1, even if the level state of the original write enable signal wen_rtx is 0 at this time, through the circuit structure of the level expansion unit 1, the level state of the level signal wr_level can still be 1, so that the write flag signal generation unit 2 sets the write flag signal wr_ctrl at the rising clock edge under the first clock; when the level state of the communication end flag signal end_flag changes from 1 to 0, at the rising clock edge under the first clock, it is sampled by the first flip-flop D1, and the level state of the level signal wr_level changes from 1 to 0.

[0071] More specifically, please refer to Figure 3 , Figure 3 which is a schematic structural diagram of another cross-clock domain communication circuit provided by the present invention. Figure 3For the sake of simplicity, the first clock is represented by rtxclk, the second clock is represented by sysclk, the communication end flag signal is represented by end_flag, the original write enable signal is represented by wen_rtx, and the write enable signal is represented by wen_sys.

[0072] The trigger logic circuit 11 may include a sixth NOT gate U1, a seventh NOT gate U2, a fifth AND gate U3, and a second OR gate U4; the input terminal of the sixth NOT gate U1 is used to connect to the first input terminal of the second OR gate U4, and the common connection terminal is used as the first input terminal of the trigger logic circuit 11, and the output terminal is connected to the first input terminal of the fifth AND gate U3; the input terminal of the seventh NOT gate U2 is used as the second input terminal of the trigger logic circuit 11, and the output terminal is connected to the second input terminal of the fifth AND gate U3; the third input terminal of the fifth AND gate U3 is used as the third input terminal of the trigger logic circuit 11, and the output terminal is connected to the second input terminal of the second OR gate U4; the output terminal of the second OR gate U4 is used as the output terminal of the trigger logic circuit 11.

[0073] It can be seen that through the above settings, the function of the trigger logic circuit 11 can be reliably realized.

[0074] In some embodiments, the write flag signal generation unit 2 includes a first AND gate U5, a first NOT gate U6, a second AND gate U7, a first OR gate U8, and a second flip-flop D2;

[0075] The first input terminal of the first AND gate U5 is connected to the output terminal of the level expansion unit 1, the second input terminal is used to receive the communication end flag signal, and the output terminal is respectively connected to the input terminal of the first NOT gate U6 and the first input terminal of the first OR gate U8;

[0076] The first input terminal of the second AND gate U7 is connected to the data output terminal of the second flip-flop D2, and the common connection terminal is connected to the synchronization unit 3. The second input terminal is connected to the output terminal of the first NOT gate U6, and the output terminal is connected to the second input terminal of the first OR gate U8;

[0077] The data input terminal of the second flip-flop D2 is connected to the output terminal of the first OR gate U8, and the clock signal input terminal is connected to the first clock.

[0078] In this embodiment, the second flip-flop D2 here may be a D flip-flop. Specifically, for the circuit structure, please refer to Figure 3 As shown, from the perspective of the implementation principle, on the basis of this circuit structure, refer to Figure 2 As shown, when the level state of the write flag signal wr_ctrl is 0, when the level state of the level signal wr_level is 1 and the level state of the communication end flag signal end_flag is 1, at the rising clock edge of the first clock, the write flag signal wr_ctrl can be reliably set and maintained to start the write synchronization operation.

[0079] In some embodiments, the synchronization unit 3 includes M third flip - flops connected in sequence, where M is an integer not less than 3;

[0080] The clock signal input terminals of each third flip - flop are connected to the second clock. The data input terminal of the first third flip - flop is connected to the data output terminal of the second flip - flop D2. The data output terminal of the (M - 1)th third flip - flop is respectively connected to the data input terminal of the Mth third flip - flop and the first input terminal of the write enable signal generation unit 4. The data output terminal of the Mth third flip - flop is connected to the second input terminal of the write enable signal generation unit 4.

[0081] In this embodiment, the synchronization unit 3 includes M third flip - flops connected in sequence. The third flip - flop can be a D flip - flop. Preferably, M = 3 can be set. On the one hand, it is beneficial to ensure the stable and reliable generation of the subsequent write enable signal and avoid metastability problems. On the other hand, it is beneficial to ensure the reliable synchronization of the write synchronization signal under the second clock with the least number of third flip - flops, avoiding wasting resources by using more third flip - flops. Specifically, please refer to Figure 3 , Figure 3 which takes M = 3 as an example for illustration. That is, the synchronization unit 3 includes the first third flip - flop D3, the second third flip - flop D4, and the third third flip - flop D5. Please further refer to Figure 2 Let the first signal output from the data output terminal of the first third flip - flop D3 be represented as d1_sys, the second signal output from the data output terminal of the second third flip - flop D4 be represented as d2_sys, and the third signal output from the data output terminal of the third third flip - flop D5 be represented as d3_sys. Then, under the second clock, each third flip - flop performs input acquisition and output when the rising clock edge arrives. Figure 2 shows the waveform change schematic of the first signal d1_sys, the second signal d2_sys, and the third signal d3_sys over time.

[0082] In some embodiments, the write enable signal generation unit 4 includes a second NOT gate U9 and a third AND gate U10;

[0083] The input terminal of the second NOT gate U9 serves as the second input terminal of the write enable signal generation unit 4;

[0084] The first input terminal of the third AND gate U10 serves as the first input terminal of the write enable signal generation unit 4. The second input terminal is connected to the output terminal of the second NOT gate U9, and the output terminal is used to output the write enable signal under the second clock generated.

[0085] Specifically, the synchronization signal includes the above - mentioned second signal d2_sys and third signal d3_sys. Here, the write enable signal is a pulse - shaped signal; refer to Figure 2As shown, when the original write enable signal wen_rtx is in the valid state for the first time, it indicates that there is a write communication instruction. The level expansion unit 1 expands it into a level signal wr_level at the first clock. When the level states of both the level signal wr_level and the communication end flag signal end_flag are 1, the write flag signal wr_ctrl is set, that is, the level state changes from 0 to 1. At the second clock, when the rising clock edge arrives, it is captured by the first third flip-flop D3, and then the level state of the first signal d1_sys changes to 1. When the next rising clock edge arrives, it is captured by the second third flip-flop D4, and then the level state of the second signal d2_sys changes to 1. At this time, through the trigger logic circuit 11 formed by the second NOT gate U9 and the third AND gate U10, the write enable signal wen_sys becomes valid, that is, the level state of the write enable signal wen_sys is 1, and the target data is written from the cache into the register. When the next rising clock edge arrives and is captured by the third third flip-flop D5, the level state of the third signal d3_sys changes to 1, and the level state of the write enable signal wen_sys returns to 0.

[0086] It can be understood that, referring to Figure 2 it can be known that, based on the above circuit structure, the time when the valid write enable signal is generated = the time when the communication end flag signal is received + the time difference. This time difference = two cycles at the second clock + the error, and this error can be controlled within one cycle at the second clock. The reason for the existence of a certain error is that the level state transition occurs at the moment when the rising clock edge arrives.

[0087] In some embodiments, the cross-clock domain communication circuit further includes a state reset unit 5;

[0088] The input end of the state reset unit 5 is connected to the data output end of the Mth third flip-flop, and the output end is connected to the third input end of the second AND gate U7, and is used to synchronize the received synchronous signal output by the Mth third flip-flop at the first clock to output a state reset signal; wherein, the state reset signal becomes valid after synchronization when the synchronous signal is in the valid state, so as to convert the currently valid write flag signal into an invalid state.

[0089] In this embodiment, further considering that the write flag signal wr_ctrl remains in the valid state after being set, therefore, when the data writing is completed, it should also be converted so that the write flag signal wr_ctrl is restored and converted into an invalid state, so as to normally respond to the next write communication instruction signal. Therefore, the above state reset unit 5 is set.

[0090] In addition, since the reset terminals of the third flip - flops are active - low, the state reset signal being in the active state here means that the level state of the state reset signal is low; and the state reset signal is in the inactive state when the synchronization signal is in the inactive state. The state reset signal being in the inactive state here means that the level state of the state reset signal is high; the synchronization signal being in the active state here means that the level state of the third signal d3_sys is high, and the synchronization signal being in the inactive state means that the level state of the third signal d3_sys is low.

[0091] It should also be noted that, referring to Figure 3 , when the synchronization unit 3 includes three third flip - flops connected in sequence, the input end of the state reset unit 5 is specifically connected to the data output end of the third third flip - flop D5.

[0092] In some embodiments, the state reset unit 5 includes a third NOT gate U11, a fourth NOT gate U12, a fourth AND gate U13, and S fourth flip - flops, where S is an integer not less than 3;

[0093] The S fourth flip - flops are connected in sequence, and the clock signal input terminals of each fourth flip - flop are connected to the first clock. The data input terminal of the first fourth flip - flop serves as the input end of the state reset unit 5. The data output end of the (S - 1)th fourth flip - flop is respectively connected to the data input terminal of the Sth fourth flip - flop and the first input terminal of the fourth AND gate U13. The data output end of the Sth fourth flip - flop is connected to the input end of the third NOT gate U11;

[0094] The second input terminal of the fourth AND gate U13 is connected to the output end of the third NOT gate U11, and the output end is connected to the input end of the fourth NOT gate U12;

[0095] The output end of the fourth NOT gate U12 serves as the output end of the state reset unit 5.

[0096] In this embodiment, through the above - mentioned settings, the function of the state reset unit 5 can be reliably implemented. Here, the fourth flip - flop can be a D flip - flop. Preferably, S = 3 can be set. On the one hand, it is beneficial to ensure the stable and reliable generation of the fourth signal output to the third NOT gate U11 and avoid metastability problems. On the other hand, it is beneficial to ensure the reliable synchronization of the third signal d3_sys under the first clock with the minimum number of fourth flip - flops and avoid wasting resources by using more fourth flip - flops; please refer to Figure 3 , Figure 3 which takes S = 3 as an example for illustration, that is, it includes the first fourth flip - flop D6, the second fourth flip - flop D7, and the third fourth flip - flop D8. Please further refer to Figure 2, the fifth signal output from the data output terminal of the first fourth flip - flop D6 is represented as d1_rtx, the sixth signal output from the data output terminal of the second fourth flip - flop D7 is represented as d2_rtx, and the fourth signal output from the data output terminal of the third fourth flip - flop D8 is represented as d3_rtx. Then, at the first clock, each fourth flip - flop performs input acquisition and output when the rising clock edge arrives. Figure 2 Shows the waveform change schematic of the fifth signal d1_rtx, the sixth signal d2_rtx, and the fourth signal d3_rtx over time.

[0097] In addition, Figure 2 in it, the seventh signal output from the output terminal of the fourth AND gate U13 is represented as pd_wr. When the seventh signal pd_wr is in the valid state (i.e., its level state is 1), the status reset signal output from the fourth NOT gate U12 is in the valid state (i.e., its level state is 0). Thus, at the first clock, when the rising clock edge arrives, the write flag signal wr_ctrl is converted to the invalid state, that is, the level state of the write flag signal wr_ctrl is converted to 0; and after the write flag signal wr_ctrl is converted to the low level, it is sequentially transmitted to the first signal d1_sys, the second signal d2_sys, the third signal d3_sys, the fifth signal d1_rtx, the sixth signal d2_rtx, and the fourth signal d3_rtx, and all write - related signals are restored to the low level, waiting to respond to the next write communication instruction.

[0098] In some embodiments, the cross - clock - domain communication circuit further includes a reset unit;

[0099] The reset terminal of the reset unit is used to receive the original write enable signal, the input terminal is used to receive the reference signal bias, the first output terminal is connected to the reset terminal of the write flag signal generation unit 2, and the second output terminal is connected to the reset terminal of the synchronization unit 3. It is used to output the first reset signal through its first output terminal according to the original write enable signal received by its reset terminal at the second clock, and output the second reset signal through its second output terminal according to the original write enable signal and the reference signal;

[0100] Among them, the first reset signal is in the invalid state when the original write enable signal is in the invalid state, and is in the valid state when the original write enable signal is in the valid state to reset the write flag signal generation unit 2, so as to reset the currently valid write flag signal to the invalid state;

[0101] The second reset signal is in the invalid state after synchronization when the original write enable signal is in the invalid state, and is in the valid state when the original write enable signal is in the valid state to reset the synchronization unit 3, so that the synchronization unit 3 re - synchronizes the write flag signal at the second clock.

[0102] In this embodiment, further considering the actual application, when two write communication instructions are separated by a sufficiently long time, that is, when the second write communication instruction arrives after the state reset unit 5 converts the write flag signal wr_ctrl, the above method can be used for accurate response. However, there is still a situation where two adjacent write communication instructions are close to each other, that is, the synchronization process of the first write communication instruction is still in progress when the second write communication instruction arrives. At this time, according to the second method in the current related technologies, the second write communication instruction cannot be reliably responded to, that is, the write synchronization process cannot be reliably triggered for the second write communication instruction, making it impossible to reliably write the latest target data corresponding to the second write communication instruction into the register. In the present application, further, when there are two adjacent write communication instructions, the above settings can be used to quickly reset the synchronization unit 3 and the write flag signal generation unit 2 to ensure a reliable response to the second write communication instruction, and then ensure that the latest target data is written into the register, so that the present solution can support the effective execution of multiple write communication instructions with any time interval without generating recovery time or removal time conflicts.

[0103] It should be noted that when the original write enable signal is in an invalid state, the first reset signal is in an invalid state. At this time, the first reset signal does not affect the function of the write flag signal generation unit 2, that is, it does not affect the output of the write flag signal. When the original write enable signal is in an effective state, the first reset signal is in an effective state. At this time, the first reset signal resets the write flag signal generation unit 2 so that the currently effective write flag signal is reset to an invalid state to better respond to the second write communication instruction and re-output the corresponding write flag signal. More specifically, when the write flag signal generation unit 2 includes a first AND gate U5, a first NOT gate U6, a second AND gate U7, a first OR gate U8, and a second flip-flop D2, the reset terminal of the second flip-flop D2 serves as the reset terminal of the write flag signal generation unit 2. In addition, since the reset terminal of the second flip-flop D2 is active low, when the level state of the original write enable signal is high when it is in an effective state, the level state of the first reset signal is low when it is in an effective state; when the level state of the original write enable signal is low when it is in an invalid state, the level state of the first reset signal is high when it is in an invalid state.

[0104] Further, when the original write enable signal is in an invalid state, the second reset signal is in an invalid state, and at this time, the level state of the second reset signal is the same as the level state corresponding to the reference signal bias, and at this time, it does not affect the synchronization function of the synchronization unit 3 for the write flag signal. When the original write enable signal is in an effective state, the second reset signal is in an effective state, and at this time, the level state of the second reset signal is opposite to the level state corresponding to the reference signal bias, and the synchronization unit 3 is reset.

[0105] Specifically, the synchronization unit 3 may include M third flip-flops. The output terminal of the second reset unit may be connected to the reset terminals of the respective third flip-flops. Since the reset terminal of the third flip-flop is active low, the reference signal bias may be a signal maintained at a high level at this time; when the second reset signal is in an active state, its level state is low, and when the second reset signal is in an inactive state, its level state is high.

[0106] Please refer to Figure 2 , Figure 2 In the figure, rstn_sync represents the second reset signal. After the first write communication instruction (the arrival of the first write communication instruction here means that the original write enable signal wen_rtx is in an active state for the first time and the corresponding level state is 1), when the second write communication instruction has not arrived, the original write enable signal wen_rtx is in an inactive state and the corresponding level state is 0, and the level state of the second reset signal rstn_sync is 1. At this time, the synchronization function of each third flip-flop is not affected; when the adjacent second write communication instruction arrives, the original write enable signal wen_rtx is in an active state and the corresponding level state is 1. At this time, the level state of the second reset signal rstn_sync is 0 to reset the first signal d1_sys, the second signal d2_sys, and the third signal d3_sys. Of course, at this time, the level state of the first reset signal is also 0 to reset the second flip-flop D2 and make the level state of the write flag signal wr_ctrl reset to 0, so as to respond to this write communication instruction and facilitate the generation of the corresponding write enable signal wen_sys at the second clock subsequently.

[0107] In some embodiments, the reset unit includes a fifth NOT gate and T fifth flip-flops, where T is an integer not less than 2;

[0108] The T fifth flip-flops are connected in sequence, and the clock signal input terminals of the respective fifth flip-flops are connected to the second clock. The reset terminals of the respective fifth flip-flops are connected to the output terminal of the fifth NOT gate, and the common connection end is used as the first output terminal of the reset unit;

[0109] The input terminal of the fifth NOT gate is used as the reset terminal of the reset unit; the data input terminal of the first fifth flip-flop is used as the input terminal of the reset unit, and the output terminal of the T-th fifth flip-flop is used as the second output terminal of the reset unit.

[0110] Specifically, the fifth flip-flop here can be a D flip-flop. When the synchronization unit 3 includes M third flip-flops, the output terminal of the T-th fifth flip-flop is connected to the reset terminals of the third flip-flops. When the write flag signal generation unit 2 includes a first AND gate U5, a first NOT gate U6, a second AND gate U7, a first OR gate U8, and a second flip-flop D2, the reset terminals of the fifth flip-flops are connected to the output terminal of the fifth NOT gate, and the common connection end is connected to the reset terminal of the second flip-flop D2. Preferably, T = 2 to ensure stable and reliable signal output and avoid resource waste; please refer to Figure 3 , Figure 3 Taking T = 3 as an example, the structure of the second reset unit is illustrated, that is, it includes a first fifth flip-flop D9 and a second fifth flip-flop D10. Similarly, Figure 2 the waveform change of the second reset signal rstn_sync in

[0111] is also corresponding to T = 2. Since it takes time for the fifth flip-flop to achieve signal synchronization, after the original write enable signal wen_rtx returns to the invalid state, the second reset signal rstn_sync needs to go through two rising edges of the second clock before releasing the reset. Here, releasing the reset means that the second reset signal rstn_sync changes from the valid state to the invalid state, that is, from low level to high level. Figure 3 This is a schematic illustration of this situation.

[0112] It can be seen that the above settings achieve the asynchronous reset of each fifth flip-flop under the second clock through the original write enable signal wen_rtx under the first clock, and at the same time, combined with the synchronous release under the second clock, the synchronization unit 3 is reset to ensure the resynchronization of the write flag signal under the second clock.

[0113] Please refer to Figure 4 , Figure 4 which is a flowchart of a data reading and writing method provided by the present invention.

[0114] This data reading and writing method is applied to an electronic device, and the electronic device includes the cross-clock domain communication circuit as described above; this data reading and writing method includes:

[0115] S11: When receiving a write communication instruction, write the target data into the cache under the first clock, and based on the write enable signal generated by the cross-clock domain communication circuit, write the target data from the cache into the register under the second clock;

[0116] S12: When receiving a read communication instruction, obtain the write flag signal output by the write flag signal generation unit in the cross-clock domain communication circuit;

[0117] S13: Determine whether the write flag signal is in an effective state; if so, proceed to S14; if not, proceed to S15;

[0118] S14: In response to the read communication instruction, perform data reading from the cache;

[0119] S15: In response to the read communication instruction, perform data reading from the register.

[0120] For the introduction of the data reading and writing method provided in this application, please refer to the embodiments of the above cross-clock domain communication circuit, which will not be elaborated here.

[0121] It can be understood that when facing cross-clock domain communication, in the methods of the current related technologies, when there is a write communication instruction, data writing is performed first. However, in the case of two adjacent write communication instructions, since the write synchronization process cannot be reliably triggered as described above, the data stored in the register may be the old target data. Then, in response to the immediately following read communication instruction, old data may be read. In this application, relying on the above method, data writing is implemented using the cross-clock domain communication circuit, and data reading can also be responded to during the process, that is, it is determined whether the data writing is completed according to whether the write flag signal is in an effective state, so as to determine the way to respond to the immediately following read communication instruction.

[0122] Specifically, when the write flag signal is in an effective state, it indicates that the data writing is not completed yet, and the latest target data is stored in the cache. Therefore, in response to the read communication instruction, data is read from the cache; when the write flag signal is in an invalid state, it indicates that the data writing is completed, and the latest target data has been stored in the register. Therefore, in response to the read communication instruction, data is read from the register. It can be seen that through the above settings, it can be ensured that the latest target data is always obtained, avoiding misreading data, facilitating ensuring data consistency, and being able to support read communication instructions at any time interval after the write communication instruction.

[0123] In addition, in actual operation, the write flag signal wr_ctrl can be continuously obtained and used as the write cache flag signal buf_idx, and then it is determined whether the write cache flag signal buf_idx is in an effective state. If so, in response to the read communication instruction, data is read from the cache; if not, in response to the read communication instruction, data is read from the register. As Figure 2 shown, the waveform change trends of the write flag signal wr_ctrl and the write cache flag signal buf_idx are the same.

[0124] In this specification, the various embodiments are described in a progressive manner. Each embodiment focuses on the differences from other embodiments, and the same or similar parts among the embodiments can be referred to each other. For the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple. For the relevant parts, reference can be made to the description in the method section. Relative terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements not only includes those elements, but also includes other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising one" does not exclude the existence of additional identical elements in the process, method, article or device comprising the element.

[0125] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present invention. Various modifications to these embodiments will be obvious to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but will be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A cross-clock domain communication circuit, characterized in that It includes a level expansion unit, a write flag signal generation unit, a synchronization unit, and a write enable signal generation unit connected in sequence; The level expansion unit is configured to perform level expansion according to the received original write enable signal and communication end flag signal at the first clock to output a level signal; The original write enable signal is in an active state when a write communication instruction is received at the first clock, and the communication end flag signal is in an active state when the write communication instruction has ended and the target data of N bytes has been written into the buffer, where N is an integer not less than 1; The write flag signal generation unit is configured to output a write flag signal according to the received level signal and communication end flag signal at the first clock; the write flag signal is configured to be set to an active state and maintained when both the level signal and the communication end flag signal are in an active state in the case of being in an inactive state; The synchronization unit is configured to synchronize the write flag signal at the second clock to obtain a synchronization signal, so that the write enable signal generation unit performs edge extraction according to the synchronization signal to generate a write enable signal at the second clock; wherein, the first clock and the second clock are asynchronous clocks; The level expansion unit includes a trigger logic circuit and a first flip-flop; The first input terminal of the trigger logic circuit is configured to receive the original write enable signal, the second input terminal is configured to receive the communication end flag signal, the third input terminal is connected to the data output terminal of the first flip-flop and the common connection end is connected to the write flag signal generation unit, and the output terminal is connected to the data input terminal of the first flip-flop, and is configured to output a first level when the original write enable signal changes from an inactive state to an active state, and maintain the output of the first level until the communication end flag signal changes from an active state to an inactive state and then output a second level; The clock signal input terminal of the first flip-flop is connected to the first clock, and is configured to output a level signal in an active state when receiving the first level, and output a level signal in an inactive state when receiving the second level; The trigger logic circuit includes a sixth NOT gate, a seventh NOT gate, a fifth AND gate, and a second OR gate; the input terminal of the sixth NOT gate is configured to be connected to the first input terminal of the second OR gate and the common connection end is used as the first input terminal of the trigger logic circuit, and the output terminal is connected to the first input terminal of the fifth AND gate; the input terminal of the seventh NOT gate is used as the second input terminal of the trigger logic circuit, and the output terminal is connected to the second input terminal of the fifth AND gate; the third input terminal of the fifth AND gate is used as the third input terminal of the trigger logic circuit, and the output terminal is connected to the second input terminal of the second OR gate; the output terminal of the second OR gate is used as the output terminal of the trigger logic circuit.

2. The cross-clock domain communication circuit according to claim 1, wherein The write flag signal generation unit includes a first AND gate, a first NOT gate, a second AND gate, a first OR gate, and a second flip-flop; The first input terminal of the first AND gate is connected to the output terminal of the level expansion unit, the second input terminal is used to receive the communication end flag signal, and the output terminal is respectively connected to the input terminal of the first NOT gate and the first input terminal of the first OR gate; The first input terminal of the second AND gate is connected to the data output terminal of the second flip-flop, and the common connection terminal is connected to the synchronization unit. The second input terminal is connected to the output terminal of the first NOT gate, and the output terminal is connected to the second input terminal of the first OR gate; The data input terminal of the second flip-flop is connected to the output terminal of the first OR gate, and the clock signal input terminal is connected to the first clock.

3. The cross-clock domain communication circuit according to claim 2, wherein The synchronization unit includes M third flip-flops connected in sequence, where M is an integer not less than 3; The clock signal input terminals of each of the third flip-flops are connected to the second clock. The data input terminal of the first third flip-flop is connected to the data output terminal of the second flip-flop. The data output terminal of the (M - 1)-th third flip-flop is respectively connected to the data input terminal of the M-th third flip-flop and the first input terminal of the write enable signal generation unit. The data output terminal of the M-th third flip-flop is connected to the second input terminal of the write enable signal generation unit.

4. The cross-clock domain communication circuit according to claim 3, wherein, The write enable signal generation unit includes a second NOT gate and a third AND gate; The input terminal of the second NOT gate serves as the second input terminal of the write enable signal generation unit; The first input terminal of the third AND gate serves as the first input terminal of the write enable signal generation unit. The second input terminal is connected to the output terminal of the second NOT gate, and the output terminal is used to output the generated write enable signal under the second clock.

5. The cross-clock domain communication circuit according to claim 3, wherein The cross-clock domain communication circuit further includes a state reset unit; The input terminal of the state reset unit is connected to the data output terminal of the M-th third flip-flop, and the output terminal is connected to the third input terminal of the second AND gate. It is used to synchronize the received synchronization signal output by the M-th third flip-flop under the first clock to output a state reset signal. Among them, the state reset signal is in an effective state after synchronization when the synchronization signal is in an effective state, so as to convert the currently effective write flag signal into an ineffective state.

6. The cross-clock domain communication circuit according to claim 5, wherein The state reset unit includes a third NOT gate, a fourth NOT gate, a fourth AND gate, and S fourth flip-flops, where S is an integer not less than 3; The S fourth flip-flops are connected in sequence, and the clock signal input terminals of each of the fourth flip-flops are connected to the first clock. The data input terminal of the first fourth flip-flop serves as the input terminal of the state reset unit. The data output terminal of the (S - 1)-th fourth flip-flop is respectively connected to the data input terminal of the S-th fourth flip-flop and the first input terminal of the fourth AND gate. The data output terminal of the S-th fourth flip-flop is connected to the input terminal of the third NOT gate; The second input terminal of the fourth AND gate is connected to the output terminal of the third NOT gate, and the output terminal is connected to the input terminal of the fourth NOT gate; The output terminal of the fourth NOT gate serves as the output terminal of the state reset unit.

7. The cross-clock domain communication circuit according to any one of claims 1 to 6, characterized in that The cross-clock domain communication circuit further includes a reset unit; The reset terminal of the reset unit is used to receive the original write enable signal, the input terminal is used to receive a reference signal, the first output terminal is connected to the reset terminal of the write flag signal generation unit, and the second output terminal is connected to the reset terminal of the synchronization unit. It is used to output a first reset signal through its first output terminal according to the original write enable signal received by its own reset terminal under the second clock, and output a second reset signal through its second output terminal according to the original write enable signal and the reference signal; Among them, the first reset signal is in an invalid state when the original write enable signal is in an invalid state, and is in a valid state when the original write enable signal is in a valid state to reset the write flag signal generation unit, so as to reset the currently valid write flag signal to an invalid state; The second reset signal is synchronized and remains in an invalid state when the original write enable signal is in an invalid state, and is in a valid state when the original write enable signal is in a valid state to reset the synchronization unit, so that the synchronization unit re-synchronizes the received write flag signal under the second clock.

8. The cross-clock domain communication circuit according to claim 7, characterized in that, The reset unit includes a fifth NOT gate and T fifth flip-flops, where T is an integer not less than 2; The T fifth flip-flops are connected in sequence, and the clock signal input terminals of each fifth flip-flop are connected to the second clock. The reset terminals of each fifth flip-flop are connected to the output terminal of the fifth NOT gate, and the common connection end is used as the first output terminal of the reset unit; The input terminal of the fifth NOT gate is used as the reset terminal of the reset unit; The data input terminal of the first fifth flip-flop is used as the input terminal of the reset unit, and the output terminal of the T-th fifth flip-flop is used as the second output terminal of the reset unit.

9. A data reading and writing method, characterized in that, Applied to an electronic device, the electronic device includes the cross-clock domain communication circuit according to any one of claims 1 to 8; the data reading and writing method includes: When a write communication instruction is received, write the target data into the cache under the first clock, and based on the write enable signal generated by the cross-clock domain communication circuit, write the target data from the cache into the register under the second clock; When a read communication instruction is received, obtain the write flag signal output by the write flag signal generation unit in the cross-clock domain communication circuit; Judge whether the write flag signal is in a valid state; If so, perform data reading from the cache in response to the read communication instruction; If not, perform data reading from the register in response to the read communication instruction.

Citation Information

Patent Citations

  • Cross-clock domain synchronization circuit and method

    CN113615088A

  • Asynchronous FIFO circuit

    CN117406954A