Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Digital design bcd counter some assistance

  1. Dec 3, 2011 #1
    hey yal'....so i was doing a bcd down counter, but I couldn't get it to run as i intended it to. The testbench gives me no results. Can someone help me debug it, please?

    Here's my code:


    ----------------------------------------------------------------------------------
    -- Company:
    -- Engineer:
    --
    -- Create Date: 18:29:02 12/01/2011
    -- Design Name:
    -- Module Name: bcd_example - 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 using
    -- arithmetic functions with Signed or Unsigned values
    --use IEEE.NUMERIC_STD.ALL;

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

    entity bcd_example is
    Port ( --data_in: in STD_LOGIC_VECTOR( 7 downto 0);
    -- load: in std_logic;
    start : in STD_LOGIC;
    --pause: in STD_LOGIC;
    clk : in STD_LOGIC;
    reset : in STD_LOGIC;
    bcd_output : out STD_LOGIC_VECTOR (7 downto 0));
    end bcd_example;

    architecture Behavioral of bcd_example is

    signal bcd_counter: std_logic_vector(7 downto 0);

    begin

    process(reset, clk, start)
    begin

    if (reset = '1') then
    bcd_counter <= (others => '0');

    elsif(clk'event and clk = '1') then
    if( start = '1' ) then
    bcd_counter <= "01011001";
    bcd_counter <= bcd_counter - 1;--count down
    if(bcd_counter = x"00") then
    bcd_counter <= bcd_counter;--hold value
    elsif(bcd_counter(3 downto 0) = "0000") then--once it reaches 0000 then switch to 1001
    bcd_counter(3 downto 0) <= "1001";
    bcd_counter(7 downto 4) <= bcd_counter(7 downto 4) - 1;--meanwhile keep decrementing our first four bits (MSB's)
    end if;
    end if;
    end if;
    end process;a
    bcd_output <= bcd_counter;


    end Behavioral;
     
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted



Similar Discussions: Digital design bcd counter some assistance
  1. Digital Design Career? (Replies: 1)

Loading...