Monday, June 29, 2009

Techniques to make clock switching glitch free

With more and more multi-frequency clocks being used in today's chips, especially in the communications field, it is often necessary to switch the source of a clock line while the chip is running. This is usually implemented by multiplexing two different frequency clock sources in hardware and controlling the multiplexer select line by internal logic.

The two clock frequencies could be totally unrelated to each other or they may be multiples of each other. In either case, there is a chance of generating a glitch on the clock line at the time of the switch. A glitch on the clock line is hazardous to the whole system, as it could be interpreted as a capture clock edge by some registers while missed by others.

In this article, two different methods of avoiding a glitch at the output clock line of a switch are presented. The first method is used when clocks are multiples of each other, while the second deals with clocks totally unrelated to each o ther.

The problem with on-the-fly clock switching

Figure 1 shows a simple implementation of a clock switch, using an AND-OR type multiplexer logic.

The multiplexer has one control signal, named SELECT, which either propagates CLK0 to the output when set to “zero” or propagates CLK1 to the output when set to “one." A glitch may be caused due to immediate switching of the output from Current Clock source to the Next Clock source, when the SELECT value changes. Current Clock is the clock source currently selected while Next Clock is the clock source corresponding to the new SELECT value.

The timing diagram in Figure 1 shows how a glitch is generated at the output, OUT CLOCK, when the SELECT control signal changes. The problem with this kind of switch is that the switch control signal can change any time with respect to the source clocks, thus creating a potential for chopping the output clock or creating a glitch at the output.

The select control signal is most likely generated by a register driven by either of the two source clocks, which means that either it has a known timing relationship to both clocks, if both clocks are multiples of each other, or it may be asynchronous to at least one clock, if source clocks are not related in any way.

Switching during either clock's high state needs to be avoided without having any idea about the frequencies or phase relationship of these clocks. Fixed delay can be used to induce the gap between the start and stop time of the two source clocks, but only if a fixed relationship exists between the two clock sources. It cannot be used where either the input frequencies are not known, or the clocks are not related.


Figure 1 -- Clock switching multiplexer

Glitch protection for related clock sources

A solution to prevent glitch at the output of a clock switch where source clocks are multiples of each other is presented in Fi gure 2. A negative edge triggered D flip-flop is inserted in the selection path for each of the clock sources. Registering the selection control at negative edge of the clock, along with enabling the selection only after other clock is de-selected first, provides excellent protection against glitches at the output.

Registering the select signal at negative edge of the clock guarantees that no changes occur at the output while either of the clocks is at high level, thus protecting against chopping the output clock. Feedback from one clock's selection to the other enables the switch to wait for de-selection of the Current Clock before starting the propagation of the Next Clock, avoiding any glitches.

The figure 2 timing diagram shows how the transition of the SELECT signal from 0 to 1 first stops propagation of CLK0 to the output at the proceeding falling edge of CLK0, then starts the propagation of CLK1 to the output at following negative edge of CLK1.

There are three timing paths in this circuit that need special consideration — the SELECT control signal to either one of the two negative edge triggered flip flops, the output of DFF0 to input of DFF1, and the output of DFF1 to the input of DFF0. If the signal on any of these three paths changes at the same time as the capturing edge of the destination flip flop's clock, there is a small chance that the output of that register may become meta-stable, meaning it may go to a state between an ideal “one” and an ideal “zero.”

A meta-stable state can be interpreted differently by the clock multiplexer and the enable feedback of the other flip flop. Therefore, it is required that capturing edges of both flip flops and the launch edge of the SELECT signal should be set apart from each other to avoid any asynchronous interfacing. This can be easily accomplished by using proper multi-cycle hold constraints or minimum delay constraints, as the timing relationship is known between the two clocks.


Figure2 -- Glitch-free clock switching for related clocks

Fault tolerance

At chip startup time, both flip flops DFF0 and DFF1 should be reset to the “zero” state so that neither one of the clocks is propagated initially. By starting both flip flops in “zero” state, fault tolerance is built into the clock switch.

Let's say that one of the clocks was not toggling due to a fault at startup time. If the flip flop associated with the faulty clock had started up in “one” state, it would prevent the selection of other clock as the Next Clock, and its own state is not changeable due to lack of a running clock. By starting both flip flops in “zero” state, even if one of the source clocks is not running, there is still the ability to propagate the other good clock to the output of the switch.

