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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? i2c_slave.vhd

?? IIC的IP.這是經(jīng)過(guò)驗(yàn)證的源代碼
?? VHD
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
--------------------------------------------
-- Input De-Mux
inmux :process(clk,rst_l)
begin 
 if (rst_l = '0') then 
   in_reg <= "00000000";
 elsif(rising_edge(clk)) then
   if (in_reg_enable = '1') then 
     case bit_counter is
       when "0000" =>
          in_reg(7) <= sda_reg_delayed;
       when "0001" =>
          in_reg(6) <= sda_reg_delayed;
       when "0010" =>
          in_reg(5) <= sda_reg_delayed;
       when "0011" =>
          in_reg(4) <= sda_reg_delayed;
       when "0100" =>
          in_reg(3) <= sda_reg_delayed;
       when "0101" =>
          in_reg(2) <= sda_reg_delayed;
       when "0110" =>
          in_reg(1) <= sda_reg_delayed;
       when "0111" =>
          in_reg(0) <= sda_reg_delayed;
       when others =>
          in_reg <= in_reg;
     end case;
   else
     in_reg <= in_reg;
   end if;
 end if;
end process;

--------------------------------------------


--------------------------------------------
-- I2C Slave State Machine
slave_state_machine : process(clk,rst_l)
variable L:line;
variable cnt : std_logic_vector(7 downto 0);
begin 

  if (rst_l = '0') then 
      current_state  <= idle;
      next_state     <= idle;
      r_w_bit        <= '0';
      out_reg        <= "00000000";
      out_en         <= '0'; -- disable output
      bit_counter    <= "0000";
      word_address   <= "00000000"; -- initialize byte #
      word_add_flag  <= '0';
      ack_flag       <= '0';
      in_reg_enable  <= '0';
      temp_add_upper <= "0000000";
      temp_add_lower <= "00000000";
      read_10_flag   <= '0';
      hit_10_upper   <= '0';
      hit_10_lower   <= '0';
      hit_7          <= '0';
      sda_out2       <= '0';

