"A loop" 如何在一个时钟内完成
how "A loop" complete in a clock
我试着找了很多代码来参考。
但是我找不到我需要的解决方案。
谁能帮我找到问题和解决方案?
非常感谢。
问题是我需要这个代码可以变量。
ero_check_t <= erosion_buf(0)(0)+erosion_buf(0)(1)+erosion_buf(0)(2)+
erosion_buf(1)(0)+erosion_buf(1)(1)+erosion_buf(1)(2)+
erosion_buf(2)(0)+erosion_buf(2)(1)+erosion_buf(2)(2);
像上码(3*3)可以变下码(2*2)。
ero_check_t <= erosion_buf(0)(0)+erosion_buf(0)(1)+
erosion_buf(1)(0)+erosion_buf(1)(1);
我该怎么写?可以使用循环来编码吗?
process(rst)
begin
if rst = '0' then
ero_check <= "0000000000";
ero_check_t <= "0000000000";
else
for i in 0 to array_x loop
for j in 0 to (array_y - 1) loop
if i = array_x then
if j= 0 then
ero_check_t <= ero_check;
ero_check <= "0000000000";
exit;
end if;
else
ero_check := ero_check + erosion_buf(i)(j);
end if;
end loop;
end loop;
end if;
end process;
简短的回答是肯定的。更长的答案是您可能想要检查您的代码是否完全符合您的要求(并且它也存在一些问题)。如果您想要执行此操作的 组合 逻辑:
ero_check_t <= erosion_buf(0)(0)+erosion_buf(0)(1)+erosion_buf(0)(2) + ...
erosion_buf(1)(0)+erosion_buf(1)(1)+erosion_buf(1)(2) + ...
erosion_buf(2)(0)+erosion_buf(2)(1)+erosion_buf(2)(2) + ...
...
那么像这样的东西就可以了:
process(erosion_buf) -- erosion_buf is the only input
variable e : -- the same type as ero_check_t
begin
e := -- zero (I don't know what type ero_check_t is)
for i in 0 to array_x-1 loop -- assuming array_x is the LENGTH of the x dimension
for j in 0 to array_y-1 loop -- assuming array_y is the LENGTH of the y dimension
e := e + erosion_buf(i)(j);
end loop;
end loop;
ero_check_t <= e; -- drive the output signal
end process;
ero_chek
是一个 变量 。这被初始化为零,然后嵌套循环执行所有添加。最后,用变量 ero_check
.
的内容驱动信号 ero_check_t
我试着找了很多代码来参考。
但是我找不到我需要的解决方案。
谁能帮我找到问题和解决方案?
非常感谢。
问题是我需要这个代码可以变量。
ero_check_t <= erosion_buf(0)(0)+erosion_buf(0)(1)+erosion_buf(0)(2)+
erosion_buf(1)(0)+erosion_buf(1)(1)+erosion_buf(1)(2)+
erosion_buf(2)(0)+erosion_buf(2)(1)+erosion_buf(2)(2);
像上码(3*3)可以变下码(2*2)。
ero_check_t <= erosion_buf(0)(0)+erosion_buf(0)(1)+
erosion_buf(1)(0)+erosion_buf(1)(1);
我该怎么写?可以使用循环来编码吗?
process(rst)
begin
if rst = '0' then
ero_check <= "0000000000";
ero_check_t <= "0000000000";
else
for i in 0 to array_x loop
for j in 0 to (array_y - 1) loop
if i = array_x then
if j= 0 then
ero_check_t <= ero_check;
ero_check <= "0000000000";
exit;
end if;
else
ero_check := ero_check + erosion_buf(i)(j);
end if;
end loop;
end loop;
end if;
end process;
简短的回答是肯定的。更长的答案是您可能想要检查您的代码是否完全符合您的要求(并且它也存在一些问题)。如果您想要执行此操作的 组合 逻辑:
ero_check_t <= erosion_buf(0)(0)+erosion_buf(0)(1)+erosion_buf(0)(2) + ...
erosion_buf(1)(0)+erosion_buf(1)(1)+erosion_buf(1)(2) + ...
erosion_buf(2)(0)+erosion_buf(2)(1)+erosion_buf(2)(2) + ...
...
那么像这样的东西就可以了:
process(erosion_buf) -- erosion_buf is the only input
variable e : -- the same type as ero_check_t
begin
e := -- zero (I don't know what type ero_check_t is)
for i in 0 to array_x-1 loop -- assuming array_x is the LENGTH of the x dimension
for j in 0 to array_y-1 loop -- assuming array_y is the LENGTH of the y dimension
e := e + erosion_buf(i)(j);
end loop;
end loop;
ero_check_t <= e; -- drive the output signal
end process;
ero_chek
是一个 变量 。这被初始化为零,然后嵌套循环执行所有添加。最后,用变量 ero_check
.
ero_check_t