老古开发网首页
导航:老古开发网首页文章索引索引第2376页文章分类CPLD/FPGA第14页→[I2C在CPLD上的模拟实现源程序]
| -文章搜索 - 最新文章 - |

第3098篇:I2C在CPLD上的模拟实现源程序

发布时间:2006年10月15日 点击次数:3694
来源:   作者:
 

I2C在CPLD上的模拟实现源程序

程序1:
type clock_type is (s0,s1,s2,s3);
signal state0:clock_type;
signal state1:state_type;
case state is
        when s0=>
          da<=''1'';
          scl<=''1'';
          state<=s1;
        when s1=>
          da<=''1'';
          scl<=''1'';
          state<=s2;
        when s2=>
          da<=''0'';
          scl<=''1'';
          state<=s3;
        when s3=>
          da<=''0'';
          scl<=''0'';
          state<=s0;
          state1<=s_byte;
        when others=>
          state<=s0;
       end case;


下面是利用case…when语句编写的移位及输入、输出字节模块。
inoutdata:block
 signal code:std_logic_vector(2 downto 0);
 begin
process(read,endata,cl)   --cl与scl同步
begin
  code<=read & endata & flag;
  if cl''event and cl=''1''then
   case code is          
     when "010" "011" =>   --从MCU读入一个要发送的数据
        datain<=data;
     when "001"=>        --8位左移寄存器,将要输出的位存于data7
        data7<=datain(7);
        datain(0)<=''1'';
        for i in 1 to 7 loop
         datain(i)<=datain(i-1);
        end loop;
     when "101"=>        --将向MCU发送的数据暂存于dataout
        dataout<=data1;
     when "100"=>        --8位右移寄存器,data0为从SDA接收的值
        data1(0)<=data0;
        for i in 1 to 7 loop
         data1(i)<=data1(i-1);
        end loop;
     when others=>
        null;
   end case;
  end if;
end process;
end block inoutdata;


欢迎进入老古论坛进行讨论
[CPLD/FPGA] 相关文章:
XILINX将在DICC2006展示可编程低成本数字显示解决方案
简介:
  赛灵思公司将在由中国电子视像行业协会(CVIA)主办的&#8220;2006中国数字电视产业链建设报告会&#8221;(DICC 2006) 上展示其可编程低成本数字显示解决方案。赛灵思公司中国区总经理及处理方案部亚太区总监吴晓东先生将在大会上作题为&#8220;FPGA在DTV/IPTV系统中的发展&#8221;的演讲。 时间:2006年9月20-21日 地点:北京,中苑宾馆 赛灵思公司参与DICC 2006活动的情况: 大会演讲 时间:9......

IDT推出业界首个针对PCI Express 应用的具有250 MHz 基准时钟的抖动衰减器
Actel的FusionTM PSC在中国荣获嵌入式系统新技术奖
基于FPGA的数字滤波器的设计与实现
基于FPGA的前向纠错算法
 
下一个:[综合电子]ASK信号解码接收程序
简介:
作者FREE ;/*============================================================================= ; 通用ASK信号解码接收程序 ; ;1. 接收数据位数最多为40(5*8)位. ;2. 由定时器对time进行渐增,在TCC中断程序中加......

上一个:[网络协议]USB协议及规范---(之一)绪论

老古开发网版权所有 2006年9月 asp.Net V2.0 设计:老古
2008-5-14 1:18:19 页面缓存:30分钟 执行时间:109毫秒