FPGA Center



NEXT

This expression is used to complete one of the repeated statements in the loop. It is used in conjunction with conditional expression.

"Next" statement is used to move to the next iterative process, notwithstanding ending the loop. If this is to be connected to a condition situation "when" is written with "next". If the specified condition is TRUE, all operations in the loop are bypassed until the end of the first statement, by increasing the order. If the loop label is not specified while using "Next" , the process in the innermost loop is continued.

next;
next loop_name;
next loop_name when condition;

NOTE: Exit statement is often confused with the next statement. The important point to remember is that, loop ends by using "exit", but the next iterative expression is processed in the same loop by using "next".

EXAMPLE 1

U1:  for i in 1 to15 loop
            Assignment1:  count(i) := '0';
           next U1 when a='1';
           Assignment2: temp(i) := '1';
         end loop U1;

If the condition is TRUE, repeat number is increased by one and Assignment1 becomes the next expression. For example, during the 2nd repeat, if the condition is TRUE in the next statement, the loop starts at the begining as 3rd repeat. This means that Assignment1 is processed. If it is FALSE, loop continues with Assignment2.

EXAMPLE 2

In this example, we will design a program to calculate the sum of odd numbers up to a value given as generic. for example if the determined number is 10, the sum will be 1+3+5+7+9= 25.

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;

entity odd_calculate is
      generic(number:integer:=10);
      Port ( clk : in STD_LOGIC;
                sum:out STD_LOGIC_VECTOR(7 downto 0) );
end odd_calculate;

architecture Behavioral of odd_calculate is
signal temp:integer range 0 to 250:=0;
begin
    U2: process(CLK)
               variable mode_f:integer:=0;
               variable temp:integer range 0 to 250:=0;
               begin
                    temp:=0;
                        U1: for i in 1 to number loop
                                   mode_f:=i mod 2 ;
                                   next U1 when mode_f=0;
                                   temp:=temp+i;
                              end loop;
                     sum<= CONV_STD_LOGIC_VECTOR(temp,8);
             end process;
end Behavioral;

After simulating the program with ModelSim, we get the plot below:

1

 

 

    

                                                                                                                                    

 

                                                                                                                                                                                                                                                                   

Home | Fpga | VHDL | VHDL Dictionary | Digital Design | Simulation | PCB | Examples | Contact Us
Copyright © 2010 - 2013 FPGAcenter. All Rights Reserved.