Long and Fast Up/Down Counters Pushpinder Kaur CHOUHAN 6 th Jan, 2003

Similar documents
Counter dan Register

Asynchronous (Ripple) Counters

NH 67, Karur Trichy Highways, Puliyur C.F, Karur District UNIT-III SEQUENTIAL CIRCUITS

Counters

IT T35 Digital system desigm y - ii /s - iii

DIGITAL SYSTEM FUNDAMENTALS (ECE421) DIGITAL ELECTRONICS FUNDAMENTAL (ECE422) COUNTERS

Vignana Bharathi Institute of Technology UNIT 4 DLD

MC9211 Computer Organization

Logic Design. Flip Flops, Registers and Counters

Module -5 Sequential Logic Design

Logic Design Viva Question Bank Compiled By Channveer Patil

Sequential Digital Design. Laboratory Manual. Experiment #7. Counters

MODULE 3. Combinational & Sequential logic

Chapter 6. Flip-Flops and Simple Flip-Flop Applications

Chapter 4. Logic Design

Long and Fast Up/Down Counters

CHAPTER 4: Logic Circuits

Advanced Devices. Registers Counters Multiplexers Decoders Adders. CSC258 Lecture Slides Steve Engels, 2006 Slide 1 of 20

SEQUENTIAL LOGIC. Satish Chandra Assistant Professor Department of Physics P P N College, Kanpur

UNIT III. Combinational Circuit- Block Diagram. Sequential Circuit- Block Diagram

RS flip-flop using NOR gate

ASYNCHRONOUS COUNTER CIRCUITS

Flip Flop. S-R Flip Flop. Sequential Circuits. Block diagram. Prepared by:- Anwar Bari

Switching Theory And Logic Design UNIT-IV SEQUENTIAL LOGIC CIRCUITS

VTU NOTES QUESTION PAPERS NEWS RESULTS FORUMS Registers

Experiment 8 Introduction to Latches and Flip-Flops and registers

CHAPTER 4: Logic Circuits

Digital Systems Based on Principles and Applications of Electrical Engineering/Rizzoni (McGraw Hill

Registers and Counters

UNIT IV. Sequential circuit

Logic and Computer Design Fundamentals. Chapter 7. Registers and Counters

Decade Counters Mod-5 counter: Decade Counter:

Chapter 7 Counters and Registers

Introduction. NAND Gate Latch. Digital Logic Design 1 FLIP-FLOP. Digital Logic Design 1

CSE 352 Laboratory Assignment 3

Digital Fundamentals: A Systems Approach

problem maximum score 1 28pts 2 10pts 3 10pts 4 15pts 5 14pts 6 12pts 7 11pts total 100pts

Name Of The Experiment: Sequential circuit design Latch, Flip-flop and Registers

Logic Gates, Timers, Flip-Flops & Counters. Subhasish Chandra Assistant Professor Department of Physics Institute of Forensic Science, Nagpur

Chapter 3 Unit Combinational

EMT 125 Digital Electronic Principles I CHAPTER 6 : FLIP-FLOP

LATCHES & FLIP-FLOP. Chapter 7

RS flip-flop using NOR gate

Chapter 5 Flip-Flops and Related Devices

Digital Systems Laboratory 3 Counters & Registers Time 4 hours

CHAPTER 6 COUNTERS & REGISTERS

DIGITAL TECHNICS. Dr. Bálint Pődör. Óbuda University, Microelectronics and Technology Institute

Figure 30.1a Timing diagram of the divide by 60 minutes/seconds counter

MODEL QUESTIONS WITH ANSWERS THIRD SEMESTER B.TECH DEGREE EXAMINATION DECEMBER CS 203: Switching Theory and Logic Design. Time: 3 Hrs Marks: 100

UNIT-3: SEQUENTIAL LOGIC CIRCUITS

Registers and Counters

The basic logic gates are the inverter (or NOT gate), the AND gate, the OR gate and the exclusive-or gate (XOR). If you put an inverter in front of

Solution to Digital Logic )What is the magnitude comparator? Design a logic circuit for 4 bit magnitude comparator and explain it,

