0
\$\begingroup\$

I want to convert from binary to hexadecimal but I found a few problems with VHDL in Quartus II.

library ieee;
use ieee.std_logic_1164.all;

entity Hexadecimal is port


(
hexadecimal: in integer range 0 to 9; 
binario: out std_logic_vector(3 downto 0)
);
end Hexadecimal;
architecture comportamiento of Hexadecimal is
begin
    process (hexadecimal)
    begin
        If hexadecimal = 0 then
            binario <= "0000";
        elsif hexadecimal = 1 then
            binario <= "0001";
        elsif hexadecimal = 2 then
            binario <= "0010";
        elsif hexadecimal = 3 then
            binario <= "0011";
        elsif hexadecimal = 4 then
            binario <= "0100";
        elsif hexadecimal = 5 then
            binario <= "0101";
        elsif hexadecimal = 6 then
            binario <= "0110";
        elsif hexadecimal = 7 then
            binario <= "0111";
        elsif hexadecimal = 8 then
            binario <= "1000";
        elsif hexadecimal = 9 then
            binario <= "1001";
        elsif hexadecimal = 'A' then
            binario <= "1010";
        elsif hexadecimal = 'B' then
            binario <= "1011";
        elsif hexadecimal = 'C' then
            binario <= "1100";
        elsif hexadecimal = 'D' then
            binario <= "1101";
        elsif hexadecimal = 'E' then
            binario <= "1110";
        else
            binario <= "1111";
        end if;
    end process;
end comportamiento;

But when I try to compile it, it throws this error:

Error (10327): VHDL error at Hexadecimal.vhd(33): can't determine definition of operator ""="" -- found 0 possible definitions

I came to this forum at last because I tried everything. I hope you guys know how to solve this.

New contributor
ReneYami is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
\$\endgroup\$
  • 1
    \$\begingroup\$ First you say hexadecimal is in the range 0 to 9. Then you check if it's equal to A, B, C, etc. I don't know VHDL, but there's probably a problem there. \$\endgroup\$ – The Photon Mar 26 at 5:37
  • \$\begingroup\$ Yes that is wrong . Also you are not converting binary to hexadecimal but the other way around. Note that an integer hexadecimal number already HAS the right binary bits. All you need is to convert from integer to std_logic_vector. \$\endgroup\$ – Oldfart Mar 26 at 7:11
-1
\$\begingroup\$

Type conversion is possibly a easier and more efficient way to do this. For hex to std_logic use

binario <= to_stdlogicvector(hexadecimal);

Make sure you include the ieee std_logic_arith package.

\$\endgroup\$
  • \$\begingroup\$ Better to use the standard libraries. \$\endgroup\$ – Brian Drummond Mar 26 at 12:57

Your Answer

ReneYami is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.