在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 2052|回复: 3

[求助] 并行总线 FPGA读取数据出现问题

[复制链接]
发表于 2015-4-1 23:12:10 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
本帖最后由 sundonga 于 2015-4-1 23:15 编辑

大家好,我写了一段程序来与PCI9052接口,由PCI9052来读写FPGA几个寄存器的数据。下图是逻辑分析仪得到的时序图,本来应该读到的是0x34,就是逻辑分析仪图里红色方框里的TED7~TED0的值,可不知道为什么实际会读成0xb5,程序是状态机写的,附在后面,大家帮忙看看这是怎么回事?谢过!

WR.png






  1. ------------------------------------------
  2. process(CLK)
  3. begin
  4. if(CLK='1' and CLK'event) then
  5. if RSTn='0' then
  6. CURRENT_STATE <= IDLE_STATE;
  7. TED(15 downto 0)<=(others => 'Z');
  8. TLRDYn <= '1';       
  9. led_out <= X"00";
  10. else       
  11. case CURRENT_STATE is
  12. when IDLE_STATE =>
  13. TLRDYn <= '1';       
  14. TED(15 DOWNTO 0) <= (others => 'Z');
  15. if ((not TADSn) and TLWorRn and (not TCS1n))= '1' then
  16. CURRENT_STATE <= WR_START_STATE;
  17. elsif ((not TADSn) and (not TLWorRn) and (not TCS1n))= '1' then
  18. CURRENT_STATE <= RD_START_STATE;
  19. else
  20. CURRENT_STATE <= IDLE_STATE;
  21. end if;
  22. when WR_START_STATE =>
  23. --led_out <= X"FF";
  24. if TWRn = '0'  then   
  25. CURRENT_STATE <= WR_WAIT_STATE;
  26. else
  27. CURRENT_STATE <= WR_START_STATE;
  28. end if;
  29. when WR_WAIT_STATE =>  
  30. --led_out <= X"AA";
  31. CURRENT_STATE <= WR_ACCEPT_STATE;
  32. when WR_ACCEPT_STATE =>
  33. IF(TBE1n = '0') THEN
  34. CASE TEA IS
  35. WHEN ADR_tempd => tempd(15 DOWNTO 0) <= TED(15 DOWNTO 0);
  36.                                         led_out <= X"FF";
  37. WHEN ADR_tempe => tempe(15 DOWNTO 0) <= TED(15 DOWNTO 0);       
  38. WHEN ADR_tempf => tempf(15 DOWNTO 0) <= TED(15 DOWNTO 0);
  39. WHEN ADR_tempg => tempg(15 DOWNTO 0) <= TED(15 DOWNTO 0);
  40. WHEN ADR_temph => temph(15 DOWNTO 0) <= TED(15 DOWNTO 0);
  41. WHEN ADR_tempi => tempi(15 DOWNTO 0) <= TED(15 DOWNTO 0);

  42. WHEN OTHERS => NULL;
  43. END CASE;
  44. END IF;       

  45. IF(TBE1n = '1') THEN
  46. CASE TEA IS
  47. WHEN ADR_tempd => tempd(31 DOWNTO 16) <= TED(15 DOWNTO 0);
  48. WHEN ADR_tempe => tempe(31 DOWNTO 16) <= TED(15 DOWNTO 0);       
  49. WHEN ADR_tempf => tempf(31 DOWNTO 16) <= TED(15 DOWNTO 0);
  50. WHEN ADR_tempg => tempg(31 DOWNTO 16) <= TED(15 DOWNTO 0);
  51. WHEN ADR_temph => temph(31 DOWNTO 16) <= TED(15 DOWNTO 0);
  52. WHEN ADR_tempi => tempi(31 DOWNTO 16) <= TED(15 DOWNTO 0);

  53. WHEN OTHERS => NULL;
  54. END CASE;
  55. END IF;
  56. --led_out <= X"33";
  57. CURRENT_STATE <= WR_READY_STATE;                                                       
  58. when WR_READY_STATE =>
  59. --led_out <= X"AF";
  60. CURRENT_STATE <= IDLE_STATE;       
  61. TLRDYn <= '0';
  62. when WR_END_STATE =>
  63. CURRENT_STATE <= IDLE_STATE;       
  64. TLRDYn <= '1';                                       
  65. ------------------------RD-------------------------------------------------------                                       
  66. when RD_START_STATE =>
  67. if TRDn = '0'  then   
  68. CURRENT_STATE <= RD_WAIT_STATE;
  69. else
  70. CURRENT_STATE <= RD_START_STATE;
  71. end if;
  72. when RD_WAIT_STATE =>  
  73. CURRENT_STATE <= WR_ACCEPT_STATE;
  74. when RD_ACCEPT_STATE =>
  75. IF(TBE1n = '0') THEN                     
  76. CASE TEA IS
  77. WHEN ADR_tempd => TED(15 downto 0) <=tempd(15 DOWNTO 0);
  78. WHEN ADR_tempe => TED(15 DOWNTO 0) <=tempe(15 DOWNTO 0);       
  79.                                                 --led_out <= X"EE";
  80. WHEN ADR_tempf => TED(15 DOWNTO 0) <=tempf(15 DOWNTO 0);
  81. WHEN ADR_tempg => TED(15 DOWNTO 0) <=tempg(15 DOWNTO 0);
  82. WHEN ADR_temph => TED(15 DOWNTO 0) <=temph(15 DOWNTO 0);
  83. WHEN ADR_tempi => TED(15 DOWNTO 0) <=tempi(15 DOWNTO 0);

  84. WHEN OTHERS => TED(15 downto 0)<= X"FFFF";--(others => 'Z');
  85. END CASE;
  86. END IF;

  87. IF(TBE1n = '1') THEN                     
  88. CASE TEA IS
  89. WHEN ADR_tempd => TED(15 DOWNTO 0) <=tempd(31 DOWNTO 16);
  90.                                                 --led_out <= X"DD";
  91. WHEN ADR_tempe => TED(15 DOWNTO 0) <=tempe(31 DOWNTO 16);       
  92.                                                 --led_out <= X"EE";
  93. WHEN ADR_tempf => TED(15 DOWNTO 0) <=tempf(31 DOWNTO 16);
  94. WHEN ADR_tempg => TED(15 DOWNTO 0) <=tempg(31 DOWNTO 16);
  95. WHEN ADR_temph => TED(15 DOWNTO 0) <=temph(31 DOWNTO 16);
  96. WHEN ADR_tempi => TED(15 DOWNTO 0) <=tempi(31 DOWNTO 16);

  97. WHEN OTHERS => TED(15 downto 0)<= X"FFFF";--(others => 'Z');
  98.                                         --led_out <= X"FF";
  99. END CASE;
  100. END IF;
  101. CURRENT_STATE <= RD_WAIT2_STATE;       
  102. when RD_WAIT2_STATE =>                --多一个等待周期,让数据稳定之后再发READY
  103. CURRENT_STATE <= RD_READY_STATE;
  104. when RD_READY_STATE =>
  105. CURRENT_STATE <= IDLE_STATE;       
  106. TLRDYn <= '0';
  107. when RD_END_STATE =>
  108. CURRENT_STATE <= IDLE_STATE;       
  109. TLRDYn <= '1';       
  110. when others => CURRENT_STATE <= IDLE_STATE;
  111. end case;
  112. end if;
  113. end if;
  114. end process;


复制代码

发表于 2015-4-2 07:37:14 | 显示全部楼层
逻辑分析仪抓到的数据是对的,看是不是软件的问题
 楼主| 发表于 2015-4-2 10:24:53 | 显示全部楼层
回复 2# 董小三

你说上位机的软件,应该没问题,因为是测试用的只有读和写这个寄存器,没有别的功能。而且板子上恰好有几个LED灯,我用LED显示了一下那个寄存器的值,确实是错了。不知道什么会导致读回来错误的值。
 楼主| 发表于 2015-4-2 20:11:08 | 显示全部楼层
谢谢各位,原因找到了,是状态机跳错了状态。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /2 下一条


小黑屋| 手机版| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-11-22 09:14 , Processed in 0.022195 second(s), 10 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表