实验三彩灯实验.docVIP

  • 19
  • 0
  • 约4.44千字
  • 约 4页
  • 2017-12-11 发布于河南
  • 举报
实验三彩灯实验

实验三 彩灯实验 一、实验目的 通过实验初步了解实验箱上的频率源的基本使用方法。 通过阅读彩灯实验程序,了解编程并行处理的思维方式。 初步掌握EDA开发软件的调试方法。 二、实验要求 阅读和了解彩灯的编程思路。 验证彩灯实验。 三、实验设备 计算机 一台 EDA——Ⅳ实验箱 一台 四、实验原理 在本实验中(如附录1-NO.4所示),8个彩灯共阴接地,阳极分别为10k10的8个I/O相连,I/O输出变化的电平,来控制彩灯的点亮。 五、实验连线 1 将实验板正中上方,JPLED1(数码管右下方)的短路帽右插;JPLED的七个短路帽全部上插; 2 实验板右下方频率选择区中CLK5(即JP153)的短路帽接1Hz或23Hz; 五、实验内容与步骤 打开MAX+plusⅡ软件,编辑项目文件“File →Project →Name →light,”。 打开文本文件,light.vhd。 阅读原文件: --彩灯显示实验 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; ----定义信号banner为两种节拍转换信号; signal clk,clk2: std_logic; ----信号CLK1,CLK2作为辅助时钟 begin clk=(clk1 and banner) or (clk2 and not banner); process(clk1) begin if clk1event and clk1=1 then ---CLK1二分频得CLK2 clk2=not clk2; end if; end process; process(clk) ---- variable flag: bit_vector(2 downto 0):=000; begin 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)=1l

文档评论(0)

1亿VIP精品文档

相关文档