The don't care value '-' in std_logic is an actual value - i.e. it
doesn't cause any value to match.

As an example:

case test is
    when "111-" =>
        output <= '1';
    when others =>
        output => '0';
end case;

When examining the first clause "111-" a literal match is required -
i.e. "1110", "111Z", "111H" etc will NOT match and will not cause output
to be set. The only thing that will cause a match here is if the value
really is "111-".

This means that you would effectively have to write out the case
statement long-hand, e.g.

case test is
    when "1111" =>
        output <= '1';
    when "1110" =>
        output <= '1';
    when "111H" =>
        output <= '1';
    when "111L" =>
        output <= '1';
    when "111Z" =>
        output <= '1';

    -- etc

    when others =>
        output => '0';
end case;

VHDL 2008 introduced an alternative to this obvious pain in the
backside. If you write the "case" with a question mark then it will
cause the '-' to be evaluated as don't care rather than the actual
value:

?case test is
    when "111-" =>
        output <= '1';
    when others =>
        output => '0';
end case;

In this example (assuming that you've compiled the code as VHDL 2008 and
your compiler actually supports this) then "1110", "1111", "111H" etc
will all cause the output to be set.

BUT, hopefully someone will correct me if I'm wrong but I don't think
that GHDL supports VHDL 2008 yet. Tristan obviously has a lot of work to
do and what he has produced to date is very admirable and generous, so
please don't read this as any criticism. I know ActiveHDL from Aldec
only supports a few features of VHDL 2008; I don't know about Modelsim
but I wouldn't want to touch that with a barge pole anyway.

I guess that ties in with what you are seeing. Check the Doulos site for
correct VHDL 2008 syntax and hopefully someone will correct me if I'm
out of date on what GHDL can and can't do.

As ever thanks to Tristan for his sterling efforts with GHDL. I think it
compares very favourably against the expensive proprietary tools and
usually sticks closer than any to the LRM.


-----Original Message-----
From: Stephen Leake <[email protected]>
Reply-to: GHDL discuss list <[email protected]>
To: GHDL discuss list <[email protected]>
Subject: Re: [Ghdl-discuss] case statement with don't care
Date: Sun, 12 Jun 2011 11:03:18 -0400


KIMURA Masaru <[email protected]> writes:

> I use "case statement with don't care" in my KCPSM6 clone[1] and it
> doesn't work as I expected.
> To ease to understand what I expected, summarized code is attached.

What are you expecting, and what does it do instead?



_______________________________________________
Ghdl-discuss mailing list
[email protected]
https://mail.gna.org/listinfo/ghdl-discuss

Reply via email to