Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
2490 connectés 

  FORUM HardWare.fr
  Programmation
  Divers

  vhdl

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

vhdl

n°2192056
gege3869
Posté le 29-05-2013 à 10:39:20  profilanswer
 

bonjour,  
 
le but de mon programme est de pouvoir créer différentes implusion. Je reçoit un mon Dutycycle de 8 bit qui est la base de mes impulsions.  je voudrais savoir si je peux utiliser mes deux compteurs à la suite. Je veux utiliser un compteur pour la période et l'autre pour le temps d'impulsion. Je ne suis pas très doué en Vhdl et je ne  sais pas si peux faire une programmation de ce type. merci pour votre aide

Code :
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3. use IEEE.STD_LOGIC_ARITH.ALL;
  4. use IEEE.STD_LOGIC_UNSIGNED.ALL;
  5. entity gege1 is
  6.     Port ( Clock : in  STD_LOGIC;
  7.            Dutycycle : in  STD_LOGIC_VECTOR (7 downto 0);
  8.            reset : in  STD_LOGIC;
  9.            A : out  STD_LOGIC;
  10.            B : out  STD_LOGIC;
  11.            C : out  STD_LOGIC;
  12.            D : out  STD_LOGIC);
  13. end gege1;
  14. architecture Behavioral of gege1 is
  15. signal tps_debut: std_logic_vector (9 downto 0) := (others => '0');
  16. signal tps_cycle: std_logic_vector(8 downto 0) := (others => '0');
  17. signal pulse: std_logic_vector(7 downto 0) := (others => '0');
  18. --constant tps_mort: std_logic_vector (9 downto 0 ) := 1001000;
  19. --constant tps_f2: std_logic_vector (9 downto 0) := 1110000;
  20. Signal outa : std_logic := '0';
  21. Signal outb : std_logic := '0';
  22. Signal outc : std_logic := '0';
  23. Signal outd : std_logic := '0';
  24. begin
  25. PWM: process (reset, Clock, pulse, tps_debut, tps_cycle)
  26. begin
  27.     if (reset = '0') then
  28.        outa <= '0'; outb <= '0';outc <= '0'; outd <= '0';
  29.  elsif (Clock' event and Clock = '1') then
  30.     if ( pulse = "00000000" ) then
  31.        outa <= '0'; outb <= '0'; outc <= '0'; outd <= '0';
  32.     else
  33.              
  34.       if ( tps_debut = "00000000000" ) then
  35.      if ( tps_cycle = "000000000" ) then
  36.        outa <= '1'; outb <= '0';
  37.      elsif ( tps_cycle = (pulse  +"10111000" )) then
  38.      outa <= '0'; outb <= '0';
  39.      end if;
  40.      elsif (tps_debut = "111111111" ) then
  41.     if ( tps_cycle = "000000000" ) then
  42.        outa <= '0'; outb <= '1';
  43.      elsif ( tps_cycle = (pulse  +"10111000" )) then
  44.      outa <= '0'; outb <= '0';
  45.      end if;
  46.    end if;
  47.  end if;
  48.  end if ;
  49. end process;
  50. sortie : process (outa, outb, outc, outd)
  51. begin
  52. A <= outa and not outb ;
  53. B <= outb  and not outa;
  54. C <=  outc and not outd ;
  55. D <= outd and not outc;
  56. end process;
  57. COMPTEUR: process (reset, Clock, Dutycycle)
  58. begin
  59.  if (reset ='0') then
  60.   tps_debut <= "0000000000";
  61.  elsif (Clock' event and Clock ='1') then
  62.   if (tps_debut = "1111111111" ) then
  63.      tps_debut <= "0000000000";
  64.   else
  65.    tps_debut <= tps_debut + 1; pulse <= Dutycycle;
  66.   end if;
  67.  end if;
  68. end process;
  69. compteur_suite: process ( reset, Clock )
  70. begin
  71.   if (reset ='0') then
  72.  tps_cycle <= "000000000";
  73.  elsif (Clock' event and Clock ='1') then
  74.   if (tps_cycle = "111111111" ) then
  75.   tps_cycle <= "000000000";
  76.   else
  77.   tps_cycle <= tps_cycle + 1;
  78.  end if;
  79.  end if;
  80. end process;
  81. end Behavioral;

mood
Publicité
Posté le 29-05-2013 à 10:39:20  profilanswer
 

n°2192061
h3bus
Troll Inside
Posté le 29-05-2013 à 11:03:24  profilanswer
 

Oui tu peux utiliser un même compteur pour les deux.

 

Il suffit de compter le temps de ta période, de déclencher l'impulsion quand ton compteur est à 0 et de la rester à un temps (valeur du compteur) Toff.

 

Sinon pour ton code, j'ai faillit (:o) arrêter de lire à

Code :
  1. use IEEE.STD_LOGIC_ARITH.ALL;
  2. use IEEE.STD_LOGIC_UNSIGNED.ALL;
 

Il est fortement conseiller de n'utiliser que numeric_std.
De même pourquoi utiliser des std_logic_vector pour représenter un compteur? Un integer est bien plus adapté.

 

Aller je te fait un exemple a peu près bien codé (j'ai pas essayé de le synthétiser, y'a peut-être des fôtes)

Code :
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3. use NUMERIC_STD.ALL;
  4.  
  5. entity square is
  6.    Generic
  7.    (
  8.      g_cycle_time      : integer := 255;
  9.      g_switch_time     : integer := 23;
  10.      g_start_polarity  : std_logic := '1'
  11.    );
  12.    Port
  13.    (
  14.       clk        : in  std_logic;
  15.       reset_n    : in  std_logic;
  16.      
  17.       dutycycle  : in  integer range (0 to g_cycle_time);
  18.      
  19.       output     : out std_logic
  20.     );
  21. end entity square;
  22.  
  23. architecture rtl of square is
  24.  signal counter  : integer range (0 to g_cycle_time);
  25. begin
  26.  
  27. counter_proc: process(clk, reset_n)
  28. begin
  29.  if reset_n = '0' then
  30.    counter <= counter'LOW;
  31.    
  32.  elsif rising_edge(clk) then
  33.    if counter = counter'HIGH then
  34.      counter <= counter'LOW;
  35.      
  36.    else
  37.      counter <= counter + 1;
  38.      
  39.    end if;
  40.    
  41.  end if;
  42. end process;
  43.  
  44. output_proc:  process(clk, reset_n)
  45. begin
  46.  if reset_n = '0' then
  47.    output <= g_start_polarity;
  48.    
  49.  elsif rising_edge(clk) then
  50.    if counter = g_switch_time then
  51.      output <= NOT g_start_polarity;
  52.      
  53.    elsif counter = counter'LOW then
  54.      output <= g_start_polarity;
  55.      
  56.    end if;
  57.    
  58.  end if;
  59. end process;
  60.  
  61. end architecture rtl;


Message édité par h3bus le 29-05-2013 à 11:04:23

---------------
sheep++
n°2192086
gege3869
Posté le 29-05-2013 à 14:20:35  profilanswer
 

merci pour votre réponse. je suis d'accord que je peux utiliser un compteur pour pour gérer le temps d'impulsion et la période, mais je veux faire quatre chronogrammes différents. donc ma question est (excusez-moi si je l'ai mal formulé):
mon impulsion comprend un mot de 8 bit Dutycycle que je reçoit et d'un mot de 8 bit fixe en gros c'est une impulsion de 10 bit qui varie.
puis faire deux compteurs: le compteur A s'occupe de la période et le compteur B qui s'occupe de l'impulsion et que mon programme principal fonctionne de telle manière:  
if  compteur_A = 0 then  
        if compteur _B = 0 then  
                instructions
        elsif compteur_ B = (Dutycycle + "11001100" ) then  
              instructions
        end if;
elsif compteur_A = "1000000000" then  
        if compteur _B = 0 then  
                instructions
        elsif compteur_ B = (Dutycycle + "11001100" ) then  
              instructions
        end if;
end if;  
 Sachant que mes compteur fonctionne sur la même horloge. Je veux savoir si c'est possible en Vhdl.
 

n°2192110
h3bus
Troll Inside
Posté le 29-05-2013 à 15:44:24  profilanswer
 

Citation :

mon impulsion comprend un mot de 8 bit Dutycycle que je reçoit et d'un mot de 8 bit fixe en gros c'est une impulsion de 10 bit qui varie.


 [:pingouino dei]  
Je comprends pas ce que ça signifie.
 
Si tu souhaites faire 4 impulsions à des moments différents il suffit d'envoyer en generic les tempsON tempsOFF pour chaque, puis de modifier le process output_proc pour un truc comme ça:

Code :
  1. output_proc:  process(clk, reset_n)
  2. begin
  3.  if reset_n = '0' then
  4.    outputA <= g_start_polarity;
  5.    outputB <= g_start_polarity;
  6.    ...
  7.    
  8.  elsif rising_edge(clk) then
  9.    if counter = g_ON_timeA then
  10.      outputA <= NOT g_start_polarity;
  11.      
  12.    elsif counter = g_OFF_timeA then
  13.      outputA <= g_start_polarity;
  14.      
  15.    end if;
  16.    
  17.    if counter = g_ON_timeB then
  18.      outputB <= NOT g_start_polarity;
  19.      
  20.    elsif counter = g_OFF_timeB then
  21.      outputB <= g_start_polarity;
  22.      
  23.    end if;
  24.    
  25.    ...
  26.    
  27.  end if;
  28. end process;


 
Après si tu souhaites modifier le duty_cycle en live, c'est facile en passant par des ports d'entrées au lieu de généric (ce que je voulais faire dans mon post précédent) mais j'ai codé trop vite ^^


---------------
sheep++
n°2192187
gege3869
Posté le 30-05-2013 à 08:28:19  profilanswer
 

merci, je vais essayer


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  Divers

  vhdl

 

Sujets relatifs
VHDL entityAdaptation SystemC en VHDL
question sur la description structurelle en vhdl[VHDL] Question concernant les case avec des if
VHDL - Contrôleur de feux[VHDL/Verilog] Les FPGA et leur programmation
Problème de gestion de la liaison série RS232 en VHDL[VHDL] Décodeur Reed Solomon (15,9)
[VHDL] Problème sous Quartuscomment faire un tableau en VHDL ?
Plus de sujets relatifs à : vhdl


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR