文档详情

武汉纺织大学数学与计算机学院 数字逻辑 实验报告 LED流水指示灯.doc

发布:2017-12-08约4.88千字共9页下载文档
文本预览下载声明
武汉纺织大学数学与计算机学院 逻辑设计 课程设计报告 设计题目 班 级: 学 号: 姓 名: 同 组 者: 日 期: 1 题目与要求 1.1 问题提出 本人设计一个简单的LED流水指示灯,8个彩灯共阴接地,阳极分别为EP2C35的8个I/O相连,I/O输出变化的电平,来控制彩灯的点亮,流水灯分不同的时段,指示灯有不同的显示模式,开始时刻LED流水灯从右到左依次点亮,第二时间段LED流水灯从左到右依次熄灭,第三时间段LED流水从中间向两边点依次点亮,第四时间段LED流水灯从中间向两边点依次熄灭,第五时间段LED流水灯奇偶位循环点亮,最后完成一次循环又回到开始时刻,进人第二轮循环,来实现LED流水灯的控制实验。 1.2 设计原理 从LED流水灯的工作原理来看,无论是第一时间段还是其他的时间段,LED流水灯点亮还是熄灭,都是一个频率来控制LED流水灯点亮和熄灭的快慢。只不过这个频率可以在程序中控制,也可以在定义输入引脚时把频率选择不同的频率段。 2 设计过程 2.1 逻辑描述 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity light is port(clk1: in std_logic; light: buffer std_logic_vector(7 downto 0)); end light; architecture behv of light is constant len: integer:=7; signal banner: std_logic:=0; signal clk,clk2: std_logic; begin clk=(clk1 and banner) or (clk2 and not banner); process(clk1) begin if clk1event and clk1=1 then clk2=not clk2; end if; end process; -- process(clk1,clk2,banner) process(clk) variable flag: bit_vector(2 downto 0):=000; begin -- clk=(clk1 and banner) or (clk2 and not banner); if clkevent and clk=1 then if flag=000 then light=1 light(len downto 1); if light(1)=1 then flag:=001; end if; elsif flag=001 then light=light(len-1 downto 0) 0; if light(6)=0 then flag:=010; end if; elsif flag=010 then light(len downto 4)=light(len-1 downto 4)1; light(len-4 downto 0)=1light(len-4 downto 1); if light(1)=1 then flag:=011; end if; elsif flag=011 then light(len downto 4)=0light(len downto 5); light(len-4 downto 0)=light(len-5 downto 0)0; if light(2)=0 then flag:=100; end if; elsif flag=100 then light(len downto 4)=1light(len downto 5); light(len-4 downto 0)=1light(len-4 downto 1); if light(1)=1 then flag:=101; end if; elsif flag=101 then light flag:=110; elsif flag=110 then banner=not banner; flag:=000; end if; end if; end process; end behv; 在上面的VHDL程序中,clk1用于控
显示全部
相似文档