Friday, 13 March 2015

Group 1--Vending machine controller design--The bench inspection day (Mar. 13st. 2015)

Today was the final bench inspection day to show our project by the presentation with the poster and demonstration on the DE2 board.

Firstly, the poster designed of this project could be shown below:
Figure 1. The poster designed for this project


During the whole bench inspection day, we mainly gave a poster presentation and the demonstration on DE2 board to our supervisor and the assessor. Generally speaking, the whole process was successful and our work on this project was also satisfied. However, according to the question asked by the assessor and the supervisor, we found some drawbacks of the design which meant we could make some improvements for the further development. They are listed below:

  1. Firstly, the number of the product was considered as infinity in this program, in other words, we did not consider the number of products and process them which did not conform with the reality. To improve this, we could further add DFFs as the counter to process the number of products.
  2. Secondly, refer to the operation flow charts, this controller was designed to firstly choose only one item and then pay for this item which was not in agreement with the real situation. So in the future, the design can be modified to allow customers to incert money firstly and then choose the items they want to purchase which can be more than one. To realize this, we will need to calculate the total amount of money received firstly and then to process the change condition based on the price of products selected and the total amount of money.
Finally, after the bench inspection was finished, we also took photos together with our work, and we also want to give our appreciation to our supervisor and all the staffs in the department for providing the help and we really enjoyed those weeks working with this project. The photo of our group is shown below:
Figure 2. The photo of the group

Wednesday, 11 March 2015

Group 1--Vending machine controller design--The demontration vedio of the project (Mar. 11st. 2015)

Since the whole controller design, simulations and testings were completed   successfully, our group created a vedio of the demonstration of our design on the ALTERA DE2 board this week before the final bench inspection. To see the vedio, you can just click on the following 'start' button or simply go to the following URL: http://youtu.be/3YhpSKWHxIQ

The demonstration vedio of the project

Friday, 6 March 2015

Group 1--Vending machine design--Blog for fifth lab day (Mar. 5th. 2015)

This is our fifth lab day. Before this lab day, we had finished all the programming and the simulation and focused on testing and troubleshooting in the lab.The final design layout (based on the program) can be shown below.

Figure 1. Final block diagram
The upper figure showed the final design including all function blocks, circuit connetions, input and output pins. electronic circuits. Specifically, it did not have significant changes comparing to the block diagram presented in the last blog. The differences were that seven-segment blocks for dispalying functions and single pulse blocks for signal modifications were added to complete the whole function for the controller. The layout had also been rearranged in order to present a clear connection between different blocks. Additionally, the FPGA pins were also added for the testing on the DE2 board. 

Then in the process of testing. we met some problems.They were listed below.

(a) The first problem occurred in the ‘change’ process. Since the number of coins stored in the machine initially was not considered before, so it was difficult for the machine to change for the initial several purchase since not enough number of corresponding coins stored. In order to solve the problem, the ‘subtraction’ block was further modified which would initialize the value of the number for each coins with a suitable value and this process could be performed by a ‘system_reset’ switch. After the modification, the number of coins would be generally enough for the first few purchasing processes. Additionally, the ‘switch_reset’ should be enabled once in the very beginning before the purchasing to initialize the number of coins. Then the codes for the block named 'subs' was modified to realize the initialization which can be shown below.

Codes of 'subs' block after modification

SUBDESIGN subs
(
clk, sys_reset, change_end                                                                     : INPUT ;
temp_10p[3..0] , temp_20p[3..0] , temp_50p[3..0] , temp_100p[3..0]                             : INPUT;
coin_change_10p[3..0] , coin_change_20p[3..0] , coin_change_50p[3..0] , coin_change_100p[3..0] : INPUT;
number_10p[3..0] , number_20p[3..0] , number_50p[3..0] , number_100p[3..0]                     : OUTPUT;
)

