Talk About Network

Google





Electronic Equipment > VHDL > Re: Comparing m...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 6 Topic 6052 of 6445
Post > Topic >>

Re: Comparing more than one bits?

by Jonathan Bromley <jonathan.bromley@[EMAIL PROTECTED] > May 28, 2008 at 02:56 PM

On Wed, 28 May 2008 14:40:02 +0100, Rob <Rob@[EMAIL PROTECTED]
> 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@[EMAIL PROTECTED]
 contents of this message may contain personal views which 
are not the views of Doulos Ltd., unless specifically stated.
 




 6 Posts in Topic:
Comparing more than one bits?
Rob <Rob@[EMAIL PROTEC  2008-05-28 12:52:34 
Re: Comparing more than one bits?
rickman <gnuarm@[EMAIL  2008-05-28 06:32:57 
Re: Comparing more than one bits?
Rob <Rob@[EMAIL PROTEC  2008-05-28 14:40:02 
Re: Comparing more than one bits?
Jonathan Bromley <jona  2008-05-28 14:56:16 
Re: Comparing more than one bits?
rickman <gnuarm@[EMAIL  2008-05-28 07:19:25 
Re: Comparing more than one bits?
Brian Drummond <brian_  2008-05-29 13:11:53 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Thu Jan 8 17:57:57 PST 2009.