Very new to VHDL, but I have a fundamental issue understanding processes in VHDL. I have the two below processes:
entity BLINKY_LED is
Generic (
NUM_LEDS : integer := 4;
CLK_RATE : integer := 100000000;
BLINK_RATE : integer := 2);
Port (
Led_Out : out std_logic_vector(NUM_LEDS-1 downto 0);
Clk : in std_logic;
Reset : in std_logic);
end BLINKY_LED;
architecture Behavioral of BLINKY_LED is
constant MAX_VAL : integer := CLK_RATE/BLINK_RATE;
constant BIT_DEPTH : integer := integer(ceil(log2(real(MAX_VAL))));
signal counter : unsigned(BIT_DEPTH - 1 downto 0) := (others => '0');
signal led_reg : std_logic_vector(NUM_LEDS-1 downto 0) := "1010";
begin
Led_out <= led_reg;
count_process : process(Clk)
begin
if rising_edge(Clk) then
if((Reset = '0') OR (counter = MAX_VAL)) then
counter <= (others => '0');
else
counter <= counter + 1;
end if;
end if;
end process count_process;
output_process : process(clk)
begin
if rising_edge(Clk) then
if MAX_VAL = counter then
led_reg <= NOT led_reg;
end if;
end if;
end process output_process;
end Behavioral;
What happens when 'counter' reaches 'MAX_VAL'? One process sets 'counter' to 0, and the other toggles some LEDs. I understand it such that both processes happen at the same time, so 'counter' could be sat to 0 so the LEDs will never be toggled or what?
counter
as a variable, think of it as actual counter component, whose output is connected to a comparator generating it's own reset signal and is connected to an input of a T-flipflop or similar that is connected to a LED. Think hardware, not software. \$\endgroup\$