generic compare in if statement help?

K

Kamachi923

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

Jim Lewis

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
 

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,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top