Programmable Logic


Doubling counter/timer resolutions with CoolRunner-II

23 August 2006 Programmable Logic

Counter and timer modules are often incorporated in CPLD (complex programmable logic device) designs. But, while counters and timers are ideal for some designs, they are not so ideal for designs that need greater resolution.

This article demonstrates how to double timer/counter resolution by using DualEDGE-triggered registers in CoolRunner-II CPLDs, and includes a design trick to achieve higher frequency beyond the device's maximum specified frequency, FMAX.

Timer/counter units are found in many applications. In some cases, they are used to measure elapsed time by counting processor cycles or clock ticks. For example, to generate a pulse width modulation (PWM) signal by using two different initial or terminal count values, and a one-shot timer that toggles the I/O pin on overflow, the pin could be set to 1 for a desired amount of time, then 0 for a different amount of time, then 1 again, and so on. The period of the PWM signal in this case is a function of the sum of the two timer periods, and the duty cycle is the length of time that the pin is set to 1 as a percentage of the period.

PPWM = Ptimer1 + Ptimer2

DutyCycle = 100 x t1/(t0 + t1)

PWM waveform accuracy is dependent on the input clock frequency. A 100 MHz clock can generate resolution accuracy of 10 ns. For a PWM waveform with 100 ns period and 60% duty cycle, the terminal count for '1' is six and for '0' is four for a 100 MHz counter. For the same period with 55% duty cycle (55 ns) at 100 MHz, the counter will have a problem since it cannot count to 5,5. It will require a 200 MHz clock, which has 5 ns resolution, and count to 11 for 55 ns.

The CoolRunner-II CPLD with DualEDGE triggered registers is the ideal solution for this type of application. It can achieve 200 MHz counter resolution while using a 100 MHz clock, and solve the resolution problem while also maintaining the low power and low noise operation.

DualEDGE registers

CoolRunner-II DualEDGE triggered registers allow designers to reach unprecedented performance levels. These CPLDs can double system performance by creating DualEDGE Triggered (DET) registers. CoolRunner-II DET registers allow data to be registered on both the rising and falling edge of a clock. DET registers can be used for logic functions that include shift registers, counters, comparators, and state machines. Designers must evaluate the desired performance of the CPLD logic to determine use of DET registers. The DET register is available on all macrocells in all devices of the CoolRunner-II family.

Doubling resolution using DualEDGE

DualEDGE registers allow CoolRunner-II CPLDs to effectively double the resolution of any clocked operation. Let us examine a system that needs 5 ns of resolution. Given a 100 MHz clock in a conventional system, this would be impossible, as 10 ns is the best achievable resolution. However, if a counter is implemented with DualEDGE, it can actually accept a 100 MHz external clock, and count at an internal frequency of 200 MHz, giving us the needed 5 ns of accuracy.

Putting DualEDGE to use

Let us use a more realistic example, rather than using perfect, round integer values. Imagine a system that requires a 2,35 MHz (425 ns period) clock output from the CoolRunner-II device, given a 100 MHz (10 ns) clock input. There is insufficient resolution given a 100 MHz input, and hence we need to use DualEDGE registers to complete the task. A 100 MHz clocked Dual Edge register would provide the equivalent of a 5 ns period. So, the DualEDGE counter would need to count 85 clock cycles in order to create a 425 ns period output clock (see Figures 1 and 2).

Figure 1. DualEDGE clocking
Figure 1. DualEDGE clocking

Figure 2. Macrocell clock chain with DualEDGE option shown
Figure 2. Macrocell clock chain with DualEDGE option shown

It should be noted that although the DET registers can double the system performance with a lower frequency clock input, the DET registers cannot exceed the device maximum operating frequency (FMAX). For example, the FMAX for XC2C64A is 263 MHz, so the incoming clock FMAX for the DET register must be 131,5 MHz or less.

Beyond FMAX with a simple design trick

Let us say we need to generate a 2,34 MHz clock from a 200 MHz internal clock. Using the same trick as above, a 2,34 MHz frequency corresponds to a 427,5 ns clock period, and a 200 MHz frequency corresponds to a 5 ns clock period. In theory, using 200 MHz DualEDGE registers would allow a terminal counter to be clocked at an internal frequency of 400 MHz (2,5 ns resolution). Given this 2,5 ns resolution, we would simply need to count to a terminal value of 171 in order to generate a 2,34 MHz clock (427,5 ns period). But alas, as stated above, DualEDGE Triggered registers can only be clocked at an external frequency of FMAX divided by two, or less: fEXT ≤ fMAX/2.

Design code example
Design code example

