VHDL Compilation error. Please help

R

raju

Hello,
I'm quite new to VHDL. I need to write VHDL code for a vending machine
as part of my assignment.

I get the following errors.
# Error: ELBWRITE_0028: vendingMachine.vhd : (199, 0):
Signal "Number_Of_Cans" has two sources, but is not
resolved signal (at line 199: Number_Of_Cans & at line
46: Number_Of_Cans).
# Error: ELBWRITE_0028: vendingMachine.vhd : (200, 0):
Signal "Next_State" has two sources, but is not
resolved signal (at line 200: Next_State & at line 58:
Next_State).
# Error: ELBWRITE_0028: vendingMachine.vhd : (241, 0):
Signal "Number_Of_Bottles" has two sources, but is not
resolved signal (at line 241: Number_Of_Bottles & at
line 45: Number_Of_Bottles).

Can someone please throw some light on these errors & any other
comments on the following code is greatly appreciated.

-------------------------------------------------------
-------------------------------------------------------

Library IEEE;
use IEEE.std_logic_1164.all;

------------------------------
-- Entity Definition
------------------------------

entity CokeMachine is
Port ( CLK : In std_logic ;
Reset_N : In std_logic ;
Money_In : In std_logic_vector ( 0 to 1 ) ;
CBR_Buttons : In std_logic_vector ( 0 to 1 ) ;

Bottle_Out : Out std_logic ;
Can_Out : Out std_logic ;
Refund_10p : Out std_logic ;
Refund_20p : Out std_logic ;
Refund_50p : Out std_logic ;
Refund_All : Out std_logic ;
No_Cans_Left : Out std_logic ;
No_Bottles_Left : Out std_logic ;
Need_More_Money : Out std_logic );
end CokeMachine ;

architecture RTL of CokeMachine is
type State_Type is ( Start, State_10p, State_20p,
State_30p, State_40p, State_50p,
State_60p, State_70p );

signal Current_State : State_Type ;
signal Next_State : State_Type ;

signal Number_Of_Bottles, Number_Of_Cans : integer := 0 ;

begin

State_Clock : process( Reset_N, CLK, Next_State )
begin
if rising_edge( CLK ) then
if Reset_N = '1' then
Current_State <= Start;
Number_Of_Bottles <= 10;
Number_Of_Cans <= 10;
else
Current_State <= Next_State ;
end if;
end if;
end process State_Clock;

Next_State_Control : process( Money_In, Current_State )
begin
case Current_State is
when Start =>
if Money_In = "00" then
Next_State <= Current_State ;
elsif Money_In = "01" then
Next_State <= State_10p ;
elsif Money_In = "10" then
Next_State <= State_20p ;
elsif Money_In = "11" then
Next_State <= State_50p ;
end if ;
when State_10p =>
if Money_In = "00" then
Next_State <= Current_State ;
elsif Money_In = "01" then
Next_State <= State_20p ;
elsif Money_In = "10" then
Next_State <= State_30p ;
elsif Money_In = "11" then
Next_State <= State_60p ;
end if ;
when State_20p =>
if Money_In = "00" then
Next_State <= Current_State ;
elsif Money_In = "01" then
Next_State <= State_30p ;
elsif Money_In = "10" then
Next_State <= State_40p ;
elsif Money_In = "11" then
Next_State <= State_70p ;
end if ;
when State_30p =>
if Money_In = "00" then
Next_State <= Current_State ;
elsif Money_In = "01" then
Next_State <= State_40p ;
elsif Money_In = "10" then
Next_State <= State_50p ;
elsif Money_In = "11" then
Next_State <= Current_State ;
Refund_50p <= '1' ;
end if ;
when State_40p =>
if Money_In = "00" then
Next_State <= Current_State ;
elsif Money_In = "01" then
Next_State <= State_50p ;
elsif Money_In = "10" then
Next_State <= State_70p ;
elsif Money_In = "11" then
Next_State <= Current_State ;
Refund_50p <= '1' ;
end if ;
when State_50p =>
if Money_In = "00" then
Next_State <= Current_State ;
elsif Money_In = "01" then
Next_State <= State_60p ;
elsif Money_In = "10" then
Next_State <= State_70p ;
elsif Money_In = "11" then
Next_State <= Current_State ;
Refund_50p <= '1' ;
end if ;
when State_60p =>
if Money_In = "00" then
Next_State <= Current_State ;
elsif Money_In = "01" then
Next_State <= State_70p ;
elsif Money_In = "10" then
Next_State <= Current_State ;
Refund_20p <= '1' ;
elsif Money_In = "11" then
Next_State <= Current_State ;
Refund_50p <= '1' ;
end if ;
when State_70p =>
if Money_In = "00" then
Next_State <= Current_State ;
elsif Money_In = "01" then
Next_State <= Current_State ;
Refund_10p <= '1' ;
elsif Money_In = "10" then
Next_State <= Current_State ;
Refund_20p <= '1' ;
elsif Money_In = "11" then
Next_State <= Current_State ;
Refund_50p <= '1' ;
end if ;
end case ;
end process ;

