Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
verilog code for elevator controller free download
#1

verilog code for elevator controller free download

/* program for the emulator device that connect the controller to the units */
module emulator(clk,floor,reset,motor,dir,ledup,leddn,dropen,drclose,doorstate, clk4,motion);
input clk;
input reset;
input motor;
input dir;
input [2:0] floor; /* input from the units/level sensor that shows where the elev is*/
input [2:0] doorstate; /* input from the units showing the door status. 1 = open & 0 = closed */
output ledup;
output leddn;
output dropen;
output drclose;
output [1:0] clk4; /*clock timer for the units 4Hz */
output motion;

reg ledup;
reg leddn;
reg drclose;
reg dropen;
reg [1:0] clk4;
reg motion;

/* function 'isclosed' checks to see if the doors are fully closed*/
function isclosed;
input [2:0] d;
isclosed = ( d == 0);
endfunction

always @(posedge clk)
begin
/* reset turns everything off but leaves the doors closed */
if (reset) begin
ledup <= 0;
leddn <= 0;
drclose <= 1;
dropen <= 0;
end

if (motor == 1 && dir == 1) begin ledup <= 1; motion <= 1; end

if (motor ==1 && dir == 0) begin leddn <= 1; motion <= 1; end

if (motor == 0)
begin
ledup <= 0;
leddn <=0;
end

/* The following section check whether the elevator has reached the
desired floor, with the doors closed and has turned of the motor
before opening the doors. */
begin
if (floor[0] == 0 floor[1] == 0 floor[2] == 0)
/* if the door is closed and the motor is off then open the door */
if (isclosed(doorstate) && motor == 0 && motion)
begin dropen <= 1; motion <= 0; end
end
/* once the doors are open stop opening i.e dropen =0 and then close them */
if(dropen && !isclosed(doorstate)) begin dropen <= 0; drclose <= 1; end

/* doors are closed stop closing i.e drclose =0 */
if(drclose && isclosed(doorstate)) drclose <= 0;

clk4 <= clk4 + 1;

end
endmodule

// Verilog program for the unit device
module unit(gndfloor,clk,reset,ledup,leddn,dropen,drclose,TC,bottom,top,position,door,doorstate);
input gndfloor;
input clk;
input reset;
input ledup;
input leddn;
input dropen,drclose;
input TC;
input bottom;
input top;

output doorstate;
output [4:0] position;
output [0:2] door;
reg doorstate;
reg [4:0] position;
reg [0:2] door;

always@(posedge clk)
begin
if (reset) begin
position[0] <= gndfloor;
position[1] <= 1;
position[2] <= 1;
position[3] <= 1;
position[4] <= 1;
door[0] <= 1;
door[1] <= 1;
door[2] <= 1;
end

if (ledup == 1) begin
//position <= ((position * 2) + bottom);
//position <= ({position, bottom})*2;
position[4:1] <= position[3:0];
position[0] <= bottom;
end

if (leddn ==1)
//position <= 'b11111; //{position, top} << 1;
//position <= ((position/2) + top ? 'b10000: 0);
position <= ({top,position})/2;


if (position[0]==0 && dropen) begin door[0]<=0; door[1:2]<=door[0:1]; end

if (drclose) begin door[0:1] <= door[1:2]; door[2] <= 1; end

if (door[0] == 0 && door[1] ==0 && door[2] ==0)
doorstate <= 1; /* if the door leds are lit then the door isn't closed (open)*/

if (door[0] == 1 && door[1] == 1 && door[2] ==1)
doorstate <= 0; /* if the door leds are not lit then door is closed */

end
endmodule


// Verilog program for a three-level elevator controller
module lift3(floor,clk,reset,Ecall,motor,dir,Target,presentfloor);

input [2:0] floor;
input clk;
input reset;
input [2:0] Ecall;

output motor;
output dir;
output Target;
output presentfloor;

reg motor;
reg dir;
reg [3:1] Target;
reg [3:1] presentfloor;

always @(posedge clk)
begin

if (reset) begin
motor <= 0;
presentfloor <= 1;
Target <= 0;
end

if (Target==0)
begin
if (Ecall[0]==1) Target <= 'b001;
if (Ecall[1]==1) Target <= 'b010;
if (Ecall[2]==1) Target <= 'b100;
end



begin
if (floor[0]==0) presentfloor <='b001;
if (floor[1]==0) presentfloor <='b010;
if (floor[2]==0) presentfloor <='b100;
end

if (motor==1 && presentfloor==Target) begin
motor <= 0;
Target <= 0;
end

if (motor==0 && Target !=0)
begin
if (presentfloor < Target) begin
//dir up
motor <= 1;
dir <= 1;
end

if (presentfloor > Target) begin
//dir down
motor <= 1;
dir <= 0;
end
end

end

endmodule
Reply

#2

I need document of dual elevator controller using verilog
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

Powered By MyBB, © 2002-2024 iAndrew & Melroy van den Berg.