我正在vhdl中编写代码并遇到此错误
Assignment target incompatible with right side. Cannot convert 'dataArray' to 'STRING'
这是我的代码
entity instructionTranslator is
port(clk :in std_logic;
instructionCode :in std_logic_vector(4 downto 0);
instructionType:out std_logic_vector(1 downto 0) ;
data :out string (1 to 1)--here is data
);
end instructionTranslator;
.
.
.
architecture Translator of instructionTranslator is
type dataArray is array (0 to 13)of string(1 to 1);
process(clk) begin
data<=dataArray(1);
如何在vhdl中选择数组的特殊索引。
答案 0 :(得分:5)
下面。我为你做了一个[MCVE]。这个编译。
您声明了类型dataArray
。
然后你没有继续声明该类型的信号(或变量或常量)。
将一个类型的成员(这是抽象的)分配给一个真实的信号显然是行不通的。
分配该类型的信号(等)的成员,但是......
library ieee;
use ieee.std_logic_1164.all;
entity instructionTranslator is
port(clk :in std_logic;
instructionCode :in std_logic_vector(4 downto 0);
instructionType:out std_logic_vector(1 downto 0) ;
data :out string (1 to 1)--here is data
);
end instructionTranslator;
architecture Translator of instructionTranslator is
type dataArray is array (0 to 13)of string(1 to 1);
signal da : dataArray;
begin
process(clk) is
begin
data<=da(1);
end process;
end Translator;