-- clockgene.vhd -- Eurobot 2004 : APB Team -- Auteur : Pierre Prot -- clock -- fréquence d'entrée : 30MHz -- fréquence de sortie : 115kHz -- diviseur = (freq d'entrée)/(frequ sortie) library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use work.nono_const.all; -- pour la valeur de DIVIS_CK_SERIAL -- param : -- 00 -> 9600 bauds -- 01 -> 19200 bauds -- 10 -> 57600 bauds -- 11 -> 115200 bauds -- horloge de ref entity clockgene is port( rst: in std_logic; ckin: in std_logic; ckout: out std_logic; param: in std_logic_vector(1 downto 0) ); end clockgene; architecture rtl of clockgene is signal compteur:std_logic_vector(9 downto 0):="0000000000"; signal div_param:integer; -- le diviseur paramétrable signal clr:std_logic; begin clr<=rst; process(param,rst) begin case param is when "00" => div_param <= (DIVIS_CK_SERIAL*12); -- 9600 * 12 =115200 when "01" => div_param <= (DIVIS_CK_SERIAL*6); -- 19200 * 6 =115200 when "10" => div_param <= (DIVIS_CK_SERIAL*2); -- 57600 * 2 =115200 when "11" => div_param <= DIVIS_CK_SERIAL; -- 115200 * 1=115200 when others => div_param <= (DIVIS_CK_SERIAL*12); -- 9600 * 12 =115200 end case; end process; -- baudmax : génère la fréquence nécéssaire à du 115200 baudmax:process(ckin,clr) begin if(clr='1') then ckout<='0'; compteur<=conv_std_logic_vector(div_param, 10); elsif(ckin'event and ckin='1') then if(compteur = "0000000000") then ckout<='1'; compteur<=conv_std_logic_vector(div_param, 10); else compteur <= conv_std_logic_vector( (unsigned(compteur) - 1),10); ckout<='0'; end if; end if; end process; end rtl;