Train Ticket Machine using VHDL

OP #3407505
Rate this post
• ▲ useful
▼ not useful
Hello. I am new in VHDL. I try to create train ticket machine using 
vhdl. It have 3 destination and all destination have fee. When user 
insert money with same of fee, ticket will out and no change but if user 
enter extra money than fee, ticket will out also with change.When i run 
the simulation all output does not appear but it appear UUU. Anybody can 
help me with my code,please. Thanks. God bless you.
Attached files:
Moderator (Company: Titel) #3407860
Rate this post
• ▲ useful
▼ not useful
Schmidt n. wrote:
> Anybody can help me with my code,please.
Your code is doing exactly what you described...
You can have a closer look to the signals inside the entity 
trainticket_machine. Just dig around a littlte bit in the simulators 
projekt structure (the projekt window is on the left halnd side to your 
screenshot)...


Money_sum is missing in this sensitivity list, so the simulation is 
wrong:
1
PROCESS (p_state,Cancel,RM1,RM2,RM5,KL_station,Mid_station,Klang_station)
But after adding it you will find an issue with a combinational loop 
with all those statements:
1
    Money_sum <= Money_sum + 1; -- also +2 and +5...


BTW:
Never ever use all of the arithmetic libs:
1
use ieee.numeric_std.all;  
2
use ieee.std_logic_unsigned.all;
3
use ieee.std_logic_arith.all;
You will have some definitions doubled and you will encounter courious 
problems with that...

Schmidt n. wrote:
> Assume that I am zero in vhdl.
So, why not starting with a much simpler project like an counter or 
something else?
Moderator (Company: Titel) #3409078
Rate this post
• ▲ useful
▼ not useful
Schmidt n. wrote:
> BTW if i never use those library what should I used because when I
> enable it my code have many errors.
Start thinking, not copying.

The numeric_std has all to handle conversions from vector types to 
integer and to deal with vectorized calculations. You just cannot add 
two std_logic_vector directly, but instead you must use the signed 
or unsigned vectors.
All in all its absolutely no rocket science and its done by millions of 
students before. Think about it...

One thing more:
>     Money_sum  :  INOUT STD_LOGIC_VECTOR (3 DOWNTO 0)
Using INOUT just for laziness or for some kind of "short and compact 
code"?
In which book did you find this? Throw it away!
Never ever try to "simplify" your beginners code with such dirty tricks. 
Instead have a look inside books of Peter Ashenden, he is very close to 
the VHDL standards because he works in the VHDL standardization panel.

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.