Hello,
I'm trying to create vending machine in VHDL. It should has two kinds of products and remember theirs price and amount. My vending machine allows only tokens. When my machine is in state - payment - it starts to loop(variable vtokens is growing), ignoring conditional statement. What is wrong with my code?
I'm trying to create vending machine in VHDL. It should has two kinds of products and remember theirs price and amount. My vending machine allows only tokens. When my machine is in state - payment - it starts to loop(variable vtokens is growing), ignoring conditional statement. What is wrong with my code?
Code:
PROCESS (clock,reset)
BEGIN
IF (reset='1') THEN
fstate <= init_towar1;
ELSIF (clock'event and clock = '1') THEN
fstate <= reg_fstate;
END IF;
END PROCESS;
PROCESS (fstate)
variable vprice1 : integer range 1 to 7;
variable vamount1 : integer range 0 to 15;
variable vprice2 : integer range 1 to 7;
variable vamount2 : integer range 0 to 15;
variable vprice : integer range 1 to 7;
variable vamount : integer range 0 to 15;
variable vtokens : integer range 0 to 7;
variable vselection: integer range 0 to 2;
BEGIN
CASE fstate IS
.
.
.
WHEN payment =>
IF ((IN_resign = '1')) THEN
reg_fstate <= return;
ELSIF ((IN_tokens = '1')) THEN
vtokens := vtokens+1;
IF ((vtokens < vprice)) THEN
reg_fstate <= payment;
ELSIF (vtokens = vprice) THEN
reg_fstate <= paid;
ELSE
reg_fstate <= payment;
END IF;
ELSE
reg_fstate <= payment;
END IF;
.
.
.
END PROCESS;