打印

fpga触发器建立时间的问题,求高手指教

[复制链接]
1017|2
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主

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

-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;

-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;

entity my_dff is
    Port (
                                clk_a : in  STD_LOGIC;
                                reset_a : in  STD_LOGIC;
                                sync_in : in  STD_LOGIC;
                                comp_data_a     : out std_logic_vector(31 downto 0);
                                comp_data_b     : out std_logic_vector(31 downto 0)
                          );
end my_dff;

architecture Behavioral of my_dff is
        signal s_sync_in        : std_logic;
        signal s_comp_count        : std_logic_vector(2 downto 0);
        --signal s_comp_count        : std_logic_vector(1 downto 0);
        signal s_comp_data_a     : std_logic_vector(31 downto 0);
        signal s_comp_data_b     : std_logic_vector(31 downto 0);
begin
        comp_data_a <= s_comp_data_a;
        comp_data_b <= s_comp_data_b;
       
        dpram_dual_clock_b_p: process(clk_a,reset_a)
   begin
                if(reset_a ='1')then
                        s_sync_in <= '0';
                        s_comp_count <= "100";
                        --s_comp_count <= "11";                       
                        s_comp_data_a <=(others => '0');
                        s_comp_data_b <=(others => '0');
                elsif (clk_a'event and clk_a = '1') then
                        --if(s_comp_count /="11")then
                        if(s_comp_count /="100")then       
                                s_comp_count <= s_comp_count + 1;
                        else
                                s_sync_in <= '0';
                        end if;
         if (sync_in = '1') then
                                s_comp_count <= "000";
                                --s_comp_count <= "000";
                                s_sync_in <= '1';
                        end if;
                        if(s_sync_in ='1')then
                                case s_comp_count is
                                        when "000" =>
                                        --when "00" =>
                                                s_comp_data_a(7 downto 0) <= x"12";
                                                s_comp_data_b(7 downto 0) <= x"12";
                                        when "001" =>
                                        --when "01" =>
                                                s_comp_data_a(15 downto 8) <= x"34";
                                                s_comp_data_b(15 downto 8) <= x"34";
                                        when "010" =>
                                        --when "10" =>
                                                s_comp_data_a(23 downto 16) <= x"56";
                                                s_comp_data_b(23 downto 16) <= x"56";
                                        when "011" =>
                                        --when "11" =>
                                                s_comp_data_a(31 downto 24) <= x"78";
                                                s_comp_data_b(31 downto 24) <= x"78";
                                        when others =>
                                                null;
                                end case;
                        end if;
                end if;
        end process dpram_dual_clock_b_p;

end Behavioral;

相关帖子

沙发
chenzhi658|  楼主 | 2014-7-16 15:08 | 只看该作者
我想把计数器弄为2位的,到“11”停止计数。就是上面仿真的黄色纵线那里s_sync_in直接拉低,编译通不过,说会丢失case下的“11”情况。让他在延迟一个时钟就可以了,如上图的仿真。

使用特权

评论回复
板凳
chenzhi658|  楼主 | 2014-7-17 15:57 | 只看该作者
原来是case语句没有加 others 条件;加了就好了。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

29

主题

247

帖子

1

粉丝