簡體   English   中英

VHDL轉移運營商?

[英]VHDL shift operators?

我還在嘗試習慣VHDL的一些怪癖,而且我遇到了一些問題。 首先,我理解像rol,ror,ssl,srl等的移位運算符是不可合成的。 本實驗的目的是使用黃金模型檢查測試平台中同一事物的可合成版本。

現在,該程序的目的是將溫度計代碼轉換為3位二進制數。 換句話說,溫度計代碼“00000001”=“001”,“00000011”=“010”,“00000111”=“011”等。我基本上試圖從右邊計算字符串中的1的數量向左。 不存在在1的字符串之間放置'0'的情況,因此向量“00011101”無效並且永遠不會發生。

我已經設計了一個不可合成的(到目前為止,不可編譯的)算法,我無法弄清楚如何工作。 基本上,想法是讀取溫度計代碼,向右移動並遞增計數器直到溫度計代碼等於零,然后將計數器值分配給3位std_logic_vector。 以下是我迄今為止所做的代碼。

library ieee;
use ieee.std_logic_1164.all; 
use ieee.numeric_std.all;

entity therm2bin_g is
    port(therm : inout std_logic_vector(6 downto 0); -- thermometer code
         bin : out std_logic_vector(2 downto 0); -- binary code 
         i : integer range 0 to 7);
end therm2bin_g;    

architecture behavioral_g of therm2bin_g is
begin

golden : process(therm)
begin

    while(therm /= "00000000") loop
        therm <= therm srl 1;
        i = i + 1;      
    end loop;

    bin <= std_logic'(to_unsigned(i,3));

end process golden;
behavioral_g;

這是一個可綜合的版本。 while循環由for循環替換。 srl是明確實現的:

entity therm2bin_g is
port(therm : inout std_logic_vector(6 downto 0); -- thermometer code
     bin : out std_logic_vector(2 downto 0); -- binary code 
     i : out integer range 0 to 7);
end therm2bin_g;    

architecture behavioral_g of therm2bin_g is
begin

golden : process(therm)
    variable i_internal: integer range 0 to 7;
begin
    i_internal:=0;
    for idx in 0 to therm'length loop
        if therm/="0000000" then
            therm<='0' & therm(therm'left downto 1);
            i_internal := i_internal + 1;     
        end if;
    end loop;

    bin<=std_logic_vector(to_unsigned(i_internal,bin'length));
    i<=i_internal;

end process golden;
end behavioral_g;

“......像rol,ror,ssl,srl等運營商不可合成......”誰說誰的權威? 你檢查過嗎? 在哪個綜合工具? 它是最近的版本,還是20世紀90年代初的版本?

請注意, 某些工具可能不支持它的論點只是愚蠢。 一些廚房可能沒有烤箱這一事實並不能阻止人們編寫蛋糕食譜。

暫無
暫無

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

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