Advertisement
Guest User

comp_phase

a guest
Sep 23rd, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 2.87 KB | None | 0 0
  1. ------------------------------------------------------
  2. --               DETECT UP FRONT  
  3. ------------------------------------------------------
  4. library IEEE;
  5. use IEEE.std_logic_1164.all;
  6. use IEEE.numeric_std.all;
  7.  
  8. entity detect_front is
  9.   port(E ,reset ,clk : in std_logic;
  10.         Ft_mt : out std_logic);
  11. end detect_front;
  12.  
  13. architecture arch_detect_front of detect_front is
  14. type me_states is (E_0, E_1, E_2);
  15. signal etat_cr, etat_sv : me_states;
  16. begin
  17. process(clk,reset)
  18.     begin
  19.         if reset = '1' then etat_cr <= E_0;
  20.         elsif (rising_edge(clk)) then etat_cr <= etat_sv;
  21.         end if;
  22. end process;
  23.  
  24. process( etat_cr, E)
  25.     begin
  26.         etat_sv <= etat_cr; Ft_mt <= '0';
  27.         case etat_cr is
  28.             when E_0 => if E = '1' then etat_sv <= E_1; end if;
  29.             when E_1 => etat_sv <= E_2; Ft_mt <= '1';
  30.             when E_2 => if E = '0' then etat_sv <= E_0; end if;
  31.         end case;
  32. end process;
  33.  
  34. end arch_detect_front;  
  35.  
  36.  
  37. ------------------------------------------------------
  38. --                   COMP PHASE
  39. ------------------------------------------------------
  40. library IEEE;
  41. use IEEE.std_logic_1164.all;
  42. use IEEE.numeric_std.all;
  43.  
  44. entity ME_comp_phase is
  45.   port(E,S,reset,clk : in std_logic;
  46.         AV, AR : out std_logic);
  47. end ME_comp_phase;
  48.  
  49. architecture arch_ME_comp_phase of ME_comp_phase is
  50. type me_states is (EN_PHASE, AVANCE, RETARD);
  51. signal etat_cr, etat_sv : me_states;
  52. begin
  53. process(clk,reset)
  54.     begin
  55.         if reset = '1' then etat_cr <= EN_PHASE;
  56.         elsif (rising_edge(clk)) then etat_cr <= etat_sv;
  57.         end if;
  58. end process;
  59.  
  60. process(etat_cr,S,E)
  61.     begin
  62.         etat_sv <= etat_cr; AV <= '0'; AR <= '0';
  63.         case etat_cr is
  64.             when EN_PHASE => if (S = '0' and E = '1') then etat_sv <= AVANCE;
  65.                             elsif (S = '1' and E = '0') then etat_sv <= RETARD;
  66.                             end if;
  67.             when AVANCE => AV <= '1';
  68.                             if S = '1' then etat_sv <= EN_PHASE;
  69.                             end if;
  70.             when RETARD => AR <= '1';
  71.                             if E = '1' then etat_sv <= EN_PHASE;
  72.                             end if;
  73.         end case;
  74. end process;
  75.  
  76. end architecture arch_ME_comp_phase;
  77.  
  78. ------------------------------------------------------
  79. --                COMPARATEUR PHASE
  80. ------------------------------------------------------
  81. library IEEE;
  82. use IEEE.std_logic_1164.all;
  83. use IEEE.numeric_std.all;
  84. use work.all;
  85.  
  86. entity comp_phase is
  87.   port(Top_0,Top_synchro,reset,clk : in std_logic;
  88.         AV, AR : out std_logic);
  89. end comp_phase;
  90.  
  91. architecture arch_comp_phase of comp_phase is
  92. signal Ft_Top_0 : std_logic;
  93. signal Ft_Top_Synchro : std_logic;
  94. begin
  95. DETEC1 : entity detect_front port map(
  96.     E => Top_0,
  97.     reset => reset,
  98.     clk => clk,
  99.     Ft_mt => Ft_Top_0);
  100.  
  101. DETEC2 : entity detect_front port map(
  102.     E => Top_synchro,
  103.     reset => reset,
  104.     clk => clk,
  105.     Ft_mt => Ft_Top_Synchro);
  106.  
  107. COMP : entity ME_comp_phase port map(
  108.     E => Ft_Top_0,
  109.     S => Ft_Top_Synchro,
  110.     reset => reset,
  111.     clk => clk,
  112.     AV => AV,
  113.     AR => AR);
  114.    
  115. end architecture arch_comp_phase;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement