comparison of two unsigned std_logic_vectors

Guest #4574454
Hi everyone. I'm having problem comparing two unsigned same length 
std_logic_vectors. I'm using the std_logic_unsigned package which 
contains a set of comparison functions for same length std_logic_vectors 
including the function below:

function "<"(L: STD_LOGIC_VECTOR; R: STD_LOGIC_VECTOR) return BOOLEAN

Here's my code:
-----------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;


entity main_code is
  Port ( clk : in  STD_LOGIC;
         output : out  std_logic_vector (7 downto 0);
         ero : buffer  std_logic_vector (7 downto 0) := (others => '1')
        );
end main_code;


architecture Behavioral of main_code is

signal address: std_logic_vector(3 downto 0) := (others => '0');
signal dout_rom: STD_LOGIC_VECTOR(7 DOWNTO 0) := (others => '0');

--- component declaration (rom_core was generated by ISE core generator)
COMPONENT rom_core
  PORT (
    clka : IN STD_LOGIC ;
    addra : IN STD_LOGIC_VECTOR(3 DOWNTO 0);
    douta : OUT STD_LOGIC_VECTOR(7 DOWNTO 0)
  );
END COMPONENT;
---

begin

------ port map
your_instance_name : rom_core
  PORT MAP (
    clka => clk,
    addra => address,
    douta => dout_rom
  );
-----

output <= dout_rom;

process(clk)
begin
          if(clk'event and clk='0') then
      address <= address + 1;
    end if;

end process;

if (dout_rom < ero) then   -- line 83
ero_sig <= dout_rom;
end if;   -- line 85

end Behavioral;
----------------------------------------------------------------------

and here are the errors I get:

Line 83: Syntax error near "if".
Line 85: Syntax error near "if".

The rest of the code (the code minus the last if-clause) is compiled 
successfully. I can't figure the errors out. I would be really pleased 
to hear from you.
Guest #4574462
Hi Farzam,

the error message implies, that the if statement is the problem. If it 
would be the comparison, the error message would mention something about 
mismatching data types or mismatching vector lengths.

In fact, the part outside of a process, is to bee seen as a concurrent 
section, within an if-statement is not allowed.
Guest #4574480
Thanks a lot for the answer Staubfänger. I see what you're saying. The 
problem is solved. Thanks a lot again.

Reply

A question of your own? This thread is over 10 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.