当我尝试模拟我的代码时,“时间达到了迭代限制”

时间:2016-05-29 23:38:26

标签: algorithm iteration vhdl limit

我正在尝试在VHDL中实现Booth算法,已经运行了“纸质测试”并且代码显然有效,但是当我模拟它时,我没有得到期望的结果......然后我替换了代码做一个A-Shift测试,但是当我模拟我的代码时,我收到了这个错误:

错误(可抑制):( vsim-3601)在180 ns时达到迭代限制5000.

我只是替换了这一行: db.Model

为此: P := STD_LOGIC_VECTOR(unsigned(P) SRA 1);

这是代码atm:

P := P(16) & P(16 downto 1);

1 个答案:

答案 0 :(得分:-1)

经过多次尝试后,只需更改此行: P := P(16) & P(16 downto 1);

对于这个: P(16 downto 0) := P(17 downto 1);

问题解决了!

以下是固定代码:

LIBRARY IEEE;
    USE IEEE.STD_LOGIC_1164.ALL;
    USE IEEE.STD_LOGIC_UNSIGNED.ALL;

ENTITY algor_booth IS
    PORT(oper1 :  IN STD_LOGIC_VECTOR(7 DOWNTO 0);
         oper2 :  IN STD_LOGIC_VECTOR(7 DOWNTO 0);
         sel :    IN STD_LOGIC;
         result : OUT STD_LOGIC_VECTOR(15 DOWNTO 0)
            );
END ENTITY;

ARCHITECTURE algor OF algor_booth IS
BEGIN
    PROCESS (oper1, oper2)
        VARIABLE A, S, P: STD_LOGIC_VECTOR(17 DOWNTO 0);
        VARIABLE Ma2: STD_LOGIC_VECTOR(7 DOWNTO 0);
        VARIABLE flag: STD_LOGIC;
    BEGIN
            Ma2 := (NOT oper1) + 1;
            A   := '0' & oper1 & "00000000" & '0';
            S   := '0' & Ma2 & "00000000" & '0';
            P   := '0' & "00000000" & oper2 & '0';  
            flag := '0';

            FOR i IN 1 TO 8 LOOP
                IF (P(1) = '0' AND P(0) = '1') THEN
                    flag := '0';
                    P(17) := flag;
                          P := P + A;
                ELSIF (P(1) = '1' AND P(0) = '0') THEN
                    flag := '1';
                    P(17) := flag;
                          P := P + S;
                END IF;
                P(17) := flag;
                P(16 downto 0) := P(17 downto 1);
                P(17) := flag;
            END LOOP;
            result <= P(16 DOWNTO 1);
    END PROCESS;
END algor;

感谢您的帮助!