VHDL模拟错误

VHDL模拟错误,vhdl,fpga,square-root,Vhdl,Fpga,Square Root,我试图得到一个设计来模拟,但我一直在ISim中收到这个错误: ERROR: In process nearfield_processing.vhd:distance_to_delay FATAL ERROR:ISim: This application has discovered an exceptional condition from which it cannot recover. Process will terminate. To search for possible resol

我试图得到一个设计来模拟,但我一直在ISim中收到这个错误:

ERROR: In process nearfield_processing.vhd:distance_to_delay 
FATAL ERROR:ISim: This application has discovered an exceptional condition from which it cannot recover. Process will terminate. To search for possible resolutions to this issue, refer to the Xilinx answer database by going to http://www.xilinx.com/support/answers/index.htm and search with keywords 'ISim' and 'FATAL ERROR'. For technical support on this issue, please open a WebCase with this project attached at http://www.xilinx.com/support.
INFO: Simulator is stopped.
我不知道这里的问题是什么,但下面是发生错误的方法

distance_to_delay : process (i_clock)
begin

if(i_reset = '1') then
    delay_1        <= 0;
    delay_2        <= 0;
    delay_3        <= 0;
    delay_4        <= 0;
    ds_squared     <= 0;
    ds_squareroot  <= 0;
elsif(rising_edge(i_clock)) then
    -- Delay 1 calculations
    ds_squared <= (distance*distance + (speaker_distance)*(speaker_distance));
    for n in 0 to 20 loop
        ds_squareroot <=  ((50 + ds_squared/ds_squareroot)/2);
    end loop;
    delay_1 <= (ds_squareroot - distance)/ speed_sound;

    -- Delay 2 calculations
    ds_squared <= (distance*distance + (speaker_distance*2)*(speaker_distance*2));
    for n in 0 to 20 loop
        ds_squareroot <=  ((50 + ds_squared/ds_squareroot)/2);
    end loop;
    delay_2 <= (ds_squareroot - distance)/ speed_sound;

    -- Delay 3 calculations
    ds_squared <= (distance*distance + (speaker_distance*3)*(speaker_distance*3));
    for n in 0 to 20 loop
        ds_squareroot <=  ((50 + ds_squared/ds_squareroot)/2);
    end loop;
    delay_3 <= (ds_squareroot - distance)/ speed_sound;

    -- Delay 4 calculations
    ds_squared <= (distance*distance + (speaker_distance*4)*(speaker_distance*4));
    for n in 0 to 20 loop
        ds_squareroot <=  ((50 + ds_squared/ds_squareroot)/2);
    end loop;
    delay_4 <= (ds_squareroot - distance)/ speed_sound;     
end if;

    --********** Manually Set Delays ****************--

--      delay_1 <= (22+2); --42
--      delay_2 <= (44+2); --72
--      delay_3 <= (66+2); --91
--      delay_4 <= (88+2); --97
--      sample_period <= 22;

        --********** End Manually Set Delays ************--
end process;
距离到延迟:进程(i时钟)
开始
如果(i_reset='1'),则

delay_1首先,由于ds_平方根被初始化为零,所以看起来您试图除以零

另一件对我来说很突出的事情是你的循环语句

for n in 0 to 20 loop
    ds_squareroot <=  ((50 + ds_squared/ds_squareroot)/2);
end loop;
用于0到20循环中的n

重置系统时,此行初始化ds_平方根

ds_squareroot  <= 0;
不执行迭代更新,只有最后一次迭代生效,因此逻辑只“执行”一次

ArcticWhite为您提供了一些关于如何使用一系列中间信号来解决这个问题的建议,这会在您得到答案之前增加时钟周期的数量,但允许使用快速时钟,或者使用变量,这意味着您将在单个时钟周期内得到答案,但该时钟周期可能会非常缓慢(非常)长


还要注意,除以一个非常量也会创建非常大的逻辑。在逻辑中实现平方根还有其他几种方法(可能在速度、逻辑利用率、功耗方面更好)。

不要将顺序循环语句和并发生成语句混为一谈。在这种情况下(顺序循环)只有最后一个信号分配生效(一个过程顺序信号分配目标只有一个驱动器,相同的惯性延迟,0)。他不需要
n
ds_平方根
s,他需要一个变量作为分配初始ds_平方根的目标,在20个循环后将其分配给信号
ds_平方根
。注意ds_平方根是一个0到100的整数范围(参见链接,实际源)。精度不够,无法在少于7位的时间内得到有意义的答案,可能会得到大量的零。这里似乎存在算法错误。感谢您的更正。我已相应地编辑了我的帖子。此外,我推迟了引入变量,因为1。)我不认为它能够满足时间和2。)在使用变量之前,你真的需要理解语言,提供的代码没有给我这种感觉。
ds_squareroot  <= 0;
    ds_squareroot <=  ((50 + ds_squared/ds_squareroot)/2);
for n in 0 to 20 loop
    ds_squareroot <=  ((50 + ds_squared/ds_squareroot)/2);
end loop;