Re: Comparing more than one bits?
- From: Jonathan Bromley <jonathan.bromley@xxxxxxxxxxxxx>
- Date: Wed, 28 May 2008 14:56:16 +0100
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.
.
- References:
- Comparing more than one bits?
- From: Rob
- Re: Comparing more than one bits?
- From: rickman
- Re: Comparing more than one bits?
- From: Rob
- Comparing more than one bits?
- Prev by Date: Re: VHDL switch model
- Next by Date: Re: Comparing more than one bits?
- Previous by thread: Re: Comparing more than one bits?
- Next by thread: Re: Comparing more than one bits?
- Index(es):
Relevant Pages
|