YEDITEPE UNIVERSITY DEPARTMENT OF COMPUTER ENGINEERING. EXPERIMENT VIII: FLIP-FLOPS, COUNTERS 2014 Fall

Synchronous Sequential Logic

BISHOP ANSTEY HIGH SCHOOL & TRINITY COLLEGE EAST SIXTH FORM CXC CAPE PHYSICS, UNIT 2 Ms. S. S. CALBIO NOTES lesson #39

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

Experiment # 9. Clock generator circuits & Counters. Digital Design LAB

Chapter 5: Synchronous Sequential Logic

Scanned by CamScanner

Chapter 6 Registers and Counters

Chapter 5 Synchronous Sequential Logic

Principles of Computer Architecture. Appendix A: Digital Logic

QUICK GUIDE COMPUTER LOGICAL ORGANIZATION - OVERVIEW

NH 67, Karur Trichy Highways, Puliyur C.F, Karur District DEPARTMENT OF INFORMATION TECHNOLOGY CS 2202 DIGITAL PRINCIPLES AND SYSTEM DESIGN

Electrical & Computer Engineering ECE 491. Introduction to VLSI. Report 1

Lecture 8: Sequential Logic

Digital Circuits 4: Sequential Circuits

COE 202: Digital Logic Design Sequential Circuits Part 1. Dr. Ahmad Almulhem ahmadsm AT kfupm Phone: Office:

2. Counter Stages or Bits output bits least significant bit (LSB) most significant bit (MSB) 3. Frequency Division 4. Asynchronous Counters

EKT 121/4 ELEKTRONIK DIGIT 1

Review of digital electronics. Storage units Sequential circuits Counters Shifters

Digital Logic Design ENEE x. Lecture 19

D Latch (Transparent Latch)

Objectives. Combinational logics Sequential logics Finite state machine Arithmetic circuits Datapath

(Refer Slide Time: 2:00)

UNIVERSITI TEKNOLOGI MALAYSIA

Serial In/Serial Left/Serial Out Operation

Flip-Flops and Related Devices. Wen-Hung Liao, Ph.D. 4/11/2001

FLIP-FLOPS AND RELATED DEVICES

Section 6.8 Synthesis of Sequential Logic Page 1 of 8

Asynchronous Counter

Computer Architecture and Organization

6. Sequential Logic Flip-Flops

Analogue Versus Digital [5 M]

Combinational vs Sequential

Flip-Flops. Because of this the state of the latch may keep changing in circuits with feedback as long as the clock pulse remains active.

More on Flip-Flops Digital Design and Computer Architecture: ARM Edition 2015 Chapter 3 <98> 98

VeriLab. An introductory lab for using Verilog in digital design (first draft) VeriLab

Sequential Logic and Clocked Circuits

WINTER 15 EXAMINATION Model Answer

ELCT201: DIGITAL LOGIC DESIGN

Previous Lecture Sequential Circuits. Slide Summary of contents covered in this lecture. (Refer Slide Time: 01:55)

CHAPTER 6 ASYNCHRONOUS QUASI DELAY INSENSITIVE TEMPLATES (QDI) BASED VITERBI DECODER

ELE2120 Digital Circuits and Systems. Tutorial Note 8

Chapter 2. Digital Circuits

CHAPTER 1 LATCHES & FLIP-FLOPS

The NOR latch is similar to the NAND latch

Synchronous Sequential Logic

Asynchronous counters

Transcription:

1 Introduction Long and Fast Up/Down Counters Pushpinder Kaur CHOUHAN 6 th Jan, 2003 Circuits for counting both forward and backward events are frequently used in computers and other digital systems. Digital clocks and watches are everywhere, timers are found in a range of appliances from microwave ovens to VCRs and counters for other reasons are found in everything from automobiles to test equipment. Since a counter circuit must remember its past states, it has to possess memory. For this purpose flip-flops are used. The number of flip-flops used and how they are connected determine the number of states and the sequence of the states that the counter goes through in each complete cycle. Although we will see many variations on the basic counter, they are all fundamentally very similar. The paper presents recent advances in the design of constant-time up/down counters in the general context of fast counter design. An overview of existing techniques for the design of long and fast counters reveals several methods closely related to the design of fast adders, as well as some techniques that are only valid for counter design. The main idea behind the novel up/down counters is to recognize that the only extra difficulty with an up/down counter is when the counter changes direction from counting up to counting down (and vice-versa). For dealing with this difficulty, the new design uses a shadow register for storing the previous counter state. When counting only up or only down, the counter functions like a standard up-only or down-only constant time counter, but, when it changes direction instead of trying to compute the new value (which typically requires carry propagation), it simply uses the contents of the shadow register which contains the exact desired previous value. An alternative approach for restoring the previous state in constant time is to store the carry bits in a Carry/Borrow register. The simplest type of counter is the Binary Counter. The 2-bit ripple counter circuit has four different states, each one corresponding to a count value. Similarly, a counter with n flip-flops can have 2 n states. The number of states in a counter is known as its mod number. Thus a 2-bit counter is a mod-4 counter.a mod-n counter may also described as a divide-by-n counter because it can also be used to divide the input pulse frequency by factor of n(the mod number). Thus, the mod-4 counter is an example of a divide-by-4 counter. In general we can write counter as binary modulo-2 N N-bit counter where the value s(t) of the counter is incremented by one in each clock cycle: s(t+1)=s(t)mod2 N 1

Besides this basic behavior, most counter types have several other features, the most important ones being illustrated with the help of a blackbox model as in Figure 1. Figure 1. Black-box generic counter model with the most common control signals. 1. Resettable - The counter value is reset to all zeros when the RESET input is active. 2. Loadable - The counter is loaded with the N-bit value at the In input lines when the LOAD input is active. 3. Reversible - The counter counts up (increments) when the UP/DOWN input signal is inactive and counts down (decrements) when the UP/DOWN input signal is active. 4. Count-enable The counter increments every clock cycle only when the CNT input is active. 5. Terminal Count TC output signal active when the counter reaches the maximum value (all ones) counting up or reaches the minimum value (all zeros) when counting down. 6. Readable on-the-fly The counter state (Out) can be read reliably without stopping the clock. Ideally, this sampling rate should be equal to the clock rate. 2 Counters 2.1 Asynchronous Counter A three-bit asynchronous counter is shown in Figure 2. The external clock is connected to the clock input of the first flip-flop (FF0) only. So, FF0 changes state at the falling edge of each clock pulse, but FF1 changes only when triggered by the falling edge of the Q output of FF0 and so on. Because of the inherent propagation delay through a flip-flop, the transition of the input clock pulse and a transition of the Q output of FF0 can never occur at exactly 2

the same time. Therefore, the flip-flops cannot be triggered simultaneously, producing an asynchronous operation. Figure 2. Asynchronous counter. Usually, all the CLEAR inputs are connected together, so that a single pulse can clear all the flip-flops before counting starts. The clock pulse fed into FF0 is rippled through the other counters after propagation delays, like a ripple on water, hence the name Ripple Counter. 2.1.1 Asynchronous Up-Down Counters In certain applications a counter must be able to count both up and down. The circuit below is a 3-bit up-down counter. It counts up or down depending on the status of the control signals UP and DOWN. When the UP input is at 1 and the DOWN input is at 0, the NAND network between FF0 and FF1 will gate the non-inverted output (Q) of FF0 into the clock input of FF1. Similarly, Q of FF1 will be gated through the other NAND network into the clock input of FF2. Thus the counter will count up. Figure 3. Asynchronous Up-Down Counters. When the control input UP is at 0 and DOWN is at 1, the inverted outputs of FF0 and FF1 are gated into the clock inputs of FF1 and FF2 respectively. Notice that an asynchronous up-down counter is slower than an up counter or a down counter because of the additional propagation delay introduced by the NAND networks. 3

