Indexing VHDL标准“U逻辑”向量索引,带;下至;

Indexing VHDL标准“U逻辑”向量索引,带;下至;,indexing,vhdl,Indexing,Vhdl,我想分别设置std_逻辑_向量的位,以便轻松地为单个位或一组位设置注释。以下是我所拥有的: signal DataOut : std_logic_vector(7 downto 0); ... DataOut <= ( 5=>'1', -- Instruction defined 4=>'1', -- Data length control bi

我想分别设置std_逻辑_向量的位,以便轻松地为单个位或一组位设置注释。以下是我所拥有的:

signal DataOut : std_logic_vector(7 downto 0);
...
DataOut <= (                        5=>'1',     -- Instruction defined
                                    4=>'1',     -- Data length control bit, high=8bit bus mode selected
                                    3=>'1',     -- Display Line Number ctrl bit, high & N3 option pin to VDD=3 lines display
                                    2=>'0',     -- Double height font type control byte, not selected
                                    1 downto 0=>"01",   -- Select Instruction table1
                                    others=>'0' -- for bits 6,7
                                    );
任何避免使用等价物的解决方案

1=>'0',
0=>'1',
要允许我按块设置位,请执行以下操作:

DataOut(7 downto 6)<="00";
DataOut(5)<='1';
DataOut(4)<='1';
DataOut(3)<='1';
DataOut(2)<='1';
DataOut(1 downto 0)<="01";

DataOut(7到6)另一个答案是使用“&”进行连接,这失去了命名关联的清晰性,尽管您可以使用命名常量恢复一些自文档

constant Instr_Defined : std_ulogic := '1';
constant Bus_8_Bit     : std_ulogic := '1';

DataOut <= "00" & Instr_Defined
                & Bus_8_Bit
                & '1'     -- description
                & '0'     -- ditto
                & "01";
常量指令定义:标准逻辑:='1';
恒定总线8位:标准逻辑:='1';

DataOut当A是数组的元素时,赋值
X到Y=>A'
是正确的。例如,此代码段是正确的:

1 downto 0 => '1',
这个片段是错误的:

1 downto 0 => "01",
因此,您的作业是非法的。作为您的代码,您可以指定为:

DataOut <= (                        5 downto 3 =>'1',     
                                    2 downto 1 =>'0',     
                                    0 => '1',  
                                    others=>'0' 
                                    );
DataOut'1',
2到1=>0',
0 => '1',  
其他=>'0'
);
如果要通过数组的一部分访问/分配,可以使用串联:

DataOut <= Something_0 & Something_1 & "01";

DataOut是的,它是一种解决方案,但与
1=>'0',0=>'1',
相同。它更好,但还不完美…如果您只想初始化向量,例如,将位1..0设置为零,您可以使用“,…1 downto 0=>“0”,…”(其工作原理与“其他”相同)。
DataOut <= (                        5 downto 3 =>'1',     
                                    2 downto 1 =>'0',     
                                    0 => '1',  
                                    others=>'0' 
                                    );
DataOut <= Something_0 & Something_1 & "01";