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

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

?? mc8051_tmrctr.vhd

?? Standard 8051 IP Core
?? VHD
?? 第 1 頁 / 共 2 頁
字號:
--         Description: Timer/Counter unit of the mc8051 microcontroller.
--
--
--
--
-------------------------------------------------------------------------------
library IEEE; 
use IEEE.std_logic_1164.all; 
use IEEE.std_logic_arith.all; 
  
-----------------------------ENTITY DECLARATION--------------------------------

entity mc8051_tmrctr is

  port (clk        : in  std_logic;  			--< system clock
        reset      : in  std_logic;  			--< system reset
        int0_i     : in  std_logic;  			--< interrupt 0
        int1_i     : in  std_logic;  			--< interrupt 1
        t0_i       : in  std_logic;  			--< external clock for
  							--  timer/counter0
        t1_i       : in  std_logic;  			--< external clock for
  							--  timer/counter1
        tmod_i     : in  std_logic_vector(7 downto 0);  --< from SFR register
        tcon_tr0_i : in  std_logic;  			--< timer run 0
        tcon_tr1_i : in  std_logic;  			--< timer run 1
        reload_i   : in  std_logic_vector(7 downto 0);  --< to load counter
        wt_en_i    : in  std_logic;  			--< indicates reload
        wt_i       : in  std_logic_vector(1 downto 0);  --< reload which reg.
        th0_o      : out std_logic_vector(7 downto 0);  --< contents of th0 
        tl0_o      : out std_logic_vector(7 downto 0);  --< contents of tl0 
        th1_o      : out std_logic_vector(7 downto 0);  --< contents of th1 
        tl1_o      : out std_logic_vector(7 downto 0);  --< contents of tl1 
        tf0_o      : out std_logic;  			--< interrupt flag 0
        tf1_o      : out std_logic);  			--< interrupt flag 1
      
end mc8051_tmrctr;
-------------------------------------------------------------------------------
architecture rtl of mc8051_tmrctr is

  signal s_pre_count    : unsigned(3 downto 0);  -- these two signals provide
  signal s_count_enable : std_logic;             -- a clock enable signal which
                                                 -- masks out every twelfth           ***
                                                 -- rising edge of clk
  
  signal s_count0       : unsigned(15 downto 0); -- count for tmr/ctr0
  signal s_countl0      : unsigned(7 downto 0);  -- count register for tmr/ctr0
  signal s_counth0      : unsigned(7 downto 0);  -- count register for tmr/ctr0
  signal s_count1       : unsigned(15 downto 0); -- count for tmr/ctr1
  signal s_countl1      : unsigned(7 downto 0);  -- count register for tmr/ctr1
  signal s_counth1      : unsigned(7 downto 0);  -- count register for tmr/ctr1
  signal s_gate0        : std_logic;             -- gate bit for tmr/ctr 0
  signal s_gate1        : std_logic;             -- gate bit for tmr/ctr 1
  signal s_c_t0         : std_logic;             -- tmr/ctr 0 is timer if 0
  signal s_c_t1         : std_logic;             -- tmr/ctr 1 is timer if 0
  signal s_tmr_ctr0_en  : std_logic;             -- starts tmr/ctr 0 if 1
  signal s_tmr_ctr1_en  : std_logic;             -- starts tmr/ctr 1 if 1
  signal s_mode0        : unsigned(1 downto 0);  -- mode of tmr/ctr 0
  signal s_mode1        : unsigned(1 downto 0);  -- mode of tmr/ctr 1
  signal s_tf0          : std_logic;             -- overflow flag of tmr/ctr 0
  signal s_tf1          : std_logic;             -- overflow flag of tmr/ctr 1
  signal s_t0ff0        : std_logic;             -- flipflop for edge dedection
  signal s_t0ff1        : std_logic;             -- flipflop for edge dedection
  signal s_t0ff2        : std_logic;             -- flipflop for edge dedection
  signal s_t1ff0        : std_logic;             -- flipflop for edge dedection
  signal s_t1ff1        : std_logic;             -- flipflop for edge dedection
  signal s_t1ff2        : std_logic;             -- flipflop for edge dedection
  signal s_ext_edge0    : std_logic;             -- 1 if external edge dedected
  signal s_ext_edge1    : std_logic;             -- 1 if external edge dedected
  signal s_int0_sync    : std_logic;             -- synchronized int0 input              *** 
  signal s_int1_sync    : std_logic;             -- synchronized int1 input              *** 
  
  
  
begin                 -- architecture rtl

  -- The names of the following signals make the code more readable.
  s_gate0 <= tmod_i(3);
  s_c_t0  <= tmod_i(2);
  s_mode0(1) <= tmod_i(1);
  s_mode0(0) <= tmod_i(0);
  
  s_gate1 <= tmod_i(7);
  s_c_t1  <= tmod_i(6);
  s_mode1(1) <= tmod_i(5);
  s_mode1(0) <= tmod_i(4);

  -- These two synchronized signals start the corresponding timer/counter if they are 1.  -- ***
  s_tmr_ctr0_en <= tcon_tr0_i and (not(s_gate0) or s_int0_sync);                          -- *** 
  s_tmr_ctr1_en <= tcon_tr1_i and (not(s_gate1) or s_int1_sync);                          -- *** 

  -- The outputs of this unit are the two timer overflow flags, which are read
  -- by the control unit and the two 16 bit count registers to enable read
  -- access.
  tf0_o <= s_tf0;
  tf1_o <= s_tf1;
  th0_o <= std_logic_vector(s_count0(15 downto 8));
  tl0_o <= std_logic_vector(s_count0(7 downto 0));
  th1_o <= std_logic_vector(s_count1(15 downto 8));
  tl1_o <= std_logic_vector(s_count1(7 downto 0));

-------------------------------------------------------------------------------
  -- The two interrupt inputs are synchronized.   *** 

  p_sync_inputs: process (clk, reset)          -- *** 
    
    begin                                      -- ***

      if reset = '1' then                  -- ***
        s_int0_sync <= '0';                -- ***
        s_int1_sync <= '0';                -- ***
      else                                 -- ***
        if clk'event and clk='1' then      -- ***
          s_int0_sync <= int0_i;           -- ***
          s_int1_sync <= int1_i;           -- ***
        end if;                            -- ***
      end if;                              -- ***

  end process p_sync_inputs;               -- ***

-------------------------------------------------------------------------------
  -- The register s_pre_count is driven with the system clock. So a
  -- good enable signal (which is stable when clk has its rising edge) can be
  -- derived to mask out every twelfth pulse of clk.                                  ***

  s_count_enable <= '1' when s_pre_count = conv_unsigned(11,4) else '0';           -- ***
  
  p_divide_clk: process (clk, reset)
    
    begin

      if reset = '1' then
        s_pre_count <= conv_unsigned(0,4);
      else
        if clk'event and clk='1' then
	  if (s_pre_count = conv_unsigned(11,4)) then                              -- ***
            s_pre_count <= conv_unsigned(0,4);                                     -- ***
	  else                                                                     -- ***
	    s_pre_count <= s_pre_count + conv_unsigned(1,1);                       -- ***
	  end if;
        end if;
      end if;    

  end process p_divide_clk;

-------------------------------------------------------------------------------
  -- The two flip flops are updated every second clock period.
  -- If a falling edge
  -- on the port t0_i is dedected the signal s_ext_edge0 is set to 1 and with
  -- the next rising edge of clk the counter0 is incremented.
  -- The same function is realised for counter1.
  s_ext_edge0 <= '1' when (s_t0ff1 = '0' and s_t0ff2 = '1') else '0';      

  p_sample_t0: process (clk, reset)
      
    begin

      if reset = '1' then
        s_t0ff0 <= '0';
        s_t0ff1 <= '0';
        s_t0ff2 <= '0';
      else
            
        if clk'event and clk = '1' then
          if s_pre_count = conv_unsigned(6,3) then
            if s_c_t0 = '1' then
              s_t0ff0 <= t0_i;
              s_t0ff1 <= s_t0ff0;
              s_t0ff2 <= s_t0ff1;
            end if;
          end if;
        end if;  
      end if;    

  end process p_sample_t0;
      
  s_ext_edge1 <= '1' when (s_t1ff1 = '0' and s_t1ff2 = '1') else '0';

  p_sample_t1: process (clk, reset)
      
    begin

      if reset = '1' then
        s_t1ff0 <= '0';
        s_t1ff1 <= '0';
        s_t1ff2 <= '0';
      else
        if clk'event and clk = '1' then
          if s_pre_count = conv_unsigned(6,3) then
            if s_c_t1 = '1' then
              s_t1ff0 <= t1_i;
              s_t1ff1 <= s_t1ff0;
              s_t1ff2 <= s_t1ff1;
            end if;              
          end if;
        end if;  
      end if;    

  end process p_sample_t1;

