VHDL kódvariációk

Zoltán Radó elektro1.zrado at axelero.hu
Sun Jul 23 12:40:51 CEST 2006


Szépnagyot!

Egy "state machine"-t az alábbi két verzióban lehet kódolni. Van-e
különbség a kettő között (valamilyen előny/hátrány)? Vagy inkább csak
kódolási stílus különbség?

Sok helyen látom a második megoldást és nem tudom, hogy miért így
csinálják...


Üdv.: Zoli



----Variáció 1--------------------------

smreg: process(clk,reset)
begin
     if reset = '1' then

     elsif clk'event and clk = '1' then
           case sm_state is
                when idle =>
                     if wrrd = '1' then
                         sm_state <= write;
                     else
                         sm_state <= read;
                     end if;
                     ........
                     
                when write => ......;
                     sm_state <= idle;

                when read =>
                     sm_state <= idle;
                when others =>
                     sm_state <= idle;
            end case;
     end if;
end process;

---------------------------------------------------------

------ Variáció 2 ---------------------------------------

sm_reg: process(clk, reset)
begin
     if reset = '1' then

     elsif clk'event and clk = '1' then
           sm_state <= next_state;
     end if;
end process;

sm_com: process(sm_state, wr_rd)
begin
           case sm_state is
                when idle =>
                     if wrrd = '1' then
                         next_state <= write;
                     else
                         next_state <= read;
                     end if;
                     ........
                     
                when write => ......;
                     next_state <= idle;

                when read =>
                     next_state <= idle;
                when others =>
                     next_state <= idle;
            end case;
end process;



More information about the Elektro mailing list