I have this VHDL code
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity addDecoder is
port(addrInput : in real;
ROM_sel_n, RAM_sel_n, PIO_sel_n, SIO_sel_n, INT_sel_n : out bit);
end addDecoder;
architecture Behavioral of addDecoder is
begin
AddSelect : process(addrInput) is
begin
if(addrInput <= X'3FFF') then
ROM_sel_n <= '1';
elsif(addrInput > X'3FFF' and addrInput <= X'5FFF') then
RAM_sel_n <= '1';
elsif(addrInput > X'5FFF' and addrInput <= X'8FFF') then
PIO_sel_n <= '1';
elsif(addrInput > X'8FFF' and addrInput <= X'9FFF') then
SIO_sel_n <= '1';
elsif(addrInput > X'9FFF' and addrInput <= X'FFFF') then
INT_sel_n <= '1';
end process AddSelect;
end Behavioral;
What is wrong with it. I’m getting an error with the comparing of the hexadecimal values. Am I not doing this correctly? The error is this: parse error, unexpected INTEGER_LITERAL, expecting OPENPAR or IDENTIFIER
As Philippe already said, don’t use std_logic_arith/unsigned. Use
numeric_std. I’ve written about why….If you want to continue to make comparisons with vectors (as well as using
"rather than'around the values) you should make youraddrInputanunsignedvector.Alternatively make it a
naturaland compare against integer values:Also, as you are using
elsif, you could simplify your statements thus:Finally, drop the
()s around yourifconditions, it makes you look like a C-programmer 🙂