Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --processo di sincronizzazione del reset
- synchronous_process: process(clk, rst)
- begin
- if rising_edge(clk) then
- if rst = '1' then
- current_state <= s0;
- else
- current_state <= next_state;
- end if;
- end if;
- end process;
- --processo principale tramite il quale si descrive il comportamento dell'automa di Mealy
- next_state_and_output_Mealy: process(current_state, badge, col, row)
- begin
- case current_state is
- when s0 =>if(badge = '1') then --lettura badge 1
- next_state <= s1;
- output <="01";--ingresso inserito con successo
- else
- next_state <= s0; --il badge resta a 0
- output<= "00";
- end if;
- state_debug<= conv_std_logic_vector(state'POS(current_state),4);
- --alla lettura del badge '1' si transita in s1
- when s1=>if(badge='1')then
- --non stato inserito nulla da stastierino: resta in attesa (out 00) i s1
- if(col="000" and row="0000") then
- next_state<= s1;
- output<="00" ;
- elsif(col="001" and row="0001")then--inserimento cancelletto: resta in s1 con out 01
- next_state<= s1;
- output<="01";
- elsif(col="010" and row="0001") then--inserimento 0: va in s3 con out 01
- next_state <= s3;
- output <= "01";
- else--nessuna delle precedenti: va in errore in s2 con out 10
- next_state<= s2;
- output<= "10";
- end if;
- else--badge=0 quindi torna in s0
- next_state<= s0;
- output<= "00";
- end if;
- state_debug<= conv_std_logic_vector(state'POS(current_state),4);
- when s2 =>if(badge='1')then
- --non stato inserito nulla da tastierino: resta in attesa (out 00) i s2
- if(col="000" and row="0000") then
- next_state<= s2;
- output<="00" ;
- elsif(col="001" and row="0001")then--inserimento cancelletto
- next_state<= s1;
- output<="01";
- else
- next_state <= s2;
- output <= "10";
- end if;
- else
- next_state<= s0;
- output<= "00";
- end if; --chiusura primo if
- state_debug<= conv_std_logic_vector(state'POS(current_state),4);
- when s3 => if(badge='1')then
- --non e' stato inserito nulla da stastierino: resta in attesa (out 00) i s3
- if(col="000" and row="0000") then
- next_state<= s3;
- output<="00" ;
- elsif(col="001" and row="0001")then--inserimento cancelletto
- next_state<= s3;
- output<="01";
- elsif((col="010" and row="0001") or (col="100" and row= "1000")) then--inserimento 0 o 1
- next_state <= s5;
- output <= "01";
- else
- next_state<= s4;
- output<= "10";
- end if;
- else
- next_state<= s0;
- output<= "00";
- end if;
- state_debug<= conv_std_logic_vector(state'POS(current_state),4);
- when s4 =>if(badge='1')then
- --non e' stato inserito nulla da stastierino: resta in attesa (out 00) i s4
- if(col="000" and row="0000") then
- next_state<= s4;
- output<="00";
- elsif(col="001" and row="0001")then--inserimento cancelletto
- next_state<= s3;
- output<="01";
- else
- next_state <= s4;
- output <= "01";
- end if;
- else
- next_state<= s0;
- output<= "00";
- end if;
- state_debug<= conv_std_logic_vector(state'POS(current_state),4);
- when s5 =>if(badge='1')then
- --non stato inserito nulla da stastierino: resta in attesa (out 00) i s5
- if(col="000" and row="0000") then
- next_state<= s5;
- output<="00" ;
- elsif(col="001" and row="0001")then--inserimento cancelletto
- next_state<= s5;
- output<="01";
- --inserimento 1 o 2
- elsif((col="010" and row="1000") or (col="100" and row= "1000")) then
- next_state <= s7;
- output <= "01";
- else
- next_state<= s6;
- output<= "10";
- end if;
- else
- next_state<= s0;
- output<= "00";
- end if;
- state_debug<= conv_std_logic_vector(state'POS(current_state),4);
- when s6 =>if(badge='1')then
- --non stato inserito nulla da stastierino: resta in attesa (out 00) i s6
- if(col="000" and row="0000") then
- next_state<= s6;
- output<="00" ;
- elsif(col="001" and row="0001")then--inserimento cancelletto
- next_state<= s5;
- output<="01";
- else
- next_state <= s6;
- output <= "10";
- end if;
- else
- next_state<= s0;
- output<= "00";
- end if;
- state_debug<= conv_std_logic_vector(state'POS(current_state),4);
- when s7 =>if(badge='1')then
- --non stato inserito nulla da stastierino: resta in attesa (out 00) i s7
- if(col="000" and row="0000") then
- next_state<= s7;
- output<="00" ;
- elsif(col="001" and row="0001")then--inserimento cancelletto
- next_state<= s7;
- output<="01";
- --inserimento * per confermare apertura sessione
- elsif(col="100" and row="0001") then
- next_state <= s9;
- output <= "01";
- else
- next_state<= s8;
- output<= "10";
- end if;
- else
- next_state<= s0;
- output<= "00";
- end if;
- state_debug<= conv_std_logic_vector(state'POS(current_state),4);
- when s8 =>if(badge='1')then
- --non e' stato inserito nulla da stastierino: resta in attesa (out 00) i s8
- if(col="000" and row="0000") then
- next_state<= s8;
- output<="00";
- elsif(col="001" and row="0001")then--inserimento cancelletto
- next_state<= s7;
- output<="01";
- else
- next_state <= s8;
- output <= "10";
- end if;
- else
- next_state<= s0;
- output<= "00";
- end if;
- state_debug<= conv_std_logic_vector(state'POS(current_state),4);
- when s9 =>if(badge = '1') then
- next_state <= s9;
- output <="11";--apertura lezione
- else
- next_state <= s0;
- output<= "00";
- end if;
- state_debug<= conv_std_logic_vector(state'POS(current_state),4);
- end case;
- end process;
- end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement