# Patent

## Title
Latency counter having frequency detector and latency counting method thereof

## Abstract

The present invention discloses a latency counter applied to a memory, for delaying a memory accessing control signal. The latency counter includes: a clock delay module for applying at least one delay amount to the input clock to generate a delayed input clock; a frequency detector for detecting a frequency of a specific signal of the memory to set the delay amount; and a delay control signal generating module for generating a first delayed control signal and a second delayed control signal corresponding to the delayed input clock and the memory accessing control signal respectively, wherein timing of the first delayed control signal is earlier than timing of the second delayed control signal.

## Background
BACKGROUND OF THE INVENTION
1. Field of the Invention
The present invention relates to a latency counter, which is applied to a memory, and more particularly relates to a latency counter having a frequency detector, and a method thereof.
2. Description of the Prior Art
In recent times, random access memory (RAM) has become an increasingly important component in modern electronic devices. In order to increase the writing/reading data rate of the random access memory (RAM), the technique of double data rate (DDR) has become more and more important. A random access memory that utilizes the technique of double data rate is known as a double data rate random access memory (DDR RAM). Normally, when a microprocessor is ready to access a memory, the microprocessor transmits a reading signal to the control circuit of the memory, wherein the reading signal is synchronized with an external clock. In addition, according to prior art, a latency counter is coupled between the microprocessor and the control circuit, for providing a delay time (delay clock period number) to the reading signal in order to guarantee that there is enough time for the memory to access the specific address. Furthermore, because of the wide operating frequency range of the memory, the latency counter needs to have a different delay clock period number at a high operating frequency from that at a low operating frequency. In other words, when operating at the high operating frequency, the delay clock period number should be larger, but when operating at the low operating frequency, the delay clock period number should be smaller. However, the intrinsic delay of the circuit will affect the synchronization between the external clock and the reading signal. In other words, when operating at the high operating frequency, the intrinsic delay of the circuit may be higher than the clock period of the high operating frequency; thus the latency counter may output an error latency delay when the reading signal has slight non-synchronicity with the external clock, and the control circuit will read the error signal consequently. Furthermore, the latency counter designed for being utilized at a high memory operating frequency having a larger delay period number is not appropriate to be used at a low memory operating frequency having a smaller delay period number.
SUMMARY OF THE INVENTION
Therefore, one of the objectives of the present invention is to provide a latency counter having a frequency detector for adjusting the delay period number, and a method thereof, to solve the above-mentioned problems.
According to an embodiment of the present invention, a latency counter is disclosed. The latency counter is applied to a memory for delaying a memory accessing control signal. The latency counter comprises: a clock delay module, a frequency detector, and a delay control signal generating module. The clock delay module is coupled to an input clock for applying at least one delay amount to the input clock to generate a delayed input clock; the frequency detector is coupled to the clock delay module for detecting a frequency of a specific signal of the memory to set the delay amount; and the delay control signal generating module is coupled to the delayed input clock and the memory accessing control signal, for generating a first delayed control signal and a second delayed control signal corresponding to the delayed input clock and the memory accessing control signal respectively; wherein timing of the first delayed control signal is earlier than timing of the second delayed control signal.
According to an embodiment of the present invention, a latency counting method is disclosed. The latency counting method is applied to a memory for delaying a memory accessing control signal, the method comprising: delaying an input clock of the memory to generate a delayed input clock according to a delay amount; detecting a frequency of a specific signal of the memory to set the delay amount; and generating a first delayed control signal and a second delayed control signal corresponding to the memory accessing control signal according to the delayed input clock and the memory accessing control signal respectively; wherein timing of the first delayed control signal is earlier than timing of the second delayed control signal.
These and other objectives of the present invention will no doubt become obvious to those of ordinary skill in the art after reading the following detailed description of the preferred embodiment that is illustrated in the various figures and drawings.



BRIEF DESCRIPTION OF THE DRAWINGS
FIG. 1 is a diagram illustrating a latency counter according to an embodiment of the present invention.
FIG. 2 is a timing diagram of the latency counter in FIG. 1 when operated at a high accessing frequency mode.
FIG. 3 is a timing diagram of the latency counter in FIG. 1 when operated at a low accessing frequency mode.
FIG. 4 is a flowchart illustrating a latency counting method according to an embodiment of the present invention.



