意外的 TICK 错误

发布于 2024-09-30 11:29:33 字数 867 浏览 0 评论 0原文

我正在尝试编写 VHDL 模块,但 if 语句有问题。这很可能是一个愚蠢的错误,但由于我对 VHDL 很陌生,所以我无法找出问题所在。这是我的代码:

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;


entity binary_add is
    port( n1 : in std_logic_vector(3 downto 0);
    n2 : in std_logic_vector(3 downto 0);
    segments : out std_logic_vector(7 downto 0);
    bool : out bit;
    o : out std_logic_vector(3 downto 0);
    DNout : out std_logic_vector(3 downto 0));

end binary_add;

architecture Behavioral of binary_add is
begin

process(n1, n2) 
begin

o <= n1 + n2;

if( o = '1010') then 
bool <= '1';
else
bool <= '0';
end if;

end process;

end Behavioral;

我从 if 语句的第一行得到以下答案:

ERROR:HDLParsers:## - "C:/Xilinx/12.3/ISE_DS/ISE/.../binary_add.vhd" Line ##. parse error, unexpected TICK

我做错了什么?

I am trying to write a VHDL module but I have a problem with the if statement. Most probably it is a silly mistake, but since I am very new to VHDL, I could not figure out the problem. Here is my code:

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;


entity binary_add is
    port( n1 : in std_logic_vector(3 downto 0);
    n2 : in std_logic_vector(3 downto 0);
    segments : out std_logic_vector(7 downto 0);
    bool : out bit;
    o : out std_logic_vector(3 downto 0);
    DNout : out std_logic_vector(3 downto 0));

end binary_add;

architecture Behavioral of binary_add is
begin

process(n1, n2) 
begin

o <= n1 + n2;

if( o = '1010') then 
bool <= '1';
else
bool <= '0';
end if;

end process;

end Behavioral;

And I get the following answer from the first line of if statement:

ERROR:HDLParsers:## - "C:/Xilinx/12.3/ISE_DS/ISE/.../binary_add.vhd" Line ##. parse error, unexpected TICK

What am I doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

谢绝鈎搭 2024-10-07 11:29:33

“1010”应该是“1010”(双引号)。单引号用于字符文字(单个字符)。

The '1010' should be "1010" (double quotes). A single quote is used for a character literal (a single character).

寄居者 2024-10-07 11:29:33

所以你已经按照马克的回答修复了第一个错误。

第二个错误是您无法利用输出的值。

if output = "0101";    -- illegal

some_signal <= output; -- illegal

为了解决这个问题,您需要创建一个内部信号(例如求和)。然后,您可以使用内部信号,并将其分配给外部信号。

architecture Behavioral of binary_add is

signal sum : std_logic_vector(3 downto 0);

begin

process(n1, n2, sum) 
begin

sum <= n1 + n2;

if( sum = '1010') then 
bool <= '1';
else
bool <= '0';
end if;

end process;

o <= sum;

end Behavioral;

So you have fixed the first error as per Mark's answer.

The second error is that you can not make use of the value of an output.

if output = "0101";    -- illegal

some_signal <= output; -- illegal

To solve this you need to create an internal signal (say sum). You then use the internal signal, and assign it to the external signal.

architecture Behavioral of binary_add is

signal sum : std_logic_vector(3 downto 0);

begin

process(n1, n2, sum) 
begin

sum <= n1 + n2;

if( sum = '1010') then 
bool <= '1';
else
bool <= '0';
end if;

end process;

o <= sum;

end Behavioral;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文