generic compare in if statement help?

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.
 
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.
 

Welcome to EDABoard.com

Sponsor

Back
Top