VARIABLE
a1[3..0] : node;
a2[3..0] : node;
a3[3..0] : node;
a4[3..0] : node;
b1 : node;
b2 : node;
b3 : node;
b4 : node;
c1 : node;
c2 : node;
c3 : node;
c4 : node;
coin_10p[3..0] : DFF;
coin_20p[3..0] : DFF;
coin_50p[3..0] : DFF;
coin_100p[3..0] : DFF;

BEGIN

Number_10p[] = coin_10p[];
Number_20p[] = coin_20p[];
Number_50p[] = coin_50p[];
Number_100p[] = coin_100p[];

coin_10p[].clk = clk;
coin_20p[].clk = clk;
coin_50p[].clk = clk;
coin_100p[].clk = clk;

IF (sys_reset)THEN
coin_10p[].d = B"1000";
coin_20p[].d = B"1000";
coin_50p[].d = B"0100";
coin_100p[].d = B"0100";

ELSE
    IF(change_end)THEN
(b1,a1[])=(gnd,temp_10p[])+(gnd,coin_10p[].q);
(b2,a2[])=(gnd,temp_20p[])+(gnd,coin_20p[].q);
(b3,a3[])=(gnd,temp_50p[])+(gnd,coin_50p[].q);
(b4,a4[])=(gnd,temp_100p[])+(gnd,coin_100p[].q);
(c1,coin_10p[].d )=(b1,a1[])-(gnd,coin_change_10p[]);
(c2,coin_20p[].d )=(b2,a2[])-(gnd,coin_change_20p[]);
(c3,coin_50p[].d )=(b3,a3[])-(gnd,coin_change_50p[]);
(c4,coin_100p[].d )=(b4,a4[])-(gnd,coin_change_100p[]);
ELSE
coin_10p[].d = coin_10p[].q + 0;
coin_20p[].d = coin_20p[].q + 0;
coin_50p[].d = coin_50p[].q + 0;
coin_100p[].d = coin_100p[].q + 0;
END IF;
END IF;

END;
)

(b) The second was the issue regarding displaying the correct amount of the money input. Although the controller could be correctly operated to finish all the imporatnt procedure in the purchasing as expected, we found out that there was always one ten penny presented on the board initially and it seemed that the program was correct which would not generate that problem. After asking our supervisor for help, we found out that it was the key button of DE2 board (designed for entering coins)is designed to gnerate a low signal each time the button was pressed and we wrongly assumed it would generate high signals as usual. As a result, we then changed the polarity of the four coin input receivers (single pulse) from the key buttons and the ten penny problem was then fixed.The small change could be seen below (denoted as 'y!').

Figure 2. The change of coin_input signal polarity


Friday, 27 February 2015

Group 1--Vending machine design--Blog for forth lab day (Feb. 27th. 2015)

This is our forth lab day. Our objective today was to revise the ASM chart for some of the blocks and try to code for them.
Figure 1. Revised block diagram
Figure 1 is the revised (forth edition) block diagram for our design. Compared to the one in week three, one new block has been added to obtain the correct number of coins in the machine after giving out the change. As for other blocks, they remained the same. 

By this week, we have also finished the code for all imporatant functional blocks (1st edition).
Codes for the 'product_choice' block:
SUBDESIGN product_choice

(
reset,sw[14..0]: INPUT;
product_price_LSB[3..0], product_price_MSB[3..0], sw_error: OUTPUT;
)

BEGIN
IF (reset)THEN
product_price_LSB[]=B"0000" ; product_price_MSB[]=B"0000" ; sw_error=B"0";

ELSIF (sw[]==B"000000000000000")then
sw_error=B"0";

ELSIF (sw[]==B"000000000000001")then
product_price_LSB[]=B"0010" ; product_price_MSB[]=B"0000";

ELSIF (sw[]==B"000000000000010")then
product_price_LSB[]=B"0010" ; product_price_MSB[]=B"0000";

