亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? i2c_main_blk.vhd

?? IIC的IP.這是經(jīng)過驗證的源代碼
?? VHD
?? 第 1 頁 / 共 2 頁
字號:
------------------------------------------------------------------------------
-- 
--  Name:  I2C_Main_Blk.vhd
-- 
--  Description:  Main state machine block controls the transaction on the 
--              I2C bus. It acts as an interface between the I2C controller 
--              and the I2C bus. 
-- 
--  $Revision: 1.0 $          
--  
--  Copyright 2004 Lattice Semiconductor Corporation.  All rights reserved.
--
------------------------------------------------------------------------------
-- Permission:
--
--   Lattice Semiconductor grants permission to use this code for use
--   in synthesis for any Lattice programmable logic product.  Other
--   use of this code, including the selling or duplication of any
--   portion is strictly prohibited.
--
-- Disclaimer:
--
--   This VHDL or Verilog source code is intended as a design reference
--   which illustrates how these types of functions can be implemented.
--   It is the user's responsibility to verify their design for
--   consistency and functionality through the use of formal
--   verification methods.  Lattice Semiconductor provides no warranty
--   regarding the use or functionality of this code.
------------------------------------------------------------------------------
--
--    Lattice Semiconductor Corporation
--    5555 NE Moore Court
--    Hillsboro, OR 97124
--    U.S.A
--
--    TEL: 1-800-Lattice (USA and Canada)
--    408-826-6000 (other locations)
--
--    web: http://www.latticesemi.com/
--    email: techsupport@latticesemi.com
-- 
------------------------------------------------------------------------------


library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;

entity I2C_Main is
  port(MPU_CLK           : in std_logic;                        -- MP Clock 
       Rst_L             : in std_logic;                        -- Main Reset, active low
       SCL               : in bit;--7/14std_logic;                      -- I2C F/S mode Clock
       SDA               : in bit;--7/14std_logic;                      -- SDA
       Bit_Count         : in std_logic_vector(2 downto 0);     -- Bit count for I2C packets
       Bit_Cnt_Flag      : in std_logic;                        -- Bit Count overflow flag
       Byte_Cnt_Flag     : in std_logic;                        -- Byte Count overflow flag
       Trans_Buffer      : in std_logic_vector(7 downto 0);     -- Data from MPU for I2C Write
       Low_Address_Reg   : in std_logic_vector(7 downto 0);     -- Low order Address bits for I2C Slave
       Lost_Arb          : in std_logic;                        -- Lost Arbitration Bit
       Start_Det         : in std_logic;                        -- I2C Start Detect
       Stop_Det          : in std_logic;                        -- I2C Stop Detect       
       Command_Reg       : in std_logic_vector(1 downto 0);     -- CMD part of Command_Status Reg Contains:
                                                                -- Go, Abort. Does not include: I2C_Mode, 
                                                                -- I2C_address Size,Iack,Trans_IE and Recieve_IE.      
       Status_Reg        : out std_logic_vector(3 downto 0);    -- Status part of Command_Status Reg Contains:
                                                                -- I2C_Bus_Busy, Abort_Ack, Error,Done
                                                                -- Does not include:Trans_Buf_Empty, Recieve_Buf_Full,
                                                                -- Lost_Arb. Lost Arb comes from arbiter
       Read_Buffer       : out std_logic_vector(7 downto 0);    -- I2C read data byte                                                                   
       Bit_Cnt_EN        : out std_logic;                       -- Bit count enable
       Byte_Cnt_EN       : out std_logic;                       -- Byte count enable
       Start_EN          : out std_logic;                       -- Start enable
       Stop_EN           : out std_logic;                       -- Stop enable
       SDA_EN1           : out std_logic;                       -- SDA enable
       TBE_Set           : out std_logic;                       -- set Transmit_Buffer_Empty flag for MPU block
       RBF_Set           : out std_logic;                       -- set Recieve_Buffer_Full flag for MPU block
       Go_Clear          : out std_logic;                      -- Request to clear go bit
       WCS_Ack           : out std_logic;
       RCS_Ack           : out std_logic);

end I2C_Main;

architecture I2C_Main_Behave of I2C_Main is
--Command_Reg bits (used by I2C Main Blk)
 signal go           : std_logic;
 signal abort        : std_logic;
-- signal I2C_Add_Size : std_logic; -- not implemented yet
--Status_Reg bits (set by I2C Main Blk)
 signal I2C_Bus_Busy         : std_logic;
 signal Error                : std_logic;
 signal Abort_Ack            : std_logic;
 signal Done                 : std_logic;
 signal Reset                : std_logic;
  
 --signal Retry_Cnt            : std_logic_vector(1 downto 0);
--Low_Address_Reg bits
 signal I2C_RW_Bit           : std_logic;