Glitch protection for unrelated clock sources

The previous method of avoiding a glitch at the output of a clock switch requires the two cl ock sources to be multiples of each other, such that user can avoid signals to be asynchronous with either one of the clock domains. There is no mechanism to handle asynchronous signals in that implementation.

This leads to the second method of implementing the clock switch with synchronizer circuits to avoid potential meta-stability caused by asynchronous signals. The source of asynchronous behavior could either the be SELECT signal or the feedback from one clock domain to the other, when the two clock sources are totally unrelated to each other.

As shown in Figure 3, protection is provided against meta-stability by adding one extra stage of positive edge triggered flip flop for each of the clock sources. The positive edge triggered flip flop in each of the selection paths, along with the existing negative edge triggered flip flop, guards against potential meta-stability, which may be caused by asynchronous SELECT signal or asynchronous feedback from one clock domain to the other.

A synchroniz er is simply two stages of flip flops, where the first stage helps stabilize data by latching it and later passing it on to the next stage to be interpreted by rest of the circuit.


Figure 3 -- Glitch-free clock switching for unrelated clocks

Conclusion

The hazard of generating a glitch on a clock line while switching between clock sources can be avoided with very little overhead by using the design techniques presented in this article. These techniques are fully scalable and can be extended to a clock switch for more than two clocks. For multiple clock sources, the select signal for each clock source will be enabled by feedback from all the other sources.

Monday, June 22, 2009

VCS on Ubuntu

Now I am trying to install VCSmx C-2009.06 on the Ubuntu 9.10.

1. Install the scl
I have try the scl11.0. But the old license doesn't work. So I have changed it back to scl10.9

2. Install the vcsmx c-2009.06
  • Replace the /bin/sh with /bin/bash
  • Add link /bin/basename from /usr/bin/basename

25 awesome Cross-platform games you can download for free

Regardless of what operating system you run on your computer, it doesn't have to be all work and no play. Heck, that could turn you into some kind of axe-wielding homicidal maniac bent on destroying your own family while watching over a remote resort hotel in the dead of winter.

I'd certainly never want that to happen to any of our DownloadSquad readers, so here's a list of games that you can install on Windows, Mac, and Linux (and some even on BeOS and BSD). Enjoy!

...And, as usual, if there's a particularly killer cross-platform game that I didn't include, feel free to post it in the comments -- and tell us why you love it!


Battle for Wesnoth - One of the best known open source games around, Wesnoth is an excellent fantasy-themed turn-based strategy game. There's plenty here to keep you busy - multiple campaigns and large maps, and online multiplayer for when you grow weary of playing on your own.

Battle Tanks - It's got colorful, cartoonish graphics, massive explosions, tanks....And best of all, it's got multiplayer. What could be more fun than blowing up your friends while causing immeasurable damage to an unsuspecting city?


Bos Wars - Realtime strategy in the future. With rocket tanks. That's a thousand times cooler than sharks with laser beams on their heads.

Crack Attack - No, it's not a Dope Wars clone - it's similar to Bejewelled or any of the other click-and-eliminate-blocks games that have been created by world + dog over the past few years. Bonus points to the developer for his awesome advanced features page.

Cube2: Sauerbraten - Another excellent open source FPS. One of the coolest things about it is that you can build and edit levels while you're in the game. There's also Quadropolis, a massive repository of goodies for the Cube engine including maps, scripts, and mods.

Eat the Whistle - If you're into uber-realist sports games, go ahead and scroll right past this one. If, however, you enjoy a little bit of humor and some old-school visuals, Eat the Whistle is a must-have download. Features sim, career, and arcade (complete with power-ups) modes.

FreeCiv - Another cornerstone of open source gaming. Inspired by Sid Meier's classic series, FreeCiv challenges you to develop your civilization from primitive roots into a thriving, modern society. Multiplayer mode support up to 30 (yes, 30) players. With more than 100 playable nations and 29 translations, FreeCiv is a truly international Time Waster.


FreeDroid - A modern take on the C64 classic Paradroid. It's a rich, futuristic RPG with plenty of robot butt kicking. In addition to dozens of different weapons, there's also a wide range of magic attacks, and you can even take control of your enemies and use them against each other.

