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.





Share this article:
Share via emailShare via LinkedInPrint this page

Further reading:

Solving industry 4.0 challenges with software-configurable I/O
Altron Arrow Programmable Logic
Software-configurable I/O modules solve problems caused by connecting legacy equipment to modern Ethernet controllers by allowing for the efficient use of all channels in an I/O system.

Read more...
Rapid prototyping with new Xilinx FPGA evaluation kit
EBV Electrolink Programmable Logic
Equipped with the Xilinx Spartan-7 FPGA, the kit is built for rapid prototyping of industrial networking, embedded vision and automotive designs.

Read more...
Embedded vision development tool for RISC-V FPGA
EBV Electrolink Programmable Logic
Microchip Technology announced the second development tool offering in its Smart Embedded Vision initiative for designers using its PolarFire RISC-V system-on-chip (SoC) FPGA. The industry’s lowest-power ...

Read more...
Latest updates to Libero SoC v2021.3 Design Suite
Altron Arrow Programmable Logic
Microchip Technology recently introduced new MPFS025T/095T/160T/250T PolarFire SoC devices with Tgrade2 operating conditions in standard and -1 speed grades and MPFS095TS/250TS/460TS devices with MIL ...

Read more...
HLS tool suite for PolarFire FPGAs
EBV Electrolink Programmable Logic
The need to combine performance with low power consumption in edge compute applications has driven demand for field programmable gate arrays (FPGAs) to be used as power-efficient accelerators while also ...

Read more...
Mid-range FPGAs for edge compute systems
Avnet Silica Programmable Logic
Edge compute systems need compact programmable devices with low power consumption and a small enough thermal footprint to eliminate fans and other heat mitigation while providing robust compute horsepower. ...

Read more...
Microchip achieves JEDEC qualification for rad-tolerant FPGA
Future Electronics Programmable Logic
Developers of small-satellite constellations and other systems used in ‘New Space’ missions must deliver both high reliability and radiation protection while meeting stringent cost and scheduling requirements. ...

Read more...
Intel Agilex FPGAs deliver flexibility and agility for the data-centric world
Altron Arrow Editor's Choice Programmable Logic
The Agilex FPGA fabric and innovative chiplet architecture delivers an extensible FPGA platform that scales across a wide range of device densities and brings key features and benefits to the table.

Read more...
Security tool for mission-critical FPGAs
Future Electronics Programmable Logic
Mission-critical and other high-assurance systems deployed worldwide are under rapidly evolving threats from cybercriminals who attempt to extract Critical Program Information (CPI) via the FPGAs that ...

Read more...
Lattice releases new version of sensAI
Future Electronics Programmable Logic Design Automation
New enhancements have been made to Lattice Semiconductor’s award-winning sensAI solution stack for accelerating AI/ML (artificial intelligence/machine learning) application development on low-power Lattice ...

Read more...