-- initialize the mem array
    write(L,now, justified => right, field=>10,unit=>ns);
    write(L,string'(" Initializing Memory "));
    writeline(output,L);   
    cnt := "00000000";
    for I in 0 to 255 loop
      mem(I) <= cnt;  
      cnt := cnt + '1';
    end loop;
-- initialize the mem array
    write(L,now, justified => right, field=>10,unit=>ns);
    write(L,string'(" Done Initializing Memory "));
    writeline(output,L);   

  elsif(rising_edge(clk)) then
    case current_state is
      when idle =>
              sda_out2 <= '0';
              if (start_detect = '1' and scl1 = '1') then 
                current_state <= start;
              else
                current_state <= idle;
                in_reg_enable <= '0';
              end if;
      when start =>
              sda_out2 <= '0';
              if (start_detect = '1' and scl1 = '1') then 
                current_state <= start;
              end if;
        
              if (stop_detect = '1' and scl1 = '1') then
                current_state <= idle;

              elsif (scl_pulse = '1') then
                  bit_counter <= "0000";
                  in_reg_enable <= '1';

              elsif (in_reg_enable = '1') then
                  in_reg_enable <= '0'; 
                  bit_counter <= bit_counter + '1';
                  current_state <= address;
-- clear all the address hit flags
                  hit_7 <= '0';
                  hit_10_upper <= '0';
                  hit_10_lower <= '0';
                  word_add_flag <= '0';
                  ack_flag <= '0';
              end if;

      when address =>
        
                if (start_detect = '1' and scl1 = '1') then 
                  current_state <= start;
                  ack_ctrl <= '0';
                  sda_out2 <= '0' after 2 ns;
        
                elsif (stop_detect = '1' and scl1 = '1') then
                  current_state <= idle;
                  ack_ctrl <= '0';
                  sda_out2 <= '0' after 2 ns;
 
                elsif (scl_pulse = '1' and (bit_counter <= "1000")) then                
                  in_reg_enable <= '1';
                  ack_ctrl <= '0';
                  sda_out2 <= '0' after 2 ns;
        
                elsif (in_reg_enable = '1') then 
                  in_reg_enable <= '0'; 
                  bit_counter <= bit_counter + '1';
                  current_state <= address;
                  ack_ctrl <= '0';
                  sda_out2 <= '0' after 2 ns;
        
                elsif (bit_counter = "1000" and address_mode = seven_bit) then 
-- determine if r or w and set r_w_bit
                  if (in_reg(7 downto 1) = address_reg_7) then 
                    r_w_bit <= in_reg(0);
                    current_state <= ack;
                    hit_7 <= '1';
                    ack_flag <= '0'; -- used in ack state
                    ack_ctrl <= '0';
                    sda_out2 <= '0' after 2 ns;
                  else 
-- the address is not for this slave                 
                    ack_ctrl <= '1';
                    sda_out2 <= '1' after 2 ns;
                    current_state <= idle;
                  end if;
        
-- check if upper address byte is a hit in 10 bit addressing
                elsif (bit_counter = "1000" and address_mode = ten_bit and hit_10_upper = '0') then
-- first time checking upper hit
                  if (in_reg(7 downto 1) = address_reg_10_upper) then 
                    ack_ctrl <= '0';
                    sda_out2 <= '0' after 2 ns;
                    r_w_bit <= in_reg(0);
                    current_state <= ack;
                    hit_10_upper <= '1';
                    ack_flag <= '0'; -- used in ack state
                    if (in_reg(0) = '0') then
                      temp_add_upper <= in_reg(7 downto 1);
                      read_10_flag <= '0'; -- clear
                    elsif ((in_reg(0) = '1') and (temp_add_upper = in_reg(7 downto 1))
                            and (temp_add_lower = address_reg_10_lower) ) then
-- This flag is set because the last 10 bit addressing 
-- mode write was for this slave, so this read only 
-- requires a match of the first byte of addressing
                      read_10_flag <= '1'; -- set             
                    end if;
                  else 
-- the address is not for this slave
                    ack_ctrl <= '1';
                    sda_out2 <= '1' after 2 ns;
                    current_state <= idle;
                    temp_add_upper <= in_reg(7 downto 1); -- holds value of last
                                                  -- upper add
                    read_10_flag <= '0'; -- clear
                  end if;

        
-- check if lower address byte is a hit in 10 bit addressing
                elsif (bit_counter = "1000" and address_mode = ten_bit and hit_10_upper = '1') then
-- is the lower address a hit?
                  if (in_reg(7 downto 0) = address_reg_10_lower) then
                    current_state <= ack;
                    hit_10_lower <= '1';
                    ack_flag <= '0'; -- used in ack state
                    temp_add_lower <= in_reg(7 downto 0);
                    ack_ctrl <= '0';
                    sda_out2 <= '0' after 2 ns;
                  else 
-- the address is not for this slave
                    ack_ctrl <= '1';
                    sda_out2 <= '1' after 2 ns;
                    current_state <= idle;
                    temp_add_lower <= in_reg(7 downto 0);
                  end if; 
                end if;  
 
      when ack =>
-- starts with scl high
          ack_ctrl <= '0';
          sda_out2 <= '0' after 2 ns;   
-- if we get a start goto start
              if (start_detect = '1' and scl1 = '1') then
                  current_state <= start;


-- if there is a stop goto idle
              elsif (stop_detect = '1' and scl1 = '1') then
                  current_state <= idle;

-- if there is an address hit acknowledge the address 
              elsif (((hit_7 = '1') or (hit_10_upper = '1') or (hit_10_lower = '1')) 
                       and scl_neg_pulse = '1' and ack_flag = '0') then 
                 out_en <= '1' after 2 ns; -- turn on OE
                 ack_flag <= '1';
        
-- once the acknowledge is presented turn off the OE
-- print the address, and goto address or data depending on
-- addressing mode
              elsif (((hit_7 = '1') or (hit_10_upper = '1') or (hit_10_lower = '1')) 
                       and scl_neg_pulse = '1' and ack_flag = '1' ) then 
                 out_en <= '0' after 2 ns; -- turn off OE
                 bit_counter <= "0000";

                 
                 if (hit_10_upper = '1' and hit_10_lower = '0') then
                 write(L,now, justified => right, field=>10,unit=>ns);
                 write(L,string'(" 10 bit addressing Upper address is "));
                 write(L, in_reg);
                 writeline(output,L);   

                  if (read_10_flag = '0') then 
                    current_state <= address;
                  elsif (read_10_flag = '1') then
-- going to the data state because a read in 10 bit
-- addressing only requires a hit on the upper address if
-- the last write was a hit.
                    current_state <= data;
                  end if;
                 elsif (hit_7 = '1' or hit_10_lower = '1') then
-- hit_10_lower or hit_7 
                  current_state <= data;
                  if (hit_10_lower = '1') then
                    write(L,now, justified => right, field=>10,unit=>ns);
                    write(L,string'(" 10 bit addressing Lower address is  "));
                    write(L, in_reg);
                    writeline(output,L);   

                  elsif (hit_7 = '1') then
                    write(L,now, justified => right, field=>10,unit=>ns);
                    write(L,string'(" 7 bit addressing & address is "));
                    write(L, in_reg);
                    writeline(output,L);   
                  end if;
                 end if;                 
 
-- if there is no hit, return to idle
              elsif (hit_7 = '0' and hit_10_upper = '0' and hit_10_lower = '0') then
-- no_ack
                 out_en <= '0' after 2 ns;
                 bit_counter <= "0000";
                 current_state <= idle;

              end if;
 
      when data =>
              ack_ctrl <= '0';
              sda_out2 <= '0' after 2 ns; 
-- starts with scl low
              if (start_detect = '1' and scl1 = '1') then
                  current_state <= start;
        
              elsif (stop_detect = '1' and scl1 = '1') then
                current_state <= idle;

-- write data
              else -- outer else
                if (r_w_bit = '0' and scl_pulse = '1' and (bit_counter <= "1000") ) then
-- write
                  in_reg_enable <= '1';
                elsif (r_w_bit = '0' and in_reg_enable = '1' and (bit_counter <= "1000")) then
-- write more
                  in_reg_enable <= '0'; 
                  bit_counter <= bit_counter + '1';
                  current_state <= data;
                elsif (r_w_bit = '0' and (bit_counter = "1000")) then
-- write last bit
                   in_reg_enable <= '0'; -- disable
                   current_state <= data_ack;
                   ack_flag <= '0'; -- used in data_ack state
                   if (word_add_flag = '0') then 
                     word_address <= in_reg;
                     word_add_flag <= '1'; -- set the flag
                   else 
                     mem(to_integer(unsigned(word_address))) <= in_reg;
                     word_address <= word_address + '1';
                   end if;
-- read data
                elsif (r_w_bit = '1' and (bit_counter = "0000") and scl_neg_pulse = '0') then 
-- read first bit of word
-- scl is low at start of read
                   out_en <= '1' after 2 ns; -- turn on OE
                   out_reg <= mem(to_integer(unsigned(word_address)));
                elsif (r_w_bit = '1' and (bit_counter < "0111") and scl_neg_pulse = '1') then 
-- set up next bit
                    bit_counter <= bit_counter + '1';
                elsif (r_w_bit = '1' and (bit_counter = "0111") and scl_neg_pulse = '1') then 
-- we already output the last bit
                  bit_counter <= "0000";
                  out_en <= '0' after 2 ns; -- turn off OE
                  word_address <= word_address + '1';
                  current_state <= data_ack;
                  ack_flag <= '0'; -- used in data_ack state
                end if;
              end if; -- outer else
 
      when data_ack =>

              if (start_detect = '1' and scl1 = '1') then
                  current_state <= start;
                  ack_ctrl <= '0';
                  sda_out2 <= '0' after 2 ns; 
              elsif (stop_detect = '1' and scl1 = '1') then
                  current_state <= idle;
                  ack_ctrl <= '0';
                  sda_out2 <= '0' after 2 ns;
-- starts with scl high on write
              elsif ( r_w_bit = '0' and scl_neg_pulse = '1' and ack_flag = '0') then
                 write(L,now, justified => right, field=>10,unit=>ns);
                 write(L,string'(" Slave Data Received on write is "));
                 write(L, in_reg);
                 writeline(output,L);   
                 out_en <= '1' after 2 ns; -- turn on OE
                 ack_ctrl <= '1';
                 sda_out2 <= '0' after 2 ns;
                 ack_flag <= '1';
              elsif ( r_w_bit = '0' and scl_neg_pulse = '1' and ack_flag = '1' ) then
                 out_en <= '0' after 2 ns; -- turn off OE
                 ack_ctrl <= '1';
                 sda_out2 <= '1' after 2 ns;
                 bit_counter <= "0000";
                 current_state <= data; 
        
-- starts with scl low on read
              elsif (r_w_bit = '1' and scl_pulse = '1') then 
-- check sda for ack now
                 write(L,now, justified => right, field=>10,unit=>ns);
                 write(L,string'(" Slave Data transmitted on read is "));
                 write(L, out_reg);
                 writeline(output,L);   
                 ack_ctrl <= '0';
                 sda_out2 <= '0' after 2 ns;

                   if (sda1 = '0') then
                     next_state <= data;
                     bit_counter <= "0000";
                     write(L,now, justified => right, field=>10,unit=>ns);
                     write(L,string'(" Master ACK'd on a Data Read, returning to Data "));
                     writeline(output,L);   

                     ack_flag <= '1';
                   elsif (sda1 = '1') then
                     write(L,now, justified => right, field=>10,unit=>ns);
                     write(L,string'(" No ACK on a Data Read, returning to Idle "));
                     writeline(output,L);   
                     next_state <= idle;
                     ack_flag <= '1';
                   end if;
                elsif (r_w_bit = '1' and ack_flag = '0') then
                  out_en <= '0' after 2 ns; -- turn off OE
                elsif (r_w_bit = '1' and scl_neg_pulse = '1') then
                  current_state <= next_state;
                end if;
 
      when others =>
                ack_ctrl <= '0';
                sda_out2 <= '0' after 2 ns; 
                if (start_detect = '1' and scl1 ='1') then
                  current_state <= start;
                elsif (stop_detect = '1' and scl1 = '1') then
                  current_state <= idle;
                else 
                  current_state <= idle;
                  write(L,now, justified => right, field=>10,unit=>ns);
                  write(L,string'(" Something is broken is the SM returning to idle "));
                  writeline(output,L);   
                end if;
    end case;
  end if;
end process;

end behave;

--------------------------------- E O F --------------------------------------

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
天堂蜜桃91精品| 怡红院av一区二区三区| 91在线观看高清| 青草av.久久免费一区| 中文字幕国产一区二区| 欧美人与z0zoxxxx视频| 99视频有精品| 国产精品中文字幕日韩精品| 午夜精品久久久久久久久久久 | 国产一区二区网址| 亚洲综合激情另类小说区| 久久久久免费观看| 欧美一级日韩一级| 精品视频123区在线观看| 99热在这里有精品免费| 国产精品99久久久久久有的能看| 日韩电影在线观看一区| 亚洲激情在线激情| 国产精品国产a| 国产欧美日韩另类视频免费观看| 欧美变态口味重另类| 欧美日韩国产综合视频在线观看 | 成人精品在线视频观看| 狠狠色狠狠色合久久伊人| 日本免费在线视频不卡一不卡二| 一区二区三区中文在线观看| 一色屋精品亚洲香蕉网站| 国产欧美一区二区三区在线看蜜臀| 日韩欧美国产一区二区三区| 欧美二区三区91| 欧美高清一级片在线| 欧美另类一区二区三区| 在线不卡免费av| 337p亚洲精品色噜噜噜| 欧美丰满高潮xxxx喷水动漫| 欧美日韩中文字幕精品| 欧美精品粉嫩高潮一区二区| 欧美人与禽zozo性伦| 91精品免费观看| 日韩美女视频一区二区在线观看| 欧美白人最猛性xxxxx69交| 日韩欧美123| 精品国产百合女同互慰| 久久久影院官网| 国产欧美日韩亚州综合 | 日本视频一区二区| 男人的天堂亚洲一区| 开心九九激情九九欧美日韩精美视频电影 | 欧美一区二区三区精品| 777亚洲妇女| 日韩欧美一区二区视频| 久久老女人爱爱| 国产欧美一区二区精品性色超碰| 国产午夜一区二区三区| 国产欧美一区二区精品婷婷| 日韩理论在线观看| 亚洲精品一卡二卡| 亚洲第一电影网| 蜜桃在线一区二区三区| 国产麻豆精品视频| 99久久99久久精品免费观看| 91免费国产在线| 欧美性生活影院| 日韩免费在线观看| 欧美国产日韩亚洲一区| 中文字幕日韩一区| 日韩精品1区2区3区| 国产一区二区三区免费| 国产不卡视频一区二区三区| 色网站国产精品| 日韩一卡二卡三卡四卡| 欧美精品一区二区精品网| 亚洲欧洲国产日韩| 一区二区在线看| 日韩激情一二三区| 国产一区二区三区免费看| 91久久精品一区二区二区| 欧美一区二区三区成人| 国产精品视频一二三区| 亚洲第一激情av| 国产真实精品久久二三区| 日本精品一区二区三区四区的功能| 欧洲亚洲国产日韩| 久久综合九色欧美综合狠狠 | 国产精品欧美一区二区三区| 五月婷婷综合在线| 成人国产免费视频| 91精品福利在线一区二区三区 | 一区二区三区在线免费观看| 极品少妇xxxx偷拍精品少妇| 一本久道中文字幕精品亚洲嫩| 精品久久久久一区| 亚洲自拍偷拍av| 成人免费观看视频| 日韩欧美激情一区| 一区二区三区四区国产精品| 国产精品99久久久久久宅男| 欧美日韩一级二级| 国产精品久久久久久久久晋中| 麻豆精品一区二区三区| 一本色道久久综合狠狠躁的推荐| 精品捆绑美女sm三区| 亚洲成年人影院| 色综合久久天天| 国产欧美日韩综合| 亚洲高清久久久| 91免费视频观看| 国产精品视频yy9299一区| 久久se精品一区精品二区| 欧美日韩国产天堂| 樱花草国产18久久久久| 99久久99久久免费精品蜜臀| 欧美电影免费观看高清完整版| 亚洲成人午夜电影| 色综合欧美在线| 国产精品进线69影院| 国产成人免费在线视频| 欧美成人a在线| 奇米一区二区三区av| 欧美日本一区二区三区四区| 一区二区三区精品| 91视视频在线直接观看在线看网页在线看| 久久毛片高清国产| 国产一区二区三区在线观看免费| 日韩精品中午字幕| 日本中文字幕一区二区视频| 欧美色图在线观看| 亚洲午夜久久久久久久久电影院| 91麻豆国产精品久久| 中文字幕一区二区视频| 不卡大黄网站免费看| 国产精品久久久久久亚洲伦| 成人高清在线视频| 日韩一区欧美一区| aaa欧美大片| 成人欧美一区二区三区| 91视频观看视频| 亚洲欧美在线视频观看| 99久久国产免费看| 亚洲精品菠萝久久久久久久| 91福利精品视频| 天堂成人免费av电影一区| 欧美疯狂性受xxxxx喷水图片| 青青草精品视频| 久久这里只有精品视频网| 国产精品乡下勾搭老头1| 欧美激情在线一区二区三区| 成人国产精品免费观看动漫| 亚洲色图欧洲色图婷婷| 一本在线高清不卡dvd| 亚洲成人综合网站| 日韩精品影音先锋| 国产精品一区久久久久| 国产精品国产自产拍高清av| 一本大道久久精品懂色aⅴ| 亚洲综合图片区| 欧美一区2区视频在线观看| 久久成人免费电影| 国产精品日韩成人| 欧美色视频在线| 国产裸体歌舞团一区二区| 中文字幕成人在线观看| 91亚洲男人天堂| 天天操天天综合网| 久久蜜臀精品av| 色婷婷亚洲精品| 麻豆91精品91久久久的内涵| 国产精品免费视频观看| 精品视频123区在线观看| 国产一区二区三区国产| 亚洲男同性视频| 欧美一区二区播放| av成人免费在线| 免费成人在线视频观看| 中文字幕精品三区| 91精品国产综合久久蜜臀| 粉嫩蜜臀av国产精品网站| 亚洲一区在线观看视频| 久久久久久免费网| 在线一区二区视频| 国产一区二区三区四区在线观看| 亚洲另类在线制服丝袜| 精品国内片67194| 在线一区二区三区四区五区 | 中文字幕va一区二区三区| 欧美日韩精品电影| 不卡区在线中文字幕| 日本欧美在线观看| 亚洲嫩草精品久久| 国产视频一区在线观看 | 91精品国产福利在线观看| 成人av免费在线观看| 青青草伊人久久| 一区二区三区精品视频在线| 国产欧美一区二区精品秋霞影院| 欧美精品欧美精品系列| 色综合久久66| 成人午夜大片免费观看| 麻豆精品国产传媒mv男同 | 亚洲一区中文在线|