library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.NUMERIC_STD.all; entity lab is Port ( clk, rst, rx : in STD_LOGIC; -- rst är tryckknappen i mitten under displayen seg: out UNSIGNED(7 downto 0); an : out UNSIGNED (3 downto 0)); end lab; architecture Behavioral of lab is component leddriver Port ( clk,rst : in STD_LOGIC; seg : out UNSIGNED(7 downto 0); an : out UNSIGNED (3 downto 0); value : in UNSIGNED (15 downto 0)); end component; signal sreg : UNSIGNED(9 downto 0) := B"0_00000000_0"; -- 10 bit skiftregister signal tal : UNSIGNED(15 downto 0) := X"0000"; signal rx1,rx2 : std_logic; -- vippor på insignalen signal sp : std_logic; -- skiftpuls signal lp : std_logic; -- laddpuls signal pos : UNSIGNED(1 downto 0) := "00"; begin -- ***************************** -- * synkroniseringsvippor * -- ***************************** -- 1 process -- -- Förändringarna på insignalen ska komma i takt med vår klocka. process(clk) begin if rising_edge(clk) then if rst='1' then rx1 <= '0'; rx2 <= '0'; else rx1 <= rx; rx2 <= rx1; end if; end if; end process; -- ***************************** -- * styrenhet * -- ***************************** -- 1 eller 2 processer -- -- Denna producerar två styrsignaler, båda enpulsade: -- – Skiftpulsen sp, som kommer mitt i (ungefär) varje bit. -- – Laddpulsen lp, som kommer efter den sista skiftpulsen. process(clk) begin if rising_edge(clk) then if rst='1' then sp <= '0'; lp <= '0'; elsif _ then else end if; end if; end process; process(clk) begin if rising_edge(clk) then if rst='1' then elsif _ then else end if; end if; end process; -- ***************************** -- * 10 bit skiftregister * -- ***************************** -- 1 process -- -- De 10 bitarna i varje siffra skiftas in i skiftregistret. process(clk) begin if rising_edge(clk) then if rst='1' then elsif _ then else end if; end if; end process; -- ***************************** -- * 2 bit räknare * -- ***************************** -- 1 process process(clk) begin if rising_edge(clk) then if rst='1' then elsif _ then else end if; end if; end process; -- ***************************** -- * 16 bit register * -- ***************************** -- 1 process -- -- ... för 4 siffror. Laddas av laddpulsen, samtidigt räknas räknaren upp. process(clk) begin if rising_edge(clk) then if rst='1' then elsif _ then else end if; end if; end process; -- ***************************** -- * Multiplexad display * -- ***************************** -- Inkoppling av komponenten leddriver led: leddriver port map (clk, rst, seg, an, tal); end Behavioral;