BCD counter vhdl code

Discussion in 'Programmer's Corner' started by xzr3b0rnzx, Feb 1, 2011.

  1. xzr3b0rnzx

    Thread Starter New Member

    Feb 1, 2011
    [​IMG]This is my written code:

    library ieee;
    use ieee.std_logic_1164.all;
    use ieee.numeric_std.all;

    entity d4 is
    port (reset, sensor, load :in std_logic;
    p :in std_logic_vector (5 downto 0);
    led_on [​IMG]ut std_logic;
    q [​IMG]ut std_logic_vector (5 downto 0));
    end d4;

    architecture flow of d4 is
    signal count_sig : unsigned (5 downto 0);
    signal load_sig : unsigned (5 downto 0);

    process (sensor, reset, load, p)
    if (reset = '1') then
    count_sig <= "000000";

    elsif rising_edge (sensor) then
    if (count_sig = 32) then
    count_sig <= "000000";

    count_sig <= count_sig + 1;

    if (load = '0') then
    count_sig <= load_sig;

    count_sig <= count_sig + 1;

    end if;
    end if;
    end if;
    end process;

    q <= std_logic_vector (count_sig);

    end flow;


    I did not add LED_ON in the code because i don't know the correct way to to put in the LED, always getting error when i try to put in LED code..

    and i can't make P to activate Q when load is low.

    i don't know what i am talking about too. Please help me ! appreciate if u do so :confused: