Handling the Don’t Care Value

Facebooktwittergoogle_plusredditpinterestlinkedinmail

In my previous blog, I talked about the nine-value VHDL logic system. As part of those discussions, I mentioned the “Don’t Care” value ‘–’. In particular, we noted how this value is not really meant to be used in comparison operations such as “IF” and “CASE” statements. Instead, the “Don’t Care” value is traditionally used as an assignment when specifying output values.

Having said this, people often ask “Is it possible to use the ‘Don’t Care’ value with comparison operators as it could be very useful?” Like many things, the answer is “yes” with the help of a very useful function — the “std_match()” function provided in the “numeric_std” package (“USE ieee.numeric_std.ALL”).

The “std_match()” function allows the use of “Don’t Care” values during comparison operations. This comes in very useful when we are trying to implement functions like priority encoders, because it allows the “CASE” or “IF” statement to be specified in many fewer lines of code as demonstrated below where a simple priority encoder is implemented.

If we were to perform a comparison just using the “=” operator, we would receive a synthesis warning similar to the following:

Possible simulation mismatch due to ‘-‘ in condition expression

By comparison (no pun intended), if we were to employ the “std_match()” function as demonstrated in the following snippet of code, we would not receive this warning:

174254_897604

In attempt to reduce the need to use the “std_match()” function, VHDL 2008 — which was published by Accellera in 2008, and which is now the official IEEE 1076-2008 standard — introduced many useful upgrades to the language. In addition to including support for new fixed- and floating-point number systems, and the incorporation of the Property Specification Language (PSL) into VHDL, VHDL 2008 also introduced the “CASE?” keyword. This new keyword allows the ‘-‘ to be used as a “Don’t Care” value in comparison operations provided the choices are overlapping. Thus, using the new “CASE?” operator, the code above would be rewritten as follows:

174306_955553

The only remaining question would be why have I included both the “std_match()” approach and the newer “CASE?” method of performing this operation in this column? Why didn’t I just talk about the “CASE?” approach and have done with it?

Well, the answer is both simple and mundane. Although VHDL 2008 was published by Accellera in 2008, and was accepted by the IEEE in January 2009, it takes time for the various tool manufacturers to support new languages features. Often it is pressure from the users that is responsible for the manufacturers introducing new features. As is often the case in life, if you do not ask you will not get. (“The squeaky wheel is the one that gets the oil,” as the old saying goes.)

Facebooktwittergoogle_plusredditpinterestlinkedinmail