--- Quote Start ---
Take some time, look at the error. It is on line 126. Look closely, your compiler is trying to help you. See lines 118 and 122 for reference.
--- Quote End ---
i wasn't the main problem, but i already solved it
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
package my_pkg is
function to_bcd (bin : std_logic_vector(7 downto 0)) return std_logic_vector;
end package my_pkg;
package body my_pkg is
function to_bcd (bin : std_logic_vector(7 downto 0)) return std_logic_vector is
variable aux: std_logic_vector (20 downto 0);
variable bcd: std_logic_vector(11 downto 0);
begin
aux := (OTHERS=>'0');
aux(8 downto 1) := bin(7 downto 0);
for i in 0 to 7 loop
if aux(12 downto 9) > 4 then
aux(12 downto 9) := aux(12 downto 9) + 3;
end if;
if aux(16 downto 13) > 4 then
aux(16 downto 13) := aux(16 downto 13) + 3;
end if;
aux(20 downto 1) := aux(19 downto 0);
end loop;
bcd := aux(20 downto 9);
return bcd;
end to_bcd;
end package body my_pkg;
library ieee;
use ieee.std_logic_1164.all;
library work;
use work.my_pkg.all;
entity termometro is
port (
data: in std_logic_vector(7 downto 0);
Di: out std_logic_vector (6 downto 0);
Vtc:out std_logic_vector(2 downto 0); -- como soh usarar 3 displays nao precisa colocar energia nos 4
clk: in std_logic
);
end termometro;
architecture behavior of termometro is
signal bcd1, bcd2, bcd3: std_logic_vector(3 downto 0);
signal aux: std_logic_vector(11 downto 0);
type segs is(se0, se1, se2);
signal seg_atual, prox_seg: segs;
signal S1, S2, S3: std_logic_vector(6 downto 0);
begin
aux <= to_bcd(data);
bcd1<=aux(3 downto 0);
bcd2<=aux(7 downto 4);
bcd3<=aux(11 downto 8);
WITH bcd1 SELECT
S1 <= "1111110" when "0000",
"0110000" when "0001",
"1101101" when "0010",
"1111001" when "0011",
"0110011" when "0100",
"1011011" when "0101",
"0100000" when "0110",
"1110000" when "0111",
"1111111" when "1000",
"1111011" when "1001",
"0000000" when others;
WITH bcd2 SELECT
S2 <= "1111110" when "0000",
"0110000" when "0001",
"1101101" when "0010",
"1111001" when "0011",
"0110011" when "0100",
"1011011" when "0101",
"0100000" when "0110",
"1110000" when "0111",
"1111111" when "1000",
"1111011" when "1001",
"0000000" when others;
WITH bcd3 SELECT
S3 <= "1111110" when "0000",
"0110000" when "0001",
"1101101" when "0010",
"1111001" when "0011",
"0110011" when "0100",
"1011011" when "0101",
"0100000" when "0110",
"1110000" when "0111",
"1111111" when "1000",
"1111011" when "1001",
"0000000" when others;
process(clk) is
begin
if(clk = '1' and clk'event) then
seg_atual<=prox_seg;
end if;
end process;
process (S1, S2, S3) is
begin
case seg_atual is
when se0=>
Di <= S1;
Vtc<= "001";
prox_seg <= se1;
when se1 =>
Di <= S2;
Vtc<= "010";
prox_seg <= se2;
when se2 =>
Di <= S3;
Vtc<= "100";
prox_seg <= se0;
end case;
end process;
end behavior;