vhdl - “索引名称不是 std_logic_vector”
问题描述
我试图在我的代码中使用“端口映射”,但我不知道如何修复错误。它说两个端口映射的“索引名称不是std_logic_vector”。我必须实现下面的电路。
我做了计数器和 MPG 并将它们添加为组件,它们分别工作。我将留下电路的代码。它说这是“端口地图”的问题。
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity test_env is
Port ( clk : in STD_LOGIC;
btn : in STD_LOGIC_VECTOR (15 downto 0);
sw : in STD_LOGIC_VECTOR (15 downto 0);
led : out STD_LOGIC_VECTOR (15 downto 0));
end test_env;
architecture Behavioral of test_env is
component MPG
Port(clk : in STD_LOGIC;
btn : in STD_LOGIC_VECTOR (15 downto 0);
enable : out STD_LOGIC);
end component;
component counter
Port ( clk : in STD_LOGIC;
btn : in STD_LOGIC_VECTOR (15 downto 0);
sw : in STD_LOGIC_VECTOR (15 downto 0);
led: out STD_LOGIC_VECTOR (15 downto 0));
end component;
signal en: STD_LOGIC;
signal s: STD_LOGIC_VECTOR(2 downto 0);
signal dcd: STD_LOGIC_VECTOR (7 downto 0);
begin
--led<=sw;
--an<=btn(3 downto 0);
--cat<=(others=>'0');
process(s)
begin
case s is
when "000" => dcd<="00000001";
when "001" => dcd<="00000010";
when "010" => dcd<="00000100";
when "011" => dcd<="00001000";
when "100" => dcd<="00010000";
when "101" => dcd<="00100000";
when "110" => dcd<="01000000";
when others => dcd<="10000000";
end case;
end process;
monopulse: MPG port map(clk, btn, en);
count: counter port map(clk, btn, sw(0), s);
led(7 downto 0)<= dcd;
end Behavioral;
我也会留下组件的代码
计数器(16 位)
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity counter is
Port ( clk : in STD_LOGIC;
btn : in STD_LOGIC_VECTOR (15 downto 0);
sw : in STD_LOGIC_VECTOR (15 downto 0);
led: out STD_LOGIC_VECTOR (15 downto 0));
end counter;
architecture Behavioral of counter is
signal Q: STD_LOGIC_VECTOR (15 downto 0);
begin
process(btn)
begin
if rising_edge(clk) then
if(btn(0)='1') then
if(sw(0)='1') then
Q<= Q + "0000000000000001";
else Q<=Q - "0000000000000001";
end if;
end if;
end if;
end process;
led<=Q;
end Behavioral;
手推车
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity MPG is
Port(clk : in STD_LOGIC;
btn : in STD_LOGIC_VECTOR (15 downto 0);
enable : out STD_LOGIC);
end MPG;
architecture Behavioral of MPG is
signal count : STD_LOGIC_VECTOR (15 downto 0) := (others => '0');
signal Q1 : STD_LOGIC;
signal Q2 : STD_LOGIC;
signal Q3 : STD_LOGIC;
begin
enable<=Q2 and (not(Q3));
process(btn)
begin
if rising_edge(clk) then
count<=count + "0000000000000001";
end if;
end process;
process(btn)
begin
if rising_edge(clk) then
if count(15 downto 0)= "1111111111111111" then
Q1<=btn(1);
end if;
end if;
end process;
process(btn)
begin
if rising_edge(clk) then
Q2<=Q1;
Q3<=Q2;
end if;
end process;
end Behavioral;
如果有人可以帮助我,非常感谢!
解决方案
推荐阅读
- ios - 将 UIView 包裹在 SwiftUI 周围,触摸和绘制的坐标现在没有对齐?
- javascript - 将数据从 JS 变量解析到 Vue 实例
- javascript - Taiwlind CSS:样式在生产中不加载,在开发中工作。将 Next.js 与 MDX 一起使用
- python - 如何使用相机计算正方形物体相对于二维平面图像的角度?
- jgrapht - jGraphT - 删除一个顶点并重新连接所有连接到已删除顶点的顶点
- python - 使用 Opencv 检测梯形和菱形时的容差问题
- python - 仅在 Beautifulsoup 中的特定 span 内容之后获取表格内容
- java - 使用 UTF-8 将二维码编码为 JasperReports 上的图像
- recursion - Mips中的斐波那契递归函数
- java - 如何在 NIO 中将字节从 ByteBuffer 解码为 UTF-8 符号?