summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgalmes2004-04-28 18:51:19 +0000
committergalmes2004-04-28 18:51:19 +0000
commit2cc572c158db009811d9de1d5174d9b7043f4217 (patch)
tree2f84320896879cc9961f7b577ba9b9eec0a6bdc6
parent5fc9600f130c7a356f33312b679fd2a35580ed6d (diff)
pwm : Suppression de tb (non, pas Thomas Burg, les test_benchs ;)
pwm : modifications des fichiers de pwm ! Dernier refit du code pour qu'il soit beau et simple et compréhensible...
-rw-r--r--2004/n/fpga/src/pwm/clk1us.vhd48
-rw-r--r--2004/n/fpga/src/pwm/convert_pwm.vhd29
-rw-r--r--2004/n/fpga/src/pwm/pwm_generator.vhd31
-rw-r--r--2004/n/fpga/src/pwm/toppwm3.vhd141
4 files changed, 38 insertions, 211 deletions
diff --git a/2004/n/fpga/src/pwm/clk1us.vhd b/2004/n/fpga/src/pwm/clk1us.vhd
deleted file mode 100644
index 2fc2705..0000000
--- a/2004/n/fpga/src/pwm/clk1us.vhd
+++ /dev/null
@@ -1,48 +0,0 @@
--- clk1us.vhd
--- Eurobot 2004 : APB Team
--- Auteur : Fidèle GAFAN et Pierre-André Galmes
--- Module générateur d'horloge 1us-périodique.
---
--- REMARQUE(S): pour les constantes, se reporter à pwm_const.vhd
-
-
-library ieee;
-use ieee.std_logic_1164.all;
-use ieee.std_logic_unsigned.all;
-use ieee.std_logic_arith.all;
-
-use work.nono_const.all;
-use work.pwm_const.all;
-
---ENTITY
-entity clk1us is
- port (
- RST : in std_logic;
- CLK : in std_logic; --40MHz
- CLK1USOUT : out std_logic
- );
-end entity;
-
---ARCHITECTURE
-architecture RTL of clk1us is
- -- nombres de cycles de clk necessaires pour 1us incrémente.
- signal compt: T_OCTET;
-begin
- process(RST,CLK)
- begin
- if (RST = '1') then
- CLK1USOUT <= '0';
- compt <= x"00";
- elsif (CLK'event and CLK = '1') then
- compt <= compt + x"01";
- if (compt = x"00") then -- 30
- CLK1USOUT <= '1';
- else
- CLK1USOUT <= '0';
- if (compt = (PWM_NB_CYCLE_1US - x"01")) then
- compt <= x"00"; -- 30
- end if;
- end if;
- end if;
- end process;
-end RTL;
diff --git a/2004/n/fpga/src/pwm/convert_pwm.vhd b/2004/n/fpga/src/pwm/convert_pwm.vhd
index c043111..a3ab92e 100644
--- a/2004/n/fpga/src/pwm/convert_pwm.vhd
+++ b/2004/n/fpga/src/pwm/convert_pwm.vhd
@@ -1,14 +1,21 @@
--- convert_pwm.vhd
--- Eurobot 2004 : APB Team
--- Auteur : Fidèle GAFAN et Pierre-André Galmes
-
--- Principe :
+-------------------------------------------------------------------------------
+--convert_pwm.vhd
+--Eurobot 2004 : APB Team
+--Auteur : Fidèle GAFAN
+--Module générateur des PWM
--
--- Converti la valeur comprise dans l'intervalle [0 - 255]
--- et transmise par le -- PC en une valeur comprise dans
--- l'interval suivant :
--- [PWM_VALUE_MIN - (PWM_VALUE_MIN + data_in * -- PWM_INC_INT]
-
+--REMARQUE(S):changer tccompt,q et data_out
+-- si CLK#32MHz et/ou qu'on modifie les valeurs de référence de T1
+-- et T2
+-- Tcmax=20ms/1us=20161cycles.
+--*Si DATACOMPT=0,on veut que T2 vale 0,5ms donc on initialise Q à la valeur
+--Q=0,5ms/1us=PWM_VALUE_MIN.
+--*Si DATACOMPT=255,on veut que T2 vale 1,5ms donc on initialise Q à la valeur
+--Q=1,5ms/1us=PWM_VALUE_MAX.
+--*Pour toute autre valeur de DATACOMPT comprise entre les deux précédentes et
+--différentes de ces dernières,on initialise Q avec
+--Q=(0,5ms/1us)+(DATACOMPT*min[((1,5ms-0,5ms)/1us)/(255-0)]
+-------------------------------------------------------------------------------
--LIBRARY
library ieee;
use ieee.std_logic_1164.all;
@@ -22,7 +29,7 @@ use work.pwm_const.all;
entity convert_pwm is
port (
data_in : in T_OCTET;
- data_out : out T_DOUBLE_OCTET
+ data_out : out T_DOUBLE_OCTET --duree pdt laql la sortie
);
end entity;
diff --git a/2004/n/fpga/src/pwm/pwm_generator.vhd b/2004/n/fpga/src/pwm/pwm_generator.vhd
index 960a734..af73f00 100644
--- a/2004/n/fpga/src/pwm/pwm_generator.vhd
+++ b/2004/n/fpga/src/pwm/pwm_generator.vhd
@@ -1,22 +1,31 @@
--- pwm_generator.vhd
--- Eurobot 2004 : APB Team
--- Auteur : Fidèle GAFAN et Pierre-André Galmes
--- Génèrateur de signal PWM à partir du nombre de cycles
--- à l'état haut et du nombre de cycles de l'enveloppe .
+-------------------------------------------------------------------------------
+--pwm_generator.vhd
+--Eurobot 2004 : APB Team
+--Auteur : Fidèle GAFAN
+--Registre à décalage affichantles signaux PWM
--
-- Les commentaires ci-dessous ne sont plus trop valables.
-- Maintenant, clock = 40MHz
+
+--REMARQUE(S):changer tccompt,q et valuecompt
+-- si CLK#32MHz et/ou qu'on modifie les valeurs de référence de T1
+-- et T2
-- Tcmax = 20ms / 1us
-- = 20161 cycles.
--- Si DATACOMPT = 0, on veut que T2 vale 0,5ms donc on
--- initialise Q à la -- valeur Q=0,5ms/1us=505.
+-- Si DATACOMPT = 0, on veut que T2 vale 0,5ms donc on initialise Q à la
+-- valeur Q=0,5ms/1us=505.
+
+-- Si DATACOMPT=255,on veut que T2 vale 1,5ms donc on initialise Q à la
+-- valeur Q=1,5ms/1us=1515.
--- Si DATACOMPT=255,on veut que T2 vale 1,5ms donc on
--- initialise Q à la -- valeur Q=1,5ms/1us=1515.
+-- Pour toute autre valeur de DATACOMPT comprise entre les deux
+-- précédentes et différentes de ces dernières,on initialise Q avec
+-- Q=(0,5ms/1us)+(DATACOMPT*min[((1,5ms-0,5ms)/1us)/(255-1)]
+------------------------------------------------rtl de la sortie pwm en fonction de tc
library ieee;
use ieee.std_logic_1164.all;
@@ -24,7 +33,7 @@ use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
use work.nono_const.all;
-use work.pwm_const.all;
+use work.pwm_const.all;
--ENTITE
entity pwm_generator is
@@ -50,7 +59,7 @@ begin
pwm_out <= '0';
elsif (clk'event and clk = '1') then
compt <= compt + x"0001";
- if (compt <= reg) then
+ if (compt < reg) then
pwm_out <= '1';
else
pwm_out <= '0';
diff --git a/2004/n/fpga/src/pwm/toppwm3.vhd b/2004/n/fpga/src/pwm/toppwm3.vhd
deleted file mode 100644
index 60e8105..0000000
--- a/2004/n/fpga/src/pwm/toppwm3.vhd
+++ /dev/null
@@ -1,141 +0,0 @@
---LIBRARIES SUCCEPTIBLES D'ETRE UTILISEES
-library IEEE;
-use IEEE.std_logic_1164.all;
-use IEEE.std_logic_arith.all;
-use IEEE.std_logic_unsigned.all;
---library work;
-library synopsys;
-use synopsys.bv_arithmetic.all;
-
---ENTITY
-entity toppwm3 is
-port( RST :in std_logic;
- CLK :in std_logic;
- DATA :in std_logic_vector (7 downto 0);
- OUTPWM :out std_logic
- );
-end toppwm3;
-
---CONSTANT
-
---ARCHITECTURE
-architecture RTL of toppwm3 is
---LES COMPONENTS
---sequenceur fsm
-component fsmpwm3 is
- port(
- RST :in std_logic;
- CLK :in std_logic;
- CLK1USFSM :in std_logic;
- tcfsm :in integer range 0 to 20161;
- enloadfsm :out std_logic
- );
-end component;
---generateur d'horloge a 1 us
-component clk1us is
- port (
- RST : in std_logic;
- CLK : in std_logic;
- CLK1USOUT : out std_logic
- );
-end component;
---registre de stabilité des données
-component regdata3
- port(
- RST :in std_logic;
- CLK :in std_logic;
- CLK1USREG :in std_logic;
- enloadreg :in std_logic;
- datain :in std_logic_vector (7 downto 0);
- datareg :out integer range 0 to 255--signaux de sortie du registre
- );
-end component;
---compteur
-component comptvalue3
- port(
- RST :in std_logic;
- CLK :in std_logic;
- CLK1USCOMPT :in std_logic;
- loadcompt :in std_logic;
- datacompt :in integer range 0 to 255;
- tccompt :buffer integer range 0 to 20161;
- valuecompt :out integer range 0 to 1000000
- );
-end component ;
---afficheur de sortie
-component affichepwm3
- port(RST :in std_logic;
- CLK :in std_logic;
- CLK1USAFF :in std_logic;
- valueaff :in integer range 0 to 1000000;
- outpwm :out std_logic
- );
-end component;
-
---DECLARATION DES SIGNAUX LOCAUX
--- sortie sequenceur
-signal enload_s :std_logic;
---sortie horloge a 1 us
-signal clk1us_s : std_logic;
---sortie du registre de stabilité des données
-signal datareg_s: integer range 0 to 255;
--- sorties compteur
-signal tc_s : integer range 0 to 20161;
-signal value_s : integer range 0 to 1000000;
---sortie afficheur
-
-begin
---PORT MAP DES SIGNAUX INTERNES
-sequenceur3:fsmpwm3 port map(
- RST=>RST,
- CLK=>CLK,CLK1USFSM=>clk1us_s,
- tcfsm=>tc_s,
- enloadfsm=>enload_s
- );
-horloge1us:clk1us port map(
-
-RST=>RST,
-CLK=>CLK,
-CLK1USOUT=>clk1us_s
-);
-registredata3:regdata3 port map(
- RST=>RST,
- CLK=>CLK,CLK1USREG=>clk1us_s,
- enloadreg=>enload_s,
- datain=>data,
- datareg=>datareg_s
- );
-
-compteurvaleur3:comptvalue3 port map(
- RST=>RST,
- CLK=>CLK,CLK1USCOMPT=>clk1us_s,
- loadcompt=>enload_s,
- datacompt=>datareg_s,
- tccompt=>tc_s,
- valuecompt=>value_s
- );
-
-afficheur3: affichepwm3 port map(
- RST=>RST,
- CLK=>CLK,CLK1USAFF=>clk1us_s,
- valueaff=>value_s,
- outpwm=>outpwm
- );
-
-end RTL;
-
---configuration cf_toppwm3_rtl of toppwm3 is
-
- --for RTL
- --for sequenceur:fsm1 use entity WORK.fsm1(BEHAV);end for;
- --for memory_j: regjp use entity WORK.regjp(BEHAV);end for;
- --for memory_p: regjp use entity WORK.regjp(BEHAV);end for;
- --for mux_j: mux164 use entity WORK.mux164(M164behav);end for;
- --for mux_p: mux164 use entity WORK.mux164(M164behav);end for;
- --for comp4couleur: comp4 use entity WORK.comp4(C4behav);end for;
- --for comp2position: comp2 use entity WORK.comp2(C2behav);end for;
- --for cnt4couleur: CPT4 use entity WORK.cpt4(BEHAV);end for;
- --for cnt2position:CPT2 use entity WORK.cpt2(BEHAV);end for;
- --end for;
-
---end cf_toppwm3_rtl