Use of std_logic '-' don't care.

Discussion in 'VHDL' started by M. Norton, Oct 17, 2008.

  1. M. Norton

    M. Norton Guest

    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. Norton, Oct 17, 2008
    #1
    1. Advertising

  2. Mike Treseler, Oct 17, 2008
    #2
    1. Advertising

  3. M. Norton

    M. Norton Guest

    On Oct 16, 5:09 pm, Mike Treseler <> wrote:
    > M. Norton wrote:
    > > constant MY_ADDR : std_logic_vector(7 downto 0) := "10010---";

    > ...
    > > What I discovered was that my incredibly interesting code was not
    > > being used.  

    >
    > http://www.vhdl.org/comp.lang.vhdl/FAQ1.html#dont_cares


    Again, thank you! I had no idea that function existed (the
    std_match). Does precisely what I wanted for this.
     
    M. Norton, Oct 17, 2008
    #3
  4. M. Norton

    M. Norton Guest

    On Oct 19, 4:00 pm, David Bishop <> wrote:
    > 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. Norton, Oct 20, 2008
    #4
  5. Mike Treseler, Oct 20, 2008
    #5
  6. M. Norton

    M. Norton Guest

    On Oct 20, 2:11 pm, Mike Treseler <> wrote:
    > M. Norton wrote:
    > > 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.

    >
    > Check out the qualis cheat sheets
    >
    >  http://www.vhdl.org/rassp/vhdl/guidelines/vhdlqrc.pdf
    >  http://www.vhdl.org/rassp/vhdl/guidelines/1164qrc.pdf


    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.
     
    M. Norton, Oct 20, 2008
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gregory Huffman

    How to include don't care minterms

    Gregory Huffman, Jan 26, 2004, in forum: VHDL
    Replies:
    3
    Views:
    7,590
    Gregory Huffman
    Jan 28, 2004
  2. bittor

    Don't care signals

    bittor, Feb 14, 2005, in forum: VHDL
    Replies:
    1
    Views:
    5,424
    Tim Hubberstey
    Feb 14, 2005
  3. Andrew Greensted

    Don't care and optimization

    Andrew Greensted, Jan 10, 2006, in forum: VHDL
    Replies:
    3
    Views:
    3,231
    Andrew Greensted
    Jan 11, 2006
  4. Simon  Willison
    Replies:
    8
    Views:
    308
    John J. Lee
    Oct 3, 2006
  5. janeruth

    conditional on a don't care

    janeruth, Aug 3, 2010, in forum: VHDL
    Replies:
    4
    Views:
    742
    janeruth
    Aug 4, 2010
Loading...

Share This Page