The present invention claims priority of Korean patent application number 10-2007-0098190, filed on Sep. 28, 2007, which is incorporated by reference in its entirety.
The present invention relates to a counter for various semiconductor devices and logic circuit systems, and more particularly, to a counter that can prevent a code overflowing.
An overflow occurs when a counter counts a code as described below with reference to
Referring to
Referring to
Referring to
The overflow of the code may output a wrong result code OUT<0:N-1> if an input value is more than or less than a value that can be expressed with N bits. Therefore, there is a need for a circuit that can stop increasing or decreasing the code OUT<0:N-1> of the counter from “111 . . . 1” or “000 . . . 0”.
Embodiments of the present invention are directed to providing a counter with an overflow prevention capability.
In accordance with an aspect of the present invention, there is provided a counter includes a counting unit configured to count an output code in response to an input signal and an overflow preventing unit configured to control the counting unit to stop counting the output code when a current value of the output code is a maximum value but a previous value thereof is not the maximum value.
Hereinafter, a counter with an overflow prevention capability in accordance with the present invention will be described in detail with reference to the accompanying drawings.
Referring to
The counting unit 420 operates as a general counter that increases or decreases a code value of the output code in response to the flag signal FLAG and the strobe signal STROBE. The counting unit 420 is enabled or disabled by controlling of the overflow preventing unit 410. The counting unit 420 may be implemented with the counter of
The overflow preventing unit 410 prevents the overflow by disabling the counting unit 420 immediately before an overflow occurs when the counting unit 420 counts the output code OUT<0:N-1>. The overflow preventing unit 410 can be designed to prevent either or both of a high overflow and a low overflow.
When the overflow preventing unit 410 is designed to prevent a high overflow, the overflow preventing unit 410 controls the counting unit 420 to stop counting the output code OUT<0:N-1> when the output code OUT<0:N-1> is a maximum value of, for example, 111 . . . 1 while it did not have the maximum value at a previous time.
When the overflow preventing unit 410 is designed to prevent a low overflow, the overflow preventing unit 410 controls the counting unit 420 to stop counting the output code OUT<0:N-1> when the output code OUT<0:N-1> is a minimum value of, for example, 000 . . . 0 while it did not have the minimum value at a previous time.
When the overflow preventing unit 410 is designed to prevent both the high overflow and the low overflow, the overflow preventing unit 410 controls the counting unit 420 to stop counting the output code OUT<0:N-1> when the output code OUT<0:N-1> is a maximum value or a minimum value while it did not have the maximum value or the minimum value at a previous time.
In all the three cases, the overflow preventing unit 410 gets feed back the output code OUT<0:N-1> from the counting unit 420, and determines whether the current output code OUT<0:N-1> is a maximum value or a minimum value. Thereafter, the overflow preventing unit 410 delays the determination result and determines whether the output code OUT<0:N-1> had a maximum value at a previous time. When the current value is the maximum value or the minimum value but was not at a previous time, the overflow preventing unit 410 controls the counting unit 420 to stop counting the output code OUT<0:N-1>. The “previous time” means a time that is taken to perform the counting one time.
Therefore, the counting operation of the counting unit 420 is stopped only when the output code OUT<0:N-1> is caused to have the minimum value or the maximum value by the counting. For example, when the output code OUT<0:N-1> is counted from “000 . . . 1” and finally is the minimum value “000 . . . 0”, the overflow preventing unit 410 stops the counting operation of the counting unit 420. However, when the output code OUT<0:N-1> was “000 . . . 0” at a previous time and is still “000 . . . 0”, the overflow preventing unit 410 does not stop the counting operation of the counting unit 420. Therefore, there is no problem in counting the output code OUT<0:N-1> while setting the maximum value or the minimum value as an initial value.
Referring to
Specifically, the detecting unit 510 includes an AND gate configured to receive the output code OUT<0:N-1>. The stop signal generating unit 530 may include a delay line 533, an inverter 531, and an AND gate 532. The delay line 533 is configured to delay the output signal of the detecting unit 510, and the inverter 531 is configured to invert the output signal of the delay line 533. The AND gate is configured to receive the output signal of the detecting unit 510 and the output signal of the inverter 531 to output the counting stop signal COUNTING_STOP. Further, the controlling unit 540 may include an SR latch 542 configured to output the counting enable signal COUNTING_ENABLE. The SR latch 542 is set in response to the counting start signal COUNTING_START and is reset in response to the counting stop signal COUNTING_STOP.
Upon operation of the detecting unit 510, the AND gate outputs a high level signal only when the output code OUT<0:N-1> is a maximum value. The stop signal generating unit 530 activates the counting stop signal COUNTING_STOP to a high level only when the output signal of the delay line 533 is a low level and the output signal of the AND gate 510 is a high level. At this point, the output signal of the delay line 533 corresponds to the detection result at a previous time. That is, the stop signal generating unit 530 activates the counting stop signal COUNTING_STOP to a high level only when the current value of the output code OUT<0:N-1> is the maximum value but its previous value is not the maximum value. Since the output of the detecting unit 510 is reflected on the output of the delay line 533 after a predetermined time, the counting stop signal COUNTING_STOP is a high pulse signal having a pulse width corresponding to the delay value of the delay line 533.
In other words, the counting stop signal COUNTING_STOP is activated in a pulse form only when the current value of the output code OUT<0:N-1> is a maximum value but its previous value is not the maximum value.
The controlling unit 540 generates the counting enable signal COUNTING_ENABLE for controlling the enabling and disabling of the counting unit 420. The counting start signal COUNTING_START is a pulse signal that is activated to a low level when the counting unit 420 starts the counting operation. The enable signal ENABLE is a signal for determining whether to use the counting stop signal COUNTING_STOP, that is, whether to perform the overflow prevention operation.
Upon operation of the controlling unit 540, the SR latch 542 activates the counting enable signal COUNTING_ENABLE to a high level when the counting start signal COUNTING_START is activated to a low level. Then, the counting stop signal COUNTING_STOP is activated to a high level in such a state that the enable signal ENABLE is activated, and thus the NAND gate 541 outputs a low level signal. Thus, the counting enable signal COUNTING_ENABLE is deactivated to a low level.
The counting unit 420 is enabled by the counting start signal COUNTING_START to perform the counting operation normally, and stops the counting operation when the counting stop signal COUNTING_STOP is activated, thereby preventing the occurrence of the overflow.
Referring to
Specifically, the detecting unit 610 includes a NOR gate configured to receive the output code OUT<0:N-1>. The stop signal generating unit 630 may include a delay line 633, an inverter 631, and an AND gate 632. The delay line 633 is configured to delay the output signal of the detecting unit 610, and the inverter 631 is configured to invert the output signal of the delay line 633. The AND gate is configured to receive the output signal of the detecting unit 610 and the output signal of the inverter 631 to output the counting stop signal COUNTING_STOP.
Upon operation of the detecting unit 610, the NOR gate outputs a high level signal only when the output code OUT<0:N-1> is a minimum value. The stop signal generating unit 630 activates the counting stop signal COUNTING_STOP to a high level only when the output signal of the delay line 633 is a low level and the output signal of the AND gate 610 is a high level. That is, the stop signal generating unit 530 activates the counting stop signal COUNTING_STOP to a high level only when the current value of the output code OUT<0:N-1> is the minimum value but its previous value is not the minimum value. Since the output of the detecting unit 610 is reflected on the output of the delay line 633 after a predetermined time, the counting stop signal COUNTING_STOP is a high pulse signal having a pulse width corresponding to the delay value of the delay line 633.
In other words, the counting stop signal COUNTING_STOP is activated to a high level only when the current value of the output code OUT<0:N-1> is a minimum value but its previous value is not the minimum value. The controlling unit 640 activates the counting enable signal COUNTING_ENABLE in response to the counting start signal COUNTING_START and deactivates it in response to the counting stop signal COUNTING_STOP. Since this operation is identical to that described with reference to
Referring to
Specifically, the detecting unit 710 includes an AND gate 711 configured to receive the output code OUT<0:N-1> to detect a maximum value, and a NOR gate 712 configured to receive the output code OUT<0:N-1> to detect a minimum value. The stop signal generating unit 730 includes an exclusive NOR (XNOR) gate 731 configured to receive an output signal of the AND gate 711 and an output signal of the NOR gate 712, a first delay line 733 configured to receive an output signal of the NOR gate 712, a second delay line 734 configured to receive an output signal of the AND gate 711, and a NOR gate 732 configured to receive an output signal of the XNOR gate 731, an output signal XD of the first delay line 733, and an output signal YD of the second delay line 734 to output the counting stop signal COUNTING_STOP.
The operation of the overflow preventing unit 410 will be described centering around nodes X, Y, XD and YD. The counting stop signal COUNTING_STOP outputted from the NOR gate 732 is activated only when logic levels of the nodes X, Y, XD, YD are 1, 0, 0 and 0, or 0, 0, 1 and 0. That is, the counting stop signal COUNTING_STOP is activated only when the current value of the output node OUT<0:N-1> is a maximum or a minimum but its previous value is not a maximum or a minimum. In this way, the overflow of the counting unit 420 can be prevented.
It can be seen from
In accordance with the embodiments of the present invention, the code overflow can be prevented because the counting operation of the counter is stopped when the code value of the counter is a maximum value or a minimum value.
The counting operation of the counter is not stopped simply because the code value is a maximum or a minimum value. The counting operation of the counter is stopped only when the current value of the output code is the maximum value or the minimum value but its previous value is not the maximum value or the minimum value. That is, the counting operation of the counting unit is stopped only when the output code is caused to have the minimum value or the maximum value by the counting. Therefore, there is no problem in counting the output code while setting the maximum value or the minimum value as an initial value.
While the present invention has been described with respect to the specific embodiments, it will be apparent to those skilled in the art that various changes and modifications may be made without departing from the spirit and scope of the invention as defined in the following claims.
Number | Date | Country | Kind |
---|---|---|---|
10-2007-0098190 | Sep 2007 | KR | national |
Number | Name | Date | Kind |
---|---|---|---|
3962565 | Guyen-Phuoc | Jun 1976 | A |
4546487 | Dackow | Oct 1985 | A |
5157701 | Parker | Oct 1992 | A |
5199052 | Fujita | Mar 1993 | A |
5303279 | Fujii | Apr 1994 | A |
5666390 | Morzano | Sep 1997 | A |
Number | Date | Country |
---|---|---|
402189026 | Jul 1990 | JP |
04-294654 | Oct 1992 | JP |
405343986 | Dec 1993 | JP |
11-214984 | Aug 1999 | JP |
2002-124882 | Apr 2002 | JP |
0145893 | Sep 1998 | KR |
Number | Date | Country | |
---|---|---|---|
20090086881 A1 | Apr 2009 | US |