train ticket machine help needed!

Discussion in 'VHDL' started by sicazoR, May 27, 2013.

  1. sicazoR

    sicazoR

    Joined:
    May 27, 2013
    Messages:
    1
    HI there,

    I'm designing a ticketing machine. The distance and the money are introduce by the user on a FPGA board. I have 4 states, s0 when I initialize the data, s1 when i read the distance and calculate the price for the ticket, s2 when i read the money user introduce and s3 when i compare the price with the money user introduced and give the ticket, the rest etc.

    I have a problem in the state 2 of the machine. User introduces the money (1 euro = "01", 5 euro = "10" and 10 euro = "11") and when he push the clock button the signal SUM_INTRODUCED and TOTAL_SUM increases with that value as long as another input signal BTN1 is '0'. The problem is that after introducing 1 euro, if you introduce 1 euro again my signals don't change there values. But if you introduce 10 euro it change and work. Any help?

    The code looks like this:

    Code:
    signal INTRODUCED_SUM			: unsigned (5 downto 0):="000000";
    signal TOTAL_SUM				: unsigned (5 downto 0):="000000";
    ....
    type state_type is (s0,s1,s2,s3);  --type of state machine.
    signal current_s,next_s: state_type;
    
    begin
    	process (CLK,RESET)
    	begin
    		if (RESET = '1') then
    			current_s <= s0;  
    		elsif (RISING_EDGE(CLK)) then
    			current_s <= next_s;   
    		end if;
    	end process;
    
    prelucrare: process(current_s,BTN1)
    begin
    case current_s is ...
    			when s2 =>
    						if (BTN1 = '1') then
    							next_s <= s3;
    						elsif (BTN1 = '0') then
    							if (SEL = "01") then
    								INTRODUCED_SUM 	<= INTRODUCED_SUM + 1;
    								1euro_COIN 		<= 1euro_COIN + 1;
    								TOTAL_SUM 	<= 	TOTAL_SUM +1;
    								
    								elsif (SEL = "10") then
    								INTRODUCED_SUM 	<= INTRODUCED_SUM + 5;
    								5euro_COIN 		<= 5euro_COIN + 1;
    								TOTAL_SUM 	<= 	TOTAL_SUM +5;
    									
    									elsif (SEL = "11") then
    								INTRODUCED_SUM 	<= INTRODUCED_SUM + 10;
    								10euro_COIN 		<= 10euro_COIN + 1;
    								TOTAL_SUM 	<= 	TOTAL_SUM +10;
    							end if;
    							next_s <= s2;
    						end if;
    sicazoR, May 27, 2013
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Diez B. Roggisch

    Python train spotting doodle

    Diez B. Roggisch, Mar 17, 2006, in forum: Python
    Replies:
    2
    Views:
    316
    Diez B. Roggisch
    Mar 17, 2006
  2. omara007
    Replies:
    0
    Views:
    467
    omara007
    Aug 17, 2008
  3. abhi
    Replies:
    0
    Views:
    255
  4. kizk
    Replies:
    0
    Views:
    562
  5. zoat
    Replies:
    2
    Views:
    106
    Guido Sohne
    Sep 15, 2006
Loading...

Share This Page