我正在尝试用VHDL计算图像直方图。我有24位强度值,因为强度水平太多,我必须创建箱(最大1920)。 我在比较每个输入像素的强度值和决定bin值时遇到麻烦,因此我可以使用bin值作为地址并更新BRAM中的计数。
我在模拟时遇到错误:达到了迭代限制
如果有不同的方法来计算垃圾箱,请告诉我。谢谢!
声明 -
signal data_in : std_logic_vector(23 downto 0);
signal bin : std_logic_vector(11 downto 0);
signal s_data_in : integer ;
signal s_binsize : integer :=2048;
signal s_bin : integer ;
signal s_bincount : integer :=0 ;
signal s_temp: integer :=2048;
p_clk: process
begin
s_clk <= '0';
while (s_SimuDone /= 'H') loop
wait for C_CLOCK_PERIOD/2;
s_clk <= not s_clk;
end loop;
wait;
end process p_clk;
stimulus: process
begin
data_in <= x"0000ff";
wait for C_CLOCK_PERIOD*10;
data_in <= x"00000f";
wait for C_CLOCK_PERIOD*10;
data_in <= x"000fff";
wait for C_CLOCK_PERIOD*10;
data_in <= x"0fffff";
wait;
end process stimulus;
s_data_in <= to_integer(unsigned (data_in));
bin <= std_logic_vector(to_unsigned(s_bin, 12));
process (s_data_in, s_bincount)
begin
if (s_data_in < s_binsize) then
s_bin <= 0;
else if (s_data_in < s_temp) then
s_bin <= s_bincount;
s_bincount <= 0;
s_temp <= 2048;
else
s_bincount <= s_bincount + 1;
s_temp <= s_temp + s_binsize;
end if;
end if;
end process;
答案 0 :(得分:0)
由于语句s_bincount <= s_bincount + 1
,错误与一个模拟增量中的过多迭代有关。由于设计是同步的,因此需要指定时钟。
但是,为了满足您的需求,您可以将测试平台更改为以下内容:
signal data_in : std_logic_vector(23 downto 0);
signal bin : std_logic_vector(11 downto 0);
signal s_data_in : integer ;
signal s_binsize : integer :=2048;
signal s_bin : integer ;
signal s_bincount : integer :=0 ;
signal s_temp: integer :=2048;
p_clk: process
begin
s_clk <= '0';
while (s_SimuDone /= 'H') loop
wait for C_CLOCK_PERIOD/2;
s_clk <= not s_clk;
end loop;
wait;
end process p_clk;
stimulus: process
begin
data_in <= x"0000ff";
wait for C_CLOCK_PERIOD*10;
data_in <= x"00000f";
wait for C_CLOCK_PERIOD*10;
data_in <= x"000fff";
wait for C_CLOCK_PERIOD*10;
data_in <= x"0fffff";
wait;
end process stimulus;
s_data_in <= to_integer(unsigned (data_in));
bin <= data_in(22 downto 11);
如果您愿意,可以将 bin 设为时钟变量,但在这种情况下您不需要。 bin 也应该是13位,而不是12位。
请模拟这个并告诉我。