毕业论文开发语言企业开发JAVA技术.NET技术WEB开发Linux/Unix数据库技术Windows平台移动平台嵌入式论文范文英语论文
您现在的位置: 毕业论文 >> 嵌入式 >> 正文

vhdl写uart接收没有输出

更新时间:2012-9-10:  来源:毕业论文

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity uart is
port(
clk_in_325hz : in std_logic;--50M晶振输出325HZ
rxd_in: in std_logic;--资料输入
rxd_out:out std_logic_vector(7 downto 0)--资料输出
);
end uart;

architecture a of uart is  
type state is(idle,check,rec);
signal check_ck,rec_ck,rec_re,rec_cc,ok:std_logic;
signal rxd_ck : std_logic:='1';
signal check_re: std_logic_vector(1 downto 0):="00";
signal recv,recv_sig : std_logic_vector(8 downto 0):="000000000";
signal rxd_ck_sig : std_logic_vector(3 downto 0):="0000";
signal sta : state;
begin

process(sta,rxd_in,check_re,rec_re)
begin
case sta is
when idle=>--第一个状态当输入变成低电位时进入第二个状态
recv_sig<="000000000";
if rxd_in='0' then 
sta<=check;
else
sta<=idle;
end if;
when check=>--第二个状态判断是否为初始位元
check_ck<='1';
case check_re is
when "01"=>
check_ck<='0';
sta<=rec;
when "10"=>
check_ck<='0';
sta<=idle;
when others=> null;
end case;
when rec=>--第三个状态接收
rec_ck<='1';
if rec_re='1' then 
sta<=idle;
rec_ck<='0';
elsif ok='1' then 
rxd_out<=recv(7 downto 0);
sta<=idle;
rec_ck<='0';
end if;
end case;
end process;

process(clk_in_325hz,check_ck,rec_ck)
variable rxd_ck_st : integer range 0 to 4:=0;
variable rec_st : integer range 0 to 8:=0;
variable rec_ck_st: integer range 0 to 9:=0;
begin
if check_ck='1' then--第二个状态所运行325HZ上延信号4次之后取是否为低电位如果是则回传为初始位元
if clk_in_325hz'event and clk_in_325hz='1' then
rxd_ck_st:=rxd_ck_st+1;
if rxd_ck_st=4 then 
rxd_ck<=rxd_in;
if rxd_ck='0' then 
check_re<="01";
rxd_ck_st:=0;
else 
check_re<="10";
rxd_ck_st:=0;
end if;
end if;
end if;
end if;
if rec_ck='1' then--第三個狀態所運行325HZ上延信號8次之後取一位資料位元,總共取9次(包含停止位元)最後判斷停止位元是否為高電位回傳
if clk_in_325hz'event and clk_in_325hz='1' then
rec_st:=rec_st+1;
if rec_st=8 then 
recv<=rxd_in & recv_sig(8 downto 1);
rec_st:=0;
rec_ck_st:=rec_ck_st+1;
elsif rec_ck_st=9 then 
if recv(8)='1' then 
ok<='1';
rec_ck_st:=0;
else
rec_re<='1';
rec_ck_st:=0;
end if;
end if;
end if;
end if;
end process;
end a;

做仿真的时候资料接收没有输出
烧进板子用示波器测发现在状态机内要测量很困难...
实际输出有输出不过结果都是错的
不知道上面这样子写有没有问题呢?
 
仿真才是出路 fpga上多用示波器 逻辑分析仪

哈哈,解决的办法很简单:1、用指示灯或者数码管来提示。可以在代码里面设置一些变量来输出。
  2、一步一步仿真 
先把代码风格纠正了再查问题,你这代码太乱了。
1.尽量用时序逻辑
2.一个process只做一件事
3.尽量不用variable

可以找个别人写的任意一个标准代码看看。仿真都通不过完全没必要上板子

设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优尔论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。