Can't resolve multiple constant drivers for net

1473 views vhdl
-2

I wrote this code. I want to count the numbers that I pressed they key_0 and if I press 2 times then the red led will turn on, how ever I get this error:

Can't resolve multiple constant drivers for net.

The thing is that I try to torn on 2 process at the same time how ever this tow process have the same variable: duty_cycle_counter.

What is the problem?

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;


ENTITY Pwm_control IS

                        GENERIC (display_resolution : INTEGER :=8);  


PORT (





    key_0:IN BIT;
    green_led :OUT BIT;
    red_led   :OUT BIT



    );
END Pwm_control;


ARCHITECTURE Behavioral OF Pwm_control IS

SIGNAL counter:std_logic_vector(display_resolution downto 0);
SIGNAL general_counter:std_logic_vector (23 downto 0);-- general_counter is for the clock divider , can get till 23 

SIGNAL step_10_dc           : STD_LOGIC_VECTOR(8 downto 0);         --10 step PWM 
SIGNAL step_5_dc                : STD_LOGIC_VECTOR(8 downto 0);         --5 step PWM 
SIGNAL starting_value_0     : STD_LOGIC_VECTOR(8 downto 0);         --0 step PWM 
SIGNAL duty_cycle_counter  : STD_LOGIC_VECTOR(8 downto 0);      


        BEGIN
        starting_value_0      <= "000000000";
        step_5_dc             <= "000011010";
        step_10_dc            <= "000110011";
        duty_cycle_counter  <= "000000000";

                        key_testing :PROCESS (key_0) -- 
        BEGIN 


                    IF (key_0='0') THEN             
                    green_led <='1';
                    duty_cycle_counter <= (duty_cycle_counter+step_5_dc);
                    ELSE
                   green_led <='0';
                    END IF;

        END  PROCESS key_testing;   


                                key_test_red_led :PROCESS(duty_cycle_counter)
        BEGIN 
                                IF (step_10_dc <= duty_cycle_counter  ) THEN

                                red_led <='1';

                                END IF;
        END  PROCESS key_test_red_led;  



END Behavioral;

answered question

1 Answer

8

You're driving duty_cycle_counter continuously with 0 and trying to update it in the key_testing process. It looks like you wanted a start value (possible in most RAM-based FPGAs) or a reset, though in real life it will have some value so you could just leave out the initialization.

posted this

Have an answer?

JD

Please login first before posting an answer.