2.2 Synchronous Counter In synchronous counters, the clock inputs of all the flip-flops are connected together and are triggered by the input pulses. Thus, all the flip-flops change state simultaneously (in parallel). The circuit in Figure 4 is a 3-bit synchronous counter. The J and K inputs of FF0 are connected to HIGH. FF1 has its J and K inputs connected to the output of FF0, and the J and K inputs of FF2 are connected to the output of an AND gate that is fed by the outputs of FF0 and FF1. After the 3rd clock pulse, both outputs of FF0 and FF1 are HIGH. The positive edge of the 4th clock pulse will cause FF2 to change its state due to the AND gate. Figure 4. Synchronous Counter. The most important advantage of synchronous counters is that there is no cumulative time delay because all flip-flops are triggered in parallel. Thus, the maximum operating frequency for this counter will be significantly higher than for the corresponding ripple counter. 2.2.1 Synchronous Up-Down Counters A circuit of a 3-bit synchronous up-down counter is shown in Figure 5. Similar to an asynchronous up-down counter, a synchronous up-down counter also has an up-down control input. It is used to control the direction of the counter through a certain sequence. Figure 5. Synchronous Up-Down Counters. See the sequence shown in Table 1. For both the UP and DOWN sequences, Q0 toggles on each clock pulse. For the UP sequence, Q1 changes state on the next clock pulse when Q0=1. For the DOWN sequence, Q1 changes state on the next clock pulse when Q0=0. For the UP sequence, Q2 changes state on the next clock pulse when Q0=Q1=1. For the DOWN sequence, Q2 changes state on the next clock pulse when Q0=Q1=0. 4

Table 1. Sequence Table. 2.3 Ring Counter The simplest shift register counter is a circulating shift register connected so that the last FF shifts its value into the first FF. The FFs are so connected so that information shifts from left to right and back around from Q0 to Q3. In most instances only a single 1 is in the register and it is made to circulate around the register as long as clock pulses are applied. Thus it is called a ring counter. Figure 6. Ring Counter (a) Block Diagram; (b) Waveforms; (c) State Diagram; (d) Sequence Table. The waveforms, block diagram, sequence table and state diagram is shown in Figure 6. We have assumed the starting state of Q3=1 and Q2=Q1=Q0=0. This counter function as Mod-4 counter, since it has four distinct states before the sequence repeats. Although this circuit does not progress through the normal binary counting sequence, it is still a counter because each count correspond to unique set of FF states. Each FF output waveform has a frequency equal to one-fourth of the clock frequency. A Mod-N ring counter uses N flip-flops connected in the same arrangement as shown in Figure 6. 2.4 Twisted-tail Counter The basic ring counter can be modified slightly to produce another type of shift register counter, which will have somewhat different properties. The Twisted-ring counter is constructed exactly like a normal ring counter except 5

that the inverted output of the last FF is connected to the input of the first FF. It is also known as Johnson counter. Figure 7. Twisted-ring counter (a) Block Diagram; (b) Waveforms; (c) State Diagram; (d) Sequence Table. We assume all FFs are initially 0. This counter has six distinct states. Thus, it is a Mod-6 Johnson counter. It does not count in a normal binary sequence. The waveform of each FF is a square wave at one-sixth the frequency of the clock. The FF waveform are shifted by one clock period with respect to each other. The mod number of a Johnson counter will always be equal to twice the number of FFs. Thus, it is possible to construct a Mod-N counter by connecting N/2 flip flops in a Johnson-counter arrangement. 2.5 Differential Counter For applications that need even faster counting, it is possible to derive structures that count differentially with a structure which has some similarities to a ring counter. When measuring very short time intervals using a regular counter, the accuracy of any time measurement will be determined by the clock period, hence, when the interval to be measured is of the same order of magnitude as the clock period, any measurement becomes meaningless. Counting differentially allows the accuracy to be determined by the difference between two different periods. Figure 8. Differential Counter. Assuming that we can accurately control the two periods, very short intervals can be measured with high accuracy, even with relatively slow logic. A 6

differential counter is shown in Figure 10, has two periods which are combinational delays, the faster one through a buffer, the slower one through a transparent latch. The idea is to measure the short interval between two events (signal edges) by propagating the first coming signal through the slower path (transparent latches) and the second one through the faster path (buffers). Since the path for the second signal is faster, there will be a moment when it will catch up the first signal, and the circuit in Figure 10 captures that moment into a one-hot representation. If the two delays are denoted as δ1 and δ2 and the second signal catches up after k stages, then the time interval between the two events is = k (δ1 δ2) and it can be seen that very small intervals can indeed be measured accurately if the difference (δ1 δ2) can be made small enough. 3 Counters Classification There are many variations possible on the basic counter behavior by combining the basic counter behavior in order to obtain a more complex counter behavior, hence it is useful to classify counters. The following list is not complete but have the most commonly found cases. Depending on whether the counter can be initialized to one state or to any state counters can be classified as: Noninitializable This is the simplest case, it can only be used for specific applications (e.g., frequency divider). Resettable This is necessary for most applications and also necessary for testing purposes, without a large penalty in performance or area. Loadable This is a more general case but typically has lower performance and higher complexity. Depending on whether the counter traverses the circular state diagram in one direction only or in both, counters can be classified as: Up-only This is the most common case and easy to understand. Counter counts in forward direction. Down-only This is equivalent to the up-only case but it counts in backward direction. In simple words it is opposite of the up-counter. Up/down This is the most versatile but typically at the cost of lower performance. Depending upon the signal activated the counter counts in forward direction or in backward direction. Because of this property it is sometimes called a reversible counter. 7

Depending on whether all the state registers are clocked with the same signal counters can be: Asynchronous Simple structure, cannot be read on-the- fly, can have registers that are clocked by other signals than the clock. Like in the ripple-carry counter, the first flip-flop is clocked by the external clock pulse, and then each successive flip-flop is clocked by the Q or Q output of the previous flip-flop. Semisynchronous A hybrid attempt of combining the simplicity of asynchronous designs with a synchronous behavior on only some of the outputs. Synchronous This is the most robust and can be read on-the-fly, but the routing and loading of the clock can become a performance bottleneck. In synchronous counter all memory elements are simultaneously triggered by the same clock. Sometimes it is possible to use counters with a state diagram that does not return from the last state to the initial state. Depending on whether this happens or not, counters can be classified as: Periodic This is the normal case with a circular state diagram. Aperiodic This is the case where the counter does not return to the initial state (e.g., the differential counter). Periodic counters can be classified according to the number of states: Modulo-2 N Special case of 2 N states, typical for an N-bit binary counter, the counter wraps-around from the last state by itself. Modulo-P This is more general case than the modulo-2 N, the modulo- P counter is many times obtained from a modulo-2 N counter, either by decoding the state P and resetting to zero, or by loading with P when the counter reaches zero. Modulo-P ring counters are obtained without a need to decode states or explicitly load the counter. Depending on the state encoding, counters can be classified as: Binary The most common case in which the sequence of states is the ascending or descending binary sequence. Quasi-binary The case where the relation between a state and its binary equivalent can be easily determined. Non-binary The state encoding is not related to the binary sequence(e.g., ring counters). 8

4 Prescaled Counters The Prescaled counters, on which the paper is based, are synchronous circuits having the following characteristics: 1. Binary counting sequence. 2. Clock period independent of counter size. 3. Readable on the fly with the sampling rate being equal to the counting rate. 4. Space complexity linear in the number of bits (i.e., O(N)). 5. Count up, down, or up/down. 6. Resettable. The idea behind prescaled counter is the characteristic of the binary number system. The higher order bits are stable for long periods of time and the terminal count (TC) output from the two least significant bits, which becomes a CARRY-in into the most significant block, is periodic with a lower frequency than the clock signal. For an M-bit counter block, the terminal count will have a frequency 2 M lower than the clock, with the moment when the terminal count from low-order bits is active being exactly the time when higher order bits need to be incremented. This means that the virtual frequency at which high-order bits need to operate is much lower than for the low order bits. Therefore, Prescaling long counters requires partitioning them into a series of sub-blocks of increasing sizes in order to take advantage of the reduced frequency required by high order bits. The simplest prescaled counters have only two such blocks, with a small and fast least-significant module called the prescaler and a slower large counter for high-order bits as shown in Figure 9. Figure 9. Counter partition into a fast prescaler and a slower high-order partition. For higher order blocks, successive terminal count signals from the previous stages become exponentially farther apart in time, hence, higher order blocks can have exponentially increasing sizes. In a correctly designed constant time counter, the clock period is limited only by the speed of the least significant block, hence, the first prescaler is typically very small (one or two bits). The size of each sub-block must be chosen such that the CARRY propagation inside the block is shorter than the delay between two successive terminal counts from the corresponding prescaler. Thus, the CARRY 9

