最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 正文

VHDL串口程序

来源:动视网 责编:小OO 时间:2025-09-22 23:12:47
文档

VHDL串口程序

要做FPGA的串口通信毕业设计,一点思路都没有.谁做过这个题目啊!谁有这个题目的论文发我邮箱,最好是一套的开题报告英文翻译什么的都有.有点是点!本问题满意50分.问题补充:邮箱baiguihu2008@163.com提问者:wetsky2008-一级最佳答案检举   你应该是想实现单片机与FPGA的串口通信。以下内容可能会对你有所帮助:根据RS232异步串行通信来的帧格式,在FPGA发送模块中采用的每一帧格式为:1位开始位+8位数据位+1位奇校验位+1位停止位,波特率为2400。本系统设计的是
推荐度:
导读要做FPGA的串口通信毕业设计,一点思路都没有.谁做过这个题目啊!谁有这个题目的论文发我邮箱,最好是一套的开题报告英文翻译什么的都有.有点是点!本问题满意50分.问题补充:邮箱baiguihu2008@163.com提问者:wetsky2008-一级最佳答案检举   你应该是想实现单片机与FPGA的串口通信。以下内容可能会对你有所帮助:根据RS232异步串行通信来的帧格式,在FPGA发送模块中采用的每一帧格式为:1位开始位+8位数据位+1位奇校验位+1位停止位,波特率为2400。本系统设计的是
要做FPGA的串口通信毕业设计,一点思路都没有.谁做过这个题目啊!谁有这个题目的论文发我邮箱,最好是一套的开题报告 英文翻译什么的都有.有点是点!本问题满意50分. 

问题补充:

邮箱baiguihu2008@163.com

提问者: wetsky2008 - 一级

最佳答案

检举    

你应该是想实现单片机与FPGA的串口通信。以下内容可能会对你有所帮助: 

根据RS232 异步串行通信来的帧格式,在FPGA发送模块中采用的每一帧格式为:1位开始位+8位数据位+1位奇校验位+1位停止位,波特率为2400。本系统设计的是将一个16位的数据封装成高位帧和低位帧两个帧进行发送,先发送低位帧,再发送高位帧,在传输数据时,加上文件头和数据长度,文件头用555555来表示,只有单片机收到555555时,才将下面传输的数据长度和数据位进行接收,并进行奇校验位的检验,正确就对收到的数据进行存储处理功能,数据长度可以根据需要任意改变。由设置的波特率可以算出分频系数,具体算法为分频系数X=CLK/(BOUND*2)。可由此式算出所需的任意波特率。下面是实现上述功能的VHDL源程序。 

Library ieee; 

use ieee.std_logic_11.all; 

use ieee.std_logic_arith.all; 

use ieee.std_logic_unsigned.all; 

entity atel2_bin is 

port( txclk: in std_logic; --2400Hz的波特率时钟 

reset: in std_logic; --复位信号 

din: in std_logic_vector(15 downto 0); --发送的数据 

start: in std_logic; --允许传输信号 

sout: out std_logic --串行输出端口 

); 

end atel2_bin; 

architecture behav of atel2_bin is 

signal thr,len: std_logic_vector(15 downto 0); 

signal txcnt_r: std_logic_vector(2 downto 0); 

signal sout1: std_logic; 

signal cou: integer:=0; 

signal oddb:std_logic; 

type s is(start1,start2,shift1,shift2,odd1,odd2,stop1,stop2); 

signal state:s:=start1; 

begin 

process(txclk) 

begin 

if rising_edge(txclk) then 

if cou<3 then thr<=0000000001010101; --发送的文件头 

elsif cou=3 then 

thr<=0000000000000010; --发送的文件长度 

elsif (cou>3 and state=stop2) then thr<=din;--发送的数据 

end if; 

end if; 

end process; 

process(reset,txclk) 

variable tsr,tsr1,oddb1,oddb2: std_logic_vector(7 downto 0); 

begin 

if reset=1 then 

txcnt_r<=(others=>0);

sout1<=1;

state<=start1;

cou<=0;

elsif txclk event and txclk=1 then 

case state is 

when start1=>

if start=1 then 

if cou=3 then 

len<=thr;

end if; 

tsr:=thr(7 downto 0); 

oddb1:=thr(7 downto 0); 

sout1<=0; --起始位 

txcnt_r<=(others=>0);

state<=shift1;

else 

state<=start1;

end if; 

when shift1=>

oddb<=oddb1(7) xor oddb1(6) xor oddb1(5) xor oddb1(4) xor oddb1(3) xor oddb1(2) xor oddb1(1) xor oddb1(0);

sout1<=tsr(0); --数据位 

tsr(6 downto 0):=tsr(7 downto 1); 

tsr(7):=0; 

txcnt_r<=txcnt_r+1;

if (txcnt_r=7) then 

state<=odd1;cou<=cou+1;

end if; 

when odd1=> --奇校验位 

if oddb=1 then 

sout1<=0;state<=stop1;

else 

sout1<=1;state<=stop1;

end if; 

when stop1=>

sout1<=1; --停止位 

if cou<4 then

state<=start1;

else 

state<=start2;

end if; 

when start2=>

tsr1:=thr(15 downto 8); 

oddb2:=thr(15 downto 8); 

sout1<=0; --起始位 

txcnt_r<=(others=>0);

state<=shift2;