ELSIF (sw[]==B"000000000000100")then
product_price_LSB[]=B"0010" ; product_price_MSB[]=B"0000";

ELSIF (sw[]==B"000000000001000")then
product_price_LSB[]=B"0101" ; product_price_MSB[]=B"0000";

ELSIF (sw[]==B"000000000010000")then
product_price_LSB[]=B"0101" ; product_price_MSB[]=B"0000";

ELSIF (sw[]==B"000000000100000")then
product_price_LSB[]=B"0101" ; product_price_MSB[]=B"0000";

ELSIF (sw[]==B"000000001000000")then
product_price_LSB[]=B"1000" ; product_price_MSB[]=B"0000";

ELSIF (sw[]==B"000000010000000")then
product_price_LSB[]=B"1000" ; product_price_MSB[]=B"0000";
ELSIF (sw[]==B"000000100000000")then
product_price_LSB[]=B"1000" ; product_price_MSB[]=B"0000";

ELSIF (sw[]==B"000001000000000")then
product_price_LSB[]=B"0000" ; product_price_MSB[]=B"0001";

ELSIF (sw[]==B"000010000000000")then
product_price_LSB[]=B"0000" ; product_price_MSB[]=B"0001";

ELSIF (sw[]==B"000100000000000")then
product_price_LSB[]=B"0000" ; product_price_MSB[]=B"0001";

ELSIF (sw[]==B"001000000000000")then
product_price_LSB[]=B"0111" ; product_price_MSB[]=B"0001";

ELSIF (sw[]==B"010000000000000")then
product_price_LSB[]=B"0111" ; product_price_MSB[]=B"0001";

ELSIF (sw[]==B"100000000000000")then
product_price_LSB[]=B"0111" ; product_price_MSB[]=B"0001";

ELSE
sw_error=B"1";
END IF;



END;


Codes for 'coin_input' block:
SUBDESIGN coin_input
(
clk, reset :INPUT ;
coin_input[3..0] :INPUT;
total_money_LSB[3..0], total_money_MSB[3..0] : OUTPUT;
)

VARIABLE
total_money_LSB[3..0], total_money_MSB[3..0] : DFF;

BEGIN
     total_money_LSB[].clk = clk;
            total_money_MSB[].clk = clk;
           
            IF (reset) THEN
            total_money_LSB[].d = 0;
            total_money_MSB[].d = 0;
           
            ELSIF (coin_input[0] == 1) THEN
               IF(total_money_LSB[].q != 9)THEN
                     total_money_LSB[].d = total_money_LSB[].q + 1;
                     total_money_MSB[].d = total_money_MSB[].q + 0;
                    
                     ELSIF(total_money_LSB[].q == 9) THEN
                     total_money_LSB[].d = 0;
                     total_money_MSB[].d = total_money_MSB[].q + 1;
                     END IF;
                    
                     ELSIF (coin_input[1] == 1)THEN
                     IF(total_money_LSB[].q < 8)THEN
                     total_money_LSB[].d = total_money_LSB[].q + 2;
                     total_money_MSB[].d = total_money_MSB[].q + 0;
                    
                     ELSIF(total_money_LSB[].q >= 8) THEN
                     total_money_LSB[].d = total_money_LSB[].q - 8;
                     total_money_MSB[].d = total_money_MSB[].q + 1;
                     END IF;
                    
                     ELSIF (coin_input[2] == 1)THEN
                     IF(total_money_LSB[].q < 5)THEN
                     total_money_LSB[].d = total_money_LSB[].q + 5;
                     total_money_MSB[].d = total_money_MSB[].q + 0;
                    
                     ELSIF(total_money_LSB[].q >= 5 & total_money_LSB[].q <= 9) THEN
                     total_money_LSB[].d = total_money_LSB[].q - 5;
                     total_money_MSB[].d = total_money_MSB[].q + 1;
                     END IF;
                    
                     ELSIF (coin_input[3] == 1)THEN
                     total_money_LSB[].d = total_money_LSB[].q + 0;
                     total_money_MSB[].d = total_money_MSB[].q + 1;
                    
                     ELSIF (coin_input[] == B"0000")THEN
                     total_money_LSB[].d = total_money_LSB[].q + 0;
                     total_money_MSB[].d = total_money_MSB[].q + 0;
                    
                     END IF;
