基于VHDL的IIC时序电路设计

基于VHDL的IIC时序电路设计

ID:38711550

大小:31.50 KB

页数:4页

时间:2019-06-18

基于VHDL的IIC时序电路设计_第1页
基于VHDL的IIC时序电路设计_第2页
基于VHDL的IIC时序电路设计_第3页
基于VHDL的IIC时序电路设计_第4页
资源描述:

《基于VHDL的IIC时序电路设计》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、基于VHDL的IIC时序电路设计iic总线在设计时要看你所使用的器件的传输或接收时序只要会一个,其他的都一样以下是我在一本书上看到的,你看看就会用了libraryieee;useieee.std_logic_1164.all;useieee.std_logic_arith.all;useieee.std_logic_unsigned.all;entityreciverisport(reset,clk:instd_logic;sda,scl:inoutstd_logic;rd:outstd_logic;tdata:instd_l

2、ogic_vector(7downto0);rdata:outstd_logic_vector(7downto0));endreciver;architectureoneofreciverissignalrdatai:std_logic_vector(7downto0);typestateis(start,transmit,ack,sub,ack1,start1,slave,ack2,reading,ack3);signalcurrent:state;beginprocess(clk,reset)variablecount:i

3、ntegerrange0to40;variablecnt:integerrange0to8;beginifreset='1'thensda<='1';scl<='1';rdata<="00000000";current<=start;cnt:=8;count:=0;elsifclk'eventandclk='1'thencasecurrentiswhenstart=>count:=count+1;casecountiswhen1=>sda<='1';when2=>scl<='1';when3=>sda<='0';when4=>

4、scl<='0';when10=>count:=0;current<=transmit;whenothers=>null;endcase;whentransmit=>count:=count+1;casecountiswhen1=>sda<=tdata(cnt);when2=>scl<='1';when3=>scl<='0';when4=>cnt:=cnt-1;count:=0;ifcnt=0thencnt:=8;current<=ack;rd<='1';elsecurrent<=transmit;rd<='0';endif;

5、whenothers=>null;endcase;whenack=>count:=count+1;casecountiswhen1=>sda<='0';when2=>scl<='1';when3=>scl<='0';when4=>current<=sub;count:=0;whenothers=>null;endcase;whensub=>count:=count+1;casecountiswhen1=>sda<=tdata(cnt);when2=>scl<='1';when3=>scl<='0';when4=>cnt:=cn

6、t-1;count:=0;ifcnt=0thencnt:=8;current<=ack1;rd<='1';elsecurrent<=sub;rd<='0';endif;whenothers=>null;endcase;whenack1=>count:=count+1;casecountiswhen1=>sda<='0';when2=>scl<='1';when3=>scl<='0';when4=>current<=start1;count:=0;whenothers=>null;endcase;whenstart1=>coun

7、t:=count+1;casecountiswhen1=>sda<='1';when2=>scl<='1';when3=>sda<='0';when4=>scl<='0';when5=>current<=slave;count:=0;whenothers=>null;endcase;whenslave=>count:=count+1;casecountiswhen1=>sda<=tdata(cnt);when2=>scl<='1';when3=>scl<='0';when4=>cnt:=cnt-1;count:=0;ifcnt

8、=0thencnt:=8;current<=ack2;rd<='1';elsecurrent<=sub;rd<='0';endif;whenothers=>null;endcase;whenack2=>count:=count+1;casecountiswhen1=>sda<

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。