Verilog Code For Car Parking System - FPGA4student
Verilog Code For Car Parking System - FPGA4student
com
Home FPGA Projects Verilog Projects VHDL Projects FPGA Tutorial Verilog vs VHDL About
Join 12,800 Fo
Verilog code for Car Parking System
This simple project is to implement a car parking system in Verilog. The Verilog code for the car
parking system is fully presented.
In the entrance of the parking system, there is a sensor which is activated to detect a vehicle
coming. Once the sensor is triggered, a password is requested to open the gate. If the entered Subscribe to get
password is correct, the gate would open to let the vehicle get in. Otherwise, the gate is still FPGA projects
locked. If the current car is getting in the car park being detected by the exit sensor and another
Enter your email address...
the car comes, the door will be locked and requires the coming car to enter passwords.
Popular FPGA pro
Image pro
FPGA usi
This proje
show deta
process a
FPGA using Verilog fro
bitmap image (.bmp), p
w...
Verilog co
single cyc
processor
In this pro
single-cyc
processor is implement
HDL. MIPS is an RISC
which is widely used by
Verilog Co
RISC Proc
In this V e
Verilog co
RISC proc
presented. The RISC p
Verilog code for the car parking system: designed based on its i
http://www.fpga4student.com/2016/11/verilog-code-for-parking-system-using.html 1/6
3/25/2018 Verilog code for Car Parking System - FPGA4student.com
WAIT_PASSWORD: begin
if(counter_wait <= 3)
next_state = WAIT_PASSWORD;
else
begin
if((password_1==2'b01)&&(password_2==2'b10))
next_state = RIGHT_PASS;
else
next_state = WRONG_PASS;
end
end
WRONG_PASS: begin
if((password_1==2'b01)&&(password_2==2'b10))
next_state = RIGHT_PASS;
else
next_state = WRONG_PASS;
end
RIGHT_PASS: begin
if(sensor_entrance==1 && sensor_exit == 1)
next_state = STOP;
else if(sensor_exit == 1)
next_state = IDLE;
else
next_state = RIGHT_PASS;
end
STOP: begin
if((password_1==2'b01)&&(password_2==2'b10))
next_state = RIGHT_PASS;
else
next_state = STOP;
end
default: next_state = IDLE;
endcase
end
// LEDs and output, change the period of blinking LEDs here
always @(posedge clk) begin
case(current_state)
IDLE: begin
green_tmp = 1'b0;
red_tmp = 1'b0;
HEX_1 = 7'b1111111; // off
HEX_2 = 7'b1111111; // off
end
WAIT_PASSWORD: begin
green_tmp = 1'b0;
red_tmp = 1'b1;
HEX_1 = 7'b000_0110; // E
HEX_2 = 7'b010_1011; // n
end
WRONG_PASS: begin
green_tmp = 1'b0;
red_tmp = ~red_tmp;
HEX_1 = 7'b000_0110; // E
HEX_2 = 7'b000_0110; // E
end
RIGHT_PASS: begin
green_tmp = ~green_tmp;
red_tmp = 1'b0;
HEX_1 = 7'b000_0010; // 6
HEX_2 = 7'b100_0000; // 0
end
STOP: begin
green_tmp = 1'b0;
red_tmp = ~red_tmp;
HEX_1 = 7'b001_0010; // 5
HEX_2 = 7'b000_1100; // P
end
endcase
end
assign RED_LED = red_tmp ;
assign GREEN_LED = green_tmp;
endmodule
// Inputs
http://www.fpga4student.com/2016/11/verilog-code-for-parking-system-using.html 2/6
3/25/2018 Verilog code for Car Parking System - FPGA4student.com
reg clk;
reg reset_n;
reg sensor_entrance;
reg sensor_exit;
reg [1:0] password_1;
reg [1:0] password_2;
// Outputs
wire GREEN_LED;
wire RED_LED;
wire [6:0] HEX_1;
wire [6:0] HEX_2;
// fpga4student.com FPGA projects, Verilog projects, VHDL projects
// Instantiate the Unit Under Test (UUT)
parking_system uut (
.clk(clk),
.reset_n(reset_n),
.sensor_entrance(sensor_entrance),
.sensor_exit(sensor_exit),
.password_1(password_1),
.password_2(password_2),
.GREEN_LED(GREEN_LED),
.RED_LED(RED_LED),
.HEX_1(HEX_1),
.HEX_2(HEX_2)
);
initial begin
clk = 0;
forever #10 clk = ~clk;
end
initial begin
// Initialize Inputs
reset_n = 0;
sensor_entrance = 0;
sensor_exit = 0;
password_1 = 0;
password_2 = 0;
// Wait 100 ns for global reset to finish
#100;
reset_n = 1;
#20;
sensor_entrance = 1;
#1000;
sensor_entrance = 0;
password_1 = 1;
password_2 = 2;
#2000;
sensor_exit =1;
endmodule
Simulation waveform for the car parking system in Verilog:
http://www.fpga4student.com/2016/11/verilog-code-for-parking-system-using.html 3/6
3/25/2018 Verilog code for Car Parking System - FPGA4student.com
61
SHARES
Facebook Twitter Google+ Pinterest
10 comments:
Replies
Reply
Replies
Reply
http://www.fpga4student.com/2016/11/verilog-code-for-parking-system-using.html 4/6
3/25/2018 Verilog code for Car Parking System - FPGA4student.com
Reply
Replies
Reply
Publish Preview
http://www.fpga4student.com/2016/11/verilog-code-for-parking-system-using.html 5/6
3/25/2018 Verilog code for Car Parking System - FPGA4student.com
Copyright © 2016-2017 FPGA4student.com All Rights Reserved.
http://www.fpga4student.com/2016/11/verilog-code-for-parking-system-using.html 6/6