|
|
|
|
|
|
|
|
|
|
|
|
8-Bit Up-Down Counter
|
|
|
|
|
|
1 -------------------------------------------------------
2 -- Design Name : up_down_counter
3 -- File Name : up_down_counter.vhd
4 -- Function : Up down counter
5 -- Coder : Deepak Kumar Tala (Verilog)
6 -- Translator : Alexander H Pham (VHDL)
7 -------------------------------------------------------
8 library ieee;
9 use ieee.std_logic_1164.all;
10 use ieee.std_logic_unsigned.all;
11
12 entity up_down_counter is
13 port (
14 cout :out std_logic_vector (7 downto 0); 15 up_down :in std_logic; -- up_down control for counter
16 clk :in std_logic; -- Input clock
17 reset :in std_logic -- Input reset
18 );
19 end entity;
20
21 architecture rtl of up_down_counter is
22 signal count :std_logic_vector (7 downto 0);
23 begin
24 process (clk, reset) begin
25 if (reset = '1') then
26 count <= (others=>'0');
27 elsif (rising_edge(clk)) then
28 if (up_down = '1') then
29 count <= count + 1;
30 else
31 count <= count - 1;
32 end if;
33 end if;
34 end process;
35 cout <= count;
36 end architecture;
You could download file vhdl_examples here
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Copyright © 1998-2014 |
Deepak Kumar Tala - All rights reserved |
Do you have any Comment? mail me at:deepak@asic-world.com
|
|