永发信息网

怎么实现串口和FPGA之间的通信,要求是串口监控FPGA的工作情况.

答案:3  悬赏:40  手机版
解决时间 2021-03-05 08:30
比如通过串口调试助手的窗口给FPGA发送指令,FPGA收到后反馈给串口一些带有当前的工作情况的信息(这里并不是收的和发的保持一模一样),反馈的信息也显示到串口调试助手的窗口上面,这样可以实现吗,如果能实现的话需要哪些准备呢,谢谢啦,对不起,没有分了。
最佳答案
可以实现;
需要一个带串口的fpga开发板,串口线和一个带串口的电脑...
全部回答
你应该是想实现单片机与fpga的串口通信。以下内容可能会对你有所帮助: 根据rs232 异步串行通信来的帧格式,在fpga发送模块中采用的每一帧格式为:1位开始位+8位数据位+1位奇校验位+1位停止位,波特率为2400。本系统设计的是将一个16位的数据封装成高位帧和低位帧两个帧进行发送,先发送低位帧,再发送高位帧,在传输数据时,加上文件头和数据长度,文件头用555555来表示,只有单片机收到555555时,才将下面传输的数据长度和数据位进行接收,并进行奇校验位的检验,正确就对收到的数据进行存储处理功能,数据长度可以根据需要任意改变。由设置的波特率可以算出分频系数,具体算法为分频系数x=clk/(bound*2)。可由此式算出所需的任意波特率。下面是实现上述功能的vhdl源程序。 library ieee; use ieee.std_logic_1164.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 txclkevent 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; 剩下的波形仿真就自己搞定。 希望这些内容对你有所帮助!! 相关内容已发到你邮箱
可以实现; 系列FPGA开发板,串行电缆和一台电脑与一个串行端口...
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
我儿子12岁才1米45,我侄儿12岁1米72,我儿子
遵义锦之旅旅行社有限责任公司凤冈网点地址在
窗外寒星冷月隔着雾 长夜对残烛 镜中愁容满面
用一元一次方程1.毕业在即,九年级某班为纪念
0.5cmx10m是多少平方
彩韵魔法屋地址在哪,我要去那里办事
奇然唱的那首《画中仙》是出自哪本小说的?
我现在是做建筑人才的猎头,主要涉及资质这一
红烧鸡膝软骨怎么做如何做好吃
下图为“上海市某区2010年第六次人口普查统计
徐州哪里有卖儿童电动汽车,多少钱
我买彩票中奖12亿怎么办
固话怎么分是移动还联通的
伟华美食在什么地方啊,我要过去处理事情
挽曹、刘之逸步、下开李、杜之先鞭”的诗人曹
推荐资讯
尖山茶场在哪里啊,我有事要去这个地方
急!请问:南开大学少数民族预科班,中国政法
为什么携程旅行买火车票登12306网络老不对
配电系统图中BV-2*4+E4mm方 PC20 WC 什么意思
2块硬盘装了双系统,每一块硬盘都有mbr/gpt吗
dnf虚空魔石和混沌魔石现在有什么用
初1数学一元一次不等式应用题自行车保管站星
有人听说过美纳多这个奶粉品牌吗?
松既古镇到香薰花湖世界怎么走
像素生存者2怎么玩 Pixel Survival Game 2玩
去迪拜需要什么要求
5玩合金装备5幻痛说我丢失msvcp100.dll怎么办
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?