Altera_Forum
Honored Contributor
15 years agoVHDL Error (10028): Can't resolve multiple constant drivers for net...
Hi all,
I'm a rank beginner, so expect beginner errors. I am using Quartus v9.1. I'm getting the famous "Error (10028): Can't resolve multiple constant drivers for net "button1" at keyfob_top.vhd(65)" I know what it is happening, but I'm unable to see _why_ it is happening. Button1 is declared as a SIGNAL, therefore there can only be ONE line of code that changes its actual value. This is why PROCEDURE set_button1() exists, it acts as a multiplexer, reducing the number of code instances that change button1 to one. The problem starts when I add a second call to set_button1(), which gives the error above. From what I can tell, the compiler sees each call to set_button1() as a unique and different piece of code, where the intention is exactly the opposite!:( How can I solve this problem? Is there another way to approach this? Can someone point me to documents that explain in detail how to deal with this problem? The complete code follows. Yours, Robert Hodkinson. P.S. The formatting of my code was thrown out of the window by the forums, so how to people place their code into postings and keep the formatting? (edit: this has been sorted out now).:)
library ieee;
use ieee.std_logic_1164.all;
entity keyfob_top is
port
(
pin_clk: in std_logic; -- our input clock
pin_button1: in std_logic; -- user button, fires a signal1
pin_led_output: buffer std_logic; -- user sees that a button has been pushed
pin_ir_output: buffer std_logic -- IR output signal
);
end keyfob_top;
architecture led_behaviour of keyfob_top is
constant led_off : std_logic :='0'; -- led boolean off value
constant led_on : std_logic :='1'; -- led boolean on value
constant button_up: std_logic :='0'; -- button has not been pressed
constant button_down: std_logic :='1'; -- button has been pressed
constant baud_rate : integer := 5; -- delay number
signal baud_tick : std_logic := '0'; -- baud rate delay
signal button1 : std_logic := '0'; -- internal button1
signal button1_bits_left : integer; -- bits left to transmit for button1 press
-- apply the correct value to button1 (which is a signal)
procedure set_button1(constant status : std_logic) is
variable tmp : std_logic;
begin
if status = button_up then
tmp := button_up; -- has just been pressed
else
tmp := button_down; -- has just been released
end if;
button1 <= tmp;
end procedure set_button1;
begin
-- create our baud rate
-- runs permanently in the background generating our baud rate.
baud_clock : process(pin_clk, baud_tick)
variable count : integer range 0 to 99;
begin
if count > baud_rate then
count := 0; -- reset our counter
if baud_tick = '1' then
baud_tick <= '0'; -- toggle our indicator
else
baud_tick <= '1'; -- toggle our indicator
end if;
else
count := count + 1; -- incrament the counter
end if;
end process baud_clock;
-- triggered when pin_button1 has been pressed
trigger_button1: process
begin
wait until pin_button1 = '1'; -- wait until pin_button1 is pressed
set_button1(button_down); -- pin_button1 has just been pressed.
button1_bits_left <= 8;
end process trigger_button1;
-- do we have anything to send out
data_out: process
begin
wait until baud_tick = '1'; -- line 65 -- wait on rising edge
-- does button1 need to be serviced
if button1 = button_down then
button1_bits_left <= button1_bits_left - 1; -- decrament our counter
case button1_bits_left is -- choose which bit to send out
when 7 => pin_ir_output <= led_off;
pin_led_output <= led_on; -- show user what is going on
when 6 => pin_ir_output <= led_on;
when 5 => pin_ir_output <= led_off;
when 4 => pin_ir_output <= led_off;
when 3 => pin_ir_output <= led_on;
when 2 => pin_ir_output <= led_off;
when 1 => pin_ir_output <= led_on;
when 0 => pin_ir_output <= led_off;
set_button1(button_up); -- reset our button
pin_led_output <= led_off; -- show user what is going on
when others => null;
end case;
end if;
-- list other button presses here.
end process data_out;
end led_behaviour;