首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用AXI流信号来计数像素?

如何使用AXI流信号来计数像素?
EN

Stack Overflow用户
提问于 2017-05-30 09:35:32
回答 1查看 115关注 0票数 0

我试图根据来自AXI流信号(如tusertlast )的信号来计数像素。我写了这个:

代码语言:javascript
复制
  p_pixelcount : process (s_clk)
    variable v_hcount : integer := 1; 
    variable v_linecount: integer:= 1;
  begin
  if (rising_edge(s_clk)) then
    if (s_maxis_s_tvalid_out = '1')and (s_maxis_s_tready_in = '1') then 
        if ( rising_edge(s_maxis_s_tuser_out) ) then
           v_hcount    := 0;
           v_linecount := 0;
        else 
           v_hcount := v_hcount + 1;

        end if; 

        if (s_maxis_s_tlast_out = '1') then
           v_hcount := 0;
           v_linecount := v_linecount + 1;
        end if;

    end if;
  end if;
  end process p_pixelcount;

我收到了以下模拟输出

我的问题:

  1. tuser高时,v_hcount不是应该是0吗?
  2. 是否允许在同一进程中对不同的信号使用两个rising_edge(signal)条件?
  3. 我想数到tlast,然后在下一个循环中计数设置为零。不使用信号就能做到这一点吗?

谢谢

EN

回答 1

Stack Overflow用户

发布于 2017-06-01 11:23:35

首先:不要设置v_hcountv_linecount变量。它们是定时的,所以需要注册:为此使用信号。(用于可综合的代码)

不,您不能在这样的进程中使用rising_edge两次。如果您希望检测到0->1的转换,则需要在(正确的)时钟域中执行此操作。例如。

代码语言:javascript
复制
s_maxis_s_tuser_out_delay <= s_maxis_s_tuser_out when rising_edge(s_clk);
s_maxis_s_tuser_out_rising <= 
    '1' when s_maxis_s_tuser_out = '1' and s_maxis_s_tuser_out_rising = '0'
    else '0';

但在这种情况下,你应该直接用

代码语言:javascript
复制
if (s_maxis_s_tuser_out = '1') then
    v_hcount    <= 1;
    v_linecount <= 0;
else 
    v_hcount <= v_hcount + 1;
    if (s_maxis_s_tlast_out = '1') then
       v_hcount <= 0;
       v_linecount <= v_linecount + 1;
    end if;
end if; 

为什么在1时初始化v_hcountv_linecount,但将它们重置为0?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44258616

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档