--
 signal Read_SR              : std_logic_vector(7 downto 0);
 signal Trans_Buffer_SR      : std_logic_vector(7 downto 0);

 signal Value                : std_logic;
 
 signal det_low              : std_logic;
 signal det_high             : std_logic;
 signal MCS_Write_Flag       : std_logic; 
 signal MCS_Read_Flag        : std_logic; 
 signal load                 : std_logic_vector(1 downto 0);
 signal shift                : std_logic;
 signal bit_cnt2             : std_logic; 


--testing 7/26
signal b0                    :std_logic;
signal b1                    :std_logic;
signal s                     :std_logic;

--7/20 signal condition : std_logic_vector(2 downto 0); 
-- State Bits for the Main State Machine
-- ONLY 3 state bits
signal   MCS                     : std_logic_vector(4 downto 0);
constant Idle_State              : std_logic_vector(4 downto 0)  := "00001";
constant Delay_Start_EN_State    : std_logic_vector(4 downto 0)  := "00010";
constant Write_Slv_Addr_State    : std_logic_vector(4 downto 0)  := "00100";
constant Main_Write_State        : std_logic_vector(4 downto 0)  := "01000";
constant Main_Read_State         : std_logic_vector(4 downto 0)  := "10000";

-- State Bits for the Write State Machine
-- ONLY 2 state bits
signal   WCS                     : std_logic_vector(4 downto 0);
signal   Next_WCS                : std_logic_vector(4 downto 0);
constant Write_State             : std_logic_vector(4 downto 0)  := "00001";
constant Delay_Write_State       : std_logic_vector(4 downto 0)  := "00010";
constant Delay_Ack_Write_State   : std_logic_vector(4 downto 0)  := "00100";
constant Ack_Write_State         : std_logic_vector(4 downto 0)  := "01000";
constant Error_Write_State       : std_logic_vector(4 downto 0)  := "10000";

-- State Bits for the Read State Machine
-- ONLY 2 state bits
signal   RCS                     : std_logic_vector(5 downto 0);
signal   Next_RCS                : std_logic_vector(5 downto 0);
constant Read_State              : std_logic_vector(5 downto 0)  := "000001";
constant Delay_Read_State        : std_logic_vector(5 downto 0)  := "000010";
constant Delay_Ack_Read_State    : std_logic_vector(5 downto 0)  := "000100";
constant Delay_Ack_Read_State2   : std_logic_vector(5 downto 0)  := "001000";
constant Ack_Read_State          : std_logic_vector(5 downto 0)  := "010000";
constant Error_Read_State        : std_logic_vector(5 downto 0)  := "100000";

begin
   go           <= Command_Reg(1);
   abort        <= Command_Reg(0);
   I2C_RW_Bit   <= Low_Address_Reg(0);

   WCS_Ack      <= WCS(3);
   RCS_Ack      <= RCS(4);

   Status_Reg   <= I2C_Bus_Busy & Error & Abort_Ack & Done;

   Reset        <= '0' when RST_L = '0' or abort = '1' else '1';-- or WCS(4) = '1' or RCS(3) = '1' else '1';
   
   MCS_Read_Flag   <= '1' when MCS(4) = '1' and I2C_RW_Bit = '1' else '0';

   MCS_Write_Flag   <= '1' when MCS(2) = '1' or ((MCS(3) = '1') and I2C_RW_Bit = '0') else '0';

 output_proc: process(MPU_CLK,Reset,WCS,MCS,Start_Det,Stop_Det,I2C_RW_Bit,det_low,bit_cnt2)
 begin
   if(Reset = '0') then
     Abort_Ack    <= '0';
     Error        <= '0';
     I2C_Bus_Busy <= '0';
     Done         <= '0';
     TBE_Set      <= '0';
     RBF_Set      <= '0';
     Bit_Cnt_En   <= '0';
     bit_cnt2     <= '0';
     Byte_Cnt_En  <= '0';
     Start_En     <= '0';
     Stop_En      <= '0';
     Go_Clear     <= '0';
     Read_Buffer  <= "00000000";
     b0 <= '0';
     b1 <= '0';
     s  <= '0';


   elsif(rising_edge(MPU_CLK)) then
     if(abort = '1') then
       Abort_Ack <= '1';
     else  
       Abort_Ack <= '0';
     end if;  
     
     if((WCS(4) = '1')or(RCS(5) = '1')) then      
       Error <= '1';
     else
       Error <= '0';
     end if;

     if(start_det = '1') then
       I2C_Bus_Busy <= '1';
     end if;
     if(stop_det = '1' and I2C_Bus_Busy = '1') then
       I2C_Bus_Busy <= '0';
     end if;

     if((s = '0' and b0 = '0' and b1 = '1') or ( s = '1' and ( b0 = '1' or b1 = '1'))) then
       b0 <= '1';
     else
       b0 <= '0';
     end if;

     if( s = '1' and b0 = '0' and b1 = '0') then
       b1 <= '1';
     else
       b1 <= '0';
     end if;

     if(WCS(1) = '1' and I2C_RW_Bit = '0' and Bit_Count = "001" and Byte_Cnt_Flag = '0' and MCS(3) = '1') then
       s <= '1';
     else
       s <= '0';
     end if;

     if(b0 = '0' and b1 = '1') then
       TBE_Set <= '1';
     else
       TBE_Set <= '0';
     end if;
       
     if(RCS(4) = '1' and I2C_RW_Bit = '1' and MCS(4) = '1') then
       RBF_Set <= '1';
     else
       RBF_Set <= '0';
     end if;
       
     if(((WCS(0) = '1' and MCS_Write_Flag = '1') or (RCS(0) = '1' and MCS_Read_Flag = '1' )) and bit_cnt2 = '1') then
       Bit_Cnt_En <= '1';
     else
       Bit_Cnt_En <= '0';
     end if;

     if((MCS(2) = '1' or MCS(3) = '1' ) and det_low = '1')  then
       bit_cnt2 <= '1';
     elsif(MCS(0) = '1') then
       bit_cnt2 <= '0';
     end if;
       
     if((WCS(3) = '1' and MCS_Write_Flag = '1') or (RCS(2) = '1' and MCS_Read_Flag = '1')) then
       Byte_Cnt_En <= '1';
     else
       Byte_Cnt_En <= '0';
     end if;

     if(MCS(1) = '1'  and det_low = '1' and I2C_Bus_Busy = '0') then
       Start_En <= '1';
     else
       Start_En <= '0';
     end if;

     if(MCS(1) = '1') then
       Go_Clear <= '1';
       Done     <= '0';
       Stop_En  <= '0';
     elsif((MCS(0) = '1' and (WCS(0) = '1' or RCS(2) = '1'))and 
           Bit_Cnt_Flag = '1' and Byte_Cnt_Flag = '1' and det_low = '1' and I2C_Bus_Busy = '1') then
       Done     <= '1';
       Go_Clear <= '0';
       Stop_En  <= '1';
     else
       Go_Clear <= '0';
       Stop_En  <= '0';
     end if;
    
     if(RCS(4) = '1') then
       Read_Buffer  <= Read_SR;
     end if;
 
   end if;
 end process;          
     
                             
 I2C_Det : process(MPU_CLK, Reset, SCL)
 begin
   if(Reset = '0') then
     det_low  <= '0';
     det_high <= '0';
     
   elsif(rising_edge(MPU_CLK)) then 
     if(SCL = '0') then --  data can only change during scl low    
       det_low <= '1';
     else
       det_low <= '0';
     end if;

     if(SCL = '1') then --  data can only change during scl low    
       det_high <= '1';
     else
       det_high <= '0';
     end if;
     

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
男人操女人的视频在线观看欧美 | 久久久久久久久久久久电影| 粉嫩绯色av一区二区在线观看| 亚洲制服丝袜在线| 久久综合中文字幕| 欧美综合一区二区三区| 国产一区91精品张津瑜| 亚洲mv在线观看| 国产精品久久精品日日| 2017欧美狠狠色| 欧美日韩高清一区二区三区| k8久久久一区二区三区 | av在线不卡观看免费观看| 日韩精品三区四区| 一区二区三区.www| 国产精品乱码久久久久久| 精品久久一区二区三区| 欧美日韩日日骚| 色成年激情久久综合| 国产乱码精品一区二区三区av| 视频一区中文字幕国产| 亚洲综合色视频| 国产精品国模大尺度视频| 久久久亚洲精品一区二区三区| 91麻豆精品国产91久久久久久| 在线观看国产日韩| 91免费看`日韩一区二区| 国产91精品欧美| 国产一区欧美二区| 久久不见久久见中文字幕免费| 亚洲va欧美va人人爽| 亚洲国产精品精华液网站| 一区二区三区在线播| 1区2区3区国产精品| 中文字幕av一区二区三区免费看| 久久一区二区三区四区| 欧美电影免费观看高清完整版在线| 欧美人xxxx| 欧美一区在线视频| 日韩一卡二卡三卡| 精品国精品国产尤物美女| 日韩欧美在线一区二区三区| 91麻豆精品国产91久久久资源速度| 在线播放日韩导航| 日韩视频免费观看高清在线视频| 在线播放中文一区| 日韩你懂的在线播放| 欧美一级片在线观看| 欧美电影免费观看高清完整版在线观看 | 国产午夜精品美女毛片视频| 久久亚洲影视婷婷| 国产精品美女一区二区在线观看| 国产精品免费丝袜| 一区二区三区产品免费精品久久75| 亚洲激情中文1区| 亚洲午夜精品一区二区三区他趣| 天堂蜜桃一区二区三区| 免费观看成人av| 国产在线播放一区三区四| 风间由美一区二区av101| av在线不卡免费看| 欧美日韩精品三区| 欧美成人精品二区三区99精品| 久久亚洲欧美国产精品乐播| 亚洲国产精品二十页| 一区二区三区日韩精品视频| 亚洲高清不卡在线| 激情综合亚洲精品| 99精品国产91久久久久久| 欧美日韩在线亚洲一区蜜芽| 日韩一二三区视频| 中文字幕一区二区不卡| 视频精品一区二区| 国产高清不卡一区| 欧美日韩一本到| 国产三级精品三级| 亚洲成av人片一区二区梦乃| 久久成人免费电影| 色天使色偷偷av一区二区 | 亚洲欧美日韩电影| 日韩电影在线观看一区| 国产一区二三区| 欧美影院午夜播放| 久久九九久精品国产免费直播| 一区二区在线免费观看| 久久9热精品视频| 色婷婷国产精品久久包臀| 精品美女一区二区| 亚洲制服丝袜av| 懂色av一区二区三区蜜臀| 7777女厕盗摄久久久| 亚洲欧美综合另类在线卡通| 亚洲国产日韩a在线播放性色| 国产精品自拍在线| 51精品久久久久久久蜜臀| 亚洲人快播电影网| 国产在线观看一区二区 | 国产目拍亚洲精品99久久精品| 亚洲自拍偷拍图区| 成人手机电影网| 日韩午夜小视频| 亚洲高清不卡在线观看| 99久久久精品免费观看国产蜜| 日韩欧美成人一区二区| 中文字幕一区二区在线观看| 精品制服美女丁香| 欧美日韩精品一区二区三区四区| 日韩一区日韩二区| 国产美女精品一区二区三区| 69堂精品视频| 亚洲另类一区二区| caoporn国产精品| 久久亚洲影视婷婷| 美女在线观看视频一区二区| 91美女蜜桃在线| 国产精品久久久久一区| 国产一区啦啦啦在线观看| 欧美久久久影院| 亚洲小说春色综合另类电影| 成人av免费在线观看| 久久久久久久久久美女| 日韩成人免费电影| 欧美四级电影在线观看| 夜夜嗨av一区二区三区四季av | 亚洲精品自拍动漫在线| 懂色av一区二区夜夜嗨| 久久久久国产精品厨房| 经典三级在线一区| 欧美videos大乳护士334| 日韩av中文字幕一区二区| 色噜噜狠狠成人中文综合| 亚洲同性同志一二三专区| 成人黄色综合网站| 国产精品久久久久久久久久免费看 | 欧美一区二区精品| 亚洲另类在线视频| 在线中文字幕不卡| 一区二区三区久久| 91在线观看污| 国产精品成人午夜| 99久久综合狠狠综合久久| 精品盗摄一区二区三区| 丝袜诱惑制服诱惑色一区在线观看 | 三级不卡在线观看| 91麻豆精品国产91久久久久久 | 性做久久久久久免费观看| 在线观看www91| 亚洲bdsm女犯bdsm网站| 91精品国产综合久久国产大片| 石原莉奈在线亚洲二区| 欧美一级黄色录像| 国产一区二区三区日韩| 中文字幕av不卡| 91国内精品野花午夜精品 | 五月天丁香久久| 欧美丰满嫩嫩电影| 精品一区二区三区免费视频| 国产亚洲欧美色| 91毛片在线观看| 日日夜夜精品视频免费| 久久一区二区三区国产精品| 成人免费看的视频| 一区二区不卡在线视频 午夜欧美不卡在| 欧美日韩三级在线| 极品少妇xxxx精品少妇偷拍| 国产亚洲视频系列| 91蜜桃网址入口| 青青草原综合久久大伊人精品| 久久新电视剧免费观看| 99九九99九九九视频精品| 日韩激情一区二区| 久久精品日产第一区二区三区高清版 | 亚洲人成在线播放网站岛国 | 日韩你懂的在线播放| 丁香婷婷深情五月亚洲| 亚洲综合色成人| 久久一夜天堂av一区二区三区| av男人天堂一区| 青青草成人在线观看| 国产精品视频一二三区| 欧美日韩成人综合天天影院 | 日韩午夜电影av| 99re这里都是精品| 天天色 色综合| 国产精品电影一区二区| 欧美精品国产精品| 成人动漫一区二区| 日日嗨av一区二区三区四区| 日本一区二区三区四区在线视频| 欧美写真视频网站| 国产精品99久久久久久似苏梦涵| 一二三四社区欧美黄| 久久久精品一品道一区| 欧美精品1区2区3区| 99久久国产综合色|国产精品| 日本美女一区二区三区| 亚洲另类春色国产| 欧美激情一区在线| 日韩美女视频在线| 97久久超碰精品国产|