-- Steuerwerk der FSM ******************************************** FSM: process(clk,clrn) begin if clrn = '0' then zustand <= Z1; elsif clk'event and clk='1' then case zustand is when Z1 => if start = '1' then zustand <= Z2; --warte auf start oder read elsif rd_wr = '1' then zustand <= Z9; else zustand <= Z1; end if; when Z2 => if rd_wr = '0' then zustand <= Z3; --send Daten einlesen, busy, Oe else zustand <= Z1; end if; when Z3 => if rd_wr = '0' then zustand <= Z4; --Parität ermitteln else zustand <= Z1; end if; when Z4 => if rd_wr = '0' then zustand <= Z5; -- Daten zusammenstellen else zustand <= Z1; end if; when Z5 => if rd_wr = '0' then zustand <= Z6; -- Daten ins Schieberegister schreiben else zustand <= Z1; end if; when Z6 => if shift_ready = '1' then zustand <= Z7; --Daten senden, warten bis gesendet else zustand <= Z6; end if; when Z7 => zustand <= Z8; -- Busy, oe ausschalten when Z8 => if rxd = '1' then -- warten bis Treiber freigeschaltet hat! zustand <= Z1; -- senden fertig else zustand <= Z8; end if; when Z9 => if rxd = '0'then zustand <= Z10; --empfangsbereitschaft, warten auf ruhepegel elsif rd_wr = '0' then zustand <= Z1; --startbit empfangen else zustand <= Z9; end if; when Z10 => if rxd = '1' then zustand <= Z11; --empfangsbereitschaft, warten auf startbit elsif rd_wr = '0' then zustand <= Z1; --startbit empfangen else zustand <= Z10; end if; when Z11 => if shift_ready = '1' then zustand <= Z12; --busy, daten werden empfangen else zustand <= Z11; end if; when Z12 => if pari_ok = '0' or stop_ok = '0' then zustand <= Z13; --Parität prüfen, Stopbits prüfen else zustand <= Z14; end if; when Z13 => zustand <= Z14;--Fehler when Z14 => zustand <= Z9; --Fertig when others => zustand <= Z1; end case ; end if; end process FSM; -- Ausgangsmatrix der FSM*************************************** AUS_SN: process(zustand) begin case zustand is when Z1 => shift_run <= '0'; --warte auf start oder read busy <= '0'; oe <= '0'; ena_out <= '0'; stop_timeout <= '0'; run_timeout <= '0'; when Z2 => shift_run <= '0'; --send Daten einlesen, busy, Oe busy <= '1'; oe <= '1'; ena_out <= '0'; stop_timeout <= '0'; run_timeout <= '0'; when Z3 => shift_run <= '0'; --Parität ermitteln busy <= '1'; oe <= '1'; ena_out <= '0'; stop_timeout <= '0'; run_timeout <= '0'; when Z4 => shift_run <= '0'; -- Daten zusammenstellen busy <= '1'; oe <= '1'; ena_out <= '0'; stop_timeout <= '0'; run_timeout <= '0'; when Z5 => shift_run <= '0'; -- Daten ins Schieberegister schreiben busy <= '1'; oe <= '1'; ena_out <= '0'; stop_timeout <= '0'; run_timeout <= '0'; when Z6 => shift_run <= '1'; --Daten senden, warten bis gesendet busy <= '1'; oe <= '1'; ena_out <= '0'; stop_timeout <= '0'; run_timeout <= '0'; when Z7 => shift_run <= '0'; -- Busy, oe ausschalten busy <= '0'; oe <= '0'; ena_out <= '0'; stop_timeout <= '0'; run_timeout <= '0'; when Z10 => shift_run <= '0'; --empfangsbereitschaft, warten auf startbit busy <= '0'; oe <= '0'; ena_out <= '0'; stop_timeout <= '0'; run_timeout <= '1'; when Z11 => shift_run <= '1'; --busy, daten werden empfangen busy <= '1'; oe <= '0'; ena_out <= '0'; stop_timeout <= '1'; run_timeout <= '0'; when Z12 => shift_run <= '0'; --Parität prüfen, Stopbits prüfen busy <= '1'; oe <= '0'; ena_out <= '0'; stop_timeout <= '0'; run_timeout <= '1'; when Z13 => shift_run <= '0'; --Fehler busy <= '1'; oe <= '0'; ena_out <= '0'; stop_timeout <= '0'; run_timeout <= '1'; when Z14 => shift_run <= '0'; --Fertig busy <= '0'; oe <= '0'; ena_out <= '1'; stop_timeout <= '0'; run_timeout <= '1'; when others => shift_run <= '0'; busy <= '0'; oe <= '0'; ena_out <= '0'; stop_timeout <= '0'; run_timeout <= '0'; end case; end process;