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

📄 ssdt.vhd

📁 同步串行数据发送电路SSDT的基本功能是将并行数据转换成串行数据并进行同步发送。系统写入和读出时序完全兼容Intel8086时序。 系统以同步信号开始连续发送四个字节
💻 VHD
字号:
Library IEEE;USE IEEE.std_logic_1164.all; USE IEEE.STD_LOGIC_UNSIGNED.all;Entity SSDT ISPort(        CLK2M:in std_logic;       FS:in std_logic;           RST:in std_logic;                   CS:in std_logic;       WR:in std_logic;      RD:in std_logic;	       A0:in std_logic;      D_IN: in std_logic_vector(7 downto 0);      D_OUT: out std_logic_vector(7 downto 0);      TXD: out std_logic );   End SSDT;Architecture rtl of SSDT  is   Type state is(IDLE,TRAN,FREE);    signal C_STATE, N_STATE: STATE;  signal INSERT_ZERO: std_logic;  signal TXD_SHIFT: std_logic_vector(4 downto 0);  signal TSR:std_logic_vector(7 downto 0);  signal TSR_NUM:std_logic_vector(7 downto 0);	   signal BYTE_NUM:std_logic_vector(1 downto 0);  signal TSR_EMPTY:std_logic;  signal THR:std_logic_vector(7 downto 0);  signal THR_EMPTY:std_logic;  signal IDLER:std_logic_vector(7 downto 0);    signal D_OUT_reg:std_logic_vector(7 downto 0);  signal TXD_reg:std_logic;  signal TRAN_IDLE_reg:std_logic; Begin  	  Process(RST,CLK2M)	   	                    --produce the C_STATE;Begin	      if RST='0' then        C_STATE<=FREE;    elsif( CLK2M'event and CLK2M='1' )then         C_STATE<=N_state;    end if;	 End process; 	  Process(FS,C_STATE,TSR_NUM,BYTE_NUM)			       --produce the N_STATE:OKBegin	 	  case C_STATE is    when FREE=>        if FS='0' then	 	    N_STATE<=TRAN; 	else 	    N_STATE<=FREE;	end if;    when TRAN=>        if (TSR_NUM="11111111" and BYTE_NUM="11" ) then            if(not(TSR(7)='1' and TXD_SHIFT="11110")) then 	        N_STATE<=IDLE;	    else 	        N_STATE<=TRAN;	    end if;	elsif(TRAN_IDLE_reg='1') then	    N_STATE<=IDLE;	else            N_STATE<=TRAN;        end if;    when others=>                                  -- idle        if FS='0' then	 	    N_STATE<=TRAN; 	else 	    N_STATE<=IDLE;	end if;end case; end process;Process(CLK2M)			     -- TRAN_IDLE_reg OK  Begin     if(ClK2M'event and CLK2M='1') then        if (TSR_NUM="11111111" and BYTE_NUM="11" and (TSR(7)='1' and TXD_SHIFT="11110") ) then 	    TRAN_IDLE_reg<='1';        else            TRAN_IDLE_reg<='0';        end if;    end if;End Process;    Process(TXD_SHIFT,C_STATE)			     -- INSERT_ZERO:表示插入0的标志 OK  Begin     if (TXD_SHIFT="11111")  then        INSERT_ZERO<='1';			       else        INSERT_ZERO<='0';    end if;End Process;                                        Process(CLK2M,RST)			     -- TXD and TXD_SHIFT:发送寄存器  OKBegin 	 if(RST='0') then       TXD_reg<='0';     TXD_SHIFT<="00000";elsif(ClK2M'event and CLK2M='1') then    if (FS='0')  then        TXD_reg<=TSR(7);       TXD_SHIFT<=TSR(7)&TXD_SHIFT(4 downto 1);    else         if(C_STATE=TRAN and INSERT_ZERO='0') then            TXD_reg<=TSR(7);            TXD_SHIFT<=TSR(7)&TXD_SHIFT(4 downto 1);        elsif(C_STATE=TRAN and INSERT_ZERO='1') then            TXD_reg<='0';            TXD_SHIFT<='0'&TXD_SHIFT(4 downto 1);        else            TXD_reg<=IDLER(7);            TXD_SHIFT<='0'&TXD_SHIFT(4 downto 1);        end if;    end if;end if;End Process;TXD<=TXD_reg;Process(CLK2M)			     -- TSR:移位寄存器  OKBegin 	   if(ClK2M'event and CLK2M='1') then    if (FS='0')  then        TSR<=TSR(6 downto 0)&'0';    else         if(C_STATE=TRAN) then            if(TSR_EMPTY='1' and THR_EMPTY='0' ) then                TSR<=THR;            elsif(INSERT_ZERO='0') then                TSR<=TSR(6 downto 0)&'0';            end if;        elsif(C_STATE=FREE or C_STATE=IDLE) then            if(TSR_EMPTY='1' and THR_EMPTY='0' ) then                TSR<=THR;            end if;        end if;    end if;end if;End Process;Process(CLK2M,RST)			     -- TSR_NUM:实际是个移位寄存器 OKBegin   if(RST='0') then    TSR_NUM<="00000000";  		   elsif (ClK2M'event and CLK2M='1') then    if (FS='0')  then          TSR_NUM<="11000000";    elsif(C_STATE=TRAN and INSERT_ZERO='0') then       case TSR_NUM is            when "10000000"=>  TSR_NUM<="11000000";           when "11000000"=>  TSR_NUM<="11100000";           when "11100000"=>  TSR_NUM<="11110000";           when "11110000"=>  TSR_NUM<="11111000";           when "11111000"=>  TSR_NUM<="11111100";           when "11111100"=>  TSR_NUM<="11111110";           when "11111110"=>  TSR_NUM<="11111111";           when others=>  TSR_NUM<="10000000";        --11111111       end case;               end if;end if;End Process;Process(CLK2M)			     -- BYTE_NUM:寄存器 OKBegin     		   if (ClK2M'event and CLK2M='1') then    if (FS='0')  then           BYTE_NUM<="00";    elsif(TSR_NUM= "11111111" ) then        case BYTE_NUM is             when "00"=>  BYTE_NUM<="01";            when "01"=>  BYTE_NUM<="10";            when "10"=>  BYTE_NUM<="11";            when others=>  BYTE_NUM<="11";       --"11"        end case;               end if;end if;End Process;Process(TSR_NUM)			     -- TSR_EMPTY:表示一个字节8位传送完成的标志 OKBegin     if(RST='0') then         TSR_EMPTY<='1';    elsif (TSR_NUM="11111111")  then        TSR_EMPTY<='1';			       else                TSR_EMPTY<='0';    end if;End Process;  Process(CLK2M)			     -- THR:移位寄存器  OKBegin 	   if(RST='0') then     THR<="00000000";elsif (ClK2M'event and CLK2M='1') then    if(A0='0' and CS='0' and THR_EMPTY='1' and WR='0') then         THR<=D_IN;    end if;end if;End Process;Process(CLK2M,FS)			     -- THR_EMPTY:寄存器  OKBegin 	   if(RST='0') then     THR_EMPTY<='1';elsif (ClK2M'event and CLK2M='1') then    if(A0='0' and CS='0' and WR='0' and THR_EMPTY='1') then         THR_EMPTY<='0';    elsif(TSR_EMPTY='1' and THR_EMPTY='0') then        THR_EMPTY<='1';    end if;end if;End Process;Process(CLK2M)			     -- THR_EMPTY Read Out:  OKBegin 	   if (ClK2M'event and CLK2M='1') then    if(A0='0' and CS='0' and RD='0') then         if(THR_EMPTY='1') then              D_OUT_reg<="00000000";                      -- Empty        elsif(THR_EMPTY='0') then            D_OUT_reg<="11111111";                      -- Full        end if;    end if;end if;End Process;D_OUT<=D_OUT_reg;Process(CLK2M,FS)			     -- IDLER:移位寄存器  OKBegin 	   if(RST='0') then     IDLER<="01111111";elsif (ClK2M'event and CLK2M='1') then    if (FS='0')  then        IDLER<="01111111";    elsif(C_STATE=IDLE) then       IDLER<=IDLER(6 downto 0)&IDLER(7);    end if;end if;End Process;	  end rtl;

⌨️ 快捷键说明

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