簡體   English   中英

VHDL添加2 std_ulogic_vector無效

[英]VHDL adding 2 std_ulogic_vector does not have any effect

我從VHDL開始,遇到了一些麻煩。

我試圖實現雙重涉獵算法,將輸入的二進制字符串轉換為bcd代碼。

為此,我已經像在Wiki或其他參考文獻中那樣實現了它。 但是,我有一個問題

bcdVec(3 downto 0) <= std_ulogic_vector(unsigned(bcdVec(3 downto 0)) + unsigned(three));

沒有任何效果(三= std_ulogic_vector(3到0):=“ 0011”)。 在計算之前和之后,我已經使用報告語句對它進行了測試,但結果卻相同。

at 210 ns(1): Note: 7 (/bcd_conversion_tb/uut/).
at 210 ns(1): Note: 7 (/bcd_conversion_tb/uut/).

也許有人對我有很好的提示,謝謝!

如果有幫助,這里是整個過程的代碼:

BCDProc: process(Reset, CLK_50M) is
begin
    if(Reset = ResetLevel) then
        working <= '0';
        i <= 0;
        ready <= '1';
        busy <= '0';
        bcdVec <= (others => '0');
        binVec <= binaryvec;
        hundrets_BCD <= (others => '0');
        tens_BCD <= (others => '0');
        ones_BCD <= (others => '0');
    elsif (CLK_50M'event AND CLK_50M = '1') then
        if(start = '1') then
            working <= '1';
            ready <= '0';
        end if;
        if(i = 7) then
            -- split vector to matching BCD values
            ones_BCD <= std_ulogic_vector(bcdVec(3 downto 0));
            tens_BCD <= std_ulogic_vector(bcdVec(7 downto 4));
            hundrets_BCD <= std_ulogic_vector(bcdVec(11 downto 8));
            i <= 0;
            tmp <= 0;
            ready <= '1';
            busy <= '0';
            working <= '0';
        end if;

        if (i < 8 AND working = '1') then
            busy <= '1';
            --check if bcd value is >4, if so then add 3
            if(i < 8 AND bcdVec (3 downto 0) > "0100") then
                report tmp'image(to_integer(unsigned(bcdVec(3 downto 0))));
                bcdVec(3 downto 0) <= std_ulogic_vector(unsigned(bcdVec(3 downto 0)) + unsigned(three));
                report tmp'image(to_integer(unsigned(bcdVec(3 downto 0))));
            end if;

            if(i < 8 AND bcdVec (7 downto 4) > "0100") then
                tmp <= to_integer(unsigned(bcdVec(7 downto 4)));
                tmp <= tmp + 3;
                bcdVec(7 downto 4) <= std_ulogic_vector(to_unsigned(tmp, 4));
            end if;

            if(i < 8 AND bcdVec (11 downto 8) > "0100") then
                tmp <= to_integer(unsigned(bcdVec(11 downto 8)));
                tmp <= tmp + 3;
                bcdVec(11 downto 8) <= std_ulogic_vector(to_unsigned(tmp, 4));
            end if;

            --perform the shiftoperations
            bcdVec(11 downto 0) <= bcdVec (10 downto 0) & binVec(7);
            binVec(7 downto 0) <= binVec(6 downto 0) & '0';

            --increment countervariable 
            i <= i+1;
        end if;
    end if;
end process BCDProc;

在進程掛起之前,信號分配永遠不會更新。 此過程僅在其敏感度列表處暫停。 因此,您隨后的tmp快照不會將bcdVec加3,而是將tmp值加3到該過程的最后一次執行-即:CLK_50M的上一個上升沿。

    if(i < 8 AND bcdVec (11 downto 8) > "0100") then
        tmp <= to_integer(unsigned(bcdVec(11 downto 8)));
        tmp <= tmp + 3;
        bcdVec(11 downto 8) <= std_ulogic_vector(to_unsigned(tmp, 4));
    end if;

您在整個過程中都會做類似的事情。 例如,如果開始為“ 1”,則計划將工作設置為“ 1”,然后如果“ i = 7”,則覆蓋該值,

if(start = '1') then
    working <= '1';
    ready <= '0';
end if;

if(i = 7) then
    . . .
    working <= '0';
end if;

然后,您稍后嘗試進行測試以查看是什么(以下摘錄),但是該過程尚未掛起,因此work的值尚未更新,並且仍具有上一次執行時的值。

if (i < 8 AND working = '1') then

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM