--------------------------------------------------------------------------------- -- 4xBcd counter -- Use Btn<3:0> to count each bcd-digit individually -- Use Sw<0> to select upDOWN = 0/1 -- Use Sw<1> to select Reset = 1 ---------------------------------------------------------------------------------- library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; ---- Uncomment the following library declaration if instantiating ---- any Xilinx primitives in this code. library UNISIM; use UNISIM.VComponents.all; entity Bcd_Count4 is Port ( Clk_50MHz : in STD_LOGIC; Btn : in STD_LOGIC_VECTOR (3 downto 0); Segm : out STD_LOGIC_VECTOR (1 to 8); An : out STD_LOGIC_VECTOR (3 downto 0); Sw : in STD_LOGIC_VECTOR (1 downto 0)); end Bcd_Count4; ARCHITECTURE Behavioral OF Bcd_Count4 IS COMPONENT Bcd_Counter PORT( Clk_50MHz : IN std_logic; Reset : IN std_logic; Enable : IN std_logic; Btn : IN std_logic; upDOWN : IN std_logic; TCO : OUT std_logic; Bcd : OUT std_logic_vector(3 downto 0)); END COMPONENT; COMPONENT Muxdisplay_ver5d PORT( Clk_50MHz : IN std_logic; Hex : IN std_logic_vector(15 downto 0); Dp : IN std_logic_vector( 3 downto 0); Segm : OUT std_logic_vector( 1 to 8); An : OUT std_logic_vector( 3 downto 0)); END COMPONENT; Signal Reset,upDOWN,TCO0,TCO1,TCO2,TCO3: STD_LOGIC; Signal Bcd0,Bcd1,Bcd2,Bcd3,Dp: STD_LOGIC_VECTOR ( 3 downto 0); Signal Hex: STD_LOGIC_VECTOR (15 downto 0); BEGIN Reset <= Sw(1); upDOWN <= Sw(0); --Note! The order of pins is important in the four instances below U3: Bcd_Counter PORT MAP( Clk_50MHz,Reset,TCO2,Btn(3),upDOWN,TCO3,Bcd3); U2: Bcd_Counter PORT MAP( Clk_50MHz,Reset,TCO1,Btn(2),upDOWN,TCO2,Bcd2); U1: Bcd_Counter PORT MAP( Clk_50MHz,Reset,TCO0,Btn(1),upDOWN,TCO1,Bcd1); U0: Bcd_Counter PORT MAP( Clk_50MHz,Reset, '0',Btn(0),upDOWN,TCO0,Bcd0); Dp <= (not TCO0)&(not TCO1)&(not TCO2)&(not TCO3); -- Not useful :-( Hex <= Bcd3&Bcd2&Bcd1&Bcd0; MuxDisp: Muxdisplay_ver5d PORT MAP( Hex => Hex, Dp => Dp, Segm => Segm, An => An, Clk_50MHz => Clk_50MHz); --Note! The order of pins not important END Behavioral;