Question on Comparing two std logic vecter

Tha

Joined
Apr 10, 2011
Messages
3
Reaction score
0
Hi, I am new on VHDL, and I am writing a code that comparing two 32 bits std_logic_vector. If they are equal, a result of all one bits is produce, otherwise, a result of all zero bits is produce.
However, when I simulate my code, the following warnings appears:
WARNING: There is an 'U'|'X'|'W'|'Z'|'-' in an arithmetic operand, the result will be 'X'(es).
and I didn't get the correct result. My tb values are:
a = 00000000000001111111111111111111
b = 00000000000001111111111111111111
the result should be 32 1's
but it gave me 32 0's.
Can anyone please help me out? Thank you so much!

The following is my code:
entity ceq is
port(ra : in std_logic_vector(31 downto 0);
rb : in std_logic_vector(31 downto 0);
rt : out std_logic_vector(31 downto 0));
end ceq;

architecture ceq_stru of ceq is
signal rts : std_logic_vector(31 downto 0);
begin
comp: process (ra, rb)
variable count : std_logic_vector (31 downto 0)
:= "00000000000000000000000000000000";
begin
rts <= ra xor rb;
if rts = count then
rt <= (others => '1');
else
rt <= count;
end if;

end process comp;

end ceq_stru;
 

Tha

Joined
Apr 10, 2011
Messages
3
Reaction score
0
Okay, just after I post this thread , I found out why my code doesn't work.

"Note that this library doesn't allow you to do comparisons on std_logic_vector values. That's because it's impossible for it to determine whether a particular std_logic_vector is representing a signed or unsigned value. To do this, you need to use either the std_logic_unsigned or std_logic_signed libraries."

referred from http://www.cs.sfu.ca/~ggbaker/reference/std_logic/arith/comp.html
 
Joined
Jan 29, 2009
Messages
152
Reaction score
0
The problem is signal semantics - signals are updated only after "one delta" - that is, at the end of the process.

It should work correctly after making rts a variable.
 

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,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top