Math2mat
|
00001 ----------------------------------------------------------------------- 00002 -- Loop_For.vhd -- 00003 ----------------------------------------------------------------------- 00004 -- Auteur : Trolliet Gregory -- 00005 -- Date : 15.11.2008 -- 00006 -- Description : Controle du composant boucle -- 00007 ----------------------------------------------------------------------- 00008 00009 library ieee; 00010 use ieee.std_logic_1164.all; 00011 use ieee.numeric_std.all; 00012 library fplib; 00013 use fplib.pkg_fplib.all; 00014 00015 entity Loop_For is 00016 generic( 00017 LEN : integer := 4; -- Longueur du corps de la boucle en clk 00018 NBOCC : integer := 1 -- Nombre d'occurence de la boucle 00019 ); 00020 port( 00021 clk : in std_logic; 00022 rst : in std_logic; 00023 -- Indique si les valeurs en entree sont valides 00024 valid : in std_logic; 00025 -- Permet de figer la boucle 00026 fix : in std_logic; 00027 -- Indique au corps si il faut recommencer un nouveau calcul 00028 start : out std_logic; 00029 -- Indique aux autres operateurs si il faut se figer ou pas 00030 run : out std_logic 00031 ); 00032 end Loop_For; 00033 00034 architecture comp of Loop_For is 00035 type tab_cpt is array (LEN-1 downto 0) 00036 of unsigned(9 downto 0); 00037 signal cpt : tab_cpt; 00038 signal indice : unsigned(9 downto 0); 00039 begin 00040 run <= '1' when (cpt(to_integer(indice))=0) else '0'; 00041 00042 process(clk,rst) 00043 begin 00044 if (rst='1') then 00045 cpt <= (others => (others => '0')); 00046 indice <= (others => '0'); 00047 start <= '0'; 00048 elsif rising_edge(clk) then 00049 start <= '0'; 00050 if (cpt(to_integer(indice)) /= 0) then 00051 cpt(to_integer(indice)) <= cpt(to_integer(indice)) + 1; 00052 if (cpt(to_integer(indice)) = NBOCC) then 00053 cpt(to_integer(indice)) <= (others => '0'); 00054 end if; 00055 if (valid = '1' and 00056 fix = '0' and 00057 cpt(to_integer(indice)) = 0) then 00058 cpt(to_integer(indice)) <= cpt(to_integer(indice)) + 1; 00059 start <= '1'; 00060 end if; 00061 if (fix = '0') then 00062 if (indice = LEN-1) then 00063 indice <= (others => '0'); 00064 else 00065 indice <= indice + 1; 00066 end if; 00067 end if; 00068 end if; 00069 end if; 00070 end process; 00071 end comp; 00072