END;


Codes for 'counter' block:
SUBDESIGN counter
(
clk, reset :INPUT ;
coin_input[3..0]      :INPUT;
temp_10p[3..0] , temp_20p[3..0] , temp_50p[3..0] , temp_100p[3..0] : OUTPUT;
)

VARIABLE
count_10p[3..0] , count_20p[3..0] , count_50p[3..0] , count_100p[3..0] : DFF;

BEGIN
           
     count_10p[].clk  = clk;
            count_20p[].clk  = clk;
            count_50p[].clk  = clk;
            count_100p[].clk = clk;
           
temp_10p[] = count_10p[];
temp_20p[] = count_20p[];
temp_50p[] = count_50p[];
temp_100p[] = count_100p[];
           
            IF (reset) THEN
            count_10p[].d  = 0;
            count_20p[].d  = 0;
            count_50p[].d  = 0;
            count_100p[].d = 0;

           
            ELSIF (coin_input[0] == 1) THEN
        count_10p[].d   = count_10p[].q + 1;
                     count_20p[].d   = count_20p[].q  + 0;
                     count_50p[].d   = count_50p[].q  + 0;
                     count_100p[].d  = count_100p[].q + 0;
                    
                     ELSIF (coin_input[1] == 1) THEN
           count_10p[].d   = count_10p[].q  + 0;
                        count_20p[].d   = count_20p[].q  + 1;
                        count_50p[].d   = count_50p[].q  + 0;
                        count_100p[].d  = count_100p[].q + 0;
                    
                        ELSIF (coin_input[2] == 1) THEN
              count_10p[].d   = count_10p[].q  + 0;
                           count_20p[].d   = count_20p[].q  + 0;
                           count_50p[].d   = count_50p[].q  + 1;
                           count_100p[].d  = count_100p[].q + 0;
                    
                     ELSIF (coin_input[3] == 1) THEN
                 count_10p[].d   = count_10p[].q  + 0;
                              count_20p[].d   = count_20p[].q  + 0;
                              count_50p[].d   = count_50p[].q  + 0;
                              count_100p[].d  = count_100p[].q + 1;
                    
                              ELSIF (coin_input[] == B"0000")THEN
                    count_10p[].d   = count_10p[].q  + 0;
                                 count_20p[].d   = count_20p[].q  + 0;
                                 count_50p[].d   = count_50p[].q  + 0;
                                 count_100p[].d  = count_100p[].q + 0;
                                                           
            END IF;        
END;


Codes for 'subs' block:
SUBDESIGN subs
(
sys_reset, change_end  :INPUT ;
coin_change_10p[3..0] , coin_change_20p[3..0] , coin_change_50p[3..0] , coin_change_100p[3..0] : INPUT;
temp_10p[3..0] , temp_20p[3..0] , temp_50p[3..0] , temp_100p[3..0]                             : INPUT;
number_10p[3..0] , number_20p[3..0] , number_50p[3..0] , number_100p[3..0]                     : OUTPUT;
)

VARIABLE
c1 : node;
c2 : node;
c3 : node;
c4 : node;

BEGIN

IF (sys_reset)THEN
Number_10p[] = B"0000";
Number_10p[] = B"0000";
Number_10p[] = B"0000";
Number_10p[] = B"0000";

ELSE

IF(change_end)THEN

(c1,number_10p[])=(gnd,temp_10p[])-(gnd,coin_change_10p[]);

(c1,number_20p[])=(gnd,temp_20p[])-(gnd,coin_change_20p[]);