propagation inside the block is not on the critical path and does not affect the clock period. 4.1 Terminal Count Generation The prescaled generation of the TC-in to a partition has to be synchronous with the true clock. Several different approaches have been proposed for the prescaled generation of the TC to high-order partitions. The first proposed solution, by Ercegovac and Lang, uses a relatively inefficient ring/twistedtail counter, which practically doubles the overall complexity of the counter. The ring/twisted-tail counters are regular and their VLSI implementation may not be very inefficient. A much simpler TC generation, proposed by Vuillemin, uses a backward CARRY propagation chain that takes the characteristics of the binary number system further into account. 4.2 Partitioning Partitioning is the most important part of prescale counters. Depending on the choice of the prescaled CARRY-in generation method, the partition sizes can be determined: 1. In a top-down manner, first determine the size of the most significant block, which is chosen as large as possible, and then recursively determine the sizes of the lower order blocks. By assuming unit delays for the combinational gates and a unit delay clock, an N-bit counter is first partitioned into an (N - log 2 N ) most significant block and into another log 2 N block which is recursively partitioned in the same manner. For example, in the case of a 64-bit counter, a top-down partitioning results in the following block sizes: 58, 3, 2, 1. The top-down procedure reduces the penalty paid for having ring counter prescalers, but has the disadvantage that counters of different sizes will require different partition sizes, hence, design reuse is difficult to implement. For a 128-bit counter, the top-down partioning leads to: 121, 4, 2, 1 block sizes. 2. In a bottom-up manner, first decide the size of the least significant block, then choose the second block as large as possible without affecting the clock period, then choose the third, etc. A bottom-up partitioning, assumes unit delays for the combinational gates, and a unit delay clock. It determines the least significant block with n 0 = 1 bit, the second block with n 1 = 2 n 0 = 2 bits, the third block with n 2 = 2 (n 0+n 1 ) = 8 bits, and so on. For the same example of a 64-bit counter, a bottom-up partitioning results in the following block sizes: 53, 8, 2, 1. This bottom-up procedure has the advantage of using a few standard size modules as building blocks for counters of different lengths with only the most significant block of a non-standard size. For a 128-bit counter, the bottom-up partitioning leads to: 117, 8, 2, 1 block sizes. 10

