[英]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.