(c3,number_50p[])=(gnd,temp_50p[])-(gnd,coin_change_50p[]);
                    
(c4,number_100p[])=(gnd,temp_100p[])-(gnd,coin_change_100p[]);

ELSE

number_10p[] = temp_10p[];
number_20p[] = temp_20p[];
number_50p[] = temp_50p[];
number_100p[] = temp_100p[];

END IF;

END IF;
                    
END;


Codes for 'control' block:
SUBDESIGN control
(
clk, reset, cancel                                : INPUT;
product_price_LSB[3..0], product_price_MSB[3..0]  : INPUT;
total_LSB[3..0], total_MSB[3..0]                  : INPUT;
product_out, change_total[3..0]                   : OUTPUT;
cancel_change_LSB[3..0], cancel_change_MSB[3..0]  : OUTPUT;
)

variable
c_LSB, s_LSB[3..0] : NODE;

BEGIN

(c_LSB,s_LSB[])=(gnd,total_LSB[])-(gnd,product_price_LSB[]);

IF (cancel)THEN
cancel_change_LSB[] = total_LSB[];
cancel_change_MSB[] = total_MSB[];
product_out=B"0" ;
ELSE
cancel_change_LSB[] = B"0000";
cancel_change_MSB[] = B"0000";
END IF;

IF (reset)THEN
change_total[] = B"0000";
product_out=B"0";

ELSIF (product_price_MSB[1] == 1  & total_MSB[1] == 0 )THEN
product_out=B"0" ;
change_total[] = B"0000";

ELSIF (product_price_MSB[1] == total_MSB[1])THEN
   
                 IF (product_price_MSB[0] == 1 & total_MSB[0] == 0 )THEN
                 product_out=B"0" ;
                 change_total[] = B"0000";
                 ELSIF (product_price_MSB[0] == total_MSB[0])THEN
                    
                                  IF (product_price_LSB[3] == 1 & total_LSB[3] == 0 )THEN
                                  product_out=B"0" ;
                                  change_total[] = B"0000";
                                  ELSIF (product_price_LSB[3] == total_LSB[3])THEN
                                     
                                                                IF (product_price_LSB[2] == 1 & total_LSB[2] == 0)THEN
                                      product_out=B"0" ;
                                                                change_total[] = B"0000";
                                                                ELSIF (product_price_LSB[2] == total_LSB[2])THEN
                                                                   
                                                                                 IF (product_price_LSB[1] == 1 & total_LSB[1] == 0)THEN
                                                                                 product_out=B"0" ;
                                                                                 change_total[] = B"0000";
                                                                                 ELSIF (product_price_LSB[1] == total_LSB[1])THEN
                                                                                     
                                                                                                  IF (product_price_LSB[0] == 1 & total_LSB[0] == 0)THEN
                                                                                                  product_out=B"0" ;
                                                                                                  change_total[] = B"0000";
                                                                                                  ELSIF (product_price_LSB[0] == total_LSB[0])THEN
                                                                                                  product_out=B"1" ;
                                                                                                  change_total[] = B"0000";
                                                                                                  ELSIF  (product_price_LSB[0] == 0 & total_LSB[0] == 1)THEN
                                                                                                  product_out=B"1" ;
                                                                                                  change_total[] = B"0001";
                                                                                                  END IF;
                                                                                                 
                                                                                 ELSIF (product_price_LSB[1] == 0 & total_LSB[1] == 1)THEN
                                                                                 product_out=B"1" ;
                                                                                 change_total[] = s_LSB[];
                                                                                 END IF;
                                                                                 
                                                                ELSIF (product_price_LSB[2] == 0 & total_LSB[2] == 1)THEN
                                                                product_out=B"1" ;
                                                                change_total[] = s_LSB[];
                                      END IF;                          
                                 
                                  ELSIF (product_price_LSB[3] == 0 & total_LSB[3] == 1)THEN
                                  product_out=B"1" ;
                                  change_total[] = s_LSB[];
                                  END IF;
                                 
    ELSIF (product_price_MSB[0] == 0 & total_MSB[0] == 1)THEN
                 product_out=B"1" ;
                 change_total[] = s_LSB[] + B"1010" ;
                 END IF;
                                 