5 Constant-Time Up/Down Counters The main advantage of up/down counters is that it have only a constant number of inputs (CLK, UP/DOWN, RESET, and CNT) independent of the counter size, hence, it seems more likely to be able to design a constant time up/down counter. The main idea behind the technique for designing constant time up/down counters is to realize that it is easy to have a configurable counter (configured as an up-counter, it will have a CARRY chain and, configured as a down-counter, it will have a BORROW chain) and the only extra difficulty is when an up-only or down-only counter changes direction. This change of direction is the only moment when the CARRY (or BORROW) chain inside a block may not have enough time to propagate until the next TC from the corresponding prescaler. The solution proposed in the paper is to have the desired value prestored and simply load this value when necessary, instead of trying to compute it. This can be easily accomplished by using a shadow register that is always loaded with the previous block value whenever the block is loaded with a new value. Figure 10. Block diagram of the constant time up/down counter. The block diagram of the proposed up/down constant time counter is shown in Figure 10. The design is synchronous, with a CLK active on the rising edge, a RESET active HI, and an UP/DOWN input, which is LO for counting up and HI for counting down. The following issues have determined the structure of the new counter: 1. The prescaled TC generation must itself be up/down, hence it can be implemented as an up/down ring counter and the top-down partitioning method is needed in order to minimize the size of the ring counters. 2. Each block needs to be configurable for counting either up or down. A separate configuration bit for each block is needed to keep track of the block configuration. 3. Each sub-block has a shadow register that stores the previous block value (i.e., decremented or incremented by one block-least-significant bit 11

depending on the configuration). When the block configuration is up, the shadow register stores the present value minus one LSB and when the configuration is down, it stores the present value plus one LSB. The sub-blocks in this design function is practically independent of each other, the ring counter inside each block effectively replace the need for receiving the TC from lower order blocks. The complexity of the up/down counter is more than up-only counter because of the extra shadow register and the configurable CARRY chain. 5.1 Least-Significant Bit Counter A 1-bit counter counts in the same sequence, no matter if it is up-only, down-only, or up/down, hence, the first block as shown in Figure 11, can be a simple 1-bit counter which acts both as the 1-bit least significant bit and as a ring counter for the second block. There is no need for a shadow register or configuration bit for the first block. Figure 11. Least-significant bit block. 5.2 Configuration Bit A configuration bit for each higher-order block keeps track of how the block is configured (up or down). A CARRY-in can occur only if the UP/DOWN input signal is 0 (UP), while a BORROW-in can occur only if the UP/DOWN input signal is 1 (DOWN). There are four possible cases: Case 1. The block is configured up and a CARRY-in comes from the ring counter. The configuration remains the same (up) and the block behaves like a normal up-only constant time counter. The shadow register gets loaded with the present block value, while the block gets loaded with its next (incremented) value. Since the present configuration is up, this means that the previous event was also a CARRY-in, hence, enough time has passed for CARRY propagation inside the Incrementer/Decrementer (which is configured as an incrementer). Case 2. The block is configured down and a BORROW-in comes from the ring counter. The configuration remains the same (down) and the block behaves like a normal down-only constant time counter. The shadow register gets loaded with the present block value, while the block gets loaded with its next (decremented) value. Since the present configuration is down, this means that the previous event was also a BORROW-in, hence, enough time has passed for BORROW propagation inside the Incrementer/Decrementer 12

(which is configured as an decrementer). Case 3. The block is configured up and a BORROW-in comes from the ring counter. The block changes configuration to down and it swaps the present value with the shadow register. The Incrementer/Decrementer output is disabled in this case, hence, there is no need in this case to wait for BORROW propagation. Case 4. The block is configured down and a CARRY-in comes from the ring counter. The block changes configuration to up and it swaps the present value with the shadow register. The Incrementer/Decrementer output is disabled in this case hence, there is no need in this case to wait for CARRY propagation. Figure 12. Configuration bit inside each block. When after counting up for a number of cycles, the counter changes direction by only changing lower order bits. In such a case, the high-order blocks will still remain configured up and will only change configuration when a BORROW-in comes from the again, before a BORROW-in, the higher order block will never know that the lower order blocks were in a different configuration for a period of time. The configuration register is implemented as a simple D edge-triggered flip-flop as shown in Figure 12. The configuration of each block can only change when a CARRY-in (or BORROW-in) is received from the ring counter. When the configuration changes (the present configuration is up and the next one is down, or viceversa), the SWAP signal becomes active, which enables swapping the value of the block with the shadow register. When the configuration stays the same, the block register is loaded from the Incrementer/Decrementer and the shadow register is updated with the previous block value. 5.3 Clock Period For simplicity, unit delays are assumed for all the combinational gates in the circuit (including multiplexes and XOR gates). There are several critical paths in the circuit that determine the minimum clock cycle to be larger than one unit delay, as in the case of the up-only counter: 1. The least significant bit block has a unit delay, so it does not represent the critical path. 2. Incrementing/decrementing the ring counter requires two unit delays, since the ring counter is a bidirectional shift register. 3. Swapping the value of the block with the value of the shadow register 13

