我试图根据来自AXI流信号(如tuser和tlast )的信号来计数像素。我写了这个:
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;我收到了以下模拟输出

我的问题:
tuser高时,v_hcount不是应该是0吗?rising_edge(signal)条件?tlast,然后在下一个循环中计数设置为零。不使用信号就能做到这一点吗?谢谢
发布于 2017-06-01 11:23:35
首先:不要设置v_hcount和v_linecount变量。它们是定时的,所以需要注册:为此使用信号。(用于可综合的代码)
不,您不能在这样的进程中使用rising_edge两次。如果您希望检测到0->1的转换,则需要在(正确的)时钟域中执行此操作。例如。
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';但在这种情况下,你应该直接用
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_hcount和v_linecount,但将它们重置为0?
https://stackoverflow.com/questions/44258616
复制相似问题