ELSIF (product_price_MSB[1] == 0 & total_MSB[1] == 1)THEN
product_out=B"1" ;
change_total[] = s_LSB[] + B"1010" ;
END IF;


END;

Codes for 'change' block:
SUBDESIGN change
(
reset, ent, clk, cancel                                                                        : INPUT;
change_LSB[3..0] , change_MSB[3..0]                                                            : INPUT;
number_10p[3..0] , number_20p[3..0] , number_50p[3..0] , number_100p[3..0]                     : INPUT;
change_error, change_end                                                                          : OUTPUT;
coin_change_10p[3..0] , coin_change_20p[3..0] , coin_change_50p[3..0] , coin_change_100p[3..0] : OUTPUT;
)

variable
t1, s1[3..0] : DFF;
t2, s2[3..0] : DFF;
t3, s3[3..0] : DFF;
t4, s4[3..0] : DFF;
value[3..0]  : DFF;
MSB[3..0]    : DFF;
a[3..0], b[3..0], c[3..0], d[3..0] : DFF;
change_10p[3..0] , change_20p[3..0] , change_50p[3..0], change_100p[3..0] :DFF;

BEGIN
a[] = number_10p[];
b[] = number_20p[];
c[] = number_50p[];
d[] = number_100p[];

coin_change_10p[] = change_10p[];
coin_change_20p[] = change_20p[];
coin_change_50p[] = change_50p[];
coin_change_100p[] = change_100p[];

a[].clk = clk;
b[].clk = clk;
c[].clk = clk;
d[].clk = clk;

value[].clk = clk;
MSB[].clk   = clk;
change_10p[].clk = clk;
change_20p[].clk = clk;
change_50p[].clk = clk;
change_100p[].clk = clk;

(t1,s1[])=(gnd,number_10p[])-(gnd,change_10p[]);
(t2,s2[])=(gnd,number_20p[])-(gnd,change_20p[]);
(t3,s3[])=(gnd,number_50p[])-(gnd,change_50p[]);
(t4,s4[])=(gnd,number_100p[])-(gnd,change_100p[]);
a[] = s1[];
b[] = s2[];
c[] = s3[];
d[] = s4[];

