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

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

?? txmitt.vhd

?? 利用VHDL語言開發(fā)一個UART的源代碼
?? VHD
字號:
-- --------------------------------------------------------------------
-- >>>>>>>>>>>>>>>>>>>>>>>>> COPYRIGHT NOTICE <<<<<<<<<<<<<<<<<<<<<<<<<
-- --------------------------------------------------------------------
-- Copyright (c) 2001 by Lattice Semiconductor Corporation
-- --------------------------------------------------------------------
--
-- 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 97214
--                     U.S.A
--
--                     TEL: 1-800-Lattice (USA and Canada)
--                          408-826-6000 (other locations)
--
--                     web: http://www.latticesemi.com/
--                     email: techsupport@latticesemi.com
--
-- --------------------------------------------------------------------
--
--  Project:           Universal Asynchronous Receiver Transmitter
--  File:              txmitt.vhd
--  Title:             txmitt
--  Design Library:    IEEE
--  Dependencies:      IEEE.std_logic_1164.all
--                     IEEE.std_logic_unsigned.all
--  Description:       VHDL file for the UART Transmitter Module
--
--    <Global reset and clock>
--      Reset       : Master reset
--      Clk16X      : UART internal clock
--
--    <Register>
--      THR         : Transmitter Holding Register
--
--    <Rising edge of THR write strobe>
--      ThrWRn_re   : one Clk16X width pulse indicating rising edge of ThrWRn_r
--
--    <Transmitter output>
--      SOUT        : Transmitter serial output
--
--    <Transmitter control>
--      Databits    : "00"=5-bit, "01"=6-bit, "10"=7-bit, "11"=8-bit
--      Stopbits    : "00"=1-bit, "01"=1.5-bit(5-bit data),
--                    "10"=2-bit(6,7,8-bit data)
--      ParityEnable: '0'=Parity Bit Enable, '1'=Parity Bit Disable
--      ParityEven  : '0'=Even Parity Selected, '1'=Odd Parity Selected
--      ParityStick : '0'=Stick Parity Disable, '1'=Stick Parity Enable
--      TxBreak     : '0'=Disable BREAK assertion, '1'=Assert BREAK
--
--    <Transmitter status>
--      THRE        : THR is empty
--      TEMT        : Both THR and TSR are empty
--
-- --------------------------------------------------------------------
--
-- Revision History :
-- --------------------------------------------------------------------
--   Ver  :| Author            :| Mod. Date :| Changes Made:
--   V1.1 :| J.H.              :| 06/19/01  :| Support ispMACH 5000VG
--   V1.0 :| D.W. & J.H.       :| 06/01/01  :| First Release
-- --------------------------------------------------------------------

library IEEE;
use IEEE.Std_Logic_1164.all;
use IEEE.Std_Logic_Unsigned.all;

entity Txmitt is
  port (
    -- Global reset and clock
    Reset       : in  std_logic; -- Master reset
    Clk16X      : in  std_logic; -- UART internal clock
    -- Register THR
    THR         : in  std_logic_vector(7 downto 0); -- Transmitter Holding Reg
    -- Rising edge of THR write strobe
    ThrWRn_re   : in  std_logic;   -- pulse indicating rising of ThrWRn_r
    -- Transmitter output
    SOUT        : out std_logic;
    -- Transmitter control
    DataBits    : in  std_logic_vector(1 downto 0);
    StopBits    : in  std_logic_vector(1 downto 0);
    ParityEnable: in  std_logic;
    ParityEven  : in  std_logic;
    ParityStick : in  std_logic;
    TxBreak     : in  std_logic;
    -- Transmitter status
    THRE        : out std_logic;
    TEMT        : out std_logic
  );
end Txmitt;

architecture Txmitt_a of Txmitt is

  signal TxOutput     : std_logic;
  signal TSR          : std_logic_vector(7 downto 0);
  signal TxParity_r   : std_logic;
  signal ThrEmpty     : std_logic;
  signal TsrEmpty     : std_logic;

  signal TxInStartState  : std_logic;
  signal TxInShiftState  : std_logic;
  signal TxInStopState   : std_logic;

  signal TxInStartState1 : std_logic; -- TxInStartState delayed 1 Clk16X clock
  signal TxInShiftState1 : std_logic; -- TxInShiftState delayed 1 Clk16X clock
  signal TxInStopState1  : std_logic; -- TxInStopState delayed 1 Clk16X clock

  -- Transmitter Clock Enable Signals
  signal TxClkEnA     : std_logic;
  signal TxClkEnB     : std_logic;

  signal TxCNT_r  : std_logic_vector(2 downto 0);
  signal Count_vr : std_logic_vector(3 downto 0);

  -- State Machine Definition
  type state_typ is (start, shift, parity, stop_1bit, stop_2bit, stop_halfbit);
  signal Tx_State     : state_typ;

  -- Attributes for ispMACH5000VG to get higher performance
  --   These can be removed when the UART design is targeted to other devices.
  ATTRIBUTE SYN_KEEP : integer;
  ATTRIBUTE SYN_KEEP OF TxOutput, TxCNT_r, TSR, TxParity_r : SIGNAL IS 1;
  ATTRIBUTE SYN_KEEP OF TsrEmpty, ThrEmpty : SIGNAL IS 1;
  ATTRIBUTE OPT : string;
  ATTRIBUTE OPT OF TxOutput, TxCNT_r, TSR, TxParity_r : SIGNAL IS "KEEP";
  ATTRIBUTE OPT OF TsrEmpty, ThrEmpty : SIGNAL IS "KEEP";

begin

--------------------------------------------------------------------------------
-- Transmitter Finite State Machine
--------------------------------------------------------------------------------

  Shift_Data_Proc: process(Reset, CLK16X)
  begin
    if (Reset='1') then
      TxCNT_r <= (others=>'0');
      TSR <= (others=>'0');
      TxOutput <= '1';
      TxParity_r <= '1';
      Tx_State <= start;
    elsif rising_edge(Clk16X) then
      case Tx_State is
        when start =>
          if (ThrEmpty='0') and (TxClkEnA='1') then
            -- Load data from THR to TSR
            TSR <= THR;
            -- TxParity_r initialization:
            --   set it when odd parity is selected(ParityEven='0')
            --   clear it when even parity is selected(ParityEven='1')
            TxParity_r <= not ParityEven;
            TxOutput <= '0'; -- start bit='0'
            TxCNT_r <= (others=>'0');
            Tx_State <= shift;
          else
            TxOutput <= '1';
          end if;
        when shift =>
          if (TxClkEnA='1') then
            -- Shift serial data out
            TSR <= '0' & TSR(7 downto 1);
            TxParity_r <= TxParity_r xor TSR(0);
            TxOutput <= TSR(0); -- output Data bits
            TxCNT_r <= TxCNT_r + 1;
            if ((Databits="00" and TxCNT_r=4) or
                (Databits="01" and TxCNT_r=5) or
                (Databits="10" and TxCNT_r=6) or
                (Databits="11" and TxCNT_r=7)) then
              if (ParityEnable='0') then
                Tx_State <= stop_1bit;
              else
                Tx_State <= parity;
              end if;
            end if;
          end if;
        when parity =>
          if (TxClkEnA='1') then
            -- Output 1 parity bit
            if (ParityStick='0') then
              TxOutput <= TxParity_r; -- output Parity bit
            else
              TxOutput <= not ParityEven; -- forced parity bit
            end if;
            Tx_State <= stop_1bit;
          end if;
        when stop_1bit =>
          if (TxClkEnA='1') then
            -- Output 1 bit of StopBits
            TxOutput <= '1';
            if (StopBits="00") then -- 1 stop bit
              Tx_State <= start;
            elsif (StopBits="01") then -- 1.5 stop bits(for 5-bit data only)
              Tx_State <= stop_halfbit;
            else -- 2 stop bits(for 6,7,8-bit data)
              Tx_State <= stop_2bit;
            end if;
          end if;
        when stop_2bit =>
          if (TxClkEnA='1') then
            -- Output 2nd bit of 2 Stopbits
            TxOutput <= '1';
            Tx_State <= start;
          end if;
        when stop_halfbit =>
          if (TxClkEnB='1') then -- half bit
            TxOutput <= '1';
            Tx_State <= start;
          end if;
        when others =>
          Tx_State <= Start;
      end case;
    end if;
  end process Shift_Data_Proc;

--------------------------------------------------------------------------------
-- Generate TsrEmpty and ThrEmpty signals
--------------------------------------------------------------------------------

  -- TsrEmpty : will be set whenever TSR is empty
  TsrEmpty_Proc: process(Clk16X, Reset)
  begin
    if (Reset='1') then
      TsrEmpty <= '1';
    elsif rising_edge(Clk16X) then
      if (TxInStopState='1') and (TxInStopState1='0') then
        -- Set TsrEmpty flag to '1' when StopBit(s) is transmitted
        TsrEmpty <= '1';
      elsif (TxInShiftState='1') and (TxInShiftState1='0') then
        -- Reset TsrEmpty flag to '0' when data is transferred from THR to TSR
        TsrEmpty <= '0';
      end if;
    end if;
  end process TsrEmpty_Proc;

  -- ThrEmpty : will be set whenever THR is empty
  ThrEmpty_Proc: process(Clk16X, Reset)
  begin
    if (Reset='1') then
      ThrEmpty <= '1';
    elsif rising_edge(Clk16X) then
      if (ThrWRn_re='1') then
        -- Reset ThrEmpty flag to '0' when data is written into THR by CPU
        ThrEmpty <= '0';
      elsif (TxInShiftState='1') and (TxInShiftState1='0') then
        -- Set ThrEmpty flag to '1' when data is transferred from THR to TSR
        -- (this occurs when signal TxInShiftState is changed from '0' to '1')
        ThrEmpty <= '1';
      end if;
    end if;
  end process ThrEmpty_Proc;

--------------------------------------------------------------------------------
-- Delayed signals for edge detections
--------------------------------------------------------------------------------
  Delay_Signals_Proc: process(Clk16X, Reset)
  begin
    if (Reset='1') then
      TxInStartState1 <= '1';
      TxInShiftState1 <= '1';
      TxInStopState1 <= '1';
    elsif rising_edge(Clk16X) then
      -- Signal for rising edge detection of signal TxInStartState
      TxInStartState1 <= TxInStartState;
      -- Signal for rising edge detection of signal TxInShiftState
      TxInShiftState1 <= TxInShiftState;
      -- Signal for rising edge detection of signal TxInStopState
      TxInStopState1 <= TxInStopState;
    end if;
  end process Delay_Signals_Proc;

--------------------------------------------------------------------------------
-- Transmitter FSM state indication signals
--------------------------------------------------------------------------------

  -- TxInShiftState : will be set whenever transmitter is in shift state
  TxInShiftState_Proc: process(Clk16X, Reset)
  begin
    if (Reset='1') then
      TxInShiftState <= '0';
    elsif rising_edge(Clk16X) then
      if (Tx_State=shift) then
        TxInShiftState <= '1';
      else
        TxInShiftState <= '0';
      end if;
    end if;
  end process TxInShiftState_Proc;

  -- TxInStopState : will be set whenever transmitter is in stop_1bit state
  TxInStopState_Proc: process(Clk16X, Reset)
  begin
    if (Reset='1') then
      TxInStopState <= '0';
    elsif rising_edge(Clk16X) then
      if (Tx_State=stop_1bit) then
        TxInStopState <= '1';
      else
        TxInStopState <= '0';
      end if;
    end if;
  end process TxInStopState_Proc;

  -- TxInStartState : will be set whenever transmitter is in start state
  TxInStartState_Proc: process(Clk16X, Reset)
  begin
    if (Reset='1') then
      TxInStartState <= '0';
    elsif rising_edge(Clk16X) then
      if (Tx_State=start) then
        TxInStartState <= '1';
      else
        TxInStartState <= '0';
      end if;
    end if;
  end process TxInStartState_Proc;
  
--------------------------------------------------------------------------------
-- Generate TxClkEnA/TxClkEnB signals
--------------------------------------------------------------------------------

  -- Transmitter operates at 1/16th of the input clock frequency.
  -- TxClkEnA, TxClkEnB are clock enable signals used in transmitter FSM
  TxCLK_Proc: process(Reset, Clk16X)
  begin
    if (Reset='1') then
      Count_vr <= (others => '1');
      TxClkEnA <= '0';
      TxClkEnB <= '0';
    elsif rising_edge(Clk16X) then

      if (Count_vr="0000") then
         TxClkEnA <= '1';
      else
         TxClkEnA <= '0';
      end if;
      
      -- TxClkEnB will be used only for 1.5 stop bit generation
      if (Count_vr="1000") then
         TxClkEnB <= '1';
      else
         TxClkEnB <= '0';
      end if;
      
      if (TxInStartState='1') and (TxInStartState1='0') then
         Count_vr <= "0011";  -- Offset to the 2 cycle's delay
      else
         Count_vr <= Count_vr + 1;
      end if;

    end if;
  end process TxCLK_Proc;

--------------------------------------------------------------------------------
-- Generate THRE/TEMT flags
--------------------------------------------------------------------------------

  -- Transmitter Holding Register Empty Indicator
  THRE <= ThrEmpty;

  -- Transmitter Empty Indicator is set to '1' whenever THR and TSR are
  -- both empty, and reset to '0' when either THR or TSR contain a character
  TEMT <= '1' when (ThrEmpty='1') and (TsrEmpty='1') else '0';

--------------------------------------------------------------------------------
-- Serial Data Output
--------------------------------------------------------------------------------

  -- If Break Control bit is set to 1, the serial output is forced to Zero
  SOUT <= '0' when (TxBreak='1') else TxOutput;

end Txmitt_a;

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩午夜中文字幕| 制服丝袜中文字幕亚洲| 三级久久三级久久| 欧美激情在线观看视频免费| 欧美日韩高清一区| av在线播放一区二区三区| 日韩国产精品久久久久久亚洲| 国产精品理伦片| 精品国产成人在线影院 | 国产精品全国免费观看高清 | 成人深夜福利app| 视频一区视频二区中文| 亚洲欧美怡红院| 久久精品夜夜夜夜久久| 日韩欧美在线1卡| 欧美午夜不卡在线观看免费| 99精品国产91久久久久久| 韩国女主播一区| 日本一不卡视频| 亚洲小说春色综合另类电影| 成人免费在线视频| 国产欧美日韩在线视频| 精品国产一区二区三区不卡| 欧美日韩在线直播| 在线视频欧美区| 色香蕉久久蜜桃| av毛片久久久久**hd| 成人福利视频网站| 国产suv精品一区二区三区| 国产自产v一区二区三区c| 久久精品噜噜噜成人88aⅴ | 国产成人综合网| 精品亚洲成a人在线观看| 免费成人在线网站| 欧美aaa在线| 人人狠狠综合久久亚洲| 日韩不卡一区二区三区| 亚洲国产精品一区二区尤物区| 中文字幕亚洲在| 亚洲蜜臀av乱码久久精品蜜桃| 中文字幕一区二区三中文字幕| 中文字幕一区二区三区四区| 亚洲欧洲精品一区二区三区不卡| 国产精品毛片大码女人| 亚洲欧洲日韩在线| 亚洲一区二区三区国产| 五月婷婷综合网| 欧美aa在线视频| 国产一区二区主播在线| 国产成人高清在线| av激情综合网| 欧美优质美女网站| 欧美夫妻性生活| 精品国精品自拍自在线| 国产欧美日韩激情| 亚洲日韩欧美一区二区在线| 国产精品美女久久久久aⅴ| 亚洲欧美另类久久久精品2019| 亚洲色图欧美激情| 午夜精品一区在线观看| 精品在线播放免费| 成人激情av网| 欧美日韩中文字幕精品| 欧美不卡一区二区三区四区| 中日韩av电影| 一区二区三区国产精华| 日本免费在线视频不卡一不卡二| 久久爱另类一区二区小说| 成人午夜精品一区二区三区| 色综合久久中文字幕| 欧美高清视频www夜色资源网| 日韩一区二区免费在线电影| 国产欧美精品一区二区三区四区| 中文字幕在线播放不卡一区| 五月婷婷久久综合| 国产成人精品午夜视频免费| 欧美性猛片xxxx免费看久爱| 精品国产一区二区在线观看| 亚洲国产成人一区二区三区| 亚洲伊人伊色伊影伊综合网| 国产在线播放一区| 日本韩国欧美一区二区三区| 精品嫩草影院久久| 亚洲女同女同女同女同女同69| 免费观看日韩电影| 91年精品国产| 精品久久久久久久久久久院品网| 中文字幕色av一区二区三区| 日本色综合中文字幕| av电影天堂一区二区在线| 日韩午夜在线观看视频| 中文字幕综合网| 国产真实精品久久二三区| 在线观看亚洲精品| 国产日本欧洲亚洲| 视频在线观看一区二区三区| www.亚洲激情.com| 日韩视频一区在线观看| 一区二区三区四区中文字幕| 国产一区二三区好的| 91精品中文字幕一区二区三区| 中文一区二区在线观看| 美女诱惑一区二区| 欧美这里有精品| 国产精品少妇自拍| 精品一区精品二区高清| 精品视频在线看| 国产精品久久久久久久久免费樱桃 | 日韩一区二区三区免费观看| 综合精品久久久| 国产美女视频91| 欧美一卡在线观看| 亚洲福利视频一区二区| 91小宝寻花一区二区三区| 国产亚洲成年网址在线观看| 麻豆91在线播放免费| 欧美老肥妇做.爰bbww视频| 亚洲免费在线播放| 99天天综合性| 日本一区二区综合亚洲| 国产麻豆视频一区二区| 欧美成人一级视频| 日本成人在线看| 欧美精品色一区二区三区| 亚洲一区在线观看免费| 色呦呦国产精品| 中文字幕亚洲欧美在线不卡| 成人av影院在线| 中文字幕精品一区二区精品绿巨人| 狠狠色狠狠色综合系列| 欧美xxxx在线观看| 美女高潮久久久| 日韩视频国产视频| 久久国产人妖系列| 欧美电影免费观看高清完整版在| 日韩国产欧美在线视频| 日韩欧美一区在线观看| 精品在线观看视频| 久久精品人人做| 成人影视亚洲图片在线| 国产精品国产三级国产普通话三级| 国产成人免费在线| 国产精品三级av| 色哟哟欧美精品| 天天影视涩香欲综合网| 在线成人小视频| 美女在线观看视频一区二区| www国产成人免费观看视频 深夜成人网| 蜜桃久久久久久| 日韩精品自拍偷拍| 国产精品一区二区久久精品爱涩| 国产日产亚洲精品系列| 成熟亚洲日本毛茸茸凸凹| 亚洲日韩欧美一区二区在线| 欧美视频一区二区三区四区 | 婷婷中文字幕综合| 91精品国产高清一区二区三区蜜臀 | 欧美国产1区2区| 91麻豆福利精品推荐| 香蕉成人啪国产精品视频综合网| 91精品国产一区二区| 国产一区999| 综合精品久久久| 在线综合视频播放| 国产精品原创巨作av| 中文字幕一区在线| 6080午夜不卡| 国产一区二区三区av电影| 亚洲欧洲三级电影| 欧美精品一级二级三级| 国产真实乱偷精品视频免| 17c精品麻豆一区二区免费| 欧美日韩激情一区二区三区| 激情综合亚洲精品| **欧美大码日韩| 4438x亚洲最大成人网| 国产精品1区二区.| 亚洲午夜精品网| 欧美精品一区二区三| 色综合久久久久综合体| 老司机午夜精品| 亚洲视频综合在线| 日韩精品最新网址| 色欧美片视频在线观看| 九色综合国产一区二区三区| 亚洲精品视频免费看| 亚洲精品在线一区二区| 色婷婷狠狠综合| 九九精品一区二区| 一区二区高清免费观看影视大全| 精品美女在线观看| 在线视频国产一区| 国产成人精品亚洲777人妖| 日韩精品每日更新| 亚洲日本欧美天堂| 精品国产乱码久久久久久1区2区| 91久久精品网| 高清国产午夜精品久久久久久| 日韩av成人高清| 亚洲制服丝袜一区|