Output_Control : process( CBR_Buttons, Current_State )
begin
if CBR_Buttons = "01" and Number_of_Cans = 0 then
No_Cans_Left <= '1' ;
elsif CBR_Buttons = "10" and Number_Of_Bottles = 0 then
No_Bottles_Left <= '1' ;
else
case Current_State is
when Start =>
if CBR_Buttons = "00" and CBR_Buttons = "11" then
-- do nothing ???
elsif CBR_Buttons = "01" or CBR_Buttons = "10"
then
Need_More_Money <= '1' ;
end if;
when State_10p =>
if CBR_Buttons = "00" then
-- do nothing ???
elsif CBR_Buttons = "01" or CBR_Buttons = "10"
then
Need_More_Money <= '1' ;
elsif CBR_Buttons = "11" then
Refund_10p <= '1' ;
end if;
when State_20p =>
if CBR_Buttons = "00" then
-- do nothing ???
elsif CBR_Buttons = "01" or CBR_Buttons = "10"
then
Need_More_Money <= '1' ;
elsif CBR_Buttons = "11" then
Refund_All <= '1' ;
end if;
when State_30p =>
if CBR_Buttons = "00" then
-- do nothing ???
elsif CBR_Buttons = "01" or CBR_Buttons = "10"
then
Need_More_Money <= '1' ;
elsif CBR_Buttons = "11" then
Refund_All <= '1' ;
end if;
when State_40p =>
if CBR_Buttons = "00" then
-- do nothing ???
elsif CBR_Buttons = "01" or CBR_Buttons = "10"
then
Need_More_Money <= '1' ;
elsif CBR_Buttons = "11" then
Refund_All <= '1' ;
end if;
when State_50p =>
if CBR_Buttons = "00" then
-- do nothing ???
elsif CBR_Buttons = "01" then
if Number_Of_Cans > 0 then
Can_Out <= '1' ;
Number_Of_Cans <= Number_Of_Cans - 1 ;
Next_State <= Start ;
else
No_Cans_Left <= '1' ;
end if;
elsif CBR_Buttons = "10" then
Need_More_Money <= '1' ;
elsif CBR_Buttons = "11" then
Refund_All <= '1' ;
end if;
when State_60p =>
if CBR_Buttons = "00" then
-- do nothing ???
elsif CBR_Buttons = "01" then
if Number_Of_Cans > 0 then
Can_Out <= '1' ;
Refund_10p <= '1' ;
Number_Of_Cans <= Number_Of_Cans - 1 ;
Next_State <= Start ;
else
No_Cans_Left <= '1' ;
end if;
elsif CBR_Buttons = "10" then
Need_More_Money <= '1' ;
elsif CBR_Buttons = "11" then
Refund_All <= '1' ;
end if;
when State_70p =>
if CBR_Buttons = "00" then
-- do nothing ???
elsif CBR_Buttons = "01" then
if Number_Of_Cans > 0 then
Can_Out <= '1' ;
Refund_20p <= '1' ;
Number_Of_Cans <= Number_Of_Cans - 1 ;
Next_State <= Start ;
else
No_Cans_Left <= '1' ;
end if;
elsif CBR_Buttons = "10" then
if Number_Of_Bottles > 0 then
Bottle_Out <= '1' ;
Number_Of_Bottles <= Number_Of_Bottles - 1
;
Next_State <= Start ;
else
No_Bottles_Left <= '1' ;
end if;
elsif CBR_Buttons = "11" then
Refund_All <= '1' ;
end if;
end case ;
end if ;
end process ;
end RTL ;
 
S

Scott Thibault

You cannot schedule values to a signal (i.e. Number_Of_Cans) in more than
one process. You need to put all the logic involved in determining the
value of Number_Of_Cans in a single process.

Forget about resolved signals. Those are for busses and that is not what
you need here.

--Scott Thibault
Green Mountain Computing Systems, Inc.
http://www.gmvhdl.com
 
C

Cameron, Charles B.

raju said:
Hello,
I'm quite new to VHDL. I need to write VHDL code for a vending machine
as part of my assignment.

I get the following errors.
# Error: ELBWRITE_0028: vendingMachine.vhd : (199, 0):
Signal "Number_Of_Cans" has two sources, but is not
resolved signal (at line 199: Number_Of_Cans & at line
46: Number_Of_Cans).
# Error: ELBWRITE_0028: vendingMachine.vhd : (200, 0):
Signal "Next_State" has two sources, but is not
resolved signal (at line 200: Next_State & at line 58:
Next_State).
# Error: ELBWRITE_0028: vendingMachine.vhd : (241, 0):
Signal "Number_Of_Bottles" has two sources, but is not
resolved signal (at line 241: Number_Of_Bottles & at
line 45: Number_Of_Bottles).

Can someone please throw some light on these errors & any other
comments on the following code is greatly appreciated.

-------------------------------------------------------
-------------------------------------------------------

Library IEEE;
use IEEE.std_logic_1164.all;

------------------------------
-- Entity Definition
------------------------------

entity CokeMachine is
Port ( CLK : In std_logic ;
Reset_N : In std_logic ;
Money_In : In std_logic_vector ( 0 to 1 ) ;
CBR_Buttons : In std_logic_vector ( 0 to 1 ) ;

Bottle_Out : Out std_logic ;
Can_Out : Out std_logic ;
Refund_10p : Out std_logic ;
Refund_20p : Out std_logic ;
Refund_50p : Out std_logic ;
Refund_All : Out std_logic ;
No_Cans_Left : Out std_logic ;
No_Bottles_Left : Out std_logic ;
Need_More_Money : Out std_logic );
end CokeMachine ;

architecture RTL of CokeMachine is
type State_Type is ( Start, State_10p, State_20p,
State_30p, State_40p, State_50p,
State_60p, State_70p );

signal Current_State : State_Type ;
signal Next_State : State_Type ;

signal Number_Of_Bottles, Number_Of_Cans : integer := 0 ;

begin

State_Clock : process( Reset_N, CLK, Next_State )
begin
if rising_edge( CLK ) then
if Reset_N = '1' then
Current_State <= Start;
Number_Of_Bottles <= 10;
Number_Of_Cans <= 10;
else
Current_State <= Next_State ;
end if;
end if;
end process State_Clock;

Next_State_Control : process( Money_In, Current_State )
begin
case Current_State is
when Start =>
if Money_In = "00" then
Next_State <= Current_State ;
elsif Money_In = "01" then
Next_State <= State_10p ;
elsif Money_In = "10" then
Next_State <= State_20p ;
elsif Money_In = "11" then
Next_State <= State_50p ;
end if ;
when State_10p =>
if Money_In = "00" then
Next_State <= Current_State ;
elsif Money_In = "01" then
Next_State <= State_20p ;
elsif Money_In = "10" then
Next_State <= State_30p ;
elsif Money_In = "11" then
Next_State <= State_60p ;
end if ;
when State_20p =>
if Money_In = "00" then
Next_State <= Current_State ;
elsif Money_In = "01" then
Next_State <= State_30p ;
elsif Money_In = "10" then
Next_State <= State_40p ;
elsif Money_In = "11" then
Next_State <= State_70p ;
end if ;
when State_30p =>
if Money_In = "00" then
Next_State <= Current_State ;
elsif Money_In = "01" then
Next_State <= State_40p ;
elsif Money_In = "10" then
Next_State <= State_50p ;
elsif Money_In = "11" then
Next_State <= Current_State ;
Refund_50p <= '1' ;
end if ;
when State_40p =>
if Money_In = "00" then
Next_State <= Current_State ;
elsif Money_In = "01" then
Next_State <= State_50p ;
elsif Money_In = "10" then
Next_State <= State_70p ;
elsif Money_In = "11" then
Next_State <= Current_State ;
Refund_50p <= '1' ;
end if ;
when State_50p =>
if Money_In = "00" then
Next_State <= Current_State ;
elsif Money_In = "01" then
Next_State <= State_60p ;
elsif Money_In = "10" then
Next_State <= State_70p ;
elsif Money_In = "11" then
Next_State <= Current_State ;
Refund_50p <= '1' ;
end if ;
when State_60p =>
if Money_In = "00" then
Next_State <= Current_State ;
elsif Money_In = "01" then
Next_State <= State_70p ;
elsif Money_In = "10" then
Next_State <= Current_State ;
Refund_20p <= '1' ;
elsif Money_In = "11" then
Next_State <= Current_State ;
Refund_50p <= '1' ;
end if ;
when State_70p =>
if Money_In = "00" then
Next_State <= Current_State ;
elsif Money_In = "01" then
Next_State <= Current_State ;
Refund_10p <= '1' ;
elsif Money_In = "10" then
Next_State <= Current_State ;
Refund_20p <= '1' ;
elsif Money_In = "11" then
Next_State <= Current_State ;
Refund_50p <= '1' ;
end if ;
end case ;
end process ;

Output_Control : process( CBR_Buttons, Current_State )
begin
if CBR_Buttons = "01" and Number_of_Cans = 0 then
No_Cans_Left <= '1' ;
elsif CBR_Buttons = "10" and Number_Of_Bottles = 0 then
No_Bottles_Left <= '1' ;
else
case Current_State is
when Start =>
if CBR_Buttons = "00" and CBR_Buttons = "11" then
-- do nothing ???
elsif CBR_Buttons = "01" or CBR_Buttons = "10"
then
Need_More_Money <= '1' ;
end if;
when State_10p =>
if CBR_Buttons = "00" then
-- do nothing ???
elsif CBR_Buttons = "01" or CBR_Buttons = "10"
then
Need_More_Money <= '1' ;
elsif CBR_Buttons = "11" then
Refund_10p <= '1' ;
end if;
when State_20p =>
if CBR_Buttons = "00" then
-- do nothing ???
elsif CBR_Buttons = "01" or CBR_Buttons = "10"
then
Need_More_Money <= '1' ;
elsif CBR_Buttons = "11" then
Refund_All <= '1' ;
end if;
when State_30p =>
if CBR_Buttons = "00" then
-- do nothing ???
elsif CBR_Buttons = "01" or CBR_Buttons = "10"
then
Need_More_Money <= '1' ;
elsif CBR_Buttons = "11" then
Refund_All <= '1' ;
end if;
when State_40p =>
if CBR_Buttons = "00" then
-- do nothing ???
elsif CBR_Buttons = "01" or CBR_Buttons = "10"
then
Need_More_Money <= '1' ;
elsif CBR_Buttons = "11" then
Refund_All <= '1' ;
end if;
when State_50p =>
if CBR_Buttons = "00" then
-- do nothing ???
elsif CBR_Buttons = "01" then
if Number_Of_Cans > 0 then
Can_Out <= '1' ;
Number_Of_Cans <= Number_Of_Cans - 1 ;
Next_State <= Start ;
else
No_Cans_Left <= '1' ;
end if;
elsif CBR_Buttons = "10" then
Need_More_Money <= '1' ;
elsif CBR_Buttons = "11" then
Refund_All <= '1' ;
end if;
when State_60p =>
if CBR_Buttons = "00" then
-- do nothing ???
elsif CBR_Buttons = "01" then
if Number_Of_Cans > 0 then
Can_Out <= '1' ;
Refund_10p <= '1' ;
Number_Of_Cans <= Number_Of_Cans - 1 ;
Next_State <= Start ;
else
No_Cans_Left <= '1' ;
end if;
elsif CBR_Buttons = "10" then
Need_More_Money <= '1' ;
elsif CBR_Buttons = "11" then
Refund_All <= '1' ;
end if;
when State_70p =>
if CBR_Buttons = "00" then
-- do nothing ???
elsif CBR_Buttons = "01" then
if Number_Of_Cans > 0 then
Can_Out <= '1' ;
Refund_20p <= '1' ;
Number_Of_Cans <= Number_Of_Cans - 1 ;
Next_State <= Start ;
else
No_Cans_Left <= '1' ;
end if;
elsif CBR_Buttons = "10" then
if Number_Of_Bottles > 0 then
Bottle_Out <= '1' ;
Number_Of_Bottles <= Number_Of_Bottles - 1
;
Next_State <= Start ;
else
No_Bottles_Left <= '1' ;
end if;
elsif CBR_Buttons = "11" then
Refund_All <= '1' ;
end if;
end case ;
end if ;
end process ;
end RTL ;

You have two processes, Next_State_Control and Output_Control, both of
which modify, for example, Number_Of_Cans. The compiler can't tell
which signal source you really mean to use. I think you would do well
to let Output_Control be in charge of modifying Number_Of_Cans and that
will eliminate the conflict. Likewise for the other signals with
multiple sources. I haven't checked carefully, but for all I know there
may be other sources for these signals, too, aside from the two I
spotted quite readily.

Charles B. Cameron
 
R

Ralf Hildebrandt

raju wrote:

I get the following errors.
# Error: ELBWRITE_0028: vendingMachine.vhd : (199, 0):
Signal "Number_Of_Cans" has two sources, but is not
resolved signal (at line 199: Number_Of_Cans & at line
46: Number_Of_Cans).

You write to the signal "Number_Of_Cans" from more than one process.
Normally this should be avoided.

An exception are tri-state busses, but as you said you are a newbie:
forget this for a while.


Ralf
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top