when shift2=>

oddb<=oddb2(7) xor oddb2(6) xor oddb2(5) xor oddb2(4) xor oddb2(3) xor oddb2(2) xor oddb2(1) xor oddb2(0);

sout1<=tsr1(0);--数据位 

tsr1(6 downto 0):=tsr1(7 downto 1); 

tsr1(7):=0; 

txcnt_r<=txcnt_r+1;

if (txcnt_r=7) then 

state<=odd2;

end if; 

when odd2=> --奇校验位 

if oddb=1 then 

sout1<=0;state<=stop2;

else 

sout1<=1;state<=stop2;

end if; 

when stop2=>

sout1<=1; --停止位 

if len=0000000000000000 then 

state<=stop2;

else 

state<=start1;

len<=len-1;

end if; 

end case; 

end if; 

end process; 

sout<=sout1;

end behav; 

剩下的波形仿真就自己搞定。 

希望这些内容对你有所帮助!!

相关内容已发到你邮箱 

Library ieee; 

use ieee.std_logic_11.all; 

use ieee.std_logic_arith.all; 

use ieee.std_logic_unsigned.all; 

entity atel2_bin is 

port( txclk: in std_logic; --2400Hz的波特率时钟 

reset: in std_logic; --复位信号 

din: in std_logic_vector(15 downto 0); --发送的数据 

start: in std_logic; --允许传输信号 

sout: out std_logic --串行输出端口 

); 

end atel2_bin; 

architecture behav of atel2_bin is 

signal thr,len: std_logic_vector(15 downto 0); 

signal txcnt_r: std_logic_vector(2 downto 0); 

signal sout1: std_logic; 

signal cou: integer:=0; 

signal oddb:std_logic; 

type s is(start1,start2,shift1,shift2,odd1,odd2,stop1,stop2); 

signal state:s:=start1; 

begin 

process(txclk) 

begin 

if rising_edge(txclk) then 

if cou<3 then thr<=0000000001010101; --发送的文件头 

       elsif cou=3 then 

thr<=0000000000000010; --发送的文件长度 

elsif (cou>3 and state=stop2) then thr<=din;--发送的数据 

    end if; 

end if; 

end process; 

process(reset,txclk) 

variable tsr,tsr1,oddb1,oddb2: std_logic_vector(7 downto 0); 

begin 

if reset=1 then 

txcnt_r<=(others=>0);

sout1<=1;

state<=start1;

cou<=0;

    elsif txclk event and txclk=1 then 

       case state is 

when start1=>

            if start=1 then 

               if cou=3 then 

len<=thr;

               end if; 

             tsr:=thr(7 downto 0); 

             oddb1:=thr(7 downto 0); 

sout1<=0; --起始位 

txcnt_r<=(others=>0);

state<=shift1;

            else 

state<=start1;

            end if; 

when shift1=>

oddb<=oddb1(7) xor oddb1(6) xor oddb1(5) xor oddb1(4) xor oddb1(3) xor oddb1(2) xor oddb1(1) xor oddb1(0);

sout1<=tsr(0); --数据位 

               tsr(6 downto 0):=tsr(7 downto 1); 

               tsr(7):=0; 

txcnt_r<=txcnt_r+1;

                 if (txcnt_r=7) then 

state<=odd1;cou<=cou+1;

                 end if; 

when odd1=> --奇校验位 

             if oddb=1 then 

sout1<=0;state<=stop1;

              else 

sout1<=1;state<=stop1;

              end if; 

when stop1=>

sout1<=1; --停止位 

if cou<4 then

state<=start1;

               else 

state<=start2;

               end if; 

when start2=>

               tsr1:=thr(15 downto 8); 

               oddb2:=thr(15 downto 8); 

sout1<=0; --起始位 

txcnt_r<=(others=>0);

state<=shift2;

when shift2=>

oddb<=oddb2(7) xor oddb2(6) xor oddb2(5) xor oddb2(4) xor oddb2(3) xor oddb2(2) xor oddb2(1) xor oddb2(0);

sout1<=tsr1(0);--数据位 

               tsr1(6 downto 0):=tsr1(7 downto 1); 

               tsr1(7):=0; 

txcnt_r<=txcnt_r+1;

               if (txcnt_r=7) then 

state<=odd2;

               end if; 

when odd2=> --奇校验位 

               if oddb=1 then 

sout1<=0;state<=stop2;

               else 

sout1<=1;state<=stop2;

               end if; 

when stop2=>

sout1<=1; --停止位 

               if len=0000000000000000 then 

state<=stop2;

               else 

state<=start1;

len<=len-1;

               end if; 

      end case; 

end if; 

end process; 

sout<=sout1;

end behav;

文档

VHDL串口程序

要做FPGA的串口通信毕业设计,一点思路都没有.谁做过这个题目啊!谁有这个题目的论文发我邮箱,最好是一套的开题报告英文翻译什么的都有.有点是点!本问题满意50分.问题补充:邮箱baiguihu2008@163.com提问者:wetsky2008-一级最佳答案检举   你应该是想实现单片机与FPGA的串口通信。以下内容可能会对你有所帮助:根据RS232异步串行通信来的帧格式,在FPGA发送模块中采用的每一帧格式为:1位开始位+8位数据位+1位奇校验位+1位停止位,波特率为2400。本系统设计的是
推荐度:
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top