VHD语言实现6层楼自动电梯控制器.doc
文本预览下载声明
设计目的:
1、熟练使用Altera QuartusII 仿真软件。
2、掌握VHDL硬件描述语言进行硬件编程。
3、掌握状态机的原理,结构和设计。
4、理解FPGA技术的层次化设计方法。
5、理解并掌握电梯控制器的原理。
实验器材和工具软件:
FPGA开发版,Quartus II软件
设计内容及要求:
设计一个层楼自动电梯控制器,个并有数码管显示电梯当前所在楼层位置在每层电梯入口处设有请求按钮开关,请求。电梯运动,电梯控制电路应能记忆所有楼层请求信号,并按规则依次应:运行过程中先响应最早的请求,再响应后续的请求。如果无请求则停留当前层如果有两个同时请求信号,则判断请求信号离当。
五、源程序:
1、分屏器:
library ieee;
use ieee.std_logic_1164.all;
entity clk is
port(
clkin :in std_logic;
clkout:out std_logic);
end clk;
architecture behave_clk of clk is
constant N: Integer:
signal Counter:Integer RANGE 0 TO N;
signal Clk1: Std_Logic;
begin
process(clkin)
begin
if rising_edge(clkin) then
if Counter=N then
Counter=0;
Clk1=NOT Clk1;
else
Counter= Counter+1;
end if;
end if;
end process;
clkout= Clk1;
end behave_clk;
2、主控模块:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity dianti is
port ( clk : in std_logic; --时钟信号(频率为2Hz)
full,dwait,quick,clr : in std_logic; --超载、关门中断、提前关门清除报警信号
c_u1,c_u2,c_u3,c_u4,c_u5: in std_logic; --电梯外人的上升请求信号
c_d2,c_d3,c_d4,c_d5,c_d6 : in std_logic; --电梯外人的下降请求信号
d1,d2,d3,d4,d5,d6 : in std_logic; --电梯内人的请求信号
door : out std_logic_vector(1 downto 0); --电梯门控制信号
led : out std_logic_vector(6 downto 0); --电梯所在楼层显示
led_c_u:out std_logic_vector(5 downto 0); --电梯外人上升请求信号显示
led_c_d:out std_logic_vector(5 downto 0); --电梯外人下降请求信号显示
led_d : out std_logic_vector(5 downto 0); --电梯内请求信号显示
wahaha : out std_logic; --看门狗报警信号
ud,alarm : out std_logic; --电梯运动方向显示,超载警告信号
up,down : out std_logic ); --电机控制信号和电梯运动
end dianti;
architecture behav of dianti is
signal d11,d22,d33,d44,d55,d66:std_logic; --电梯内人请求信号寄存信号
signal c_u11,c_u22,c_u33,c_u44,c_u55:std_logic; --电梯外人上升请求信号寄存信号
signal c_d22,c_d33,c_d44,c_d55,c_d66:std_logic; --电梯外人下降请求信号寄存信号
signal q:integer range 0 to 1; --分频信号
signal q1:integer range 0 to 5; --
显示全部