compiler-errors - STD_LOGIC_VECTOR 与整数文字不匹配
问题描述
我对 VHDL 非常陌生,我正在尝试编写此代码,该过程根据输入 SW 驱动输出向量 HEX0。这就是我到目前为止所拥有的。
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity top is
port (SW : in std_logic_vector (3 downto 0);
LEDR : out std_logic_vector (3 downto 0);
HEX0 : out std_logic_vector (6 downto 0));
end entity;
architecture top_arch of top is
begin
LEDR <= SW;
-- Decoder process goes here…
process (SW)
begin
if (SW = "0000") then
HEX0 <= (100000);
elsif (SW = "0001") then
HEX0 <= (100111);
end if;
end process;
end architecture;
这是错误信息
10517 HVDL type mismatch error at top.vhd(17): std_logic_vector type does not match integer literal
我对此很陌生,所以我不知道为什么会这样。请让我知道你的想法。谢谢你。
解决方案
在这些行中HEX0 <= (100000);
,HEX0 <= (100111);
数字被解释为整数 100000 和 100111,而不是按位排列的 1 和 0。
它抱怨您试图将整数分配给std_logic_vector
类型信号 - 这是不允许的。
要使用std_logic_vector
文字,你会写:HEX0 <= "100000";
和HEX0 <= "100111";
推荐阅读
- javascript - 使用循环在 Google Map 上打印多个标记
- javascript - React 过滤器最佳实践
- python - 错误是什么:“ValueError:赋值目标是只读的”?
- c# - Photon Server:是不是所有的ClientPeer实例都自动运行在光纤中?
- python - 在 python 中读取和处理大型 wav 文件的最佳方法是什么
- python - 套接字模块(python)工作但不使用指定的端口号?
- amazon-ec2 - 访问在 AWS 中运行的 Jupyter - 访问它时出现证书错误
- shell - 使用 sed 替换 shell 脚本中的值
- git - Git说master是最新的,但不是
- android - 改造 - 基本网址必须以 / 结尾