Altera_Forum
Honored Contributor
16 years agoCall Procedure inside Function
Hi, i have a question: How can i call a Procedure inside of a Function?
The Quartus show me: VHDL error at Decod.vhd(150): cannot access 'maissig' from inside pure function 'soma'. my code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity Decod is
port
(
CLK : in std_logic; -- SINAL DE CLOCK
Dados : in std_logic_vector (7 downto 0);
Ch_A : in std_logic;
Ch_B : in std_logic;
Ch_C : in std_logic;
out3 : out integer;
out4 : out integer;
Disp1 : out std_logic_vector(7 downto 0);
Disp2 : out std_logic_vector(7 downto 0);
Disp3 : out std_logic_vector(7 downto 0));
end Decod;
architecture Funcao of Decod is
type Chave is (Zero, Um, Dois, Tres, Quatro, Cinco, Seis, Sete);
signal Estado : Chave := Zero;
signal word : std_logic_vector (11 downto 0) := "000000000000";
signal D1 : integer range 0 to 15;
signal D2 : integer range 0 to 15;
signal D3 : integer range 0 to 15;
signal MaisSig : std_logic_vector (7 downto 0) := "00000000";
signal MenosSig : std_logic_vector (7 downto 0) := "00000000";
signal H_Alto : integer;
signal H_Baixo : integer;
signal a : std_logic_vector(3 downto 0);
signal b : std_logic_vector(3 downto 0);
PROCEDURE Nibble ( Vetor : in std_logic_vector (7 downto 0);
signal P_alta : out std_logic_vector (7 downto 0);
signal P_baixa : out std_logic_vector (7 downto 0)) is
BEGIN
P_alta (3 downto 0) <= Vetor(7 downto 4);
P_baixa (3 downto 0) <= Vetor(3 downto 0);
END Nibble;
FUNCTION Soma ( Vetor : std_logic_vector (7 downto 0);
a : integer; b : integer) RETURN INTEGER IS
variable Som : integer range 0 to 30 := 0;
variable V_a : std_logic_vector (7 downto 0);
variable V_b : std_logic_vector (7 downto 0);
BEGIN
Nibble (Vetor(7 downto 0), MaisSig(7 downto 0), MenosSig(7 downto 0));
V_a := MaisSig;
V_b := MaisSig;
a := Decimal(V_a(7 downto 0));
b := Decimal(V_b(7 downto 0));
Som := a + b;
RETURN Som;
END Soma;
end funcao;
Please, where the error?