DETAILED DESCRIPTION
Certain terms are used throughout the description and following claims to refer to particular components. As one skilled in the art will appreciate, electronic equipment manufacturers may refer to a component by different names. This document does not intend to distinguish between components that differ in name but not function. In the following description and in the claims, the terms “include” and “comprise” are used in an open-ended fashion, and thus should be interpreted to mean “include, but not limited to . . . ”. Also, the term “couple” is intended to mean either an indirect or direct electrical connection. Accordingly, if one device is coupled to another device, that connection may be through a direct electrical connection, or through an indirect electrical connection via other devices and connections.
Please refer to FIG. 1. FIG. 1 is a diagram illustrating a latency counter 100 applied to a memory, according to an embodiment of the present invention. The latency counter 100 is utilized for delaying a memory accessing control signal PAR as shown in FIG. 1. The latency counter 100 comprises a clock delay module 102, a frequency detector 104, and a delay control signal generating module 106. The clock delay module 102 is coupled to an input clock Vclk for applying a plurality of delay amounts D1, D2, D3 to the input clock Vclk to generate a plurality of delayed input clocks VDclk1, VDclk2, VDclk3 respectively. The frequency detector 104 is coupled to the clock delay module 102 for detecting a frequency fclk of a specific signal (the input clock Vclk) of the memory to set the delay amounts D1, D2, D3. In this embodiment, the input clock Vclk is the operating clock of the memory. The delay control signal generating module 106 is coupled to the delayed input clocks VDclk1, VDclk2, VDclk3, the input clock Vclk, and the memory accessing control signal PAR for generating a plurality of delayed control signals LT1 ̃LT7 corresponding to the memory accessing control signal PAR according to the delayed input clocks VDclk1, VDclk2, VDclk3, and the memory accessing control signal PAR; wherein timing of the first delayed control signal LT1 is earlier than timing of the second delayed control signal LT2, timing of the second delayed control signal LT2 is earlier than timing of the third delayed control signal LT3, and so on. According to the latency counter 100 of the present invention, the clock delay module 102 comprises a controllable clock delaying unit 102a for providing the delay amount D1 to the input clock Vclk in order to generate the delayed input clocks VDclk1; a controllable clock delaying unit 102b for providing the delay amount D2 to the input clock Vclk in order to generate the delayed input clocks VDclk2; and a controllable clock delaying unit 102c for providing the delay amount D3 to the input clock Vclk in order to generate the delayed input clocks VDclk3. The delay control signal generating module 106 comprises a registering device 106a, which is implemented by a flip-flop in this embodiment, for reading the memory accessing control signal PAR (data terminal D1) according to the triggering of the delayed input clock VDclk1 (clock terminal C1) to generate the delayed control signal LT1 (output terminal N1); a registering device 106b for reading the delayed control signal LT1 (data terminal D2) according to the triggering of the delayed input clock VDclk2 (clock terminal C2) to generate the delayed control signal LT2 (output terminal N2); and a registering device 106c for reading the delayed control signal LT2 (data terminal D3) according to the triggering of the delayed input clock VDclk3 (clock terminal C3) to generate the delayed control signal LT3 (output terminal N3). Please note that, in order to describe the spirit of the present invention more clearly, the delay control signal generating module 106 of the latency counter 100 further comprises registering devices 106d, . . . , 106g, wherein the clock terminals C4, C5, C6, C7 are coupled to the input clock Vclk, and the data terminals D4, D5, D6, D7 are coupled to the output terminals N3, N4, N5, N6 respectively, for generating the delayed control signal LT4, . . . , LT7 respectively, as shown in FIG. 1. Please note that the latency counter 100 of the present invention only utilizes three controllable clock delaying devices; however, in another embodiments, the circuit designer can also utilize any number of controllable clock delaying devices according to circuit requirements, and this modification also belongs within the scope of the present invention.
Normally, the operation of the memory may be set into a high accessing frequency mode (utilizing a higher memory clock) and a low accessing frequency mode (utilizing a lower memory clock). In high accessing frequency mode, the user always selects the delayed control signal with a larger delay amount in order to access the memory accurately, such as the delayed control signal LT5, LT6, or LT7. Therefore, when the frequency detector 104 detects that the frequency fh of the input clock Vclk is a high frequency, the frequency detector 104 will set the above mentioned three delay amounts D1, D2, D3 to be not equal to zero, wherein the values of D1, D2, D3 can be determined through the operating requirement of the memory. Please refer to FIG. 2. FIG. 2 is a timing diagram of the latency counter 100 in FIG. 1 when operating at the high accessing frequency mode. In this embodiment, if the latency counter 100 receives the first clock of the input clock Vclk (having clock period T) at time t1, then the memory accessing control signal PAR will be transmitted to the clock terminal C1 of the registering device 106a at time t2 after the first clock, and the clock terminal C1 of the registering device 106a will receive the delayed input clock VDclk1 at time t1+D1. Therefore, the output terminal N1 of the registering device 106a will output the delayed control signal LT1 at time t1+D1+D106a, as shown in FIG. 2, wherein D106a is the delay time of the registering device 106a. Then, because the controllable clock delaying unit 102b provides a delay amount D2 to the second clock of the input clock Vclk, the clock terminal C2 of the registering device 106b will receive the delayed input clock VDclk2 at time t1+T+D2. Therefore, the output terminal N2 of the registering device 106b will output the delayed control signal LT2 at time t1+T+D2+D106b, wherein D106b is the delay time of the registering device 106b. Similarly, because the controllable clock delaying unit 102c provides a delay amount D3 to the third clock of the input clock Vclk, the clock terminal C3 of the registering device 106c will receive the delayed input clock VDclk3 at time t1+2T+D3. Therefore, the output terminal N3 of the registering device 106c will output the delayed control signal LT3 at time t1+2T+D3+D106c, wherein D106c is the delay time of the registering device 106c. Then, the delayed control signal LT3 will be transmitted to the next stage data terminal D3 of the registering device 106d. At the same time, the clock terminal C3 of the registering device 106d waits for a next rising edge of the input clock Vclk to trigger the registering device 106d, which is the fourth clock of the input clock Vclk. The delayed control signal LT4 will then be outputted at time t1+3T+D106d, as shown in FIG. 2, wherein D106d is the delay time of the registering device 106d. Similarly, the delayed control signals LT5, LT6, and LT7 are generated at time t1+4T+D106e, t1+5T+D106f, and t1+6T+D106g respectively, wherein D106e, D106f, and D106g are the delay time of the registering devices 106e, 106f, and 106g respectively. The three delay amounts D1, D2, and D3 are different from each other, and when in the high accessing frequency mode, D1>D2>D3, as shown in FIG. 2.
On the other hand, when in the low accessing frequency mode, the user always selects the delayed control signal with a smaller delay amount, such as the delayed control signal LT2 or LT3. Therefore, when the frequency detector 104 detects that the frequency f1 of the input clock Vclk is a low frequency, the frequency detector 104 will set the above mentioned two delay amounts D2 and D3 to be equal to zero, and only the delay amount D1 provided by the controllable clock delaying unit 102a is utilized for delaying the input clock Vclk. Please refer to FIG. 3, FIG. 3 is a timing diagram of the latency counter 100 in FIG. 1 when operating in the low accessing frequency mode. In this embodiment, if the latency counter 100 receives the input clock Vclk and the memory accessing control signal PAR at time t1, then the clock terminal C1 of the registering device 106a will receive the delayed input clock VDclk1 at time t1+D1. Therefore, the output terminal N1 of the registering device 106a will output the delayed control signal LT1 after the time t1+D1, as shown in FIG. 3. Furthermore, because the delay amounts D2 and D3 are set to zero, the clock terminal C2 of the registering device 106b will wait for the next rising edge of the input clock Vclk to trigger the registering device 106b, and then output the delayed control signal LT2 at time t1+D1+Δt2, as shown in FIG. 3. Similarly, the delayed control signal LT3 is outputted at time t1+D1+Δt2+T.
Please refer to FIG. 4. FIG. 4 is a flowchart illustrating a latency counting method according to an embodiment of the present invention. The latency counting method is applied to the latency counter 100 of FIG. 1, for delaying a memory accessing control signal PAR of the memory, and the method can be simplified to the steps below:
Step 402: Detect a frequency fclk of a specific signal (input clock Vclk) of the memory;
Step 404: Determine if the input clock Vclk is high frequency or low frequency; if high frequency, go to step 406; if low frequency, go to step 412;
Step 406: Apply the delay amounts D1, D2, D3 to the input clock Vclk to generate the delayed input clocks VDclk1, VDclk2, VDclk3 respectively;
Step 408: Generate the delayed control signals LT1, LT2, and LT3 corresponding to the memory accessing control signal PAR according to the delayed input clocks VDclk1, VDclk2, VDclk3, and the memory accessing control signal PAR; wherein timing of the delayed control signal LT1 is earlier than timing of the delayed control signal LT2, and timing of the delayed control signal LT2 is earlier than timing of the delayed control signal LT3;
Step 410: Output the delayed control signals LT4, LT5, LT6, and LT7 at time t1+3T+D106d, t1+4T+D106e, t1+5T+D106f, and t1+6T+D106g respectively;
Step 412: Set the delay amounts D2 and D3 to zero;
Step 414: Utilize the delay amount D1 for delaying the input clock Vclk; and
Step 416: Output the delayed control signal LT2 at time t1+D1+Δt2, and output the delayed control signal LT3 at time t1+D1+Δt2+T.
Those skilled in the art will readily observe that numerous modifications and alterations of the device and method may be made while retaining the teachings of the invention. Accordingly, the above disclosure should be construed as limited only by the metes and bounds of the appended claims.

