generic compare in if statement help?

Discussion in 'VHDL' started by Kamachi923@gmail.com, Apr 24, 2007.

  1. Guest

    this is what i have

    sig : std_logic_vector((width - 1) downto 0);
    ..
    ..
    ..
    ..
    if(sig = ???????)then
    ..
    ..
    ..


    Basically what I am trying to do is compare sig to a vector that would
    be all 0's and lsb is a 1 and another one that would be msb and lsb 1
    and all the rest 0's. So some examples would would be:
    width = 3
    sig = 001 or 101

    width = 4
    sig = 0001 or 1001

    I found this line from another post
    Sig = (Sig'high downto Sig'low + 1 => '0', Sig'low => '1')

    but i tried that in my if statement and when i compile modelsim gives
    me this error.

    ** Error: C:/PROJECTS/RPECS/spi/spi.vhd(99): (vcom-1073) Non-locally
    static choice (association #1, choice #1) is allowed only if it is the
    only choice of the only association.

    so any help with this would be greatly appreciated. thanks.
     
    , Apr 24, 2007
    #1
    1. Advertising

  2. Jim Lewis Guest

    Strip out the left bit and compare to integer 1:

    use ieee.numeric_std.all ; -- before entity
    . . .

    if unsigned(sig(width-2 downto 0)) = 1 then


    > this is what i have
    >
    > sig : std_logic_vector((width - 1) downto 0);
    > .
    > .
    > .
    > .
    > if(sig = ???????)then
    > .
    > .
    > .
    >
    >
    > Basically what I am trying to do is compare sig to a vector that would
    > be all 0's and lsb is a 1 and another one that would be msb and lsb 1
    > and all the rest 0's. So some examples would would be:
    > width = 3
    > sig = 001 or 101
    >
    > width = 4
    > sig = 0001 or 1001
    >
    > I found this line from another post
    > Sig = (Sig'high downto Sig'low + 1 => '0', Sig'low => '1')
    >
    > but i tried that in my if statement and when i compile modelsim gives
    > me this error.
    >
    > ** Error: C:/PROJECTS/RPECS/spi/spi.vhd(99): (vcom-1073) Non-locally
    > static choice (association #1, choice #1) is allowed only if it is the
    > only choice of the only association.
    >
    > so any help with this would be greatly appreciated. thanks.
    >
     
    Jim Lewis, Apr 24, 2007
    #2
    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. Murat Tasan
    Replies:
    1
    Views:
    8,131
    Chaitanya
    Feb 3, 2009
  2. Replies:
    2
    Views:
    480
  3. Compare Generic Type

    , Nov 24, 2004, in forum: C Programming
    Replies:
    2
    Views:
    866
    Martin Ambuhl
    Nov 25, 2004
  4. Eddie Simons

    How to use Option Compare statement

    Eddie Simons, Feb 9, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    478
    Phil Johnson
    Feb 9, 2008
  5. minlearn
    Replies:
    2
    Views:
    493
    red floyd
    Mar 13, 2009
Loading...

Share This Page