Are you allowed to use a process inside a procedure? Here's my code and the associated error. The goal was to implement a BCD counter that counts up to 10, then restarts back at 1.
procedure BCD_Counter (signal CLK, EN: in STD_LOGIC_VECTOR;
signal Q: out STD_LOGIC_VECTOR(3 downto 0)) is
variable Qout: STD_LOGIC_VECTOR(3 downto 0);
begin
Qout := "0000"; --initially set Qout = 0 to begin
process(CLK)
begin
if CLK'event and CLK = '1' then --when En = 1, counter increments on rising edge
if EN = '1' then
Qout := Qout + 1;
else
Qout := Qout;
end if;
if Qout > 10 then
Qout := "0001";
end if;
end if;
end process;
end BCD_Counter;
The erro is: parse error, unexpected IF, expecting SEMICOLON
I'm pretty sure I have all if statements ending with an end if. I have compiled this same code in an entity declaration, and it worked just fine. I was curious if you put a process in a procedure, what's the proper way to handle that?
Thanks a lot for your help.
procedure BCD_Counter (signal CLK, EN: in STD_LOGIC_VECTOR;
signal Q: out STD_LOGIC_VECTOR(3 downto 0)) is
variable Qout: STD_LOGIC_VECTOR(3 downto 0);
begin
Qout := "0000"; --initially set Qout = 0 to begin
process(CLK)
begin
if CLK'event and CLK = '1' then --when En = 1, counter increments on rising edge
if EN = '1' then
Qout := Qout + 1;
else
Qout := Qout;
end if;
if Qout > 10 then
Qout := "0001";
end if;
end if;
end process;
end BCD_Counter;
The erro is: parse error, unexpected IF, expecting SEMICOLON
I'm pretty sure I have all if statements ending with an end if. I have compiled this same code in an entity declaration, and it worked just fine. I was curious if you put a process in a procedure, what's the proper way to handle that?
Thanks a lot for your help.