Forum Discussion
[HELP ] VHDL Parking Lot
Hello guys, i'm not idea how resolve this problem, please help me
parking lot, shown in the Fig. 2, has space for 10 cars. There is only one entrance to the parking lot, consequently one car at a time can enter or exit the parking. There are two light sensors, separated by one meter in order to detect if the car is entering or leaving the lot. There is a semaphore with signs saying FREE and FULL. Create, simulate and sinthesize a VHDL description to correctly command the lights according to the occupancy of the parking lot. http://www.alteraforum.com/forum/attachment.php?attachmentid=11198&stc=111 Replies
- Altera_Forum
Honored Contributor
What have you done so far? What are you thoughts about how to solve the problem? You won't get a finished free solution here.
- Altera_Forum
Honored Contributor
You might want to start by creating some flow chart for your code.
- Altera_Forum
Honored Contributor
Hello guys I have an advance for parking lot, only need the testbench code. If the VHDL code is wrong in some parts, please help me.
Sorry for my english :D - Altera_Forum
Honored Contributor
You haven't asked a question for us to answer
- Altera_Forum
Honored Contributor
What is the error you observe? Error during Modelsim compilation?
- Altera_Forum
Honored Contributor
My crystal ball says you have a problem on line 42.
You're welcome. - Altera_Forum
Honored Contributor
Here my vhdl code, is something wrong about the design, tell me. So the question is if my vhdl code is good abut the statement of the problem, if I'm missing something, if I'm missing signals
i'm trying to design a test benchlibrary ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; entity parking_lot is port (detector_1 : in std_logic; -- entrando carro detector_2 : in std_logic; -- saliendo carro libre : out std_logic; lleno : out std_logic ); end parking_lot; architecture behavioral of parking_lot is begin process (detector_1,detector_2) begin if (detector_1 = '0') then libre <= '1'; elsif (detector_1 ='1') then libre <= '0'; elsif (detector_2 = '0') then lleno <= '0'; elsif (detector_2 ='1') then lleno <= '1'; end if; end process; end behavioral; - Altera_Forum
Honored Contributor
Here, lleno will never be set to anything because detector_1 is always '0' or '1' in a real circuit. What exactly is the problem?
- Altera_Forum
Honored Contributor
Besides once 10 cars have filled the parking lot, it will still report it "free".
It's better to actually write the test bench first, and then see how your code behaves. - Altera_Forum
Honored Contributor
I can try being a bit more constructive....
The reason why I say you should begin with the testbench is that it makes you think about what kind of inputs your system will have and how it should react. Start with something basic. Draw a timing diagram of the signals from the two sensors when a car enters the parking lot. You need to have the whole event, from when the car is completely outside the parking until when it is fully inside. Similarly draw the diagram for when a car exits the parking lot. Then write two VHDL procedures that generate the sensor signals for both events. Then you can write your testbench. The parking starts empty, and for example call 9 times the procedure that simulates a car entering the parking lot. During all that time the testbench will also check that the "free" light is always on and will generate an error if it doesn't. Then call a 10th time the car enter simulating procedure, and check that the "free" light turns off, and the "full" light turns on (allowing a small delay before checking). Then simulate a car going outside of the parking, and check that the "full" light turns off and the "free" light turns on. This can be your first test bench to check your code. Ideally you will want to simulate other cases, with several cars going out and in again, just to check that your code behaves correctly in different situations. Once you have that, and you have a good idea on how the sensors work, you can begin designing your main VHDL code. Note that if you want something that synthesizes, you will probably need a clock, generated in the test bench.