77范文网 - 专业文章范例文档资料分享平台

基于FPGA的红外线型学习遥控器(3)

来源:网络收集 时间:2018-12-27 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:或QQ: 处理(尽可能给您提供完整文档),感谢您的支持与谅解。点击这里给我发消息

data:in std_logic_vector(31 downto 0); anjian1:in std_logic; anjian2:in std_logic; anjian3:in std_logic;

od:out std_logic_vector(15 downto 0); ad:out std_logic_vector(4 downto 0)); end entity;

architecture behav of hw_address is type state is(s0,s1,s2,s3); signal sta:state;

signal addr:std_logic_vector(4 downto 0); begin ad<=addr;

process(anjian1,anjian2,anjian3,clk) begin

if(anjian1='1'and anjian2='1'and anjian3='1')then sta<=s0; od<=x\addr<=\

elsif(clk'event and clk ='1')then case sta is

when s0=>if(anjian1='0')then od<=x\ addr<=\ sta<=s1;

elsif(anjian2='0')then od<=x\ addr<=\ sta<=s1;

elsif(anjian3='0')then od<=x\ addr<=\ sta<=s1; end if; when s1=>addr<=addr;

od<=data(15 downto 0); sta<=s2; when s2=>addr<=addr+'1';

od<=data(31 downto 16); sta<=s3; when s3=>sta<=s3; end case;

11

end if; end process; 存储读出程序

library ieee;

use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity hw_adout is port(clk:in std_logic;

inin:in std_logic_vector(15 downto 0); anjian1:in std_logic; anjian2:in std_logic; anjian3:in std_logic;

output:out std_logic_vector(31 downto 0)); end entity;

architecture behav of hw_adout is type state is(s0,s1,s2,s3); signal sta:state;

signal in1:std_logic_vector(15 downto 0); signal out1:std_logic_vector(31 downto 0); begin in1<=inin; output<=out1; process(anjian1,clk) begin

if(anjian1='1'and anjian2='1'and anjian3='1')then sta<=s0;

out1<=x\

elsif(clk'event and clk ='1')then case sta is when s0=>

out1(15 downto 0)<=in1; sta<=s1; when s1=>if(out1=in1)then sta<=s1; else

out1(15 downto 0)<=in1; sta<=s2; end if; when s2=>if(out1=in1)then sta<=s2; else

out1(31 downto 16)<=in1;

12

sta<=s3; end if; when s3=>sta<=s3; end case; end if; end process; end behav; 红外发射程序

library ieee;

use ieee.std_logic_1164.all;

entity hw_OUTPUT is

port(CLK:in std_logic;--50MHz kin:in std_logic;

DATA:in std_logic_vector(31 downto 0); IROUT:out std_logic); end entity hw_OUTPUT ;

architecture one of hw_OUTPUT is type state is(s0,s1,s2,s3,s4); signal sta:state;

signal clk_1m:std_logic; --1MHz signal clk_38k:std_logic; --38kHz begin process(CLK)

variable clk_counter:integer range 0 to 25; begin

if(CLK'event and CLK='1')then clk_counter:=clk_counter+1; if(clk_counter=25)then clk_counter:=0; clk_1m<=not clk_1m; end if; end if; end process;

process(CLK)

variable clk_counter:integer range 0 to 658; begin

if(CLK'event and CLK='1')then clk_counter:=clk_counter+1; if(clk_counter=658)then

13

clk_counter:=0; clk_38k<=not clk_38k; end if; end if; end process;

process(kin,clk_1m)

variable step:integer range 0 to 32; variable counter:integer range 0 to 100000; begin

if(kin='1')then IROUT<='0'; step:=0; sta<=s1; counter:=0;

elsif(clk_1m'event and clk_1m='1')then case sta is

when s0=>IROUT<='0'; if(counter<100000)then counter:=counter+1; else sta<=s1; counter:=0; end if; when s1=>IROUT<=clk_38k; if(counter<9000)then counter:=counter+1; else sta<=s2; counter:=0; end if; when s2=>IROUT<='0'; if(counter<4500)then counter:=counter+1; else sta<=s3; counter:=0; end if;

when s3=>IROUT<=clk_38k; if(counter<560)then counter:=counter+1; else sta<=s4; counter:=0; end if;

when s4=>IROUT<='0';

14

if(DATA(step)='0')then if(counter<565)then counter:=counter+1; elsif(step<32)then sta<=s3; step:=step+1; counter:=0; else sta<=s0; step:=0; counter:=0; end if;

elsif(DATA(step)='1')then

if(counter<1690)then counter:=counter+1; elsif(step<32)then sta<=s3; step:=step+1; counter:=0; else sta<=s0; step:=0; counter:=0; end if; end if; end case; end if; end process;

end architecture one;

15

百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库基于FPGA的红外线型学习遥控器(3)在线全文阅读。

基于FPGA的红外线型学习遥控器(3).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印 下载失败或者文档不完整,请联系客服人员解决!
本文链接:https://www.77cn.com.cn/wenku/zonghe/392440.html(转载请注明文章来源)
Copyright © 2008-2022 免费范文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ: 邮箱:tiandhx2@hotmail.com
苏ICP备16052595号-18
× 注册会员免费下载(下载后可以自由复制和排版)
注册会员下载
全站内容免费自由复制
注册会员下载
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: