⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 trans_port.vhd

📁 分别完成了异步发送电路
💻 VHD
字号:
--异步发送电路VHDL程序。library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;entity trans_port isport (rst,start_write,clk,ETBE : in std_logic ;      din  : in std_logic_vector(7 downto 0) ;      IRQ  : out std_logic;   --中断请求      sout : out std_logic ) ;end trans_port ;architecture behave of trans_port issignal TBE: std_logic:='1';   --发送缓冲器的指示位信号,为'1'表示等待发送数据写入。signal tsr: std_logic_vector (7 downto 0) ;--发送移位寄存器。signal tbr: std_logic_vector (7 downto 0) ;--发送缓冲寄存器。signal clkdiv: unsigned (5 downto 0) ; --用来控制数据发送频率的信号。signal temp:std_logic_vector(9 downto 0);signal tmp1:integer range 0 to 10;   --监测输出数据的位数beginprocess(rst,clk)begin if rst='1' then    tsr<="00000000";    tbr<="00000000";    TBE<='1';    IRQ<='0';    sout<='0';    clkdiv<="000000";    temp<="0000000000";    tmp1<=0; elsif rising_edge(clk) then    if TBE='1' then       tbr<=din;       sout<='1';    end if;    if start_write='1' then   --start_write为输入信号,用于控制发送器是否开始工作。       TBE<='0';       tsr<=tbr;             --把缓冲器的数据放移位寄存器       temp(8 downto 1) <= tsr(7 downto 0);       temp(9)<=not(tsr(7)xor tsr(6)xor tsr(5) xor tsr(4)xor tsr(3)xor tsr(2)xor tsr(1)xor tsr(0));        --奇校验位。       temp(0)<='0';--起始位信号。    elsif TBE='0' then      if ETBE='1' then    --ETBE为中断输入信号,若有中断,则停止发送数据,直到中断信号停止。         IRQ<='1';        --发生中断请求      else          IRQ<='0';         if std_logic_vector(clkdiv) = "101110" then   --用于控制输出信号的速率,使其为时钟频率的1/46.            clkdiv<="000000";         else                     clkdiv<=clkdiv+"000001";         end if;         if std_logic_vector(clkdiv) = "101110"  then            sout<=temp(0);            temp<='1' & temp(9 downto 1);  --通过移位实现并串变换。            if tmp1<10 then                --用于监测输出数据的位数               tmp1<=tmp1+1;               --1位起始位+8位数据位+1位奇校验位+1位停止位。            else                TBE<='1';                temp<="0000000000";               tmp1<=0;            end if;         end if;      end if;    end if; end if;end process;end behave;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -