数电实验报告vhdl微波炉fpga分模块实现_第1页
数电实验报告vhdl微波炉fpga分模块实现_第2页
数电实验报告vhdl微波炉fpga分模块实现_第3页
数电实验报告vhdl微波炉fpga分模块实现_第4页
数电实验报告vhdl微波炉fpga分模块实现_第5页
已阅读5页,还剩29页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、数电综合实验报告-简易微波炉控制器的设计与实现班级: 姓名: 学号: 日期: 一:设计课题的任务要求3基本要求:3提高要求:3二:系统设计(包括设计思路、总体框图、分块设计)3设计思路3总体框图3分块设计41分频器42:防抖模块43:控制器44:数据装载54:倒计时模块65:译码模块76:数码管驱动模块77:火力显示88:led显示模块99:蜂鸣器模块9三:仿真波形及波形分析91:控制器仿真92数据装载仿真103倒计时模块:104:decoder译码电路模块115:驱动数码管模块116:led显示模块117:蜂鸣器模块128:总体仿真12四:源程序121:分频器122:防抖模块133:控制器1

2、44:数据装载模块165:倒计时模块179:火力模块2311:蜂鸣器模块27五:功能说明28六:元件清单和利用情况28七:故障和问题分析28八:总结和结论29一:设计课题的任务要求设计制作一个简易微波炉控制器。基本要求:1、 微波炉的火力有大、中、小三档可选。用一个按键实现火力的选择,用点阵显示火力档位,点阵的显示随着按键的按下次数而变化,没有选择时默认的火力为大。2、 微波加热时间在0-59分59秒之间可选。用4个按键分别设置加热时间各位的长度,用数码管显示加热时间。3、 设置一个开始键,按下此键后开始加热。加热过程中,用数码管倒计时显示剩余时间。4、 加热过程中,不能修改火力和加热时间。5

3、、 加热完成后蜂鸣器至少鸣响两声以提醒使用者加热已结束,加热结束后回到等待状态。6、 设置复位键,任何时候按下复位键可以取消加热,回到等待状态,只有在等待状态下才可以修改火力和加热时间。提高要求:1、 用8个led灯作为加热进度显示条,随着加热时间的增加匀速增加点亮led灯的个数,无论加热时间是多长,最后都必须将8个led灯全部点亮。2、 增加烧烤功能,用一个键选择微波或烧烤功能,用一个数码管指示当前处于微波还是烧烤功能。3、 烧烤火力和加热时间要求与微波功能相同。4、 自拟其它功能。二:系统设计(包括设计思路、总体框图、分块设计)设计思路由一个总的控制器完成各个状态的转换。主要分两个大状态,

4、一为没有开始前的可编辑状态。二为开始后的不可编辑状态。所以总的控制器中应有个edit输出控制各个模块是否可改变。start开始前,为设置时间状态和火力状态和烧烤选择状态。start开始后edit变量为0,各个模块不可在编辑。控制器转入倒计时模块,同时led灯进入工作状态。需要注意的是需要为所有模块设置reset输入,以重置各个模块状态值。主要考虑问题:1:由于键盘输入不稳定,数字跳变太快,所以需要加键盘防抖模块。2:键盘防抖模块需要特殊的频率,所以分频器模块不止一个。综上,主要涉及以下几个模块。分频器,键盘防抖模块,控制器,数据选择,数据装载,数字译码,数码管显示模块,led进度显示模块,火力

5、选择和显示模块,倒计时模块,蜂鸣器模块总体框图数据选择与装载数字译码与显示倒计时 防抖分频器控制器led显示 蜂鸣器点阵显示火力选择键盘输入分块设计1分频器 1hz用于倒计时,100hz是时间输入防抖所用频率,10khz是火力防抖所用(也可以用100hz的,不过就是输入稳定性略差)2:防抖模块 左边为时间输入防抖,右边为火力输入和开始键的防抖。3:控制器状态控制器的功能根据输入信号和自身当时所处的状态完成状态的转换和输出相应的控制信号,其模块框图如图所示。其中,输出信号ld_done指示数据装载电路载入的烹调结束的状态信息的显示的驱动信息数据;ld_clk显示数据装载电路的设置的时间数据;ld

