意外的 TICK 错误
我正在尝试编写 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
“1010”应该是“1010”(双引号)。单引号用于字符文字(单个字符)。
The '1010' should be "1010" (double quotes). A single quote is used for a character literal (a single character).
所以你已经按照马克的回答修复了第一个错误。
第二个错误是您无法利用输出的值。
为了解决这个问题,您需要创建一个内部信号(例如求和)。然后,您可以使用内部信号,并将其分配给外部信号。
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.
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.