Generic range

A

ALuPin

Hi,

I am trying to do the following:

signal ls_test : unsigned(7 downto 0);


process(ls_test)
begin
if ls_test(7 downto 1) = "0000000" then
...
end if;
end process;


Now I want to have something like:

signal ls_test : unsigned(gWidth-1 downto 0);

process(ls_test)
begin
if ls_test = (ls_test'high downto ls_test'low +1 => '0') then
...
end if;
end process;

When compiling I get the following error:
"Operator "=" is not defined for such operands.

Can somebody share some light on it ?

Thank you.
Rgds, ALuPin
 
B

Bert_Paris

(e-mail address removed) a formulé la demande :
Hi,

I am trying to do the following:

signal ls_test : unsigned(7 downto 0);


process(ls_test)
begin
if ls_test(7 downto 1) = "0000000" then
...
end if;
end process;


Now I want to have something like:

signal ls_test : unsigned(gWidth-1 downto 0);

process(ls_test)
begin
if ls_test = (ls_test'high downto ls_test'low +1 => '0') then
...
end if;
end process;

When compiling I get the following error:
"Operator "=" is not defined for such operands.

Can somebody share some light on it ?

Thank you.
Rgds, ALuPin

Is this what you're trying to write ?

constant gWidth : positive := 8;
signal ls_test : unsigned(gWidth-1 downto 0);
Begin
process (ls_test)
begin
if ls_test (ls_test'high downto ls_test'low +1) = 0 then
report "done !";
end if;
end process;

Bert Cuzeau
 
A

ALuPin

Hi Bert,

not exactly.

Your solution works for
if ls_test = (ls_test'high downto ls_test'low +1 => '0') then

but not for
if ls_test = (ls_test'high downto ls_test'low +1 => '1') then

that is all the vector bits are '1'.

Rgds,
ALuPin
 
B

Bert_Paris

(e-mail address removed) avait soumis l'idée :
Hi Bert,

not exactly.

Your solution works for


but not for


that is all the vector bits are '1'.

Rgds,
ALuPin

Then :

constant gWidth : positive :=8;
signal ls_test : signed(gWidth-1 downto 0) := (0=>'0', others=>'1');
Begin
process (ls_test)
begin
if ls_test (ls_test'high downto ls_test'low +1) = -1 then
report "all ones, LSB ignored !";
end if;
end process;
 
R

Ralf Hildebrandt

if ls_test(7 downto 1) = "0000000" then

With IEEE.numeric_std.all you can write

if ls_test(7 downto 1) = 0 then

because ls_test is defined as unsigned vector.

Unsigned can be compared to integer and so you do this independently
from the range.

Ralf
 
A

Andy

Then :

constant gWidth : positive :=8;
signal ls_test : signed(gWidth-1 downto 0) := (0=>'0', others=>'1');
Begin
process (ls_test)
begin
     if ls_test (ls_test'high downto ls_test'low +1) = -1 then
       report "all ones, LSB ignored !";
    end if;
end process;- Hide quoted text -

- Show quoted text -

There are also easier ways to strip off the lsb of an unsigned/signed
vector.

constant gWidth : positive := 8;
signal ls_test : unsigned(gWidth-1 downto 0);
....
if lstest / 2 = 0 then...

or:

if signed(lstest) / 2 = -1 then...

Andy
 
F

florinfr

Hi,

I am trying to do the following:

signal ls_test : unsigned(7 downto 0);

process(ls_test)
begin
     if ls_test(7 downto 1) = "0000000" then
       ...
    end if;
end process;

Now I want to have something like:

signal ls_test : unsigned(gWidth-1 downto 0);

process(ls_test)
begin
     if ls_test = (ls_test'high downto ls_test'low +1 => '0') then
       ...
    end if;
end process;

When compiling I get the following error:
"Operator "=" is not defined for such operands.

Can somebody share some light on it ?

Thank you.
Rgds, ALuPin

You can try something like this:

signal ls_test : unsigned(gWidth-1 downto 0);

process(ls_test)
begin
if ls_test = conv_std_logic_vector(0,gWidth) then
...
end if;
end process;

You can replace 0 with any unsigned integer constant.

Florin
 

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

Forum statistics

Threads
473,774
Messages
2,569,600
Members
45,180
Latest member
CryptoTax Software
Top