Hence, we need another solution

In order to generate a 2,34 MHz (427,5 ns period) clock from an input frequency of 200 MHz (5 ns resolution), we would need to have a terminal counter count to a value of 85,5. Notice that there is not enough resolution! Here is a trick. We internally invert the incoming clock to the counter immediately after the counter counts to an integer value of 84. Doing this ensures that the next count will occur on the falling edge of the 85th clock cycle. This gives us the ´ cycle worth of resolution needed to count to 85,5. Figure 3 shows a block diagram of this circuit.

Figure 3. Circuit block diagram
Figure 3. Circuit block diagram

From Figure 3, the counter counts to 84 (0 to 83) and toggles the left T register. This inverts the 200 MHz clock such that the counter actually counts on the next falling edge of the 200 MHz clock. The OR gate before the counter ensures that there is no glitch during the clock inversion process.

Figure 4 is a simulation waveform for this design. It shows that the CoolRunner-II device is capable of generating a 2,34 MHz clock from a 200 MHz input signal.

Figure 4. Simulation waveform
Figure 4. Simulation waveform

Figure 5 shows how, after the 84th rising edge, the clock is internally inverted, and the counter proceeds to count on the falling edges. Note the Tco delay as this is a timing simulation.

Figure 5. Simulation waveform using different clock edges
Figure 5. Simulation waveform using different clock edges

DualEDGE example code
DualEDGE example code

Conclusion

CoolRunner II CPLDs are the ideal solution for providing the highest resolution for Timer/Counter applications. CoolRunner-II CPLDs are targeted for applications that require both low power consumptions and high performance.



Credit(s)



Share this article:
Share via emailShare via LinkedInPrint this page

Further reading:

Smallest automotive maXTouch controllers
29 July 2020, Altron Arrow, Avnet South Africa , DSP, Micros & Memory
To help enhance and ease today’s driving experience, automotive manufacturers are implementing additional touch displays beyond the centre infotainment display (CID). Supporting the application of these ...

Read more...
3 kW TVS diode arrays
30 June 2020, Avnet South Africa , Circuit & System Protection
To ensure critical operations, aviation and space systems rely on digital and logic functionality and circuitry in engine control units, environmental controls, instruments and actuators. Data centres, ...

Read more...
FPGA development suite for Pentek recorders
30 June 2020, Rugged Interconnect Technologies , Programmable Logic
Pentek’s ArchiTek FPGA Development Suite is a new product for adding custom IP to select Pentek Talon recording systems. ArchiTek is a comprehensive development environment that enables engineers to add ...

Read more...
PCIe Gen 4 switches
30 June 2020, Avnet South Africa , Computer/Embedded Technology
To support cloud, data centre and hyperscale computing that facilitates advancements in artificial intelligence (AI) and machine learning (ML), Microchip Technology released to production its Switchtec ...

Read more...
DIN-rail mounting DC-DC converters
30 June 2020, Avnet South Africa , Power Electronics / Power Management
Shortly after unveiling the brand-new DIN-rail mounting DC-DC converter family, the DDR-15/30/60/120/240 series, Mean Well has announced the DDR-480 series (480 W) to enable integration into higher-power ...

Read more...
Wi-Fi and BLE combo module
29 May 2020, Avnet South Africa , Telecoms, Datacoms, Wireless, IoT
Dialog Semiconductor announced the DA16600, a module that combines its advanced Wi-Fi and BLE (Bluetooth Low Energy) capabilities into a single solution. This two-in-one module is comprised of two ...

Read more...
HV MOSFET for ruggedness, smart PWM controller for flexibility
30 June 2020, Avnet South Africa , Power Electronics / Power Management
As the world recently celebrated Earth Day, STMicroelectronics’ blog recently featured one of its many components that help better manage the electricity people consume every day and therefore, decided ...

Read more...
Why ‘new space’ satellites demand a new approach to components
29 May 2020, Avnet South Africa , News
New space is opening up exciting opportunities for businesses, which can create completely new products, services and capabilities that were, until recently, impossible or impractical.

Read more...
The top benefits of MEMS timing
29 May 2020, Avnet South Africa , Analogue, Mixed Signal, LSI
MEMS (micro electromechanical systems), designed to resonate and generate clocks signals, may not dominate the world of timing applications right now, but the technology’s popularity is growing. Competing ...

Read more...
Microcontrollers for functional safety
29 May 2020, Avnet South Africa , DSP, Micros & Memory
As the Internet of Things (IoT) delivers greater connectivity for industrial and home applications and as connected vehicles enhance cabin and operational features, higher-performance microcontrollers ...

Read more...