-------------------------- Muxdisplay_ver5e --------------------------------------- -- Blank="1000" => Display 3 blank and the rest will be active. -- Blank= "00"&Clk_1Hz & not Clk_1Hz; will make Disp1 and Disp0 blink. -- -- Since all outputs triggered by the Clk_50MHz will there be a F/F for each signal -- This could be an advantage in order to prevent glitches, hazards etc. ---------------------------------------------------------------------------------- library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity Muxdisplay_ver5e is PORT( Clk_50MHz : IN std_logic; Blank : IN std_logic_vector(3 downto 0); -- Blanking of display Hex: IN std_logic_vector(15 downto 0); -- Hex3,Hex2,Hex1,Hex0 Dp : IN std_logic_vector( 3 downto 0); -- dp3, dp2, dp1, dp0 Segm : OUT std_logic_vector( 1 to 8); -- a,b,c,d,e,f,g,dp An : OUT std_logic_vector( 3 downto 0); -- Display selection Clk_1kHz : OUT std_logic; -- Downscaled Clock Clk_1Hz : OUT std_logic); -- ____-----__ 1 Hz end Muxdisplay_ver5e; architecture Behavioral of Muxdisplay_ver5e is begin --------------------------------------------------------------------- Mux_Display: process( Clk_50MHz) variable Scale50000: integer range 0 to 50000; variable Scale1023: std_logic_vector( 9 downto 0); variable X: std_logic_vector( 1 downto 0) := "00"; variable Xi: integer range 0 to 3; variable HexDig: std_logic_vector( 3 downto 0); type ROM_array is array (0 to 15) of std_logic_vector (1 to 7); -- abcdefg constant Hex27Segm: ROM_array := ( "0000001", -- 0 "1001111", -- 1 "0010010", -- 2 "0000110", -- 3 "1001100", -- 4 "0100100", -- 5 "0100000", -- 6 "0001111", -- 7 "0000000", -- 8 "0000100", -- 9 "0001000", -- A "1100000", -- b "0110001", -- C "1000010", -- d "0110000", -- E "0111000");-- F begin ------------------------------------- Sequential logic ---------- if rising_edge( Clk_50MHz) then if Scale50000 <50000 then Scale50000 := Scale50000 + 1; Clk_1kHz <= '0'; else Scale50000 := 1; Clk_1kHz <= '1'; Scale1023 :=Scale1023+1; Clk_1Hz <= Scale1023(9); -- approx. 1 Hz X := X+1; Xi := conv_integer(X); HexDig := Hex( Xi*4+3 downto Xi*4); if Blank(Xi)='1' then Segm <= "1111111" & Dp(Xi); else Segm <= Hex27Segm( Conv_integer(HexDig)) & Dp(Xi); end if; An <= "1111"; An(Xi) <= '0'; end if; end if; end process; end Behavioral;