6、_edit用于输出给其他分模块以便设置是否可改变;cook指示烹饪的状态,并提示计时器进行减法计算;data15.0:将key转化为二进制编码;key为定时时间输入信号,用于设置烹饪时间的长短,其高到低分别表示时间分、秒的十位、个位。当ld_done有效时,输出烹调结束数据。当ld_clk有效时,输出烹调的设置时间数据。4:数据装载当ld_done有效时,输出烹调结束的信息数据数据。当l_clk有效时,输出烹调的设置时间数据。由于结构内部用到与或表达式load<=ld_test or ld_done or ld_clk; temp:=ld_test&ld_done&ld_

7、clk; 必须3个变量才能使用,所以ld-test是用于完成这个表达式的。程序中默认接地。 4:倒计时模块电路计时模块可以由十进制减法计数器和六进制减法计数器级联组成,其中,两个十进制的减法计数器用于分、秒的个位减法计数,两个六进制的减法计数器用于分、秒的十位减法计数。由六进制计数器和十进制计数器级联构成的计时模块原理图如图所示。load有效时完成装入功能,cook(en)有效时执行减计数;载已存的数据;done返回给控制器,min和sec显示所剩时间和测试状态信息、烹调结束状态信息等。5:译码模块用于将counter输出的sec和min信号转化成数码管显示信号。输出分别对应每个数码管的管脚。

8、6:数码管驱动模块 t1t4接受来自四个decoder的译码信号。分别代表秒,十秒,分,十分位的信号。clk是用于显示的分频信号。数码管不能做到同时显示,只能以较快速度分别显示每个数码管的数字,由于人眼分辨不出快速的变化,看起来的效果是同时显示的。t输出是管脚信号,每个clk上升沿t就输出下一个t的信息,轮流显示t1-t4的信号。a是选择数码管的信号,低电平表示该数码管工作。轮流显示111110,111101,111011,110111.011111.t5是烧烤信号,作用与第一个数码管,为1时是普通功能,0时换做烧烤。edit来自控制器,表示t5信号是否可改变7:火力显示 dianzhenji

9、shu用于完成火力按钮按的次数计数。3个一循环,分别对应大中小3档。 dianzhenxuanzelie用于选择显示点阵中的哪列,原理通数码管一样,快速完成when 0=>q<="00000001"when 1=>q<="00000010"when 2=>q<="00000100"when 3=>q<="00001000"when 4=>q<="00010000"when 5=>q<="00100000"

10、when 6=>q<="01000000"when 7=>q<="10000000"的循环。dianzhenlieshuju是每列对应的数据,用于完成大中小三个字的显示。低电平有效。8:led显示模块clk外接1hz分频,用于内部对秒的计数。key接受输入的时间信号,并在内部转化成秒数。对clk的计数和key转化的总时间数比较,当计数对应1/8,2/8,3/87/8个key时点亮相应的led灯。ledbar用于输出led显示信号从00000000-11111111.clk没到达一定数字,相应的增加一位1显示。计数完成时,led全部

11、点亮。set用于清空clk计数。start用于将key的输入转化成秒数。9:蜂鸣器模块clk用于1hz输入。对秒计数。每两秒输出一个高电平。总共输出2下。reset用于清空计数done用于接收倒计时的完成信号。当done为高电平时开始计数。out1用于连接蜂鸣器。高电平蜂鸣器响。10总框图三:仿真波形及波形分析1:控制器仿真图中,clk是输入脉冲,reset复位,set_t设置时间,key按键输入,start开始计时,cook正在烹饪,key输入59分00秒。start按之前,ld_clk为有效,可改变数码管显示,start按下后ld-clk为0,不能改变,同时ld-edit变为低电平,控制其

12、他模块不可改变,同时cook信号变为1,表示开始倒计时。reset后data变回0.2数据装载仿真ldclk有效时,dataout=datain,同时load信号有效,表示倒计时接受来自loader的信号3倒计时模块:图中,load为高电平时读取信号data的值,当cook信号为高电平时,对data的值进行减法计数,并在每个时钟周期都输出减法计数器的当前值。仿真结果与预先设定的电路功能相吻合。4:decoder译码电路模块每个数字对应相应的数码管脚显示信号如0的时候数码管脚为0111111,与预期一致。5:驱动数码管模块可见a轮流显示每个数码管t则相应的数码管上显示相应的数字。符合预期。6:l

13、ed显示模块key输入11秒在start后11秒左右,ledbar全部为1,完成led功能。且reset后ledbar清零。7:蜂鸣器模块在接受done信号后每两秒输出一个高电平且持续两秒。总共响2次。完成功能。8:总体仿真四:源程序1:分频器library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity fenpinqi1hz is port(clk_in : in std_logic; clk_out : out std_logic);end;architecture a of fenpinqi

14、1hz is signal cnt : integer range 0 to 24999999; -用于clk计数。(10khz为2499,100hz为249999) signal clk_tmp : std_logic;begin process(clk_in) begin if (clk_in'event and clk_in='1') then if cnt=24999999 then cnt<=0; clk_tmp<= not clk_tmp; -输出相反电平 else cnt<=cnt+1; end if; end if; end proce

15、ss; clk_out<=clk_tmp;end;2:防抖模块library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity fangdou is port(clk_100hz:in std_logic; -定义端口 key:in std_logic_vector(3 downto 0); -按键输入 keyout:out std_logic_vector(3 downto 0) -按键输出 ); end fangdou; archit

16、ecture art of fangdou is signal tmp1:std_logic_vector(3 downto 0); signal tmp2:std_logic_vector(3 downto 0); begin process(clk_100hz,key) begin if(clk_100hz'event and clk_100hz='0')then消抖部分 tmp2(0)<=tmp1(0); tmp1(0)<=key(0); tmp2(1)<=tmp1(1); tmp1(1)<=key(1); tmp2(2)<=tmp1

17、(2); tmp1(2)<=key(2); tmp2(3)<=tmp1(3); tmp1(3)<=key(3); end if; keyout(0) <= clk_100hz and tmp1(0) and (not tmp2(0); keyout(1) <=clk_100hz and tmp1(1) and (not tmp2(1); keyout(2) <=clk_100hz and tmp1(2) and (not tmp2(2); keyout(3) <=clk_100hz and tmp1(3) and (not tmp2(3); end p

18、rocess; end art;3:控制器library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity controller is port( reset:in std_logic; -¸复位 key: in std_logic_vector(3 downto 0);-键盘时间输入 start:in std_logic;-开始键 clk:in std_logic; -1hz输入 done:in std_logic;-完成信号 co

19、ok:out std_logic; ld_clk:out std_logic; -将key载入作为时间信号 data:out std_logic_vector(15 downto 0);-key转换后的输出 ld_done:out std_logic; -完成输出 ld_edit:out std_logic );end controller;architecture rtl of controller istype states is(idle,set_clock,timer,done_msg);signal nxt,cur:states; -两个状态,当前和下一个signal datatmp

20、:std_logic_vector(15 downto 0); signal edit:std_logic;-signal startn:std_logic:='0'begin process(clk,reset) -时钟和复位进程 begin if reset='1' then -复位时将idle(显示0000)赋予当前状态 cur<=idle; elsif clk'event and clk='1' then cur<=nxt; -如果不是,遇到上边沿则自动跳转下一状态 end if;end process; proces

21、s(reset,key) -复位和输入的进程 begin -可以让输入4位数字 显示时间 if reset = '1' then -复位时不论任何状态数码管都将显示0000 datatmp <= (others => '0'); else if key(3)'event and key(3) = '1' then -设置分的十位 if datatmp(15 downto 12) = "0101" then -5自动跳转到0 datatmp(15 downto 12) <= "0000&quo

22、t; else datatmp(15 downto 12) <= datatmp(15 downto 12) + 1; end if; -否则自动加1 end if; if key(2)'event and key(2) = '1' then -设置分的个位 if datatmp(11 downto 8) = "1001" then -9自动跳转到0 datatmp(11 downto 8) <= "0000" else datatmp(11 downto 8) <= datatmp(11 downto 8) +

23、 1; end if; -否则自动加1 end if; if key(1)'event and key(1) = '1' then -设置秒的十位 if datatmp(7 downto 4) = "0101" then -5自动跳转到0 datatmp(7 downto 4) <= "0000" else datatmp(7 downto 4) <= datatmp(7 downto 4) + 1; end if; -否则自动加1 end if; if key(0)'event and key(0) = &#

24、39;1' then -设置秒的个位 if datatmp(3 downto 0) = "1001" then -9自动跳转到0 datatmp(3 downto 0) <= "0000" else datatmp(3 downto 0) <= datatmp(3 downto 0) + 1; end if; end if; -否则自动加1 end if; data <= datatmp; end process; process(start,reset) -ÉèÖÃʱ

25、;¼äºÍ¸´Î»½ø³Ì begin if reset = '1' then -将edit置1 edit <= '1' elsif start'event and start = '1' then -如何start按下将edit置0 edit <= '0' end if; end process;process(clk,cur,edit,done) isbegin nxt<=idle;

26、 -将idle载入nxt - ld_power<='0' -¸´Î» ld_done<='0' ld_clk<='0' cook<='0' case cur is when set_clock=> -烹调时间测试状态 ld_clk<='1' cook<='0' when done_msg=> -完成信息显示状态 ld_done<='0' cook<='0' when i

27、dle=> -初始状态定义 if edit='1' then -设置计时模式 nxt<=set_clock; ld_clk<='1' elsif done='0' then nxt<=timer; cook<='1' end if; when timer=> if done='1' then -设置计时完成 nxt<=done_msg; ld_done<='0' cook<='0' else nxt<=timer; cook

28、<='1' end if; - when others=>null; end case; end process;process(edit) isbeginld_edit<=edit;end process;end rtl;4:数据装载模块library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;entity loader is port( datain:in std_logic_vector(15 downto 0); -输入16位数据 ld_test:in std_logic

29、; ld_clk:in std_logic; ld_done:in std_logic; dataout:out std_logic_vector(15 downto 0); -输出16位数据 load:out std_logic -选择状态 );end loader;architecture rtl of loader isbegin process(datain,ld_test,ld_clk,ld_done) constant alls:std_logic_vector(15 downto 0)-测试信息 :="1000100010001000" -显示8888 con

30、stant done:std_logic_vector(15 downto 0)-烹调完成信息 :="1010101111001101" variable temp:std_logic_vector(2 downto 0); begin load<=ld_test or ld_done or ld_clk; -三选一状态 temp:=ld_test&ld_done&ld_clk; -中间变量定义 case temp is when"010"=>-烹调完成 dataout<=done; when"001"

31、;=> dataout<=datain; when others=>null; end case; end process;end rtl;5:倒计时模块1:十进制计数器library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity cnt10 is port( clk:in std_logic; load,clr:in std_logic; -clr:清除数据 en:in std_logic; -信号使能 datain:in std_logic_vector(3 downto 0

32、); -输入的4位数据 q:out std_logic_vector(3 downto 0); -输出的4位数据 carry_out:out std_logic -数据装载 );end cnt10;architecture rtl of cnt10 is signal tmp:std_logic_vector(3 downto 0); -链接输入输出begin -数据的信号 process(clk,load,clr,en) begin if clr = '1' then -当clr高电平,数据变为0000 tmp<= "0000" elsif load

33、='1'then -否则装载输入的数据 tmp<=datain; elsif clk'event and clk='0'then -上升沿时,执行10进制减法 if en='1'then if tmp="0000"then -0跳转到9 tmp<="1001" else -自动减1 tmp<=tmp-'1' end if; end if; end if; if tmp="0000"then carry_out<='1' -c

34、ook<=carry_out else carry_out<='0' end if; end process; q<=tmp;end rtl;2:-六进制减法计数器library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity cnt6 is port( clk:in std_logic; load,clr:in std_logic; en:in std_logic; datain:in std_logic_vector(3 downto 0); q:out std

35、_logic_vector(3 downto 0); carry_out:out std_logic );end cnt6;architecture rtl of cnt6 issignal tmp:std_logic_vector(3 downto 0);begin process(clk,load,clr,en) begin if clr = '1' then tmp<= "0000" elsif load='1' then tmp<=datain; elsif clk'event and clk='0'

36、;then -上升沿时进行6进制减法 if en='1'then if tmp="0000"then -0自动跳转到5 tmp<="0101" else tmp<=tmp-'1' -否则自动减1 end if; end if; end if; if tmp="0000"then carry_out<='1' -赋值给cook else carry_out<='0' end if; end process; q<=tmp;end rtl;lib

37、rary ieee;use ieee.std_logic_1164.all;3:总的计数器entity counter is port( cook:in std_logic; load,clr:in std_logic; clk:in std_logic; data:in std_logic_vector(15 downto 0); sec0:out std_logic_vector(3 downto 0); -秒个位 sec1:out std_logic_vector(3 downto 0); -秒十位 min0:out std_logic_vector(3 downto 0); -分个位

38、min1:out std_logic_vector(3 downto 0); -分十位 done:out std_logic -完成 );end counter;architecture rtl of counter is-定义十进制和六进制计数器电路模块component cnt10 is port( clk:in std_logic; load,clr:in std_logic; en:in std_logic; datain:in std_logic_vector(3 downto 0); -输入 q:out std_logic_vector(3 downto 0); -输出 carry

39、_out:out std_logic -状态 );end component cnt10;component cnt6 is port( clk:in std_logic; load,clr:in std_logic; en:in std_logic; datain:in std_logic_vector(3 downto 0); q:out std_logic_vector(3 downto 0); carry_out:out std_logic );end component cnt6;signal clk0:std_logic;signal s0:std_logic;signal s1:

40、std_logic;signal s2:std_logic;signal s3:std_logic;begin -元件例化 clk0 <= not clk; u1:cnt10 port map(clk0,load,clr,cook,data(3 downto 0),sec0,s0); u2:cnt6 port map(s0,load,clr,cook,data(7 downto 4),sec1,s1); u3:cnt10 port map(s1,load,clr,cook,data(11 downto 8),min0,s2); u4:cnt6 port map(s2,load,clr,c

41、ook,data(15 downto 12),min1,s3); done<=s0 and s1 and s2 and s3;end rtl;6:decoder模块library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity decoder isport(ain4:in std_logic_vector(3 downto 0); -输入的二进制数dout7:out std_logic_vector(6 downto 0) 输出二进制相应的管脚);end entity decoder;arch

42、itecture art of decoder isbeginprocess(ain4)begincase ain4 iswhen "0000" => dout7 <= "0111111"when "0001" => dout7 <= "0000110"when "0010" => dout7 <= "1011011"when "0011" => dout7 <= "1001111"whe

43、n "0100" => dout7 <= "1100110"when "0101" => dout7 <= "1101101"when "0110" => dout7 <= "1111101"when "0111" => dout7 <= "0000111"when "1000" => dout7 <= "1111111"when &qu

44、ot;1001" => dout7 <= "1101111"when "1010" => dout7 <= "1011110"when "1011" => dout7 <= "1011100"when "1100" => dout7 <= "1010100"when "1101" => dout7 <= "1111001"when others =

45、> dout7 <= "0000000"end case;end process;end architecture art;8:数码管驱动电路library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity qudong isport ( clk: in std_logic; t1 : in std_logic_vector(6 downto 0); - sec0输入 t2: in std_logic_vector(6 downto 0); -sec1输入 t3 : i

46、n std_logic_vector(6 downto 0);-min0输入 t4: in std_logic_vector(6 downto 0);-min1输入 t5:in std_logic; edit:in std_logic; t: out std_logic_vector(6 downto 0);-输出 a:out std_logic_vector(5 downto 0)选择数码管 ); end qudong; architecture arch of qudong is signal n: std_logic_vector(2 downto 0); signal t_temp2:

47、std_logic:='1'signal t_temp:std_logic_vector(6 downto 0);signal a_temp:std_logic_vector(5 downto 0); beginprocess(edit,t5)beginif(edit='1') then if(t5'event and t5='1') then t_temp2<=not t_temp2; end if; end if; end process; process(clk,t_temp2) begin if(clk'event and clk='1') then if (n="000" ) then t_temp <= t1; a_temp<="111110" n <= n+1; elsif(n="001") then t_temp <= t2; a_temp<="111101"

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论