Frets on Fire - If you've been looking for an excuse to rock out with your keyboard, go download Frets on Fire now. Tell your office mates your learning to play like Vadim Pruzhanov. Sure, he plays a different kind of keyboard, but it's still badass.


Glest - This fantasy themed RTS pits the opposing factions of magic and technology against each other. Do battle with mages, dragons, archers, horsemen, ornithopters, and more. If you grow weary of Glest itself, there are plenty of mods you can download to breath new life into the game.

Globulation 2 - A slick RTS that lets you focus on the "S" by intelligently handling part of the nettlesome micro-management this type of game usually requires. The game's built-in tutorial will help you learn how to build a powerful creature civilization that will be the envy of...er...other creatures.

Grid Wars 2 - There are times when playing this game makes you feel like you're trying to take on Asteroids, Tempest, and Gyruss all at once. If you like space shooters, bright, stunning visual,s and frantic gameplay, Grid Wars 2 will keep you riveted.

Hedgewars / Wormux - Two different takes on the turn-based goodness inspired by Worms. Both games feature awesome, cartoony graphics and fun gameplay, though I'm partial to Wormux (it may have something to do with the Gnu cannon).

LinCity - This popular open source city simulation hit version 2.0 this year, and it's looking better than ever. Manage your resources, keep people happy, and watch your creation grow into a booming metropolis - or cram everyone into spaceships and get the heck out of dodge - either way, you win!

Vega Strike - VS provides the backbone for a number of remix projects (like Pi Armada, Privateer Gemini Gold, and Parallel Universe). Explore space, build a trading empire, and blast your opponents to space dust. Plus, they just got their 'Super Ultra Cool Sound Systems' (SUCSS?) working last month.

Warsow - Warsow's developer credit Quakeworld, Quake CPMA, Jet Set Radio, and Speedball for inspiring aspects of their game, and it's a combination that really works. The game's fast pace and cell-shaded graphics work well together. Other cool features: dual firing modes (weak and strong) for weapons, wall jump, ramp slides, dashing, and dodging.

Widelands - If you enjoyed playing the Settlers games and haven't tried Widelands yet, now's the time. Lead your tribe to glory in single-player mode, or go multiplayer on your LAN or over the Internet. You and your friends can unite to form glorious new empires - or just try to kick the snot out of each other.

Wolfenstien: Enemy Territory - Mein Leben! Ok, so that was from the old, old Wolfenstein. The idea is the same: shoot all the bad guys or they'll shoot you (or blow you up). The links will take you to Planet Wolfenstein where you'll find downloads for all three OSes, map editors, source code, and more.

Yo Frankie! - Built on the Blender Game Engine, Yo Frankie is as good a 3d platformer as you'll find for free. There's lots of lighthearted action to enjoy, and new levels are constantly being developed by an enthusiastic community.

Neverball - If Marble Madness was cool, Neverball is absolute zero. Use your mouse to tilt the playing surface and manouver the ball to collect coins and reach the goal marker. The download also includes Neverputt, which is exactly what you think it is - a tilt-and-roll miniature golf game.

Phun - Two-dimensional physics sandbox tomfoolery! Create all kinds of crazy arrangements then turn Phun loose and see what happens. Objects can be made out of different materials, and they react in different ways. See how gravity, friction, and wind affect things. If only grade 12 physics had been this much fun...

Scourge - Scourge bills their project as a "graphical Rogue-like game." If that's true, think of Rogue as the plate and Scourge as a multi-layer, fancily decorated cake piled atop it. It's packed with open source Dungeons and Dragons style action. The project has some ambitious goals and is looking for contributors - if you enjoy playing it and can offer your skills, find the team on the #scourge IRC channel on Freenode.

Smokin' Guns - Take a Quake3-powered FPS, slather on some Briscoe County, Jr., and you've got Smokin' Guns. You can almost smell the black powder and road apples. It's good, old-fashioned, Wild West fun.

Vacuum Magic - If Luigi's Mansion left you thinking all vacuum-based games sucked, give this 2d side-scroller a try. It's just you and your mystical 'vacuum field' against all manner of nefarious critters. Suck in certain beasts and food items and you can spit 'em back out to inflict damage.

VDrift - Ever wished you could be just like Vin Diesel? I wouldn't go sharing that with too many people. On a related note, VDrift is an awesome 3D drift racing sim. The latest version boasts a smarter AI, better physics, new sounds, and improved overall performance.

