添加两位“VHDL返回错误中的U向量”;(vcom-1581)中缀运算符'没有可行的条目+'&引用;
这是我用VHDL将二进制文件转换为BCD的代码添加两位“VHDL返回错误中的U向量”;(vcom-1581)中缀运算符'没有可行的条目+'&引用;,vhdl,modelsim,Vhdl,Modelsim,这是我用VHDL将二进制文件转换为BCD的代码 library ieee; use ieee.numeric_bit.all; entity bin2bcd is port (bin : in bit_vector(3 downto 0) := "0000"; clk : in bit; bcdout : out bit_vector(4 downto 0) := "00000"); end bin2bcd; architecture bin2bcda
library ieee;
use ieee.numeric_bit.all;
entity bin2bcd is
port (bin : in bit_vector(3 downto 0) := "0000";
clk : in bit;
bcdout : out bit_vector(4 downto 0) := "00000");
end bin2bcd;
architecture bin2bcdarch of bin2bcd is
begin
process(clk)
variable gt9 : bit;
variable temp : bit_vector(3 downto 0) := "0110";
variable bcdout_temp : bit_vector(4 downto 0);
begin
if clk'event and clk = '1' then
gt9 := bin(3) and(bin(2) or bin(1));
if gt9 = '1' then
bcdout_temp := ('0' & bin) + ('0' & temp);
else
bcdout_temp := ('0' & bin);
end if;
end if;
bcdout <= bcdout_temp;
end process;
end bin2bcdarch;
ieee库;
使用ieee.numeric_bit.all;
实体bin2bcd是
端口(bin:在位_向量中(3到0):=“0000”;
时钟:以位为单位;
bcdout:out位_向量(4到0):=“00000”);
结束bin2bcd;
bin2bcd的架构bin2bcd是
开始
过程(clk)
变量gt9:bit;
变量温度:位向量(3到0):=“0110”;
变量bcdout_temp:位向量(4到0);
开始
如果clk'事件和clk='1',则
gt9:=第(3)和(第(2)或第(1)条仓);
如果gt9='1',则
bcdout_temp:=('0'和bin)+('0'和temp);
其他的
bcdout_temp:=('0'和bin);
如果结束;
如果结束;
bcdout如果使用ieee.numeric\u bit\u unsigned.all,则可以添加位向量,这是VHDL-2008的一部分。您正在使用的数字_std包未定义位向量的加法 如果您发现旧的CAD实验室软件不支持无符号的数字位,则可以使用类型转换,数字位包含有符号和无符号类型的声明:
library ieee;
use ieee.numeric_bit.all;
entity bin2bcd is
port (bin : in bit_vector(3 downto 0) := "0000";
clk : in bit;
bcdout : out bit_vector(4 downto 0) := "00000");
end bin2bcd;
architecture bin2bcdarch of bin2bcd is
begin
process(clk)
variable gt9 : bit;
variable temp : unsigned(3 downto 0) := "0110"; -- was bit_vector
variable bcdout_temp : unsigned(4 downto 0); -- was bit vector
begin
if clk'event and clk = '1' then
gt9 := bin(3) and(bin(2) or bin(1));
if gt9 = '1' then
bcdout_temp := '0' & unsigned(bin) + ('0' & temp); -- type conversion
else
bcdout_temp := '0' & unsigned(bin); -- type conversion
end if;
end if;
bcdout <= bit_vector(bcdout_temp); -- type conversion
end process;
end bin2bcdarch;
ieee库;
使用ieee.numeric_bit.all;
实体bin2bcd是
端口(bin:在位_向量中(3到0):=“0000”;
时钟:以位为单位;
bcdout:out位_向量(4到0):=“00000”);
结束bin2bcd;
bin2bcd的架构bin2bcd是
开始
过程(clk)
变量gt9:bit;
变量温度:无符号(3到0):=“0110”--是位u向量
变量bcdout_temp:无符号(4到0);--是位向量
开始
如果clk'事件和clk='1',则
gt9:=第(3)和(第(2)或第(1)条仓);
如果gt9='1',则
bcdout_temp:='0'和无符号(bin)+('0'和temp);--类型转换
其他的
bcdout_temp:=“0”和未签名(bin);--类型转换
如果结束;
如果结束;
b是否有充分的理由不使用类型无符号以及使用ieee.numeric\u std.all代码>?我不明白你想说什么。你能详细说明一下吗?我没有使用ieee.numeric\u std.all
,因为我没有使用std\u logic\u vector
我也尝试了unsigned('0'&bin))+unsigned('0'&temp))
,但我也得到了一个错误。你需要ieee.numeric\u std.all
来使用unsigned
。如果数据确实表示一个无符号的数字,那么这似乎比位向量
更合适。为什么您使用位向量
而不是标准逻辑向量
?在-2008年,有一个数字位无符号,允许您将位向量视为无符号。是的,这就是为什么我没有使用numeric\u std,但我不知道numeric\u bit\u unsigned。我正在试一试。Thank我收到一个错误,说(vcom-1581)中缀运算符“&”没有可行的条目。
您是否误用了上面显示的更改?所有三个“&”都是[位,无符号返回无符号]。使用错误的软件包?我在发布之前分析(编译)了上述代码。所有一维数组类型都预定义了“&”运算符。好吧,那我一定是做错了什么。对不起。我会重新检查我的代码。我试过使用你在名为“Galaxy”的旧软件上发布的代码。但是我收到一个错误,说C:\warp\lib\common\mod_mthu.vhv(第175行,第53列):(E99)无法将此分配给数组或记录。
warp VHDL Development System,1996年4月,第258页E99:无法将此分配给数组或记录。只能将具有值列表或其他数组或记录的聚合分配给数组或记录。没有聚合。摩登mthu.vhv 175线附近有什么?你能展示一下它的子程序吗?这听起来像是一个工具限制(VHDL标准的表面空谈,可能是使其难以使用的众多限制之一,CPLD还有可用的吗?)
entity bin2bcd is
port (
bin: in bit_vector(3 downto 0);
clk: in bit;
bcdout: out bit_vector(4 downto 0)
);
end entity bin2bcd;
architecture dataflow of bin2bcd is
signal bcdout_temp: bit_vector(4 downto 0);
begin
bcdout_temp(4) <= bin(3) and ( bin(2) or bin(1) ); -- gt9
bcdout_temp(3) <= not bcdout_temp(4) and bin(3); -- zero if gt9
bcdout_temp(2) <= ( bin(3) and bin(2) and bin(1)) or
(not bin(3) and bin(2));
bcdout_temp(1) <= ( bcdout_temp(4) and not bin(1)) or -- gt9 XOR bin(1)
(not bcdout_temp(4) and bin(1));
bcdout_temp(0) <= bin(0); -- doesn't change
REG5:
process (clk)
begin
if clk'event and clk = '1' then
bcdout <= bcdout_temp;
end if;
end process;
end architecture;
library ieee;
use ieee.numeric_bit.all;
entity bin2bcd_tb is
end entity;
architecture foo of bin2bcd_tb is
signal bin: bit_vector(3 downto 0);
signal clk: bit;
signal bcdout: bit_vector(4 downto 0);
begin
DUT:
entity work. bin2bcd (dataflow)
port map (
bin => bin,
clk => clk,
bcdout => bcdout
);
CLOCK:
process
begin
wait for 5 ns;
clk <= not clk;
if now > 160 ns then
wait;
end if;
end process;
STIMULI:
process
begin
for i in 0 to 2 ** bin'length - 1 loop
bin <= bit_vector(to_unsigned(i, bin'length));
wait for 10 ns;
end loop;
wait;
end process;
end architecture;