t_tone_array 类型与字符串文字不匹配

t_tone_array type does not match string literal

我想将数组中从 9 到 1 的所有向量设置为“0000000”,但我收到错误消息:错误 (10515):melody_box.vhd(251) 处的 VHDL 类型不匹配错误:t_tone_array 类型与字符串文字不匹配

type t_tone_array is array (0 to 9) of std_logic_vector(6 downto 0) ;
note_vector : out t_tone_array;
output : process(all)
    begin
    
    note_vector(9 downto 1) <= "0000000";  **--here is the error**
    
    if( button_6 = '0') then 
    note_vector(0) <= std_logic_vector(to_unsigned(melody_note_0(indexx-1),7));
    velocity(0 to 9) <= "1111111";
    
    elsif (button_6 = '1') then
    note_vector(0) <= std_logic_vector(to_unsigned(melody_note_1(indexx-1),7));
    velocity(0 to 9) <= "1111111";
    
    end if;
    end process output;

有人知道问题出在哪里吗?

A Minimal, Complete, and Verifiable example 看起来像:

library ieee;
use ieee.std_logic_1164.all;

entity t_tone is -- Minimal, Complete, and Verifiable example
end entity;

architecture mcve of t_tone is
    type t_tone_array is array (0 to 9) of std_logic_vector(6 downto 0) ;
    signal note_vector: t_tone_array;
begin
    process
    begin
        note_vector(9 downto 1) <= "0000000";
        wait;
    end process;
end architecture;

在分析(编译)时出现两个错误:

ghdl -a t_tone.vhdl
t_tone.vhdl:13:20:error: direction of the range mismatch
        note_vector(9 downto 1) <= "0000000";
                   ^
t_tone.vhdl:13:36:error: can't match string literal with type anonymous array subtype defined at t_tone.vhdl:13:21
        note_vector(9 downto 1) <= "0000000";
                                   ^
ghdl:error: compilation error

空切片(方向错误)没有元素。

纠正这些问题需要以正确的方式获取切片方向并提供赋值目标类型的值:

architecture fixed of t_tone is
    type t_tone_array is array (0 to 9) of std_logic_vector(6 downto 0) ;
    signal note_vector: t_tone_array;
begin
    process
    begin
        note_vector(1 to 9) <= (others =>"0000000");
         wait;
    wait;
    end process;
end architecture;

这分析和阐述(编译、链接和加载)和模拟。右侧的波形表达式是一个聚合,它的类型来自上下文(整个赋值语句)。此示例将使用符合 VHDL 标准修订版 -2008 的工具。