• PUDN用户
    了解作者
  • VHDL
    开发工具
  • 4KB
    文件大小
  • rar
    文件格式
  • 1
    收藏次数
  • 1 积分
    下载积分
  • 33
    下载次数
  • 2009-11-24 18:14
    上传日期
Verilog code for dual elevator controller. contains code for the controller of dual elevator for a building with 4 floors. the test bench is also present
dualelevatorcontroller.rar
  • murthy_test.v
    1.2KB
  • elevator_murthy.v.txt
    29.9KB
  • murthy_test.v.bak
    1.2KB
  • elevator_murthy.v
    28.5KB
内容介绍
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 22:19:19 10/24/2007 // Design Name: // Module Name: de // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // // Revision: // Revision 0.01 - File Created // Additional Comments: // ////////////////////////////////////////////////////////////////////////////////// module FullElevatorController1( //INPUTS Clock, Reset, //GLOBAL SIGNALS Elev1Obstructed,Elev2Obstructed, //ELEVATOR OBSTRUCTED SIGNALS Floor1UpButton, Floor2DownButton, //FLOOR SIGNALS Elev1UpButton,Elev1DownButton, //ELEVATOR-1 SIGNALS Elev2UpButton, Elev2DownButton, //ELEVATOR-2 SIGNALS //OUTPUTS Elev1CurrentStateOutput,Elev2CurrentStateOutput, ClearDownButton, ClearUpButton); //CLEAR OUTPUT SIGNALS input Clock, Reset; input Elev1Obstructed,Elev2Obstructed; input Floor1UpButton, Floor2DownButton; input Elev1UpButton, Elev1DownButton; input Elev2UpButton, Elev2DownButton; output ClearDownButton, ClearUpButton; output [2:0]Elev1CurrentStateOutput,Elev2CurrentStateOutput; reg ClearDownButton, ClearUpButton; //INTERMEDIATE REGISTERS reg Reset_counter1, Reset_counter2; //RESET SIGNALS FOR COUNTERS reg start_counter1, start_counter2; //START SIGNALS FOR COUNTERS //CURRENT STATE AND NEXT STATE REGISTERS OF ELEVATOR-1 AND ELEVATOR-2 reg [2:0]Elev1CurrentState,Elev1NextState; reg [2:0]Elev2CurrentState,Elev2NextState; //ELEVATORS MOVEMENT DIRECTION INDICATION SIGNALS reg Elev1MoveTo1, Elev1MoveTo2, Elev2MoveTo1, Elev2MoveTo2; reg Elev1Timer,Elev2Timer; ////TIMER FOR ELEVATOR1 reg [29:0]x; assign Elev1CurrentStateOutput = Elev1CurrentState; assign Elev2CurrentStateOutput = Elev2CurrentState; always@(posedge Clock) begin if(Reset_counter1) x<=30'd0; else if(start_counter1) x<=x+1; else x<=30'd0; end always@(x) begin if(x == 30'd1000000000) Elev1Timer <= 1; else Elev1Timer <= 0; end //TIMER FOR ELEVATOR2 reg [29:0]y; always@(posedge Clock) begin if(Reset_counter2) y<=30'd0; else if(start_counter2) y<=y+1; else y<=30'd0; end always@(y) begin if(y==30'd1000000000) Elev2Timer<=1; else Elev2Timer<=0; end //ELEVATOR STATES parameter Floor1DoorOpen = 3'b000, Floor1DoorClosed = 3'b001, Transition1to2 = 3'b010, Transition2to1 = 3'b011, Floor2DoorOpen = 3'b100, Floor2DoorClosed = 3'b101; //ELEVATOR-1 always@(posedge Clock) begin if(Reset) Elev1CurrentState <= Floor1DoorOpen; else Elev1CurrentState <= Elev1NextState; end always @(Elev1CurrentState or Elev1Obstructed or Elev1Timer or Elev1MoveTo1 or Elev1MoveTo2 or Elev1DownButton or Elev1UpButton) begin case(Elev1CurrentState) Floor1DoorOpen: begin if(!Elev1Obstructed & Elev1Timer) Elev1NextState = Floor1DoorClosed; else Elev1NextState = Floor1DoorOpen; end Floor1DoorClosed: begin if(Elev1MoveTo1 | Elev1DownButton) Elev1NextState = Floor1DoorOpen; else if(Elev1MoveTo2 | Elev1UpButton) Elev1NextState = Transition1to2; else Elev1NextState = Floor1DoorClosed; end Transition1to2: Elev1NextState = Floor2DoorOpen; Transition2to1: Elev1NextState = Floor1DoorOpen; Floor2DoorOpen: begin if(!Elev1Obstructed & Elev1Timer) Elev1NextState = Floor2DoorClosed; else Elev1NextState = Floor2DoorOpen; end Floor2DoorClosed: begin if(Elev1MoveTo2 | Elev1UpButton) Elev1NextState = Floor2DoorOpen; else if(Elev1MoveTo1 | Elev1DownButton) Elev1NextState = Transition2to1; else Elev1NextState = Floor2DoorClosed; end endcase end //ELEVATOR-2 always@(posedge Clock) begin if(Reset) Elev2CurrentState <= Floor1DoorOpen; else Elev2CurrentState <= Elev1NextState; end always @(Elev2CurrentState or Elev2Obstructed or Elev2Timer or Elev2MoveTo1 or Elev2MoveTo2 or Elev2DownButton or Elev2UpButton) begin case(Elev2CurrentState) Floor1DoorOpen: begin if(!Elev2Obstructed & Elev2Timer) Elev2NextState = Floor1DoorClosed; else Elev2NextState = Floor1DoorOpen; end Floor1DoorClosed: begin if(Elev2MoveTo1 | Elev2DownButton) Elev2NextState = Floor1DoorOpen; else if(Elev2MoveTo2 | Elev2UpButton) Elev2NextState = Transition1to2; else Elev2NextState = Floor1DoorClosed; end Transition1to2: Elev2NextState = Floor2DoorOpen; Transition2to1: Elev2NextState = Floor1DoorOpen; Floor2DoorOpen: begin if(!Elev2Obstructed & Elev2Timer) Elev2NextState = Floor2DoorClosed; else Elev2NextState = Floor2DoorOpen; end Floor2DoorClosed: begin if(Elev2MoveTo2 | Elev2UpButton) Elev2NextState = Floor2DoorOpen; else if(Elev2MoveTo1 | Elev2DownButton) Elev2NextState = Transition2to1; else Elev2NextState = Floor2DoorClosed; end endcase end //ARBITER always@( Floor1UpButton or Floor2DownButton ) begin if((Elev1CurrentState == Floor1DoorOpen) && (Elev2CurrentState == Floor1DoorOpen)) begin start_counter1 <= 1'b1; start_counter2 <= 1'b1; Reset_counter1 <= 1'b0; Reset_counter2 <= 1'b0; if (Floor1UpButton==1'b1) begin ClearUpButton <= 1'b1; ClearDownButton <= 1'b0; Elev1MoveTo1 <= 1'b0; Elev1MoveTo2 <= 1'b0; Elev2MoveTo1 <= 1'b0; Elev2MoveTo2 <= 1'b0; end else if (Floor2DownButton==1'b1) begin ClearUpButton <= 1'b0; ClearDownButton <= 1'b0; Elev1MoveTo1 <= 1'b0; Elev1MoveTo2 <= 1'b0; Elev2MoveTo1 <= 1'b0; Elev2MoveTo2 <= 1'b1; end else begin ClearUpButton <= 1'b0; ClearDownButton <= 1'b0; Elev1MoveTo1 <= 1'b0; Elev1MoveTo2 <= 1'b0; Elev2MoveTo1 <= 1'b0; Elev2MoveTo2 <= 1'b0; end end if((Elev1CurrentState == Floor1DoorOpen) && (Elev2CurrentState == Floor1DoorClosed)) begin start_counter1 <= 1'b1; start_counter2 <= 1'b0; Reset_counter1 <= 1'b0; Reset_counter2 <= 1'b1; if (Floor1UpButton) begin ClearUpButton <= 1'b1; ClearDownButton <= 1'b0; Elev1MoveTo1 <= 1'b0; Elev1MoveTo2 <= 1'b0; Elev2MoveTo1 <= 1'b0; Elev2MoveTo2 <= 1'b0; end else if (Floor2DownButton) begin ClearUpButton <= 1'b0; ClearDownButton <= 1'b0; Elev1MoveTo1 <= 1'b0; Elev1MoveTo2 <= 1'b0; Elev2MoveTo1 <= 1'b0; Elev2MoveTo2 <= 1'b1; end else begin ClearUpButton <= 1'b0; ClearDownButton <= 1'b0; Elev1MoveTo1 <= 1'b0; Elev1MoveTo2 <= 1'b0; Elev2MoveTo1 <= 1'b0; Elev2MoveTo2 <= 1'b0; end end if((Elev1CurrentState == Floor1DoorOpen) && (Elev2CurrentState == Transition1to2)) begin start_counter1 <= 1'b1; start_counter2 <= 1'b0; Reset_counter1 <= 1'b0; Reset_counter2 <= 1'b1; if (Floor1UpButton) begin ClearUpButton <= 1'b1; ClearDownButton <= 1'b0; Elev1MoveTo1 <= 1'b0; Elev1MoveTo2 <= 1'b0; Elev2MoveTo1 <= 1'b0; Elev2MoveTo2 <= 1'b0; end else if (Floor2DownButton) begin ClearUpButton <= 1'b0; ClearDownButton <= 1'b0; Elev1MoveTo1 <= 1'b0; Elev1MoveTo2 <= 1'b0; Elev2MoveTo1 <= 1'b0; Elev2MoveTo2 <= 1'b1; end else begin ClearUpButton <= 1'b0; ClearDownButton <= 1'b0; Elev1MoveTo1 <= 1'b0; Elev1MoveTo2 <= 1'b0; Elev2MoveTo1 <= 1'b0; Elev2MoveTo2 <= 1'b0; end end if((Elev1CurrentState == Floor1DoorOpen) && (Elev2CurrentState == Transition2to1)) begin start_counter1 <= 1'b1; start_counter2 <= 1'b0; Reset_counter1 <= 1'b0; Reset_counter2 <= 1'b1; if (Floor1UpButton) begin ClearUpButton <= 1'b1; ClearDownButton <= 1'b0; Elev1MoveTo1 <= 1'b0; Elev1MoveTo2 <= 1'b0; Elev2MoveTo1 <= 1'b0; Elev2MoveTo2 <= 1'b0; end else if (Floor2DownButton) begin ClearUpButton <= 1'b0; ClearDownButton <= 1'b0; Elev1MoveTo1 <= 1'b0; Elev1MoveTo2 <= 1'b1; Elev2MoveTo1 <= 1'b0; Elev2MoveTo2 <= 1'b0; end else begin ClearUpButton <= 1'b0; ClearDownButton <= 1'b0; Elev1MoveTo1 <= 1'b0; Elev1MoveTo2 <= 1'b0; Elev2MoveTo1 <= 1'b0; Elev2MoveTo2 <= 1'b0; end end if((Elev1CurrentState == Floor1DoorOpen) && (Elev2CurrentState == Floor2DoorOpen)) begin start_counter1 <= 1'b1; start_counter2 <= 1'b1; Reset_counter1 <= 1'b0; Reset_counter2 <= 1'b0; if (Floor1UpButton) begin ClearUpButton <= 1'b1; ClearDownButton <= 1'b0; Elev1MoveTo1 <= 1'b0; Elev1MoveTo2 <= 1'b0; Elev2MoveTo1 <= 1'b0; Elev2MoveTo2 <= 1'b0; end else
评论
    相关推荐
    • elevator.zip
      电梯运行的控制系统,FPGA实现,基于Verilog
    • elevator.rar
      verilog写的控制电梯的代码。输入多少则计数到那个点后停止计数
    • Verilog_HDL_elevator.rar
      Verilog实现的基于FPGA的五层楼电梯运行控制逻辑设计
    • elevator-verilog-code.zip
      SRAM CONTROLLER CAN GIVE YOU CORRET IDEA ABOUT VERILOG
    • Elevator.rar
      基于Spartan-3E板的简易电梯控制,采用verilog编写,LCD1602模拟显示电梯状态
    • elevator.rar
      elevator verilog HDL code
    • elevator.rar
      de2-115开发板2人6层电梯Verilog语言实现
    • elevator.rar
      verilog语言基于FPGA设计的五层智能电梯系统。
    • elevator.rar
      本人编写的verilog电梯程序,已仿真通过,欢迎大家下载学习,批评指正。
    • elevator.zip
      电梯实现十多年妇女,时空裂缝定理可得哪里看你过来拿口上楼你发过来奶酪火锅定积分开始记录给开发商估计快了