## Claims

1. A latency counter, applied to a memory for delaying a memory accessing control signal, the latency counter comprising:
a clock delay module, coupled to an input clock, for applying at least one delay amount to the input clock to generate a delayed input clock;
a frequency detector, coupled to the clock delay module, for detecting a frequency of a specific signal of the memory to set the delay amount; and
a delay control signal generating module, coupled to the delayed input clock, the input clock, and the memory accessing control signal, for generating a first delayed control signal and a second delayed control signal corresponding to the delayed input clock and the memory accessing control signal respectively; wherein timing of the first delayed control signal is earlier than timing of the second delayed control signal.

2. The latency counter of claim 1, wherein the clock delay module comprises:
a first controllable clock delaying unit, for providing a first delay amount to the input clock to generate a first delayed input clock; and
a second controllable clock delaying unit, for providing a second delay amount to the input clock to generate a second delayed input clock; and
the delay control signal generating module comprises:
a first register device, triggered by the first delayed input clock for reading the memory accessing control signal to generate the first delayed control signal; and
a second register device, triggered by the second delayed input clock for reading the first delayed control signal to generate a third delayed control signal; wherein when the frequency detector detects that the frequency of the specific signal is a first frequency, the frequency detector sets the second delay amount to zero; and when the frequency detector detects that the frequency of the specific signal is a second frequency higher than the first frequency, the frequency detector does not set the second delay amount to zero.

3. The latency counter of claim 2, wherein the frequency detector further controls the first delay amount at the second frequency to be larger than the first delay amount at the first frequency.

4. The latency counter of claim 1, wherein the specific signal is an operating clock of the memory.

5. The latency counter of claim 1, wherein the frequency detector detects the input clock, and arbitrarily sets the delay amount adapted to any frequency of the input clock according to a detecting result.

6. A latency counting method, applied to a memory for delaying a memory accessing control signal, the method comprising:
delaying an input clock of the memory to generate a delayed input clock according to a delay amount;
detecting a frequency of a specific signal of the memory to set the delay amount; and
generating a first delayed control signal and a second delayed control signal corresponding to the memory accessing control signal according to the delayed input clock and the memory accessing control signal respectively; wherein timing of the first delayed control signal is earlier than timing of the second delayed control signal.

7. The latency counting method of claim 6, wherein the step of delaying the input clock of the memory to generate the delayed input clock according to the delay amount comprises:
providing a first delay amount upon the input clock to generate a first delayed input clock; and
providing a second delay amount upon the input clock to generate a second delayed input clock; and
the step of generating the first delayed control signal and the second delayed control signal corresponding to the memory accessing control signal according to the delayed input clock and the memory accessing control signal comprises:
reading the memory accessing control signal according to the triggering of the first delayed input clock to generate the first delayed control signal; and
reading the first delayed control signal according to the triggering of the second delayed input clock to generate a third delayed control signal;
wherein when the frequency of the specific signal is detected to be a first frequency, the second delay amount is set to zero; and when the frequency of the specific signal is detected to be a second frequency higher than the first frequency, the second delay amount is not set to zero.

8. The latency counting method of claim 7, wherein the step of detecting the frequency of the specific signal of the memory to set the delay amount further comprises:
controlling the first delay amount at the second frequency to be larger than the first delay amount at the first frequency.

9. The latency counting method of claim 6, wherein the specific signal is an operating clock of the memory.