Use of std_logic '-' don't care.

M

M. Norton

Well, when Ashenden fails me, here's where I turn. Hopefully this is
a quickie.

I defined an address constant in the following manner (as an example).

constant MY_ADDR : std_logic_vector(7 downto 0) := "10010---";

The intent here is that only the 5 most significant bits are decoded
and the last 3 are don't care.

As a matter of fact, I have an array of these addresses. So, I had
something like the following while processing the addresses (this is
testbench code, never intended for synthesis):

for i in 0 to NUM_ADDR-1 loop
if (addr = MY_ADDR(i)) then
-- Do something incredibly interesting here
end if;
end loop;

What I discovered was that my incredibly interesting code was not
being used. So, thinks I, perhaps the equality operator is taking
this a little more seriously than I wanted? I turn to Ashenden, and
study the bits where std_ulogic is discussed, and then the operators,
and there seems to be no mention of how an equality test treats don't
cares in a vector.

So, language gurus, is this correct? Is equality going to look for
EXACTLY the same vector, including don't cares? If this is true, then
I'll need to do some sort of explicit decode. I'm fairly certain
things like 'and' and 'or' behave nicely with don't cares, so that may
be the way to go. I was hoping for something a little more intuitive,
but such is life sometimes.

Thanks!
Mark Norton
 
M

M. Norton

Which is precisely why I pushed for the "std_match" function in numeric_std.

In VHDL-2008 you can use the "case?" syntax (see section 8.8) does
pretty much what you want here.  You also have the ?= syntax.

It's definitely a good function. I'm reminded that way back when,
when I did more C programming I had a small book of C functions and
library packages that was extremely handy for coding purposes. As
well as a reminder of the syntax of functions, it's information on
what functions actually EXIST.

I have to admit, if a functino doesn't show up on a quick reference
card that I have stashed around, and not a basic language feature, I'm
not likely to know about it. textio is an exception, though I have a
sticky note tab in my Ashenden book for the big list of procedures and
functions that acts as as a quick reference card. It would probably
be well worth my time digging through the standard packages for other
gems like std_match. The trick will be remembering them if/when the
opportunity to use them arises.
 
M

M. Norton


Thanks. Those look extremely handy, particularly the overloaded
operators and conversion functions. I know I'm always consulting the
notes I have on the types and how to move back and forth between
them. And lo and behold there is std_match (though not a lot of
description of what it does... would still probably need to look at
the library code to ascertain that it is accounting for the non-binary
values to which std_logic may be set.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top