summaryrefslogtreecommitdiff
path: root/2004/n/fpga/src/portserie/clockgene/clockgene.vhd
diff options
context:
space:
mode:
Diffstat (limited to '2004/n/fpga/src/portserie/clockgene/clockgene.vhd')
-rw-r--r--2004/n/fpga/src/portserie/clockgene/clockgene.vhd73
1 files changed, 73 insertions, 0 deletions
diff --git a/2004/n/fpga/src/portserie/clockgene/clockgene.vhd b/2004/n/fpga/src/portserie/clockgene/clockgene.vhd
new file mode 100644
index 0000000..b98a6b3
--- /dev/null
+++ b/2004/n/fpga/src/portserie/clockgene/clockgene.vhd
@@ -0,0 +1,73 @@
+-- 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 ieee.std_logic_unsigned.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(10 downto 0):=(others=>'0');
+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 => null;
+ 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<=(others=>'0');
+ elsif(ckin'event and ckin='1') then
+ if(compteur = div_param) then
+ ckout<='1';
+ compteur<=(others=>'0');
+ else
+ compteur <= compteur + 1;
+ ckout<='0';
+ end if;
+ end if;
+ end process;
+end rtl;
+
+