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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? up_model.vhd

?? IIC的IP.這是經過驗證的源代碼
?? VHD
?? 第 1 頁 / 共 2 頁
字號:
    cs_l     <= '0';
  wait until ack_l = '0';
  wait until rising_edge(clk);
    cs_l     <= '1';
  wait until rising_edge(clk);
    RWL  <= '1';
end clear_iack; 
  


--// write two byte test

-- this test writes to address "low_add"
-- to access the slave device. The first byte
-- of data written to the slave sets up the 
-- word pointer, and the second byte writes
-- data to the location pointed to inside
-- the slave by the address written into the 
-- word pointer.  The tasks passed a value of
-- 1 to use interrupts, and 0 to use polling mode.
-- Then low_add is the address  of the slave, 
-- and byte1 is the first byte written, and
-- byte2 is the second byte written.

procedure  write_two_byte_test
           (int_on   : in std_logic; --// a 1 uses interrupts, a 0 polling
            low_add  : in std_logic_vector(6 downto 0);
            byte1    : in std_logic_vector(7 downto 0);
            byte2    : in std_logic_vector(7 downto 0)) is
 variable L : line;
begin
 
    write(L,now, justified => right, field=>10,unit=>ns);
    write(L, string'(" << Starting the write_two_byte_test >> "));
    writeline(output,L);   

--  // set up the lower address buffer

  write_low_add(low_add & '0');
 
--  // write the upper address
--  // just initialize as zero's
  write_upper_add("00000000");
  
--  // write byte count with 2
  write_byte_count("00000010"); 

 
--  // write the data buffer
--  // this will be the value written into the 
--  // word pointer inside the model
  write_data_buf(byte1);
 
--  // write the command reg
--  // if interrupts are enabled turn them on
--  // else use polling mode.
--  // either way, set the GO bit.
 
  if (int_on = '1') then 
     write_command_reg("10000011"); --// go & int's on, and 7 bit addr 
  elsif (int_on = '0') then 
     write_command_reg("10000000"); --// go & polling, and 7 bit addr
  else 
    write(L,now, justified => right, field=>10,unit=>ns);
    write(L, string'(" ERROR write_two_byte_test passed and illegal value!! "));
    writeline(output,L);   

    num_errors <= num_errors + 1;
--    $stop;
  end if;
 
--  // so at this point the I2C controller should start it's
--  // transactions.  Address phase, and then writing the first byte of data.
--  // so, at some point the controller will set the trans_buffer_empty flag.
--  // Then the uP will write the next byte of data, which will be byte2.
--  // The following section checks for  the empty flag in the status register
--  // before writing the next byte.  This is done differently in interrupt
--  // and polling mode.
 
  
  if (int_on = '1') then 
--   // interrupt section
 
   wait for 10000 ns; --#10000; // waiting 100 us till address phase is done.
    
--   // initialize loop variables
   cntr2 <= "00000000000000";--13'h0;
   int_flag <= 0;
   
   while ((cntr2 /= "11111111111111") and (int_flag = 0)) loop
     wait until rising_edge(clk);
      if (intr_l = '0') then
--        // we have an interrupt so read status
        int_flag <= 1;
        read_status_reg('0',data_ret);
        
        if (data_ret(1) = '1') then 
--          // clear iack
          clear_iack;
--        // writing next data word.
          write_data_buf(byte2);
        elsif (data_ret(1) = '0') then 
          write(L,now, justified => right, field=>10,unit=>ns);
          write(L, string'(" ERROR: Recieved an Interrupt and expected the Transmit Buffer Empty Flag to be set, but its not"));
          writeline(output,L);   

          num_errors <= num_errors + 1;
        end if;
      else 
--      // no interrupt yet so count up
        cntr2 <= cntr2 + 1;
      end if;
   end loop; --// end of while
 
   if (cntr2 = "11111111111111") then
    write(L,now, justified => right, field=>10,unit=>ns);
    write(L, string'(" ERROR: cntr expired waiting for an Interrupt! Second Byte of Data Not Sent"));
    writeline(output,L);   

     num_errors <= num_errors + 1;
   end if;
   
--  end of interrupt section
 
 
  elsif (int_on = '0') then
--   // polling section
  
   
   wait for 100000 ns; --#100000; // waiting 100 us till address phase is done.
   
--   // initialize some variables
   cntr2 <= "00000000000000";--13'h0;
   empty_flag <= 0;
   
--   // start checking status
   while ((cntr2 /= "11111111111111") and (empty_flag = 0)) loop
     wait until rising_edge(clk);
     wait until rising_edge(clk);
--      // read the status
      read_status_reg('0',data_ret);
      
      if (data_ret(1) = '1') then
--        // we have an empty flag so write the next data word
        empty_flag <= 1;
--        // writing next data word.
        write_data_buf(byte2);
      else 
--       // status says no empty flag
        cntr2 <= cntr2 + 1;
      end if;
   end loop; --// end of while
 
   if (cntr2 = "11111111111111") then
    write(L,now, justified => right, field=>10,unit=>ns);
    write(L, string'(" ERROR: cntr expired waiting for Empty Flag! Second Byte of Data Not Sent"));
    writeline(output,L);   

     num_errors <= num_errors + 1;
   end if;
     
--  end of the polling section
  end if;
 
 
  wait for 200000 ns; --#200000; // kill some time
 

--  // check for done bit before continuing

  
  check_done; 
 
  
  
end write_two_byte_test;

--//------------------------------------------------------------------------
--// read_two_byte_test
procedure read_two_byte_test
          (int_on : in std_logic;
           low_add : in std_logic_vector(6 downto 0);
           word_pointer : in std_logic_vector(7 downto 0);
           byte1 : in std_logic_vector(7 downto 0)) is
   variable L : line;
  begin 
    
-- This test starts by accessing the slave at the 
-- value in "low_add". Then writing the word pointer to the 
-- value in "word_pointer".  Then it will read from the slave
-- at address "low_add".  The first data word it will expect 
-- back is "byte1".  Then the second byte it will expect back is
-- "word_pointer" + 1.  This is because the memory array inside
-- the I2C slave model is stored with address equals data.
-- This means the address of the location after the first read
-- will be "word_pointer" + 1. Since the address equals data
-- the data we expect back is "word_pointer" + 1;
 
  
 
    write(L,now, justified => right, field=>10,unit=>ns);
    write(L, string'(" << Starting the read_two_byte_test >> "));
    writeline(output,L);   
 
--  // set up the lower address buffer
--  // {low_add,1'b0} 1'b0 is for write
  write_low_add(low_add & '0');
 
--  // write the upper address
--  // just initialize as zero's
  write_upper_add("00000000");
  
--  // write byte count with 1
--  // because we are only writing to the 
--  // word_pointer
  write_byte_count("00000001");
 
--  // write the data buffer
--  // this will be the value written into the 
--  // word pointer inside the model
  write_data_buf(word_pointer);
 
--  // write the command reg
--  // if interrupts are enabled turn them on
--  // else use polling mode.
--  // either way, set the GO bit.
 
  if (int_on = '1') then 
     write_command_reg("10000011"); --// go & int's on, and 7 bit addr 
  elsif (int_on = '0') then 
     write_command_reg("10000000"); --// go & polling, and 7 bit addr
  else  
    write(L,now, justified => right, field=>10,unit=>ns);
    write(L, string'(" ERROR: read_two_byte_test passed and illegal value!"));
    writeline(output,L);   
    num_errors <= num_errors + 1;
--    $stop;
  end if;
 
 
--  // all right, at this point the I2C controller should be writing the
--  // word pointer. 
 
 
  wait for 200000 ns; --#200000; // waiting 200000 ns till cycle is done.
 

--  // check for done bit before continuing
  
  check_done;
 
 
 
--  // the word_pointer should contain "word_pointer"
 
--   // Now execute a 2 byte read
   
--  // set up the lower address buffer
--  // {low_add,1'b1}   1'b1 is for read
  write_low_add(low_add & '1');
  
  
--  // write byte count with 2
--  // we are reading back 2 bytes 
  write_byte_count("00000010");--8'h2);
 
--  // write the command reg
--  // if interrupts are enabled turn them on
-- // else use polling mode.
--  // either way, set the GO bit.
 
  if (int_on = '1') then 
     write_command_reg("10000011"); --// go & int's on, and 7 bit addr 
  elsif (int_on = '0') then 
     write_command_reg("10000000"); --// go & polling, and 7 bit addr
  end if;
 
 
  if (int_on = '1') then 
--    // interrupt section
   
   wait for 100000 ns; --#100000; // waiting 100 us till address phase is done.
 
 
  for I in 0 to 1 loop  
    --// wait 100us for data read to finish
 
 wait for 100000 ns; --#100000;
    
--     // initialize loop variables
     cntr3 <= "00000000000000"; --13'h0;
     int_flag <= 0;
    
    while ((cntr3 /= "11111111111111") and (int_flag = 0)) loop 
     wait until rising_edge(clk);
        if (intr_l = '0') then 
--          // we have an interrupt so read status
          int_flag <= 1;
          read_status_reg('0',data_ret);
        
          if (data_ret(0) = '1') then 
            --// receive buffer is full
            --// clear iack
            clear_iack;
            --// read data_buf.

            if (I = 0) then 
              read_data_buf(byte1, not_used);
            elsif (I = 1) then
              read_data_buf((word_pointer + 1), not_used);
            end if;
          end if;

           if (data_ret(0) = '0') then
             write(L,now, justified => right, field=>10,unit=>ns);
             write(L, string'(" ERROR:recieved an Interrupt and expected the Receive Buffer Full Flag to be set, but its not"));
             writeline(output,L);   

            num_errors <= num_errors + 1;
           end if;
        else 
--        // no interrupt yet so count up
          cntr3 <= cntr3 + 1;
        end if;
     end loop;--// end of while
 
     if (cntr3 = "11111111111111") then 
       write(L,now, justified => right, field=>10,unit=>ns);
       write(L, string'(" ERROR: cntr expired waiting for an Interrupt! Data Not Received"));
       writeline(output,L);   

       num_errors <= num_errors + 1;
     end if;
 
  end loop; --// end of "for" loop
  
-- end of interrupt section
 
  elsif (int_on = '0') then 
 
--   // polling section
 
   wait for 100000 ns;--#100000; // waiting 100 us till address phase is done.
 
 
  for I in 0 to 3 loop
--     // wait 100us for data read to finish
 
  wait for 100000 ns; --#100000;
 
--  // initialize loop variables
     cntr3 <= "00000000000000";
     full_flag <= 0;
   
    while ((cntr3 /= "11111111111111") and (full_flag = 0)) loop
     wait until rising_edge(clk);
          read_status_reg('0',data_ret);
        
        if (data_ret(0) = '1') then
--            // receive buffer is full
--          // read data_buf.
            full_flag <= 1;
            if (I = 0) then 
              read_data_buf(byte1, not_used);
            elsif (I = 1) then 
              read_data_buf((word_pointer + 1), not_used);
            end if;
        else 
--        // buffer is not full yet
          cntr3 <= cntr3 + 1;
        end if;
     end loop; --// end of while
 
     if (cntr3 = "11111111111111") then 
       write(L,now, justified => right, field=>10,unit=>ns);
       write(L, string'(" ERROR: cntr expired waiting for Full Flag! Data Not Received"));
       writeline(output,L);   

       num_errors <= num_errors + 1;
     end if;
 
  end loop;--// end of "for" loop
   
  end if;  
--   end of polling section
 
--  // check for done bit before continuing

  
  check_done;
 
  
  end read_two_byte_test; --// end of the procedure



begin
num_errors <= 0;        
data_out <= "00000000"; 
RWL <= '1';             
cs_l <= '1';            
addr <= "ZZZ";

wait for 10 ns;
wait until reset_l = '1'; --// wait for reset to be deasserted
wait until rising_edge(clk);
 
--// execute the write_two_byte_test interrupt mode
--// slave responds to 7'b1010_000 
--// byte1 is 0A, and byte2 is BB
  write_two_byte_test('1', "1010000", "00001010", "10111011");
--//  write_two_byte_test(0, 7'b1010_000, 8'h0A, 8'hBB );

--// next run the read_two_byte_test in interrupt mode
--// slave responds to 7'b1010_000 bit 
--// word_pointer is set to 8'h0A
--// byte1 is set to 8'hBB
  read_two_byte_test('1', "1010000", "00001010", "10111011" );


--// execute the write_two_byte_test polling mode
--// slave responds to 7'b1010_000 
--// byte1 is 8'h10, and byte2 is 8'hFF
--//   write_two_byte_test(0, 7'b1010_000, 8'h10, 8'hFF);


--// next run the read_two_byte_test in polling mode
--// slave responds to 7'b1010_000 bit 
--// word_pointer is set to 8'h10
--// byte1 is set to 8'hFF
--//   read_two_byte_test(0, 7'b1010_000, 8'h10, 8'hFF); 


--// check the number of errors
error_check;


--// stop the simulation
--$stop;

end process;



end behave;

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

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
99久久99久久精品免费看蜜桃| 色综合欧美在线视频区| 成人午夜视频网站| 欧美日韩国产综合视频在线观看 | 久久99精品国产91久久来源| 国产成人亚洲综合a∨婷婷| 欧美视频自拍偷拍| 国产精品另类一区| 麻豆精品蜜桃视频网站| 欧美日韩午夜在线| 日韩一区有码在线| 成人性生交大片免费| 精品免费日韩av| 亚洲aⅴ怡春院| 色乱码一区二区三区88| 国产午夜精品在线观看| 精品亚洲国产成人av制服丝袜| 欧美亚洲一区三区| 亚洲欧美偷拍另类a∨色屁股| 国产a视频精品免费观看| 日韩欧美黄色影院| 老司机精品视频线观看86| 这里是久久伊人| 午夜精品一区二区三区免费视频| 色婷婷精品大在线视频| 亚洲欧美在线aaa| www.99精品| 亚洲欧美区自拍先锋| 色综合天天综合网天天狠天天| 国产精品沙发午睡系列990531| 国产精品亚洲第一区在线暖暖韩国| 欧美一二三区在线| 国内久久婷婷综合| 国产日本欧洲亚洲| 成人av在线电影| 1024亚洲合集| 91网上在线视频| 一区二区三区中文字幕精品精品| 91蜜桃免费观看视频| 悠悠色在线精品| 欧美日韩一区不卡| 毛片一区二区三区| 久久久久久影视| 不卡的电影网站| 亚洲线精品一区二区三区 | www.日本不卡| 亚洲激情在线激情| 欧美绝品在线观看成人午夜影视| 日韩av中文字幕一区二区三区| 日韩美女视频在线| 国产不卡一区视频| 亚洲欧美日韩一区二区| 欧美日韩色一区| 久久国产精品免费| 国产精品女同一区二区三区| 91麻豆免费看片| 天天射综合影视| 久久精品水蜜桃av综合天堂| 99re热这里只有精品视频| 亚洲高清久久久| 久久婷婷国产综合国色天香| av在线不卡电影| 日本午夜精品一区二区三区电影| 久久精品欧美日韩| 欧美在线观看一区二区| 久久99日本精品| 一区二区三区精品视频| 精品福利在线导航| 91黄视频在线| 国产.欧美.日韩| 亚洲成人午夜影院| 国产精品久久久久久久午夜片 | 不卡在线观看av| 五月天精品一区二区三区| 亚洲国产精品成人久久综合一区| 日本国产一区二区| 国产高清亚洲一区| 香蕉av福利精品导航| 中文字幕乱码亚洲精品一区 | 91视频观看视频| 久国产精品韩国三级视频| 亚洲丝袜制服诱惑| 久久色成人在线| 欧美日免费三级在线| 大尺度一区二区| 蜜臀av一区二区在线观看| 亚洲女爱视频在线| 欧美国产欧美综合| 精品国产污污免费网站入口 | 欧美视频中文一区二区三区在线观看| 国产精品一线二线三线精华| 亚洲成人av资源| 亚洲黄网站在线观看| 国产女人18毛片水真多成人如厕| 8x8x8国产精品| 欧洲一区在线观看| 成人avav影音| 国产精品一区二区在线看| 婷婷开心久久网| 亚洲一区在线看| 亚洲免费在线播放| 国产精品视频在线看| 亚洲精品一区二区精华| 欧美成人乱码一区二区三区| 欧美日本不卡视频| 欧美男同性恋视频网站| 在线观看日韩一区| 91蝌蚪porny九色| 99久久综合狠狠综合久久| 国产suv精品一区二区6| 国产成人午夜视频| 国产精品系列在线观看| 韩国女主播成人在线| 九九九精品视频| 国产在线一区二区| 国产精品一区二区在线看| 国产精品一区二区不卡| 韩国精品免费视频| 粉嫩av一区二区三区粉嫩| 韩国精品一区二区| 成人一级视频在线观看| 成人听书哪个软件好| heyzo一本久久综合| 91香蕉视频在线| 日本道在线观看一区二区| 欧美性色综合网| 日韩一级精品视频在线观看| 日韩精品综合一本久道在线视频| 精品欧美乱码久久久久久1区2区| 久久人人97超碰com| 国产精品日产欧美久久久久| 成人免费在线视频观看| 亚洲自拍偷拍综合| 日韩国产在线观看| 国产老妇另类xxxxx| 99在线精品观看| 欧美日韩三级在线| 精品国产第一区二区三区观看体验| 国产欧美一区二区精品秋霞影院 | 久久综合99re88久久爱| 国产精品免费aⅴ片在线观看| 亚洲美女屁股眼交3| 免费高清成人在线| 成人av在线看| 在线播放91灌醉迷j高跟美女| 精品欧美久久久| 亚洲女人****多毛耸耸8| 日本网站在线观看一区二区三区| 懂色av中文字幕一区二区三区| 一本一道波多野结衣一区二区| 欧美日韩中文字幕一区二区| 久久综合色鬼综合色| 亚洲免费观看高清完整版在线观看熊| 性感美女极品91精品| 国产一区二区三区国产| 欧美性色欧美a在线播放| 亚洲精品一区在线观看| 亚洲精品免费看| 国产激情视频一区二区在线观看| 91精品福利视频| 久久嫩草精品久久久精品| 亚洲欧美成人一区二区三区| 久久99精品久久久久| 欧美影片第一页| 国产日韩成人精品| 青青草97国产精品免费观看无弹窗版| 成人免费视频一区二区| 欧美一区二区三区的| 樱花草国产18久久久久| 国产精品原创巨作av| 777奇米四色成人影色区| 17c精品麻豆一区二区免费| 国产在线不卡视频| 在线综合视频播放| 国产精品久久精品日日| 国产麻豆视频一区二区| 在线不卡一区二区| 亚洲午夜久久久久久久久久久| 大白屁股一区二区视频| 久久久久综合网| 久久成人综合网| 91精品国产高清一区二区三区蜜臀| 亚洲视频综合在线| 成人av免费网站| 国产日韩欧美制服另类| 国模套图日韩精品一区二区| 91精品欧美久久久久久动漫| 亚洲一区二区五区| 色欧美日韩亚洲| 亚洲欧美日韩电影| 91在线视频在线| 国产精品高潮久久久久无| 成人教育av在线| 国产精品国产自产拍在线| 国产成a人亚洲精品| 久久久久久麻豆| 国产98色在线|日韩| 国产精品乱码一区二区三区软件| 成人午夜视频在线| 中文字幕一区二区三区四区|