导航: 老古网老古论坛XMOS公共讨论区XMOS开源项目区单片机程序设计嵌入式系统广告区域
→虚心求教:用 FPGA 做高速 AD 转换时突然终止??[yang547]

 *第15587篇: 虚心求教:用 FPGA 做高速 AD 转换时突然终止??

  
楼 主:yang547 2003年8月18日14:55
 虚心求教:用 FPGA 做高速 AD 转换时突然终止??
向各位大侠紧急求救!
打算让 fpga 接受到 start 信号后控制 adc 一次完成 2K 个数据的采集并送入双口 ram ,但有时会中途停止,不知道是不是程序上的问题?希望高手不吝赐教!(副VHDL程序)

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

entity ad_vhd_final1 is
port(reset : in std_logic;
     start : in std_logic;
     clk   : in std_logic;
     data_in : in std_logic_vector(7 downto 0);
     data_out: out std_logic_vector(7 downto 0);
     addr  : out std_logic_vector(10 downto 0);
     flag  : out std_logic;
     encode_out : out std_logic;
     ce    : out std_logic;
     we       : out std_logic;
     oe    : out std_logic);
end ad_vhd_final1;

architecture a of ad_vhd_final1 is
signal encode : std_logic;
signal data : std_logic_vector(7 downto 0);
signal count: std_logic_vector(10 downto 0);
type states is (s0,s1,s2,s3);
signal state : states;
begin
    encode_out   <= encode;
    data_out   <= data;
    addr   <= count;
    
----------------------------------- ad ouput data latch ----------------------------------
    process(reset,encode)
    begin
        if reset='1' then data   <= "00000000";
        elsif encode'event and encode='0' then data   <= data_in;
        end if;
    end process;
----------------------------------- state generate ---------------------------------------    
    process(reset,start,clk)
    begin
        if reset='1' then state   <= s0;
        elsif clk'event and clk='0' then 
            case state is
            when s0 =>   if start='0' then state   <= s1;
                       else state   <= s0;
                       end if;
            when s1 =>   count   <= "00000000000";
                       if start='1' then state   <= s2; 
                       else state   <= s1;
                       end if;
            when s2 =>   if count  <2047 then count   <= count + 1;
                                          state   <= s2;
                       else state   <= s3;
                       end if;
            when s3 =>   if start='0' then state   <= s1;
                       else state   <= s3;
                       end if;
            end case;
        end if;
    end process;
----------------------------------- signal value -----------------------------------------
    flag   <= '1' when (state=s3) else
            '0';
    ce   <=  clk when (state=s2) else
          '1';
    oe   <= '1';
    we   <=  clk when (state=s2) else
          '1';
    encode   <= clk when (state=s2) else
              '0';

end a;

  
2楼:imwj 2003年8月18日23:11
 程序本身没有问题,是不是你的时钟太高了?
程序本身没有问题,是不是你的时钟太高了?这样你的状态机就不稳定
还有,你这个模块式结合外围电路的,是不是外围电路的干扰,比如reset等等
你再看看吧,程序本身没毛病
  
3楼:yang547 2003年8月19日12:15
 谢谢这位大哥指教!
我也觉得可能是 R

谢谢这位大哥指教!
我也觉得可能是 RESET 的问题。
用示波器的逻辑分析功能观察后,发现采样中断后回到 S0,有两种可能:
1。由于电路干扰,错误的另程序复位。
2。状态是由软件分配,可能在 S2--》S3 的过程中,存在竞争冒险。
所以我给 RESET 信号加一级触发,用全局时钟来选通;又对状态手动 GRAY 编码,
下进去一试,情况好转,每次都能完成全部数据的采集,我想这样应该就可以了。

>>>>>>对该主题发表你的看法

本主题贴数3,分页: [第1页]


[上一篇主题]:[原创]想在家建立自己的实验室

[下一篇主题]:请问有什么芯片能做USB接口的产品。急!!