requires a unit delay through a multiplexer and in parallel, the multiplexer control signal requires two unit delays as shown in Figure 10. The timing of the UP /DOW N signal is on the critical path and the signal needs to be synchronized with the clock. 4. By choosing a proper size for each block, the delay of Incrementer/Decrementer which takes care of CARRY (or BORROW) propagation inside the block can be masked, and this delay should not be on the critical path. The clock frequency is independent of counter size but is lower (by a constant) than for an up-only counter because of the extra complexity. Instead of being limited only by the low order prescaler, the speed is also limited by the extra logic needed for swapping with the shadow register. 5.4 Up/Down Ring Counter As explained in section 2.4, a 2 N -bit twisted-tail ring counter has 2 (N+1) distinct states and clock period independent of size hence, it can function as a (N + 1)-bit counter prescaler. The ring counter inside each block is used in order to generate, in constant time, the TC-in (CARRY-in or BORROW-in) for the block. The TC signal is obtained from different conditions depending if the counter is counting up or down. When counting up, TC = 1 when the state of the enable counter is s(t) = (100... 00) (one state before the counter goes back to state 0) and CNT = 1. When counting down, TC = 1 when s(t) = (000... 00) and CNT = 1. The state bits in the twisted-tail counter are such that the s(t) = (100... 00) state can be detected by testing the two most significant bits and the s(t) = (000... 00) state can be detected by testing the most and least significant bits see Figure 13. Figure 13. up/down twisted tail TC circuit. 5.5 Partitioning Determining the partition sizes for the proposed up/down counter proceeds top-down, the minimum clock period (T clk ) is larger than the combinational unit delay due to the extra complexity. If we consider T clk = p.δ, where δ is the unit delay, the partitioning first divides the N-bit counter into a most N significant N (log 2 P ) block and into another (log 2 N P ) block which is 14

recursively divided in the same manner until the smaller block is a 1-bit counter. For p = 2 and N = 64, the partitioning leads to the sizes:60,3,1. 5.6 Incrementer/Decrementer The Incrementer/Decrementer can be easily implemented as a ripple chain, as shown in Figure 14. For an n-bit block, the delay through the ripple chain will be n times the unit logic delay and if this delay is less than the time between two consecutive CARRY-ins (or BORROW-ins) from the ring counter (which should always be true by partitioning), the Incrementer/Decrementer is not on the critical path. The configuration is controlled by the configuration bit for each block. Figure 14. Incrementer/Decrementer. 5.7 Initializing the Counter For a regular N-bit counter which has 2 N possible states, all the states are legal. In the case of the proposed constant time up/down counter, which has many extra state flip-flops (the configuration bits, the ring counters, the shadow registers), it is very important to initialize the counter to a legal state. A RESET signal is needed to initialize all the configuration bits to 0 (counting up), the counter block values to all-zeros, the shadow registers to all-ones (block value minus 1), and the ring counters to all-zeros. 6 Alternative Design - use of Carry/Borrow Register An alternative solution to the use of a shadow register is to store the bit-wise XOR between the previous state and the current state in the Carry/Borrow Register (CBReg). With this information available, it is possible to restore the desired previous state in one gate delay. For comparison, both solutions are presented in Figure 15. In Figure 15(a), the carry bit that was used in the last transition is stored in CBReg and is used in the place of the carry computed by the incrementer/decrementer chain. Figure 1(b), the value of the previous state is stored in a shadow register and can replace the next state that is being computed by the incrementer/decrementer. 15

Figure 15. Design of next state generator (a) Using carry/borrow from previous state transition; (b) using shadow register to store the previous state bit. 7 Conclusion The methodology behind designing synchronous up/douwn counters of arbitrary length with period independent of counter size is presented in detail. The main idea of the solution to the problem is to store the previous state of the counter for use when the counter reverses direction. For that use of two type of registers is described. Use of Shadow Register is explained in detail and simple procedure of the use ofcarry/borrow Register is described. The experimental results for the up/down counters were obtained using simulation for a 64-bit design and estimates of the area and delays for other cases. The paper is very technical and very well explained. To make the basic, simple counter and examples are given. Counter classification is very helpful in understanding the characteristic of the counters. Block diagrams of each counter and their parts helped in understanding the working of counters more easily. References 1: Digital Systems Principles and Application By Ronald J. Tocci. 2: Computer Arithmetic Algorithms and Hardware Designs By Behrooz Parhami 3: http://www.play-hookey.com/digital/synchronous counter.html 4: http://www.eelab.usyd.edu.au/digital tutorial/part2/counter01.html 5: http://www.hcc.hawaii.edu/ richardi/113/index.htm 16