library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; -- Portverwaltung -- entity Split is port ( clk : in std_logic; Reset: in std_logic; Start: in std_logic; AnzIN: in std_logic_vector (13 downto 0); done : out std_logic; DISP3: out std_logic_vector (3 downto 0); DISP2: out std_logic_vector (3 downto 0); DISP1: out std_logic_vector (3 downto 0); DISP0: out std_logic_vector (3 downto 0); Aus: out std_logic_vector (13 downto 0)); end Split; -- Hauptprogramm -- architecture Behavioral of Split is -- Case Struktur -> type SplitState is ( SplitReset, Split1000, Split100, Split10, Split1); signal SplitCase : SplitState := SplitReset; signal SplitNext : SplitState; -- <- -- interne Variablen signal Seg1000x: std_logic_vector (3 downto 0) := "0000"; signal Seg100x: std_logic_vector (3 downto 0) := "0000"; signal Seg10x: std_logic_vector (3 downto 0) := "0000"; signal Seg1x: std_logic_vector (3 downto 0) := "0000"; signal Save: std_logic_vector (13 downto 0) := "00000000000000"; begin DISP0 <= Seg1x; DISP1 <= Seg10x; DISP2 <= Seg100x; DISP3 <= Seg1000x; Aus <= Save; -------------------------------------------- --Hauptprogramm-- process (Reset,clk) begin if (Reset = '1') then SplitCase <= SplitReset; elsif (clk = '1' and clk'Event) then SplitCase <= SplitNext; end if; end process; --Splitprogramm-- process (Start,SplitCase,Save,clk,AnzIN) begin case SplitCase is when SplitReset => done <= '0'; if (Start = '1') then Seg1x <= "0000"; Seg10x <= "0000"; Seg100x <= "0000"; Seg1000x <= "0000"; Save <= AnzIN; SplitNext <= Split1000; else SplitNext <= SplitReset; end if; -- Splittet die Tausenderstelle: when Split1000 => if (Save < 1000) then SplitNext <= Split100; else if (clk = '1' and clk'Event) then Save <= Save - 1000; Seg1000x <= Seg1000x + 1; end if; SplitNext <= Split1000; end if; -- Splittet die Hunderterstelle: when Split100 => if (Save < 100) then SplitNext <= Split10; else if (clk = '1' and clk'Event) then Save <= Save - 100; Seg100x <= Seg100x + 1; end if; SplitNext <= Split100; end if; -- Splittet die Zehnerstelle: when split10 => if (Save < 10) then SplitNext <= Split1; else if (clk = '1' and clk'Event) then Save <= Save - 10; Seg10x <= Seg10x + 1; end if; SplitNext <= Split10; end if; -- Splittet die Einerstelle: when Split1 => Seg1x <= Save (3 downto 0); done <= '1'; SplitNext <= SplitReset; end case; end process; end Behavioral;