Altera_Forum
Honored Contributor
9 years agoWhy a second process requires a signal "conditional" statement in order to work
Hi guys.
I'm working on an exercise for an undergraduate class, where I want the students to learn about different "processes" running in a single VHDL architecture. The goal is show them, it is possible to control where a process gets executed through the usage of a "user internal" signal. So, I've thought about a time based process, that will give me a "call rate" for a 2nd process. The second one can be a 1s counter or just provide different output values each second. We use DE0-Nano boards, so our clock source is a 50MHz oscillator. I am able to synthesize the hardware for that, the point is, the second process only works if I add an "if" statement to test the signal in the sensitivity list. :confused: I can't understand why, can someone help me to make this clear? I am sure the process gets executed each second, since I use out1 to toggle a LED. I want to remove the "inc" conditional test. I managed to make it count each second by reducing "CLK_FREQ to 25E06" but the other way looks just fine to me and should be working either, don't you think? I appretiate any comment. Thank you all. Alex
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity countVHDL is
port (Clock: in std_logic;
Qc : out integer range 15 downto 0;
out1: out std_logic);
end countVHDL;
architecture behavior_counter of countVHDL is
SIGNAL inc : std_logic := '0';
CONSTANT CLK_FREQ : integer := 50E06;
begin
--the so called 2nd process...
process(inc)
variable q: integer range 0 to 15 := 0;
begin
if inc='1' then -- want to remove
q:=q+1; --this should increase each second, since "inc" gets changed at 1s rate, doesn't it?
end if;
Qc<=q;
out1<=inc;
end process;
--1st process, generates a 1s time base
process(Clock)
variable prescaler: integer := 0;
begin
if (Clock = '1') then
prescaler:=prescaler+1;
if prescaler >= CLK_FREQ then
inc<=not(inc);
prescaler := 0;
end if;
end if;
end process;
end behavior_counter;