Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ----------------------------------------------------------------------------------
- -- Company:
- -- Engineer:
- --
- -- Create Date: 08:41:32 11/10/2010
- -- Design Name:
- -- Module Name: tiktok - Behavioral
- -- Project Name:
- -- Target Devices:
- -- Tool versions:
- -- Description:
- --
- -- Dependencies:
- --
- -- Revision:
- -- Revision 0.01 - File Created
- -- Additional Comments:
- --
- ----------------------------------------------------------------------------------
- library ieee;
- use ieee.std_logic_1164.ALL;
- use ieee.std_logic_arith.all;
- use ieee.std_logic_unsigned.all;
- entity counter is
- Port ( led : inout std_logic_vector (7 downto 0);
- clk : in std_logic;
- reset : in std_logic;
- up : in std_logic;
- down : in std_logic
- );
- end counter;
- architecture Behavioral of counter is
- signal clkdiv : std_logic;
- signal shift : std_logic;
- begin
- div: process(clk)
- variable q1 : std_logic_vector(22 downto 0);
- begin
- if clk = '1' and clk'event then
- q1 := q1 + '1';
- if q1(22) = '1' then
- q1 := (others => '0');
- clkdiv <= not clkdiv;
- end if;
- end if;
- end process div;
- P1: process(clkdiv, reset, up, down)
- begin
- if reset = '1' then
- led <= (others => '0');
- elsif clkdiv'event and clkdiv = '1' then
- if (up xor down) = '1' then
- if up = '1' then
- led <= led + '1';
- else
- led <= led - '1';
- end if;
- end if;
- end if;
- end process P1;
- end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement