Freddy_
Newbie
Hello everyone. I am trying to design a parking lot system with Verilog. I have been successful in synthesizing the code. However, I am facing the multiple drive net error, when I try to implement it. I have been trying to figure out how to solve it for eight hours now. It seem I am driving a particular variable(register) in two different always block statements. And I suppose I will be able to fix it by modifying that portion. Or maybe it could be another issue.
I have, attached the code , and the errors I am getting in the implementation phase for your guys to help me out. Thank you.
This is the nature of the error I am facing.
I have, attached the code , and the errors I am getting in the implementation phase for your guys to help me out. Thank you.
Code:
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date:
// Design Name: Parking Lot System Design
// Module Name:
// Project Name: Parking System
// Target Devices: Nexys Atix 7 FPGA Board
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
//////// The code for the parking lot goes here ///////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
//Behavioural Description
//Module Instantiation
module Park_FSM(clk,
reset,
Ent_Sens,
Exit_Sens,
Tick_1,
Green_State,
Red_State,
//Car_Count,
Sev_indicator,
paid_stat
);
// Input to the system
input clk;
input reset;
input Ent_Sens;
input Exit_Sens;
input Tick_1;
input paid_stat;
// Output of the system
output Red_State;
output Green_State;
//output Car_Count;
output Sev_indicator;
// Data type declarations
wire clk;
wire reset;
wire Ent_Sens;
wire Exit_Sens;
wire Tick_1;
wire paid_stat;
wire Red_State, Green_State;
//reg [3:0] Car_Count;
reg [6:0] Sev_indicator;
reg [3:0] available_spots;
reg [3:0] Cars_in = 5'd10;
// register variable to hold current number of cars in parking lot
// reg [3:0] num_cars = Cars_in;
// State Logics
reg [3:0] current_state;
reg [3:0] next_state;
reg red_tempo, green_tempo;
// Parameters for States
parameter IDLE_STATE = 4'b0000,
AVAIL_STATE = 4'b0001,
WAIT_STATE = 4'b0010,
OCCUPIED_STATE = 4'b0011,
TICK_TAKE = 4'b0100,
PARK_STATE = 4'b0101,
PAY_STATE = 4'b0110,
EXIT_STATE = 4'b0111,
// SYSTEM_STATUS = 4'b1000;
// Parameter for initial number of cars in parking lot
//parameter Cars_in = 5'd10;
parameter number_of_spots = 5'd20;
// State memory must reset upon the reset assertion
// Asyncronous reset
always@(posedge(clk) or posedge(reset))
begin
if(reset)begin
105 current_state = IDLE_STATE;
end
else
current_state = next_state;
end
// System control logic
always@(*)
begin
//Red_State = 1'b0;
//Green_State = 1'b0;
available_spots = number_of_spots - Cars_in;
118 case(current_state)
IDLE_STATE : begin
if(Ent_Sens == 1'b1)
next_state = AVAIL_STATE;
else
next_state = IDLE_STATE;
end
AVAIL_STATE : begin
if(available_spots > 5'd0 && available_spots <= 5'd10)
next_state = WAIT_STATE; // Wait to take ticket
else
next_state = OCCUPIED_STATE; // Else go into the occupied state
end
OCCUPIED_STATE : begin
if(available_spots == 5'd0)
current_state = OCCUPIED_STATE;
else
next_state = IDLE_STATE;
end
WAIT_STATE : begin // wait and take ticket
if(Tick_1 == 1'b0)
current_state = WAIT_STATE;
else
next_state = TICK_TAKE;
end
TICK_TAKE : begin
next_state = PARK_STATE; //proceed to the park state
end
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////// PARK_STATE = FINALLY UPDATE YOUR SYSTEM THAT SOMEONE HAS PARKED//////
////////////////////////////////////////////////////////////////////////////////////////
PARK_STATE : begin
if(Exit_Sens == 1'b0)
current_state = PARK_STATE;
//Cars_in = Cars_in + 1;
else begin
next_state = PAY_STATE;
end
if (current_state == PARK_STATE && Exit_Sens == 1'b1) begin //Update the system if anyone has parked to stay in the parking lot
Cars_in <= Cars_in + 1;
end
end
PAY_STATE : begin
if(!paid_stat)
current_state = PAY_STATE;
else begin
next_state = EXIT_STATE;
// Cars_in = Cars_in - 1;
end
if (current_state == EXIT_STATE && Exit_Sens == 1'b1) begin // Update the system if anyone has paid to exit the parking lot
Cars_in <= Cars_in + 1;
end
end
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////// EXIT_STATE = FINALLY UPDATE YOUR SYSTEM THAT SOMEONE LEFT////////////
////////////////////////////////////////////////////////////////////////////////////////
EXIT_STATE : begin
next_state = IDLE_STATE;
end
default: next_state = IDLE_STATE;
endcase
end
//Output
//LEDs and output, here we change the period of blinking LEDs
always@(posedge(clk))
begin
case(current_state)
IDLE_STATE : begin
green_tempo = 1'b0; // no lights on
red_tempo = 1'b0;
Sev_indicator <= available_spots; // on the seven segment display the number of cars
end
AVAIL_STATE : begin
green_tempo = 1'b0;
red_tempo = 1'b1;
Sev_indicator <= available_spots; // on the seven segment display the number of cars
end
WAIT_STATE : begin
green_tempo = 1'b0;
red_tempo = 1'b1;
//Sev_indicator <= WT; // on the seven segment display the number of cars
end
OCCUPIED_STATE : begin
red_tempo = 1'b1;
Sev_indicator <= 7'b1000000;
end
TICK_TAKE : begin
Sev_indicator <= 7'b1111001;
end
PARK_STATE : begin
Sev_indicator <= available_spots;
end
PAY_STATE : begin
green_tempo = 1'b1;
red_tempo = 1'b0;
Sev_indicator <= available_spots; // on the seven segment display the available slots
end
EXIT_STATE : begin
green_tempo = 1'b1;
red_tempo = 1'b0;
Sev_indicator <= 7'b1011110; // on the seven segment display the number of cars
end
endcase
end
assign Red_State = red_tempo;
assign Green_State = green_tempo;
endmodule
This is the nature of the error I am facing.
Last edited by a moderator: