Microsoft AGB-00001 Spécifications Page 51

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 144
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 50
How to Write Synthesizable VHDL
VHDL Reference Manual 3-25
Template State Machine
The recommended method for describing synthesizable state machines
in VHDL is to use an enumerated type to define the states of the
machine, and use two processes to clearly distinguish between the
registered portion of the machine (the state registers and registered
state machine outputs) and the combinational portion (the state
transition logic and combinational state machine outputs). The
following sample state machine provides a template that you can use
to create your own state machine designs:
library ieee;
use ieee.std_logic_1164.all;
entity machine is
port (clk,reset: in std_logic;
state_inputs: in std_logic_vector (0 to 1);
comb_outputs: out std_logic_vector (0 to 1));
end machine;
architecture behavior of machine is
type states is (st0, st1, st2, st3);
signal present_state, next_state: states;
begin
register: process (reset,clk)
begin
if reset = '1' then
present_state <= st0; -- async reset to st0
elsif rising_edge(clk) then
present_state <= next_state; -- transition on clock
end if;
end process;
transitions: process(present_state, state_inputs)
begin
case current_state is -- describe transitions
when st0 => -- and comb. outputs
comb_outputs <= "00";
if state_inputs = "11" then
next_state <= st0; -- hold
else
next_state <= st1; -- next state
end if;
when st1 =>
comb_outputs <= "01";
if state_inputs = "11" then
next_state <= st1; -- hold
else
next_state <= st2; -- next state
end if;
when st2 =>
comb_outputs <= "10";
if state_inputs = "11" then
next_state <= st2; -- hold
else
next_state <= st3; -- next state
end if;
when st3 =>
comb_outputs <= "11";
if state_inputs = "11" then
next_state <= st3; -- hold
else
next_state <= st0; -- next state
end if;
end case;
end process;
end behavior;
Vue de la page 50
1 2 ... 46 47 48 49 50 51 52 53 54 55 56 ... 143 144

Commentaires sur ces manuels

Pas de commentaire