Re: Comparing more than one bits?



On Wed, 28 May 2008 14:40:02 +0100, Rob <Rob@xxxxxxxxxxx> wrote:

... if some_unsigned(31 downto 26) = "100111" then ...

How is data_bus declared? If it is std_logic_vector, this looks good
to me. The error message is saying that it can't find a version of
'=' that uses the two operand types and produces a boolean which is
required by the IF. Did you include the libraries?

It is declared as unsigned...so in this case I cant compare bitwise I
assume. But I could cast it to std_logic_vector, couldnt I?

I suspect the problem is that you're using the std_logic_arith
package rather than numeric_std.

std_logic_arith has overloads for unsigned=unsigned and also for
unsigned=signed. Consequently, the type of your "100111" is
ambiguous - although you aren't getting the right error message
for that - and the compiler should indeed choke on it. The
properly-standardised numeric_std package does not have an
unsigned=signed overload, so there's no ambiguity.

Fixes - ah, so many choices...

(1) cast to std_logic_vector as you suggest;
(2) type-qualify the constant as unsigned (NOTE the apostrophe):
if some_unsigned(31 downto 26) = unsigned'("100111") then...
(3) use numeric_std in preference to std_logic_arith;
(4) use an ordinary integer literal for the comparison:
if some_unsigned(31 downto 26) = 39 then ...
if some_unsigned(31 downto 26) = 2#100111# then ...

hth
--
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services

Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
jonathan.bromley@xxxxxxxxxxxxx
http://www.MYCOMPANY.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.
.



Relevant Pages

  • Re: Copy lines between two markers
    ... commented out to see error message) ... set found [regexp -nocase \ ... {(Report Summary.*?)Critical Nets} ... DOULOS - Developing Design Know-how ...
    (comp.lang.tcl)
  • Re: Error-[POISC] Property operator in sequence context
    ... The error message says it all; ... implication operator in an expression that is the ... DOULOS - Developing Design Know-how ...
    (comp.lang.verilog)
  • Re: Comparing more than one bits?
    ... The error message is saying that it can't find a version of ... '=' that uses the two operand types and produces a boolean which is ...
    (comp.lang.vhdl)
  • Re: Is this legal?
    ... Can you provide the text of the error message? ... Name 'foobar' at is an ambiguous reference to 'foobar' from ... I know that there have been some hiccups with handling ambiguity properly, so you may have run into a bug which was fixed in 4.3 or newer. ...
    (comp.lang.fortran)
  • Re: Is this legal?
    ... Can you provide the text of the error message? ... Name 'foobar' at is an ambiguous reference to 'foobar' from ... with handling ambiguity properly, ...
    (comp.lang.fortran)