FreeCol - Oh crap, I'm in trouble. As if I hadn't blown enough time over the years on the various Colonization/Civlization games. Explore new lands, build a nation, survive, and win! Thanks towcroskeys for suggesting this one!

Neuiz / Tremulous / Urban Terror - I included Nexuiz and Tremulous on a previous post, but all three of these great FPS games are worth mentioning again. There you go, zezke!

OpenArena / Alien Arena - By now you've noticed that cross-platform, open source gaming and FPS go hand in hand. Two more great choices, and as posted by 404 it may just have the most polished visuals of any in the bunch. Thanks to him, and to Austen for OpenArena!

Scorched 3D - A remake of the classic turn-based artillery game. Challenge other players online and be sure to check out some of the interesting mods, like Christmas and Stone Age. Big ba-da-boom. Thanks, Randy!

Warzone 2100 - Thanks to, er, John Doe for offering Warzone - a 3D RTS set in the future with a massive number of technologies (over 400) and units (more than 2,000). Multiplayer mode supports up to eight players.

Want more RTS action? Check out the list of games built on the Spring Engine, which feature themes like Star Wars, Gundam, and WWII (Spring: 1944). Thanks, Waldo!

Monday, June 8, 2009

Read an article about the synchronous or asynchronous reset. http://bit.ly/R9Y33

In FPGA design, I think synchronous reset is good: No clock gating, avoid glitch on reset signal. No metastable.

Synchronous Reset VS Asynchronous Reset

Why Reset?

A Reset is required to initialize a hardware design for system operation and to force an ASIC into a known state for simulation.

A reset simply changes the state of the device/design/ASIC to a user/designer defined state. There are two types of reset, what are they? As you can guess them, they are Synchronous reset and Asynchronous reset.

Synchronous Reset

A synchronous reset signal will only affect or reset the state of the flip-flop on the active edge of the clock. The reset signal is applied as is any other input to the state machine.

Advantages:

  • The advantage to this type of topology is that the reset presented to all functional flip-flops is fully synchronous to the clock and will always meet the reset recovery time.
  • Synchronous reset logic will synthesize to smaller flip-flops, particularly if the reset is gated with the logic generating the d-input. But in such a case, the combinational logic gate count grows, so the overall gate count savings may not be that significant.
  • Synchronous resets provide some filtering for the reset signal such that it is not effected by glitches, unless they occur right at the clock edge. A synchronous reset is recommended for some types of designs where the reset is generated by a set of internal conditions. As the clock will filter the logic equation glitches between clock edges.
Disadvantages:
  • The problem in this topology is with reset assertion. If the reset signal is not long enough to be captured at active clock edge (or the clock may be slow to capture the reset signal), it will result in failure of assertion. In such case the design needs a pulse stretcher to guarantee that a reset pulse is wide enough to be present during the active clock edge.
  • Another problem with synchronous resets is that the logic synthesis cannot easily distinguish the reset signal from any other data signal. So proper care has to be taken with logic synthesis, else the reset signal may take the fastest path to the flip-flop input there by making worst case timing hard to meet.
  • In some power saving designs the clocked is gated. In such designed only asynchronous reset will work.
  • Faster designs that are demanding low data path timing, can not afford to have extra gates and additional net delays in the data path due to logic inserted to handle synchronous resets.
Asynchronous Reset

An asynchronous reset will affect or reset the state of the flip-flop asynchronously i.e. no matter what the clock signal is. This is considered as high priority signal and system reset happens as soon as the reset assertion is detected.

Advantages:
  • High speeds can be achieved, as the data path is independent of reset signal.
  • Another advantage favoring asynchronous resets is that the circuit can be reset with or without a clock present.
  • As in synchronous reset, no work around is required for logic synthesis.
Disadvantages:
  • The problem with this type of reset occurs at logic de-assertion rather than at assertion like in synchronous circuits. If the asynchronous reset is released (reset release or reset removal) at or near the active clock edge of a flip-flop, the output of the flip-flop could go metastable.
  • Spurious resets can happen due to reset signal glitches.
Conclusion

Both types of resets have positives and negatives and none of them assure fail-proof design. So there is something called "Asynchronous assertion and Synchronous de-assertion" reset which can be used for best results. (which will be discussed in next post).