Sunday, April 7, 2013

CODE : BCD COUNTER VHDL

CODE : BCD COUNTER

This code is just an example for more detailed understanding of VHDL concepts I would recommend these two books :

1) A VHDL PRIMER by J. Bhasker - A VHDL PRIMER from flipkart.com
A VHDL PRIMER from amazon.com
A VHDL PRIMER from amazon.in

2)VHDL:PROGRAMMING BY EXAMPLES by PERRY - VHDL:PROGRAMMING BY EXAMPLES by PERRY from flipkart.com
VHDL:PROGRAMMING BY EXAMPLES by PERRY from amazon.com
VHDL:PROGRAMMING BY EXAMPLES by PERRY from amazon.in

----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date:    23:45:17 11/01/2006
-- Design Name:
-- Module Name:    BCDcounter_code - 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;

---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;

entity BCDcounter_code is
    Port ( count:inout std_logic_vector(3 downto 0);
            clk  :in std_logic;
              rst  :in std_logic);
end BCDcounter_code;

architecture Behavioral of BCDcounter_code is
begin
process(clk,rst)
begin
    if rst='1' then
        count <= "0000";
    elsif clk'event and clk='1' then
        if count = "1001" then
            count <= "0000";
        else
            count <= (count+1);
        end if;
    end if;
end process;

end architecture;

No comments:

Post a Comment