IF (cancel # ent)THEN
value[] = change_LSB[];
MSB[] = change_MSB[];
END IF;

IF (!reset)Then
    IF (MSB[].q == 1)THEN
MSB[].d = MSB[].q - 1;
change_100p[].d = change_100p[].q + 1;
    IF (value[].q == 0)THEN
 change_end = B"1";
 END IF;
ELSE
MSB[].d = MSB[].q + 0;
change_100p[].d = change_100p[].q + 0;
END IF;
IF (value[].q > 5)THEN
    IF (c[].q > 0)THEN
 value[].d = value[].q - 5;
 change_50p[].d = change_50p[].q + 1;
 change_20p[].d = change_20p[].q + 0;
 change_10p[].d = change_10p[].q + 0;
 ELSIF (b[].q > 0)THEN
 value[].d = value[].q - 2;
 change_50p[].d = change_50p[].q + 0;
 change_20p[].d = change_20p[].q + 1;
 change_10p[].d = change_10p[].q + 0;
 ELSIF (a[].q > 0)THEN
 value[].d = value[].q - 1;
 change_50p[].d = change_50p[].q + 0;
 change_20p[].d = change_20p[].q + 0;
 change_10p[].d = change_10p[].q + 1;
 ELSE
 value[].d = value[].q + 0;
 change_50p[].d = change_50p[].q + 0;
 change_20p[].d = change_20p[].q + 0;
 change_10p[].d = change_10p[].q + 0;
 change_error = B"1";
 END IF;
ELSIF (value[].q == 5)THEN
    IF (c[].q > 0)THEN
 value[].d = value[].q - 5;
 change_50p[].d = change_50p[].q + 1;
 change_20p[].d = change_20p[].q + 0;
 change_10p[].d = change_10p[].q + 0;
 change_end = B"1";
 ELSIF (b[].q > 0)THEN
 value[].d = value[].q - 2;
 change_50p[].d = change_50p[].q + 0;
 change_20p[].d = change_20p[].q + 1;
 change_10p[].d = change_10p[].q + 0;
 ELSIF (a[].q > 0)THEN
 value[].d = value[].q - 1;
 change_50p[].d = change_50p[].q + 0;
 change_20p[].d = change_20p[].q + 0;
 change_10p[].d = change_10p[].q + 1;
 ELSE
 value[].d = value[].q + 0;
 change_50p[].d = change_50p[].q + 0;
 change_20p[].d = change_20p[].q + 0;
 change_10p[].d = change_10p[].q + 0;
 change_error = B"1";
 END IF;
    ELSIF (value[].q > 2 & value[].q < 5)THEN
    IF (b[].q > 0)THEN
 value[].d = value[].q - 2;
 change_50p[].d = change_50p[].q + 0;
 change_20p[].d = change_20p[].q + 1;
 change_10p[].d = change_10p[].q + 0;
 ELSIF (a[].q > 0)THEN
 value[].d = value[].q - 1;
 change_50p[].d = change_50p[].q + 0;
 change_20p[].d = change_20p[].q + 0;
 change_10p[].d = change_10p[].q + 1;
 ELSE
 value[].d = value[].q + 0;
 change_50p[].d = change_50p[].q + 0;
 change_20p[].d = change_20p[].q + 0;
 change_10p[].d = change_10p[].q + 0;
 change_error = B"1";
 END IF;
ELSIF (value[].q == 2)THEN
    IF (b[].q > 0)THEN
 value[].d = value[].q - 2;
 change_50p[].d = change_50p[].q + 0;
 change_20p[].d = change_20p[].q + 1;
 change_10p[].d = change_10p[].q + 0;
 change_end = B"1";
 ELSIF (a[].q > 0)THEN
 value[].d = value[].q - 1;
 change_50p[].d = change_50p[].q + 0;
 change_20p[].d = change_20p[].q + 0;
 change_10p[].d = change_10p[].q + 1;
 ELSE
 value[].d = value[].q + 0;
 change_50p[].d = change_50p[].q + 0;
 change_20p[].d = change_20p[].q + 0;
 change_10p[].d = change_10p[].q + 0;
 change_error = B"1";
 END IF;
    ELSIF (value[].q == 1)THEN
    IF (a[].q > 0)THEN
 value[].d = value[].q - 1;
 change_50p[].d = change_50p[].q + 0;
 change_20p[].d = change_20p[].q + 0;
 change_10p[].d = change_10p[].q + 1;
 change_end = B"1";
 ELSE
 value[].d = value[].q + 0;
 change_50p[].d = change_50p[].q + 0;
 change_20p[].d = change_20p[].q + 0;
 change_10p[].d = change_10p[].q + 0;
 change_error = B"1";
 END IF;
ELSIF (value[].q == 0)THEN
value[].d = value[].q + 0;
change_50p[].d = change_50p[].q + 0;
change_20p[].d = change_20p[].q + 0;
change_10p[].d = change_10p[].q + 0;
END IF;
ELSE
coin_change_10p[] = B"0000";
         coin_change_20p[] = B"0000";
         coin_change_50p[] = B"0000";
coin_change_100p[] = B"0000";
change_error = B"0";
change_end = B"0";
END IF;


END;