------------------------------------------------------------------------------
--+++++++++++++++++++++   TIMER / COUNTER 0   ++++++++++++++++++++++++++++++--
------------------------------------------------------------------------------
-- This is timer/counter0. It is built around the 16 bit count register
-- s_count0 and realises its four operating modes
------------------------------------------------------------------------------
  s_count0(15 downto 8) <= s_counth0;
  s_count0(7 downto 0) <= s_countl0;
  s_count1(15 downto 8) <= s_counth1;
  s_count1(7 downto 0) <= s_countl1;
      
  p_tmr_ctr: process (clk, reset)
    
  begin

    if reset = '1' then                 -- perform asynchronous reset

      s_countl0 <= conv_unsigned(0,8);
      s_counth0 <= conv_unsigned(0,8);
      s_countl1 <= conv_unsigned(0,8);
      s_counth1 <= conv_unsigned(0,8);
      s_tf1    <= '0';
      s_tf0    <= '0';
        
    else
        
      if clk'event and clk = '1' then
          
-------------------------------------------------------------------------------
-- operating mode 0 (13 bit timer/counter)
-------------------------------------------------------------------------------
      case s_mode0 is
        when "00" =>

        -- This section generates the timer/counter overflow flag0
        if s_tmr_ctr0_en = '1' then
          if s_count_enable = '1' then   
            if s_c_t0 = '0' or (s_ext_edge0 = '1' and s_c_t0 = '1')  then
              if s_count0 = conv_unsigned(65311,16) then                          -- ***
                s_tf0 <= '1';
              else
                s_tf0 <= '0';
              end if;
            end if;
          end if;
        end if;
        
        -- This section generates the low byte register of tmr/ctr0
        if wt_i = "00" and wt_en_i = '1' then
          s_countl0 <= unsigned(reload_i);  
        else
          if s_tmr_ctr0_en = '1' then
            if s_count_enable = '1' then   
              if s_c_t0 = '0' then
                if s_countl0 = conv_unsigned(31,8) then                           -- *** 
                  s_countl0 <= conv_unsigned(0,8);
                else
                  s_countl0 <= s_countl0 + conv_unsigned(1,1);
                end if;
              else
                if s_ext_edge0 = '1' then
                  if s_countl0 = conv_unsigned(31,8) then                          -- *** 
                    s_countl0 <= conv_unsigned(0,8);
                  else
                    s_countl0 <= s_countl0 + conv_unsigned(1,1);
                  end if;
                end if;                  
              end if;
            end if; 
          end if;
        end if;
        
        -- This section generates the high byte register of tmr/ctr0
        if wt_i = "10" and wt_en_i = '1' then
          s_counth0 <= unsigned(reload_i);  
        else
          if s_tmr_ctr0_en = '1' then
            if s_count_enable = '1' then   
              if s_c_t0 = '0' then
                if s_count0 = conv_unsigned(65311,16) then                          -- *** 
                  s_counth0 <= conv_unsigned(0,8);
                else
                  if s_countl0 = conv_unsigned(31,8) then                          -- ***
                    s_counth0 <= s_counth0 + conv_unsigned(1,1);
                  end if;
                end if;
              else
                if s_ext_edge0 = '1' then
                  if s_count0 = conv_unsigned(65311,16) then                       -- *** 
                    s_counth0 <= conv_unsigned(0,8);
                  else
                    if s_countl0 = conv_unsigned(31,8) then                         -- *** 
                      s_counth0 <= s_counth0 + conv_unsigned(1,1);
                    end if;
                  end if;
                end if;                  
              end if;
            end if;
          end if;
        end if;
-------------------------------------------------------------------------------
-- operating mode 1 (16 bit timer/counter)
-------------------------------------------------------------------------------

      when "01" =>

        -- This section generates the timer/counter overflow flag0
        if s_tmr_ctr0_en = '1' then
          if s_count_enable = '1' then   
            if s_c_t0 = '0' or (s_ext_edge0 = '1' and s_c_t0 = '1')  then
              if s_count0 = conv_unsigned(65535,16) then
                s_tf0 <= '1';
              else
                s_tf0 <= '0';
              end if;
            end if;
          end if;
        end if;
        
        -- This section generates the low byte register of tmr/ctr0
        if wt_i = "00" and wt_en_i = '1' then
          s_countl0 <= unsigned(reload_i);  
        else
          if s_tmr_ctr0_en = '1' then
            if s_count_enable = '1' then   
              if s_c_t0 = '0' then
                if s_count0 = conv_unsigned(65535,16) then
                  s_countl0 <= conv_unsigned(0,8);
                else
                  s_countl0 <= s_countl0 + conv_unsigned(1,1);
                end if;
              else
                if s_ext_edge0 = '1' then
                  if s_count0 = conv_unsigned(65535,16) then
                    s_countl0 <= conv_unsigned(0,8);
                  else
                    s_countl0 <= s_countl0 + conv_unsigned(1,1);
                  end if;
                end if;                  
              end if;
            end if; 
          end if;
        end if;
        
        -- This section generates the high byte register of tmr/ctr0
        if wt_i = "10" and wt_en_i = '1' then
          s_counth0 <= unsigned(reload_i);  
        else
          if s_tmr_ctr0_en = '1' then
            if s_count_enable = '1' then   
              if s_c_t0 = '0' then
                if s_count0 = conv_unsigned(65535,16) then
                  s_counth0 <= conv_unsigned(0,8);
                else
                  if s_countl0 = conv_unsigned(255,8) then
                    s_counth0 <= s_counth0 + conv_unsigned(1,1);
                  end if;
                end if;
              else
                if s_ext_edge0 = '1' then
                  if s_count0 = conv_unsigned(65535,16) then
                    s_counth0 <= conv_unsigned(0,8);
                  else
                    if s_countl0 = conv_unsigned(255,8) then
                      s_counth0 <= s_counth0 + conv_unsigned(1,1);
                    end if;
                  end if;
                end if;                  
              end if;
            end if;
          end if;
        end if;


-------------------------------------------------------------------------------
-- operating mode 2 (8 bit timer/counter, autoreloaded from high byte register)

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91小视频在线观看| 色婷婷av一区二区| 91丝袜美腿高跟国产极品老师 | 久久精品国内一区二区三区| 国产xxx精品视频大全| 在线观看91精品国产麻豆| 国产精品国产三级国产aⅴ中文 | 亚洲午夜视频在线观看| 国产一区二区三区在线观看免费| 欧美午夜精品久久久久久超碰| 久久精品男人的天堂| 日韩精品视频网站| www.久久精品| 久久影音资源网| 三级成人在线视频| 欧美视频中文一区二区三区在线观看| 中文欧美字幕免费| 久久99九九99精品| 日韩欧美一级二级三级| 亚洲国产精品一区二区尤物区| 懂色一区二区三区免费观看| 精品免费国产二区三区| 秋霞电影一区二区| 日韩一区二区电影网| 午夜欧美电影在线观看| 成人av在线资源网| 国产精品免费视频观看| 粉嫩绯色av一区二区在线观看| 精品va天堂亚洲国产| 日本亚洲欧美天堂免费| 欧美一区二区精美| 狠狠狠色丁香婷婷综合激情| 欧美日韩电影在线| 日韩有码一区二区三区| 欧美二区在线观看| 美女www一区二区| 精品噜噜噜噜久久久久久久久试看| 婷婷综合在线观看| 91精品国产91热久久久做人人| 亚洲电影第三页| 欧美在线短视频| 午夜精品福利在线| 欧美成人a视频| 国产一区视频网站| 中文字幕五月欧美| 91官网在线观看| 天堂蜜桃91精品| 欧美成人三级在线| 成人综合婷婷国产精品久久| 中文字幕不卡一区| 欧美伊人久久久久久午夜久久久久| 三级一区在线视频先锋 | 国产精品久久久久久久久动漫| 粉嫩一区二区三区在线看| 亚洲视频免费看| 精品视频1区2区3区| 另类小说欧美激情| 中文无字幕一区二区三区| 99久久er热在这里只有精品15| 亚洲一区二区三区影院| 日韩免费视频一区| 成人av午夜电影| 亚瑟在线精品视频| 国产三级精品三级| 日本黄色一区二区| 美国三级日本三级久久99| 中文字幕va一区二区三区| 日本久久电影网| 久久黄色级2电影| 亚洲欧美日韩在线播放| 91精品国产黑色紧身裤美女| 国产成人av一区二区| 香蕉加勒比综合久久| 国产亚洲成av人在线观看导航| 日本高清免费不卡视频| 裸体健美xxxx欧美裸体表演| 中日韩av电影| 欧美mv日韩mv亚洲| 在线观看亚洲精品视频| 国产一区二区三区观看| 一区二区三区精品视频| 2023国产一二三区日本精品2022| 色综合av在线| 国产美女久久久久| 石原莉奈在线亚洲二区| 亚洲精品日韩一| 久久精品视频免费| 欧美一级免费大片| 色吊一区二区三区| 播五月开心婷婷综合| 裸体一区二区三区| 亚洲国产日韩一级| 亚洲欧美日韩精品久久久久| 精品欧美一区二区在线观看| 欧美日韩午夜在线| 91国偷自产一区二区三区观看| 国产一区高清在线| 热久久久久久久| 亚洲成a天堂v人片| 亚洲第一av色| 午夜国产不卡在线观看视频| 亚洲精品乱码久久久久久久久| 国产欧美日韩精品在线| 精品国产乱码久久久久久蜜臀| 欧美日韩久久久久久| 色欲综合视频天天天| 不卡的av电影在线观看| 国产成人av电影在线播放| 国产伦精品一区二区三区免费迷| 日韩电影在线免费| 日韩电影免费在线观看网站| 亚洲国产美女搞黄色| 一区二区三区在线视频观看58| 国产欧美日韩激情| 国产亚洲成年网址在线观看| 久久久一区二区三区| 久久精品亚洲国产奇米99| 久久久精品国产99久久精品芒果| 精品对白一区国产伦| 精品三级av在线| 久久久久久久久蜜桃| 久久久精品日韩欧美| 国产精品午夜久久| 亚洲日本青草视频在线怡红院| 亚洲欧洲日韩女同| 中文字幕在线一区免费| 亚洲视频1区2区| 一区二区三区欧美视频| 亚洲成人综合视频| 日本在线观看不卡视频| 福利一区福利二区| 91亚洲国产成人精品一区二区三| 欧美亚洲国产bt| 日韩欧美色电影| 中文字幕免费观看一区| 国产精品久久久爽爽爽麻豆色哟哟| 国产精品成人免费精品自在线观看 | 中文字幕的久久| 一区二区久久久| 日本 国产 欧美色综合| 国产乱码字幕精品高清av| 豆国产96在线|亚洲| 欧美日韩免费观看一区二区三区| 欧美一级片免费看| 中文字幕精品在线不卡| 婷婷综合另类小说色区| 国产精品综合二区| 日本大香伊一区二区三区| 欧美一区二区三区精品| 中文字幕欧美日本乱码一线二线| 亚洲精品免费在线播放| 久久99精品国产麻豆婷婷| 成人免费看黄yyy456| 678五月天丁香亚洲综合网| 国产三级欧美三级日产三级99| 亚洲欧美日韩国产一区二区三区| 日韩成人免费电影| 色综合欧美在线视频区| 精品国产自在久精品国产| 亚洲精品欧美二区三区中文字幕| 精品无人码麻豆乱码1区2区| 色婷婷综合久久久久中文| 精品国产免费一区二区三区香蕉| 亚洲人123区| 国产精品乡下勾搭老头1| 欧美三级电影网站| 中文字幕五月欧美| 国产电影一区在线| 日韩一二三区不卡| 亚洲成人手机在线| 99精品视频在线观看| 久久亚洲精品小早川怜子| 香蕉久久夜色精品国产使用方法 | 欧美一区二区不卡视频| 亚洲欧洲三级电影| 国产成人精品aa毛片| 日韩精品一区二区三区老鸭窝| 亚洲福利视频一区二区| 99免费精品视频| 国产精品视频在线看| 黑人巨大精品欧美黑白配亚洲| 欧美精品自拍偷拍| 夜夜嗨av一区二区三区中文字幕| 国产99精品国产| 久久久久久久一区| 激情深爱一区二区| 日韩精品专区在线影院观看| 亚洲成av人综合在线观看| 91福利在线免费观看| 亚洲视频一区二区在线| 99re这里只有精品6| 中文字幕高清一区| 成年人国产精品| 国产精品久久久久久久蜜臀| 国产成人免费在线| 国产精品私人影院| 97久久超碰国产精品| 亚洲色图都市小说| 日本韩国一区二区三区| 亚洲国产wwwccc36天堂|